babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028
  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. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * 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.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * 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).
  167. * 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.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @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.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** 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 */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** 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 */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** 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 */
  699. static readonly GEQUAL: number;
  700. /** 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 */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * 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.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. * @param options options to be passed to the loader
  1129. */
  1130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1131. /**
  1132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1133. * @param data contains the texture data
  1134. * @param texture defines the BabylonJS internal texture
  1135. * @param callback defines the method to call once ready to upload
  1136. * @param options options to be passed to the loader
  1137. */
  1138. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/IPipelineContext" {
  1142. /**
  1143. * Class used to store and describe the pipeline context associated with an effect
  1144. */
  1145. export interface IPipelineContext {
  1146. /**
  1147. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1148. */
  1149. isAsync: boolean;
  1150. /**
  1151. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1152. */
  1153. isReady: boolean;
  1154. /** @hidden */
  1155. _getVertexShaderCode(): string | null;
  1156. /** @hidden */
  1157. _getFragmentShaderCode(): string | null;
  1158. /** @hidden */
  1159. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1160. }
  1161. }
  1162. declare module "babylonjs/Meshes/dataBuffer" {
  1163. /**
  1164. * Class used to store gfx data (like WebGLBuffer)
  1165. */
  1166. export class DataBuffer {
  1167. /**
  1168. * Gets or sets the number of objects referencing this buffer
  1169. */
  1170. references: number;
  1171. /** Gets or sets the size of the underlying buffer */
  1172. capacity: number;
  1173. /**
  1174. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1175. */
  1176. is32Bits: boolean;
  1177. /**
  1178. * Gets the underlying buffer
  1179. */
  1180. get underlyingResource(): any;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1184. /** @hidden */
  1185. export interface IShaderProcessor {
  1186. attributeProcessor?: (attribute: string) => string;
  1187. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1188. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1189. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1190. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1191. lineProcessor?: (line: string, isFragment: boolean) => string;
  1192. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1193. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1194. }
  1195. }
  1196. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1197. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1198. /** @hidden */
  1199. export interface ProcessingOptions {
  1200. defines: string[];
  1201. indexParameters: any;
  1202. isFragment: boolean;
  1203. shouldUseHighPrecisionShader: boolean;
  1204. supportsUniformBuffers: boolean;
  1205. shadersRepository: string;
  1206. includesShadersStore: {
  1207. [key: string]: string;
  1208. };
  1209. processor?: IShaderProcessor;
  1210. version: string;
  1211. platformName: string;
  1212. lookForClosingBracketForUniformBuffer?: boolean;
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1216. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1217. /** @hidden */
  1218. export class ShaderCodeNode {
  1219. line: string;
  1220. children: ShaderCodeNode[];
  1221. additionalDefineKey?: string;
  1222. additionalDefineValue?: string;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. process(preprocessors: {
  1227. [key: string]: string;
  1228. }, options: ProcessingOptions): string;
  1229. }
  1230. }
  1231. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1232. /** @hidden */
  1233. export class ShaderCodeCursor {
  1234. private _lines;
  1235. lineIndex: number;
  1236. get currentLine(): string;
  1237. get canRead(): boolean;
  1238. set lines(value: string[]);
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1242. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1243. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1244. /** @hidden */
  1245. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1246. process(preprocessors: {
  1247. [key: string]: string;
  1248. }, options: ProcessingOptions): string;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1252. /** @hidden */
  1253. export class ShaderDefineExpression {
  1254. isTrue(preprocessors: {
  1255. [key: string]: string;
  1256. }): boolean;
  1257. private static _OperatorPriority;
  1258. private static _Stack;
  1259. static postfixToInfix(postfix: string[]): string;
  1260. static infixToPostfix(infix: string): string[];
  1261. }
  1262. }
  1263. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1264. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1265. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1266. /** @hidden */
  1267. export class ShaderCodeTestNode extends ShaderCodeNode {
  1268. testExpression: ShaderDefineExpression;
  1269. isValid(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1278. define: string;
  1279. not: boolean;
  1280. constructor(define: string, not?: boolean);
  1281. isTrue(preprocessors: {
  1282. [key: string]: string;
  1283. }): boolean;
  1284. }
  1285. }
  1286. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1287. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1288. /** @hidden */
  1289. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1290. leftOperand: ShaderDefineExpression;
  1291. rightOperand: ShaderDefineExpression;
  1292. isTrue(preprocessors: {
  1293. [key: string]: string;
  1294. }): boolean;
  1295. }
  1296. }
  1297. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1298. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1299. /** @hidden */
  1300. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1301. leftOperand: ShaderDefineExpression;
  1302. rightOperand: ShaderDefineExpression;
  1303. isTrue(preprocessors: {
  1304. [key: string]: string;
  1305. }): boolean;
  1306. }
  1307. }
  1308. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1309. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1310. /** @hidden */
  1311. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1312. define: string;
  1313. operand: string;
  1314. testValue: string;
  1315. constructor(define: string, operand: string, testValue: string);
  1316. isTrue(preprocessors: {
  1317. [key: string]: string;
  1318. }): boolean;
  1319. }
  1320. }
  1321. declare module "babylonjs/Offline/IOfflineProvider" {
  1322. /**
  1323. * Class used to enable access to offline support
  1324. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1325. */
  1326. export interface IOfflineProvider {
  1327. /**
  1328. * Gets a boolean indicating if scene must be saved in the database
  1329. */
  1330. enableSceneOffline: boolean;
  1331. /**
  1332. * Gets a boolean indicating if textures must be saved in the database
  1333. */
  1334. enableTexturesOffline: boolean;
  1335. /**
  1336. * Open the offline support and make it available
  1337. * @param successCallback defines the callback to call on success
  1338. * @param errorCallback defines the callback to call on error
  1339. */
  1340. open(successCallback: () => void, errorCallback: () => void): void;
  1341. /**
  1342. * Loads an image from the offline support
  1343. * @param url defines the url to load from
  1344. * @param image defines the target DOM image
  1345. */
  1346. loadImage(url: string, image: HTMLImageElement): void;
  1347. /**
  1348. * Loads a file from offline support
  1349. * @param url defines the URL to load from
  1350. * @param sceneLoaded defines a callback to call on success
  1351. * @param progressCallBack defines a callback to call when progress changed
  1352. * @param errorCallback defines a callback to call on error
  1353. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1354. */
  1355. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1356. }
  1357. }
  1358. declare module "babylonjs/Misc/filesInputStore" {
  1359. /**
  1360. * Class used to help managing file picking and drag'n'drop
  1361. * File Storage
  1362. */
  1363. export class FilesInputStore {
  1364. /**
  1365. * List of files ready to be loaded
  1366. */
  1367. static FilesToLoad: {
  1368. [key: string]: File;
  1369. };
  1370. }
  1371. }
  1372. declare module "babylonjs/Misc/retryStrategy" {
  1373. import { WebRequest } from "babylonjs/Misc/webRequest";
  1374. /**
  1375. * Class used to define a retry strategy when error happens while loading assets
  1376. */
  1377. export class RetryStrategy {
  1378. /**
  1379. * Function used to defines an exponential back off strategy
  1380. * @param maxRetries defines the maximum number of retries (3 by default)
  1381. * @param baseInterval defines the interval between retries
  1382. * @returns the strategy function to use
  1383. */
  1384. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1385. }
  1386. }
  1387. declare module "babylonjs/Misc/baseError" {
  1388. /**
  1389. * @ignore
  1390. * Application error to support additional information when loading a file
  1391. */
  1392. export abstract class BaseError extends Error {
  1393. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1394. }
  1395. }
  1396. declare module "babylonjs/Misc/fileTools" {
  1397. import { WebRequest } from "babylonjs/Misc/webRequest";
  1398. import { Nullable } from "babylonjs/types";
  1399. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1400. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1401. import { BaseError } from "babylonjs/Misc/baseError";
  1402. /** @ignore */
  1403. export class LoadFileError extends BaseError {
  1404. request?: WebRequest;
  1405. file?: File;
  1406. /**
  1407. * Creates a new LoadFileError
  1408. * @param message defines the message of the error
  1409. * @param request defines the optional web request
  1410. * @param file defines the optional file
  1411. */
  1412. constructor(message: string, object?: WebRequest | File);
  1413. }
  1414. /** @ignore */
  1415. export class RequestFileError extends BaseError {
  1416. request: WebRequest;
  1417. /**
  1418. * Creates a new LoadFileError
  1419. * @param message defines the message of the error
  1420. * @param request defines the optional web request
  1421. */
  1422. constructor(message: string, request: WebRequest);
  1423. }
  1424. /** @ignore */
  1425. export class ReadFileError extends BaseError {
  1426. file: File;
  1427. /**
  1428. * Creates a new ReadFileError
  1429. * @param message defines the message of the error
  1430. * @param file defines the optional file
  1431. */
  1432. constructor(message: string, file: File);
  1433. }
  1434. /**
  1435. * @hidden
  1436. */
  1437. export class FileTools {
  1438. /**
  1439. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1440. */
  1441. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1442. /**
  1443. * Gets or sets the base URL to use to load assets
  1444. */
  1445. static BaseUrl: string;
  1446. /**
  1447. * Default behaviour for cors in the application.
  1448. * It can be a string if the expected behavior is identical in the entire app.
  1449. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1450. */
  1451. static CorsBehavior: string | ((url: string | string[]) => string);
  1452. /**
  1453. * Gets or sets a function used to pre-process url before using them to load assets
  1454. */
  1455. static PreprocessUrl: (url: string) => string;
  1456. /**
  1457. * Removes unwanted characters from an url
  1458. * @param url defines the url to clean
  1459. * @returns the cleaned url
  1460. */
  1461. private static _CleanUrl;
  1462. /**
  1463. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1464. * @param url define the url we are trying
  1465. * @param element define the dom element where to configure the cors policy
  1466. */
  1467. static SetCorsBehavior(url: string | string[], element: {
  1468. crossOrigin: string | null;
  1469. }): void;
  1470. /**
  1471. * Loads an image as an HTMLImageElement.
  1472. * @param input url string, ArrayBuffer, or Blob to load
  1473. * @param onLoad callback called when the image successfully loads
  1474. * @param onError callback called when the image fails to load
  1475. * @param offlineProvider offline provider for caching
  1476. * @param mimeType optional mime type
  1477. * @returns the HTMLImageElement of the loaded image
  1478. */
  1479. 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>;
  1480. /**
  1481. * Reads a file from a File object
  1482. * @param file defines the file to load
  1483. * @param onSuccess defines the callback to call when data is loaded
  1484. * @param onProgress defines the callback to call during loading process
  1485. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1486. * @param onError defines the callback to call when an error occurs
  1487. * @returns a file request object
  1488. */
  1489. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1490. /**
  1491. * Loads a file from a url
  1492. * @param url url to load
  1493. * @param onSuccess callback called when the file successfully loads
  1494. * @param onProgress callback called while file is loading (if the server supports this mode)
  1495. * @param offlineProvider defines the offline provider for caching
  1496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1497. * @param onError callback called when the file fails to load
  1498. * @returns a file request object
  1499. */
  1500. 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;
  1501. /**
  1502. * Loads a file
  1503. * @param url url to load
  1504. * @param onSuccess callback called when the file successfully loads
  1505. * @param onProgress callback called while file is loading (if the server supports this mode)
  1506. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1507. * @param onError callback called when the file fails to load
  1508. * @param onOpened callback called when the web request is opened
  1509. * @returns a file request object
  1510. */
  1511. 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;
  1512. /**
  1513. * Checks if the loaded document was accessed via `file:`-Protocol.
  1514. * @returns boolean
  1515. */
  1516. static IsFileURL(): boolean;
  1517. }
  1518. }
  1519. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1520. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1521. import { WebRequest } from "babylonjs/Misc/webRequest";
  1522. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1523. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1524. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1525. /** @hidden */
  1526. export class ShaderProcessor {
  1527. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1528. private static _ProcessPrecision;
  1529. private static _ExtractOperation;
  1530. private static _BuildSubExpression;
  1531. private static _BuildExpression;
  1532. private static _MoveCursorWithinIf;
  1533. private static _MoveCursor;
  1534. private static _EvaluatePreProcessors;
  1535. private static _PreparePreProcessors;
  1536. private static _ProcessShaderConversion;
  1537. private static _ProcessIncludes;
  1538. /**
  1539. * Loads a file from a url
  1540. * @param url url to load
  1541. * @param onSuccess callback called when the file successfully loads
  1542. * @param onProgress callback called while file is loading (if the server supports this mode)
  1543. * @param offlineProvider defines the offline provider for caching
  1544. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1545. * @param onError callback called when the file fails to load
  1546. * @returns a file request object
  1547. * @hidden
  1548. */
  1549. 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;
  1550. }
  1551. }
  1552. declare module "babylonjs/Maths/math.like" {
  1553. import { float, int, DeepImmutable } from "babylonjs/types";
  1554. /**
  1555. * @hidden
  1556. */
  1557. export interface IColor4Like {
  1558. r: float;
  1559. g: float;
  1560. b: float;
  1561. a: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IColor3Like {
  1567. r: float;
  1568. g: float;
  1569. b: float;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IVector4Like {
  1575. x: float;
  1576. y: float;
  1577. z: float;
  1578. w: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IVector3Like {
  1584. x: float;
  1585. y: float;
  1586. z: float;
  1587. }
  1588. /**
  1589. * @hidden
  1590. */
  1591. export interface IVector2Like {
  1592. x: float;
  1593. y: float;
  1594. }
  1595. /**
  1596. * @hidden
  1597. */
  1598. export interface IMatrixLike {
  1599. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1600. updateFlag: int;
  1601. }
  1602. /**
  1603. * @hidden
  1604. */
  1605. export interface IViewportLike {
  1606. x: float;
  1607. y: float;
  1608. width: float;
  1609. height: float;
  1610. }
  1611. /**
  1612. * @hidden
  1613. */
  1614. export interface IPlaneLike {
  1615. normal: IVector3Like;
  1616. d: float;
  1617. normalize(): void;
  1618. }
  1619. }
  1620. declare module "babylonjs/Materials/iEffectFallbacks" {
  1621. import { Effect } from "babylonjs/Materials/effect";
  1622. /**
  1623. * Interface used to define common properties for effect fallbacks
  1624. */
  1625. export interface IEffectFallbacks {
  1626. /**
  1627. * Removes the defines that should be removed when falling back.
  1628. * @param currentDefines defines the current define statements for the shader.
  1629. * @param effect defines the current effect we try to compile
  1630. * @returns The resulting defines with defines of the current rank removed.
  1631. */
  1632. reduce(currentDefines: string, effect: Effect): string;
  1633. /**
  1634. * Removes the fallback from the bound mesh.
  1635. */
  1636. unBindMesh(): void;
  1637. /**
  1638. * Checks to see if more fallbacks are still availible.
  1639. */
  1640. hasMoreFallbacks: boolean;
  1641. }
  1642. }
  1643. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1644. /**
  1645. * Class used to evalaute queries containing `and` and `or` operators
  1646. */
  1647. export class AndOrNotEvaluator {
  1648. /**
  1649. * Evaluate a query
  1650. * @param query defines the query to evaluate
  1651. * @param evaluateCallback defines the callback used to filter result
  1652. * @returns true if the query matches
  1653. */
  1654. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1655. private static _HandleParenthesisContent;
  1656. private static _SimplifyNegation;
  1657. }
  1658. }
  1659. declare module "babylonjs/Misc/tags" {
  1660. /**
  1661. * Class used to store custom tags
  1662. */
  1663. export class Tags {
  1664. /**
  1665. * Adds support for tags on the given object
  1666. * @param obj defines the object to use
  1667. */
  1668. static EnableFor(obj: any): void;
  1669. /**
  1670. * Removes tags support
  1671. * @param obj defines the object to use
  1672. */
  1673. static DisableFor(obj: any): void;
  1674. /**
  1675. * Gets a boolean indicating if the given object has tags
  1676. * @param obj defines the object to use
  1677. * @returns a boolean
  1678. */
  1679. static HasTags(obj: any): boolean;
  1680. /**
  1681. * Gets the tags available on a given object
  1682. * @param obj defines the object to use
  1683. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1684. * @returns the tags
  1685. */
  1686. static GetTags(obj: any, asString?: boolean): any;
  1687. /**
  1688. * Adds tags to an object
  1689. * @param obj defines the object to use
  1690. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1691. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1692. */
  1693. static AddTagsTo(obj: any, tagsString: string): void;
  1694. /**
  1695. * @hidden
  1696. */
  1697. static _AddTagTo(obj: any, tag: string): void;
  1698. /**
  1699. * Removes specific tags from a specific object
  1700. * @param obj defines the object to use
  1701. * @param tagsString defines the tags to remove
  1702. */
  1703. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1704. /**
  1705. * @hidden
  1706. */
  1707. static _RemoveTagFrom(obj: any, tag: string): void;
  1708. /**
  1709. * Defines if tags hosted on an object match a given query
  1710. * @param obj defines the object to use
  1711. * @param tagsQuery defines the tag query
  1712. * @returns a boolean
  1713. */
  1714. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1715. }
  1716. }
  1717. declare module "babylonjs/Maths/math.scalar" {
  1718. /**
  1719. * Scalar computation library
  1720. */
  1721. export class Scalar {
  1722. /**
  1723. * Two pi constants convenient for computation.
  1724. */
  1725. static TwoPi: number;
  1726. /**
  1727. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1728. * @param a number
  1729. * @param b number
  1730. * @param epsilon (default = 1.401298E-45)
  1731. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1732. */
  1733. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1734. /**
  1735. * Returns a string : the upper case translation of the number i to hexadecimal.
  1736. * @param i number
  1737. * @returns the upper case translation of the number i to hexadecimal.
  1738. */
  1739. static ToHex(i: number): string;
  1740. /**
  1741. * Returns -1 if value is negative and +1 is value is positive.
  1742. * @param value the value
  1743. * @returns the value itself if it's equal to zero.
  1744. */
  1745. static Sign(value: number): number;
  1746. /**
  1747. * Returns the value itself if it's between min and max.
  1748. * Returns min if the value is lower than min.
  1749. * Returns max if the value is greater than max.
  1750. * @param value the value to clmap
  1751. * @param min the min value to clamp to (default: 0)
  1752. * @param max the max value to clamp to (default: 1)
  1753. * @returns the clamped value
  1754. */
  1755. static Clamp(value: number, min?: number, max?: number): number;
  1756. /**
  1757. * the log2 of value.
  1758. * @param value the value to compute log2 of
  1759. * @returns the log2 of value.
  1760. */
  1761. static Log2(value: number): number;
  1762. /**
  1763. * Loops the value, so that it is never larger than length and never smaller than 0.
  1764. *
  1765. * This is similar to the modulo operator but it works with floating point numbers.
  1766. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1767. * With t = 5 and length = 2.5, the result would be 0.0.
  1768. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1769. * @param value the value
  1770. * @param length the length
  1771. * @returns the looped value
  1772. */
  1773. static Repeat(value: number, length: number): number;
  1774. /**
  1775. * Normalize the value between 0.0 and 1.0 using min and max values
  1776. * @param value value to normalize
  1777. * @param min max to normalize between
  1778. * @param max min to normalize between
  1779. * @returns the normalized value
  1780. */
  1781. static Normalize(value: number, min: number, max: number): number;
  1782. /**
  1783. * Denormalize the value from 0.0 and 1.0 using min and max values
  1784. * @param normalized value to denormalize
  1785. * @param min max to denormalize between
  1786. * @param max min to denormalize between
  1787. * @returns the denormalized value
  1788. */
  1789. static Denormalize(normalized: number, min: number, max: number): number;
  1790. /**
  1791. * Calculates the shortest difference between two given angles given in degrees.
  1792. * @param current current angle in degrees
  1793. * @param target target angle in degrees
  1794. * @returns the delta
  1795. */
  1796. static DeltaAngle(current: number, target: number): number;
  1797. /**
  1798. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1799. * @param tx value
  1800. * @param length length
  1801. * @returns The returned value will move back and forth between 0 and length
  1802. */
  1803. static PingPong(tx: number, length: number): number;
  1804. /**
  1805. * Interpolates between min and max with smoothing at the limits.
  1806. *
  1807. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1808. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1809. * @param from from
  1810. * @param to to
  1811. * @param tx value
  1812. * @returns the smooth stepped value
  1813. */
  1814. static SmoothStep(from: number, to: number, tx: number): number;
  1815. /**
  1816. * Moves a value current towards target.
  1817. *
  1818. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1819. * Negative values of maxDelta pushes the value away from target.
  1820. * @param current current value
  1821. * @param target target value
  1822. * @param maxDelta max distance to move
  1823. * @returns resulting value
  1824. */
  1825. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1826. /**
  1827. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1828. *
  1829. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1830. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1831. * @param current current value
  1832. * @param target target value
  1833. * @param maxDelta max distance to move
  1834. * @returns resulting angle
  1835. */
  1836. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1837. /**
  1838. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1839. * @param start start value
  1840. * @param end target value
  1841. * @param amount amount to lerp between
  1842. * @returns the lerped value
  1843. */
  1844. static Lerp(start: number, end: number, amount: number): number;
  1845. /**
  1846. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1847. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1848. * @param start start value
  1849. * @param end target value
  1850. * @param amount amount to lerp between
  1851. * @returns the lerped value
  1852. */
  1853. static LerpAngle(start: number, end: number, amount: number): number;
  1854. /**
  1855. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1856. * @param a start value
  1857. * @param b target value
  1858. * @param value value between a and b
  1859. * @returns the inverseLerp value
  1860. */
  1861. static InverseLerp(a: number, b: number, value: number): number;
  1862. /**
  1863. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1864. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1865. * @param value1 spline value
  1866. * @param tangent1 spline value
  1867. * @param value2 spline value
  1868. * @param tangent2 spline value
  1869. * @param amount input value
  1870. * @returns hermite result
  1871. */
  1872. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1873. /**
  1874. * Returns a random float number between and min and max values
  1875. * @param min min value of random
  1876. * @param max max value of random
  1877. * @returns random value
  1878. */
  1879. static RandomRange(min: number, max: number): number;
  1880. /**
  1881. * This function returns percentage of a number in a given range.
  1882. *
  1883. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1884. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1885. * @param number to convert to percentage
  1886. * @param min min range
  1887. * @param max max range
  1888. * @returns the percentage
  1889. */
  1890. static RangeToPercent(number: number, min: number, max: number): number;
  1891. /**
  1892. * This function returns number that corresponds to the percentage in a given range.
  1893. *
  1894. * PercentToRange(0.34,0,100) will return 34.
  1895. * @param percent to convert to number
  1896. * @param min min range
  1897. * @param max max range
  1898. * @returns the number
  1899. */
  1900. static PercentToRange(percent: number, min: number, max: number): number;
  1901. /**
  1902. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1903. * @param angle The angle to normalize in radian.
  1904. * @return The converted angle.
  1905. */
  1906. static NormalizeRadians(angle: number): number;
  1907. }
  1908. }
  1909. declare module "babylonjs/Maths/math.constants" {
  1910. /**
  1911. * Constant used to convert a value to gamma space
  1912. * @ignorenaming
  1913. */
  1914. export const ToGammaSpace: number;
  1915. /**
  1916. * Constant used to convert a value to linear space
  1917. * @ignorenaming
  1918. */
  1919. export const ToLinearSpace = 2.2;
  1920. /**
  1921. * Constant used to define the minimal number value in Babylon.js
  1922. * @ignorenaming
  1923. */
  1924. let Epsilon: number;
  1925. export { Epsilon };
  1926. }
  1927. declare module "babylonjs/Maths/math.viewport" {
  1928. /**
  1929. * Class used to represent a viewport on screen
  1930. */
  1931. export class Viewport {
  1932. /** viewport left coordinate */
  1933. x: number;
  1934. /** viewport top coordinate */
  1935. y: number;
  1936. /**viewport width */
  1937. width: number;
  1938. /** viewport height */
  1939. height: number;
  1940. /**
  1941. * Creates a Viewport object located at (x, y) and sized (width, height)
  1942. * @param x defines viewport left coordinate
  1943. * @param y defines viewport top coordinate
  1944. * @param width defines the viewport width
  1945. * @param height defines the viewport height
  1946. */
  1947. constructor(
  1948. /** viewport left coordinate */
  1949. x: number,
  1950. /** viewport top coordinate */
  1951. y: number,
  1952. /**viewport width */
  1953. width: number,
  1954. /** viewport height */
  1955. height: number);
  1956. /**
  1957. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1958. * @param renderWidth defines the rendering width
  1959. * @param renderHeight defines the rendering height
  1960. * @returns a new Viewport
  1961. */
  1962. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1963. /**
  1964. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1965. * @param renderWidth defines the rendering width
  1966. * @param renderHeight defines the rendering height
  1967. * @param ref defines the target viewport
  1968. * @returns the current viewport
  1969. */
  1970. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1971. /**
  1972. * Returns a new Viewport copied from the current one
  1973. * @returns a new Viewport
  1974. */
  1975. clone(): Viewport;
  1976. }
  1977. }
  1978. declare module "babylonjs/Misc/arrayTools" {
  1979. /**
  1980. * Class containing a set of static utilities functions for arrays.
  1981. */
  1982. export class ArrayTools {
  1983. /**
  1984. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1985. * @param size the number of element to construct and put in the array
  1986. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1987. * @returns a new array filled with new objects
  1988. */
  1989. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1990. }
  1991. }
  1992. declare module "babylonjs/Maths/math.plane" {
  1993. import { DeepImmutable } from "babylonjs/types";
  1994. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1995. /**
  1996. * Represents a plane by the equation ax + by + cz + d = 0
  1997. */
  1998. export class Plane {
  1999. private static _TmpMatrix;
  2000. /**
  2001. * Normal of the plane (a,b,c)
  2002. */
  2003. normal: Vector3;
  2004. /**
  2005. * d component of the plane
  2006. */
  2007. d: number;
  2008. /**
  2009. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2010. * @param a a component of the plane
  2011. * @param b b component of the plane
  2012. * @param c c component of the plane
  2013. * @param d d component of the plane
  2014. */
  2015. constructor(a: number, b: number, c: number, d: number);
  2016. /**
  2017. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2018. */
  2019. asArray(): number[];
  2020. /**
  2021. * @returns a new plane copied from the current Plane.
  2022. */
  2023. clone(): Plane;
  2024. /**
  2025. * @returns the string "Plane".
  2026. */
  2027. getClassName(): string;
  2028. /**
  2029. * @returns the Plane hash code.
  2030. */
  2031. getHashCode(): number;
  2032. /**
  2033. * Normalize the current Plane in place.
  2034. * @returns the updated Plane.
  2035. */
  2036. normalize(): Plane;
  2037. /**
  2038. * Applies a transformation the plane and returns the result
  2039. * @param transformation the transformation matrix to be applied to the plane
  2040. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2041. */
  2042. transform(transformation: DeepImmutable<Matrix>): Plane;
  2043. /**
  2044. * Compute the dot product between the point and the plane normal
  2045. * @param point point to calculate the dot product with
  2046. * @returns the dot product (float) of the point coordinates and the plane normal.
  2047. */
  2048. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2049. /**
  2050. * Updates the current Plane from the plane defined by the three given points.
  2051. * @param point1 one of the points used to contruct the plane
  2052. * @param point2 one of the points used to contruct the plane
  2053. * @param point3 one of the points used to contruct the plane
  2054. * @returns the updated Plane.
  2055. */
  2056. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2057. /**
  2058. * Checks if the plane is facing a given direction
  2059. * @param direction the direction to check if the plane is facing
  2060. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2061. * @returns True is the vector "direction" is the same side than the plane normal.
  2062. */
  2063. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2064. /**
  2065. * Calculates the distance to a point
  2066. * @param point point to calculate distance to
  2067. * @returns the signed distance (float) from the given point to the Plane.
  2068. */
  2069. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2070. /**
  2071. * Creates a plane from an array
  2072. * @param array the array to create a plane from
  2073. * @returns a new Plane from the given array.
  2074. */
  2075. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2076. /**
  2077. * Creates a plane from three points
  2078. * @param point1 point used to create the plane
  2079. * @param point2 point used to create the plane
  2080. * @param point3 point used to create the plane
  2081. * @returns a new Plane defined by the three given points.
  2082. */
  2083. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2084. /**
  2085. * Creates a plane from an origin point and a normal
  2086. * @param origin origin of the plane to be constructed
  2087. * @param normal normal of the plane to be constructed
  2088. * @returns a new Plane the normal vector to this plane at the given origin point.
  2089. * Note : the vector "normal" is updated because normalized.
  2090. */
  2091. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2092. /**
  2093. * Calculates the distance from a plane and a point
  2094. * @param origin origin of the plane to be constructed
  2095. * @param normal normal of the plane to be constructed
  2096. * @param point point to calculate distance to
  2097. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2098. */
  2099. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2100. }
  2101. }
  2102. declare module "babylonjs/Engines/performanceConfigurator" {
  2103. /** @hidden */
  2104. export class PerformanceConfigurator {
  2105. /** @hidden */
  2106. static MatrixUse64Bits: boolean;
  2107. /** @hidden */
  2108. static MatrixTrackPrecisionChange: boolean;
  2109. /** @hidden */
  2110. static MatrixCurrentType: any;
  2111. /** @hidden */
  2112. static MatrixTrackedMatrices: Array<any> | null;
  2113. /** @hidden */
  2114. static SetMatrixPrecision(use64bits: boolean): void;
  2115. }
  2116. }
  2117. declare module "babylonjs/Maths/math.vector" {
  2118. import { Viewport } from "babylonjs/Maths/math.viewport";
  2119. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2120. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2121. import { Plane } from "babylonjs/Maths/math.plane";
  2122. /**
  2123. * Class representing a vector containing 2 coordinates
  2124. */
  2125. export class Vector2 {
  2126. /** defines the first coordinate */
  2127. x: number;
  2128. /** defines the second coordinate */
  2129. y: number;
  2130. /**
  2131. * Creates a new Vector2 from the given x and y coordinates
  2132. * @param x defines the first coordinate
  2133. * @param y defines the second coordinate
  2134. */
  2135. constructor(
  2136. /** defines the first coordinate */
  2137. x?: number,
  2138. /** defines the second coordinate */
  2139. y?: number);
  2140. /**
  2141. * Gets a string with the Vector2 coordinates
  2142. * @returns a string with the Vector2 coordinates
  2143. */
  2144. toString(): string;
  2145. /**
  2146. * Gets class name
  2147. * @returns the string "Vector2"
  2148. */
  2149. getClassName(): string;
  2150. /**
  2151. * Gets current vector hash code
  2152. * @returns the Vector2 hash code as a number
  2153. */
  2154. getHashCode(): number;
  2155. /**
  2156. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2157. * @param array defines the source array
  2158. * @param index defines the offset in source array
  2159. * @returns the current Vector2
  2160. */
  2161. toArray(array: FloatArray, index?: number): Vector2;
  2162. /**
  2163. * Update the current vector from an array
  2164. * @param array defines the destination array
  2165. * @param index defines the offset in the destination array
  2166. * @returns the current Vector3
  2167. */
  2168. fromArray(array: FloatArray, index?: number): Vector2;
  2169. /**
  2170. * Copy the current vector to an array
  2171. * @returns a new array with 2 elements: the Vector2 coordinates.
  2172. */
  2173. asArray(): number[];
  2174. /**
  2175. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2176. * @param source defines the source Vector2
  2177. * @returns the current updated Vector2
  2178. */
  2179. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2180. /**
  2181. * Sets the Vector2 coordinates with the given floats
  2182. * @param x defines the first coordinate
  2183. * @param y defines the second coordinate
  2184. * @returns the current updated Vector2
  2185. */
  2186. copyFromFloats(x: number, y: number): Vector2;
  2187. /**
  2188. * Sets the Vector2 coordinates with the given floats
  2189. * @param x defines the first coordinate
  2190. * @param y defines the second coordinate
  2191. * @returns the current updated Vector2
  2192. */
  2193. set(x: number, y: number): Vector2;
  2194. /**
  2195. * Add another vector with the current one
  2196. * @param otherVector defines the other vector
  2197. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2198. */
  2199. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @param result defines the target vector
  2204. * @returns the unmodified current Vector2
  2205. */
  2206. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2207. /**
  2208. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. addVector3(otherVector: Vector3): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2221. * @param otherVector defines the other vector
  2222. * @returns a new Vector2
  2223. */
  2224. subtract(otherVector: Vector2): Vector2;
  2225. /**
  2226. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2227. * @param otherVector defines the other vector
  2228. * @param result defines the target vector
  2229. * @returns the unmodified current Vector2
  2230. */
  2231. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2232. /**
  2233. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns the current updated Vector2
  2236. */
  2237. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Multiplies in place the current Vector2 coordinates by the given ones
  2240. * @param otherVector defines the other vector
  2241. * @returns the current updated Vector2
  2242. */
  2243. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2246. * @param otherVector defines the other vector
  2247. * @returns a new Vector2
  2248. */
  2249. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2250. /**
  2251. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2252. * @param otherVector defines the other vector
  2253. * @param result defines the target vector
  2254. * @returns the unmodified current Vector2
  2255. */
  2256. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2257. /**
  2258. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2259. * @param x defines the first coordinate
  2260. * @param y defines the second coordinate
  2261. * @returns a new Vector2
  2262. */
  2263. multiplyByFloats(x: number, y: number): Vector2;
  2264. /**
  2265. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2266. * @param otherVector defines the other vector
  2267. * @returns a new Vector2
  2268. */
  2269. divide(otherVector: Vector2): Vector2;
  2270. /**
  2271. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2272. * @param otherVector defines the other vector
  2273. * @param result defines the target vector
  2274. * @returns the unmodified current Vector2
  2275. */
  2276. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2277. /**
  2278. * Divides the current Vector2 coordinates by the given ones
  2279. * @param otherVector defines the other vector
  2280. * @returns the current updated Vector2
  2281. */
  2282. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2283. /**
  2284. * Gets a new Vector2 with current Vector2 negated coordinates
  2285. * @returns a new Vector2
  2286. */
  2287. negate(): Vector2;
  2288. /**
  2289. * Negate this vector in place
  2290. * @returns this
  2291. */
  2292. negateInPlace(): Vector2;
  2293. /**
  2294. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2295. * @param result defines the Vector3 object where to store the result
  2296. * @returns the current Vector2
  2297. */
  2298. negateToRef(result: Vector2): Vector2;
  2299. /**
  2300. * Multiply the Vector2 coordinates by scale
  2301. * @param scale defines the scaling factor
  2302. * @returns the current updated Vector2
  2303. */
  2304. scaleInPlace(scale: number): Vector2;
  2305. /**
  2306. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2307. * @param scale defines the scaling factor
  2308. * @returns a new Vector2
  2309. */
  2310. scale(scale: number): Vector2;
  2311. /**
  2312. * Scale the current Vector2 values by a factor to a given Vector2
  2313. * @param scale defines the scale factor
  2314. * @param result defines the Vector2 object where to store the result
  2315. * @returns the unmodified current Vector2
  2316. */
  2317. scaleToRef(scale: number, result: Vector2): Vector2;
  2318. /**
  2319. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2320. * @param scale defines the scale factor
  2321. * @param result defines the Vector2 object where to store the result
  2322. * @returns the unmodified current Vector2
  2323. */
  2324. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2325. /**
  2326. * Gets a boolean if two vectors are equals
  2327. * @param otherVector defines the other vector
  2328. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2329. */
  2330. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2331. /**
  2332. * Gets a boolean if two vectors are equals (using an epsilon value)
  2333. * @param otherVector defines the other vector
  2334. * @param epsilon defines the minimal distance to consider equality
  2335. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2336. */
  2337. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2338. /**
  2339. * Gets a new Vector2 from current Vector2 floored values
  2340. * @returns a new Vector2
  2341. */
  2342. floor(): Vector2;
  2343. /**
  2344. * Gets a new Vector2 from current Vector2 floored values
  2345. * @returns a new Vector2
  2346. */
  2347. fract(): Vector2;
  2348. /**
  2349. * Gets the length of the vector
  2350. * @returns the vector length (float)
  2351. */
  2352. length(): number;
  2353. /**
  2354. * Gets the vector squared length
  2355. * @returns the vector squared length (float)
  2356. */
  2357. lengthSquared(): number;
  2358. /**
  2359. * Normalize the vector
  2360. * @returns the current updated Vector2
  2361. */
  2362. normalize(): Vector2;
  2363. /**
  2364. * Gets a new Vector2 copied from the Vector2
  2365. * @returns a new Vector2
  2366. */
  2367. clone(): Vector2;
  2368. /**
  2369. * Gets a new Vector2(0, 0)
  2370. * @returns a new Vector2
  2371. */
  2372. static Zero(): Vector2;
  2373. /**
  2374. * Gets a new Vector2(1, 1)
  2375. * @returns a new Vector2
  2376. */
  2377. static One(): Vector2;
  2378. /**
  2379. * Gets a new Vector2 set from the given index element of the given array
  2380. * @param array defines the data source
  2381. * @param offset defines the offset in the data source
  2382. * @returns a new Vector2
  2383. */
  2384. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2385. /**
  2386. * Sets "result" from the given index element of the given array
  2387. * @param array defines the data source
  2388. * @param offset defines the offset in the data source
  2389. * @param result defines the target vector
  2390. */
  2391. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2392. /**
  2393. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2394. * @param value1 defines 1st point of control
  2395. * @param value2 defines 2nd point of control
  2396. * @param value3 defines 3rd point of control
  2397. * @param value4 defines 4th point of control
  2398. * @param amount defines the interpolation factor
  2399. * @returns a new Vector2
  2400. */
  2401. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2402. /**
  2403. * 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".
  2404. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2405. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2406. * @param value defines the value to clamp
  2407. * @param min defines the lower limit
  2408. * @param max defines the upper limit
  2409. * @returns a new Vector2
  2410. */
  2411. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2414. * @param value1 defines the 1st control point
  2415. * @param tangent1 defines the outgoing tangent
  2416. * @param value2 defines the 2nd control point
  2417. * @param tangent2 defines the incoming tangent
  2418. * @param amount defines the interpolation factor
  2419. * @returns a new Vector2
  2420. */
  2421. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2422. /**
  2423. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2424. * @param start defines the start vector
  2425. * @param end defines the end vector
  2426. * @param amount defines the interpolation factor
  2427. * @returns a new Vector2
  2428. */
  2429. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2430. /**
  2431. * Gets the dot product of the vector "left" and the vector "right"
  2432. * @param left defines first vector
  2433. * @param right defines second vector
  2434. * @returns the dot product (float)
  2435. */
  2436. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2437. /**
  2438. * Returns a new Vector2 equal to the normalized given vector
  2439. * @param vector defines the vector to normalize
  2440. * @returns a new Vector2
  2441. */
  2442. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2443. /**
  2444. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2445. * @param left defines 1st vector
  2446. * @param right defines 2nd vector
  2447. * @returns a new Vector2
  2448. */
  2449. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2450. /**
  2451. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2452. * @param left defines 1st vector
  2453. * @param right defines 2nd vector
  2454. * @returns a new Vector2
  2455. */
  2456. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2457. /**
  2458. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2459. * @param vector defines the vector to transform
  2460. * @param transformation defines the matrix to apply
  2461. * @returns a new Vector2
  2462. */
  2463. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2464. /**
  2465. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2466. * @param vector defines the vector to transform
  2467. * @param transformation defines the matrix to apply
  2468. * @param result defines the target vector
  2469. */
  2470. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2471. /**
  2472. * Determines if a given vector is included in a triangle
  2473. * @param p defines the vector to test
  2474. * @param p0 defines 1st triangle point
  2475. * @param p1 defines 2nd triangle point
  2476. * @param p2 defines 3rd triangle point
  2477. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2478. */
  2479. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2480. /**
  2481. * Gets the distance between the vectors "value1" and "value2"
  2482. * @param value1 defines first vector
  2483. * @param value2 defines second vector
  2484. * @returns the distance between vectors
  2485. */
  2486. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2487. /**
  2488. * Returns the squared distance between the vectors "value1" and "value2"
  2489. * @param value1 defines first vector
  2490. * @param value2 defines second vector
  2491. * @returns the squared distance between vectors
  2492. */
  2493. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2494. /**
  2495. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2496. * @param value1 defines first vector
  2497. * @param value2 defines second vector
  2498. * @returns a new Vector2
  2499. */
  2500. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2501. /**
  2502. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2503. * @param p defines the middle point
  2504. * @param segA defines one point of the segment
  2505. * @param segB defines the other point of the segment
  2506. * @returns the shortest distance
  2507. */
  2508. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2509. }
  2510. /**
  2511. * Class used to store (x,y,z) vector representation
  2512. * A Vector3 is the main object used in 3D geometry
  2513. * It can represent etiher the coordinates of a point the space, either a direction
  2514. * Reminder: js uses a left handed forward facing system
  2515. */
  2516. export class Vector3 {
  2517. private static _UpReadOnly;
  2518. private static _ZeroReadOnly;
  2519. /** @hidden */
  2520. _x: number;
  2521. /** @hidden */
  2522. _y: number;
  2523. /** @hidden */
  2524. _z: number;
  2525. /** @hidden */
  2526. _isDirty: boolean;
  2527. /** Gets or sets the x coordinate */
  2528. get x(): number;
  2529. set x(value: number);
  2530. /** Gets or sets the y coordinate */
  2531. get y(): number;
  2532. set y(value: number);
  2533. /** Gets or sets the z coordinate */
  2534. get z(): number;
  2535. set z(value: number);
  2536. /**
  2537. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2538. * @param x defines the first coordinates (on X axis)
  2539. * @param y defines the second coordinates (on Y axis)
  2540. * @param z defines the third coordinates (on Z axis)
  2541. */
  2542. constructor(x?: number, y?: number, z?: number);
  2543. /**
  2544. * Creates a string representation of the Vector3
  2545. * @returns a string with the Vector3 coordinates.
  2546. */
  2547. toString(): string;
  2548. /**
  2549. * Gets the class name
  2550. * @returns the string "Vector3"
  2551. */
  2552. getClassName(): string;
  2553. /**
  2554. * Creates the Vector3 hash code
  2555. * @returns a number which tends to be unique between Vector3 instances
  2556. */
  2557. getHashCode(): number;
  2558. /**
  2559. * Creates an array containing three elements : the coordinates of the Vector3
  2560. * @returns a new array of numbers
  2561. */
  2562. asArray(): number[];
  2563. /**
  2564. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2565. * @param array defines the destination array
  2566. * @param index defines the offset in the destination array
  2567. * @returns the current Vector3
  2568. */
  2569. toArray(array: FloatArray, index?: number): Vector3;
  2570. /**
  2571. * Update the current vector from an array
  2572. * @param array defines the destination array
  2573. * @param index defines the offset in the destination array
  2574. * @returns the current Vector3
  2575. */
  2576. fromArray(array: FloatArray, index?: number): Vector3;
  2577. /**
  2578. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2579. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2580. */
  2581. toQuaternion(): Quaternion;
  2582. /**
  2583. * Adds the given vector to the current Vector3
  2584. * @param otherVector defines the second operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2588. /**
  2589. * Adds the given coordinates to the current Vector3
  2590. * @param x defines the x coordinate of the operand
  2591. * @param y defines the y coordinate of the operand
  2592. * @param z defines the z coordinate of the operand
  2593. * @returns the current updated Vector3
  2594. */
  2595. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2596. /**
  2597. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2598. * @param otherVector defines the second operand
  2599. * @returns the resulting Vector3
  2600. */
  2601. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2602. /**
  2603. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2604. * @param otherVector defines the second operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2609. /**
  2610. * Subtract the given vector from the current Vector3
  2611. * @param otherVector defines the second operand
  2612. * @returns the current updated Vector3
  2613. */
  2614. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2615. /**
  2616. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2617. * @param otherVector defines the second operand
  2618. * @returns the resulting Vector3
  2619. */
  2620. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2621. /**
  2622. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2623. * @param otherVector defines the second operand
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector3
  2626. */
  2627. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2628. /**
  2629. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  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. * @returns the resulting Vector3
  2634. */
  2635. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2636. /**
  2637. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2638. * @param x defines the x coordinate of the operand
  2639. * @param y defines the y coordinate of the operand
  2640. * @param z defines the z coordinate of the operand
  2641. * @param result defines the Vector3 object where to store the result
  2642. * @returns the current Vector3
  2643. */
  2644. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2645. /**
  2646. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2647. * @returns a new Vector3
  2648. */
  2649. negate(): Vector3;
  2650. /**
  2651. * Negate this vector in place
  2652. * @returns this
  2653. */
  2654. negateInPlace(): Vector3;
  2655. /**
  2656. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2657. * @param result defines the Vector3 object where to store the result
  2658. * @returns the current Vector3
  2659. */
  2660. negateToRef(result: Vector3): Vector3;
  2661. /**
  2662. * Multiplies the Vector3 coordinates by the float "scale"
  2663. * @param scale defines the multiplier factor
  2664. * @returns the current updated Vector3
  2665. */
  2666. scaleInPlace(scale: number): Vector3;
  2667. /**
  2668. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2669. * @param scale defines the multiplier factor
  2670. * @returns a new Vector3
  2671. */
  2672. scale(scale: number): Vector3;
  2673. /**
  2674. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2675. * @param scale defines the multiplier factor
  2676. * @param result defines the Vector3 object where to store the result
  2677. * @returns the current Vector3
  2678. */
  2679. scaleToRef(scale: number, result: Vector3): Vector3;
  2680. /**
  2681. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2682. * @param scale defines the scale factor
  2683. * @param result defines the Vector3 object where to store the result
  2684. * @returns the unmodified current Vector3
  2685. */
  2686. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2687. /**
  2688. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2689. * @param origin defines the origin of the projection ray
  2690. * @param plane defines the plane to project to
  2691. * @returns the projected vector3
  2692. */
  2693. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2694. /**
  2695. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2696. * @param origin defines the origin of the projection ray
  2697. * @param plane defines the plane to project to
  2698. * @param result defines the Vector3 where to store the result
  2699. */
  2700. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2701. /**
  2702. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2703. * @param otherVector defines the second operand
  2704. * @returns true if both vectors are equals
  2705. */
  2706. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2707. /**
  2708. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2709. * @param otherVector defines the second operand
  2710. * @param epsilon defines the minimal distance to define values as equals
  2711. * @returns true if both vectors are distant less than epsilon
  2712. */
  2713. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2714. /**
  2715. * Returns true if the current Vector3 coordinates equals the given floats
  2716. * @param x defines the x coordinate of the operand
  2717. * @param y defines the y coordinate of the operand
  2718. * @param z defines the z coordinate of the operand
  2719. * @returns true if both vectors are equals
  2720. */
  2721. equalsToFloats(x: number, y: number, z: number): boolean;
  2722. /**
  2723. * Multiplies the current Vector3 coordinates by the given ones
  2724. * @param otherVector defines the second operand
  2725. * @returns the current updated Vector3
  2726. */
  2727. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2728. /**
  2729. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2730. * @param otherVector defines the second operand
  2731. * @returns the new Vector3
  2732. */
  2733. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2734. /**
  2735. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2736. * @param otherVector defines the second operand
  2737. * @param result defines the Vector3 object where to store the result
  2738. * @returns the current Vector3
  2739. */
  2740. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2743. * @param x defines the x coordinate of the operand
  2744. * @param y defines the y coordinate of the operand
  2745. * @param z defines the z coordinate of the operand
  2746. * @returns the new Vector3
  2747. */
  2748. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2751. * @param otherVector defines the second operand
  2752. * @returns the new Vector3
  2753. */
  2754. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2755. /**
  2756. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2757. * @param otherVector defines the second operand
  2758. * @param result defines the Vector3 object where to store the result
  2759. * @returns the current Vector3
  2760. */
  2761. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2762. /**
  2763. * Divides the current Vector3 coordinates by the given ones.
  2764. * @param otherVector defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. divideInPlace(otherVector: Vector3): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2770. * @param other defines the second operand
  2771. * @returns the current updated Vector3
  2772. */
  2773. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2774. /**
  2775. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2776. * @param other defines the second operand
  2777. * @returns the current updated Vector3
  2778. */
  2779. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2780. /**
  2781. * Updates the current Vector3 with the minimal 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. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2788. /**
  2789. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2790. * @param x defines the x coordinate of the operand
  2791. * @param y defines the y coordinate of the operand
  2792. * @param z defines the z coordinate of the operand
  2793. * @returns the current updated Vector3
  2794. */
  2795. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2796. /**
  2797. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2798. * Check if is non uniform within a certain amount of decimal places to account for this
  2799. * @param epsilon the amount the values can differ
  2800. * @returns if the the vector is non uniform to a certain number of decimal places
  2801. */
  2802. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2803. /**
  2804. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2805. */
  2806. get isNonUniform(): boolean;
  2807. /**
  2808. * Gets a new Vector3 from current Vector3 floored values
  2809. * @returns a new Vector3
  2810. */
  2811. floor(): Vector3;
  2812. /**
  2813. * Gets a new Vector3 from current Vector3 floored values
  2814. * @returns a new Vector3
  2815. */
  2816. fract(): Vector3;
  2817. /**
  2818. * Gets the length of the Vector3
  2819. * @returns the length of the Vector3
  2820. */
  2821. length(): number;
  2822. /**
  2823. * Gets the squared length of the Vector3
  2824. * @returns squared length of the Vector3
  2825. */
  2826. lengthSquared(): number;
  2827. /**
  2828. * Normalize the current Vector3.
  2829. * Please note that this is an in place operation.
  2830. * @returns the current updated Vector3
  2831. */
  2832. normalize(): Vector3;
  2833. /**
  2834. * Reorders the x y z properties of the vector in place
  2835. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2836. * @returns the current updated vector
  2837. */
  2838. reorderInPlace(order: string): this;
  2839. /**
  2840. * Rotates the vector around 0,0,0 by a quaternion
  2841. * @param quaternion the rotation quaternion
  2842. * @param result vector to store the result
  2843. * @returns the resulting vector
  2844. */
  2845. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2846. /**
  2847. * Rotates a vector around a given point
  2848. * @param quaternion the rotation quaternion
  2849. * @param point the point to rotate around
  2850. * @param result vector to store the result
  2851. * @returns the resulting vector
  2852. */
  2853. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2854. /**
  2855. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2856. * The cross product is then orthogonal to both current and "other"
  2857. * @param other defines the right operand
  2858. * @returns the cross product
  2859. */
  2860. cross(other: Vector3): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 with the given input length.
  2863. * Please note that this is an in place operation.
  2864. * @param len the length of the vector
  2865. * @returns the current updated Vector3
  2866. */
  2867. normalizeFromLength(len: number): Vector3;
  2868. /**
  2869. * Normalize the current Vector3 to a new vector
  2870. * @returns the new Vector3
  2871. */
  2872. normalizeToNew(): Vector3;
  2873. /**
  2874. * Normalize the current Vector3 to the reference
  2875. * @param reference define the Vector3 to update
  2876. * @returns the updated Vector3
  2877. */
  2878. normalizeToRef(reference: Vector3): Vector3;
  2879. /**
  2880. * Creates a new Vector3 copied from the current Vector3
  2881. * @returns the new Vector3
  2882. */
  2883. clone(): Vector3;
  2884. /**
  2885. * Copies the given vector coordinates to the current Vector3 ones
  2886. * @param source defines the source Vector3
  2887. * @returns the current updated Vector3
  2888. */
  2889. copyFrom(source: DeepImmutable<Vector3>): 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. copyFromFloats(x: number, y: number, z: number): Vector3;
  2898. /**
  2899. * Copies the given floats to the current Vector3 coordinates
  2900. * @param x defines the x coordinate of the operand
  2901. * @param y defines the y coordinate of the operand
  2902. * @param z defines the z coordinate of the operand
  2903. * @returns the current updated Vector3
  2904. */
  2905. set(x: number, y: number, z: number): Vector3;
  2906. /**
  2907. * Copies the given float to the current Vector3 coordinates
  2908. * @param v defines the x, y and z coordinates of the operand
  2909. * @returns the current updated Vector3
  2910. */
  2911. setAll(v: number): Vector3;
  2912. /**
  2913. * Get the clip factor between two vectors
  2914. * @param vector0 defines the first operand
  2915. * @param vector1 defines the second operand
  2916. * @param axis defines the axis to use
  2917. * @param size defines the size along the axis
  2918. * @returns the clip factor
  2919. */
  2920. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2921. /**
  2922. * Get angle between two vectors
  2923. * @param vector0 angle between vector0 and vector1
  2924. * @param vector1 angle between vector0 and vector1
  2925. * @param normal direction of the normal
  2926. * @return the angle between vector0 and vector1
  2927. */
  2928. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2929. /**
  2930. * Returns a new Vector3 set from the index "offset" of the given array
  2931. * @param array defines the source array
  2932. * @param offset defines the offset in the source array
  2933. * @returns the new Vector3
  2934. */
  2935. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2938. * @param array defines the source array
  2939. * @param offset defines the offset in the source array
  2940. * @returns the new Vector3
  2941. * @deprecated Please use FromArray instead.
  2942. */
  2943. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2944. /**
  2945. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2946. * @param array defines the source array
  2947. * @param offset defines the offset in the source array
  2948. * @param result defines the Vector3 where to store the result
  2949. */
  2950. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2951. /**
  2952. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2953. * @param array defines the source array
  2954. * @param offset defines the offset in the source array
  2955. * @param result defines the Vector3 where to store the result
  2956. * @deprecated Please use FromArrayToRef instead.
  2957. */
  2958. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2959. /**
  2960. * Sets the given vector "result" with the given floats.
  2961. * @param x defines the x coordinate of the source
  2962. * @param y defines the y coordinate of the source
  2963. * @param z defines the z coordinate of the source
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2967. /**
  2968. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2969. * @returns a new empty Vector3
  2970. */
  2971. static Zero(): Vector3;
  2972. /**
  2973. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2974. * @returns a new unit Vector3
  2975. */
  2976. static One(): Vector3;
  2977. /**
  2978. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2979. * @returns a new up Vector3
  2980. */
  2981. static Up(): Vector3;
  2982. /**
  2983. * Gets a up Vector3 that must not be updated
  2984. */
  2985. static get UpReadOnly(): DeepImmutable<Vector3>;
  2986. /**
  2987. * Gets a zero Vector3 that must not be updated
  2988. */
  2989. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2990. /**
  2991. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2992. * @returns a new down Vector3
  2993. */
  2994. static Down(): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2997. * @param rightHandedSystem is the scene right-handed (negative z)
  2998. * @returns a new forward Vector3
  2999. */
  3000. static Forward(rightHandedSystem?: boolean): Vector3;
  3001. /**
  3002. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3003. * @param rightHandedSystem is the scene right-handed (negative-z)
  3004. * @returns a new forward Vector3
  3005. */
  3006. static Backward(rightHandedSystem?: boolean): Vector3;
  3007. /**
  3008. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3009. * @returns a new right Vector3
  3010. */
  3011. static Right(): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3014. * @returns a new left Vector3
  3015. */
  3016. static Left(): Vector3;
  3017. /**
  3018. * Returns a new Vector3 set 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. * @returns the transformed Vector3
  3023. */
  3024. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3025. /**
  3026. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3027. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3028. * @param vector defines the Vector3 to transform
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3035. * This method computes tranformed coordinates only, not transformed direction vectors
  3036. * @param x define the x coordinate of the source vector
  3037. * @param y define the y coordinate of the source vector
  3038. * @param z define the z coordinate of the source vector
  3039. * @param transformation defines the transformation matrix
  3040. * @param result defines the Vector3 where to store the result
  3041. */
  3042. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3043. /**
  3044. * Returns a new Vector3 set 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. * @returns the new Vector3
  3049. */
  3050. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3051. /**
  3052. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3053. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3054. * @param vector defines the Vector3 to transform
  3055. * @param transformation defines the transformation matrix
  3056. * @param result defines the Vector3 where to store the result
  3057. */
  3058. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3059. /**
  3060. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3061. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3062. * @param x define the x coordinate of the source vector
  3063. * @param y define the y coordinate of the source vector
  3064. * @param z define the z coordinate of the source vector
  3065. * @param transformation defines the transformation matrix
  3066. * @param result defines the Vector3 where to store the result
  3067. */
  3068. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3069. /**
  3070. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3071. * @param value1 defines the first control point
  3072. * @param value2 defines the second control point
  3073. * @param value3 defines the third control point
  3074. * @param value4 defines the fourth control point
  3075. * @param amount defines the amount on the spline to use
  3076. * @returns the new Vector3
  3077. */
  3078. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3079. /**
  3080. * 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"
  3081. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3082. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3083. * @param value defines the current value
  3084. * @param min defines the lower range value
  3085. * @param max defines the upper range value
  3086. * @returns the new Vector3
  3087. */
  3088. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3089. /**
  3090. * 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"
  3091. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3092. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3093. * @param value defines the current value
  3094. * @param min defines the lower range value
  3095. * @param max defines the upper range value
  3096. * @param result defines the Vector3 where to store the result
  3097. */
  3098. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3099. /**
  3100. * Checks if a given vector is inside a specific range
  3101. * @param v defines the vector to test
  3102. * @param min defines the minimum range
  3103. * @param max defines the maximum range
  3104. */
  3105. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3106. /**
  3107. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3108. * @param value1 defines the first control point
  3109. * @param tangent1 defines the first tangent vector
  3110. * @param value2 defines the second control point
  3111. * @param tangent2 defines the second tangent vector
  3112. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3113. * @returns the new Vector3
  3114. */
  3115. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3116. /**
  3117. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "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. * @returns the new Vector3
  3122. */
  3123. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3124. /**
  3125. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3126. * @param start defines the start value
  3127. * @param end defines the end value
  3128. * @param amount max defines amount between both (between 0 and 1)
  3129. * @param result defines the Vector3 where to store the result
  3130. */
  3131. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3132. /**
  3133. * Returns the dot product (float) between the vectors "left" and "right"
  3134. * @param left defines the left operand
  3135. * @param right defines the right operand
  3136. * @returns the dot product
  3137. */
  3138. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3139. /**
  3140. * Returns a new Vector3 as the cross product of the vectors "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. * @returns the cross product
  3145. */
  3146. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3147. /**
  3148. * Sets the given vector "result" with the cross product of "left" and "right"
  3149. * The cross product is then orthogonal to both "left" and "right"
  3150. * @param left defines the left operand
  3151. * @param right defines the right operand
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Returns a new Vector3 as the normalization of the given vector
  3157. * @param vector defines the Vector3 to normalize
  3158. * @returns the new Vector3
  3159. */
  3160. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3161. /**
  3162. * Sets the given vector "result" with the normalization of the given first vector
  3163. * @param vector defines the Vector3 to normalize
  3164. * @param result defines the Vector3 where to store the result
  3165. */
  3166. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3167. /**
  3168. * Project a Vector3 onto screen space
  3169. * @param vector defines the Vector3 to project
  3170. * @param world defines the world matrix to use
  3171. * @param transform defines the transform (view x projection) matrix to use
  3172. * @param viewport defines the screen viewport to use
  3173. * @returns the new Vector3
  3174. */
  3175. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3176. /**
  3177. * Project a Vector3 onto screen space to reference
  3178. * @param vector defines the Vector3 to project
  3179. * @param world defines the world matrix to use
  3180. * @param transform defines the transform (view x projection) matrix to use
  3181. * @param viewport defines the screen viewport to use
  3182. * @param result the vector in which the screen space will be stored
  3183. * @returns the new Vector3
  3184. */
  3185. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3186. /** @hidden */
  3187. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3188. /**
  3189. * Unproject from screen space to object space
  3190. * @param source defines the screen space Vector3 to use
  3191. * @param viewportWidth defines the current width of the viewport
  3192. * @param viewportHeight defines the current height of the viewport
  3193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3194. * @param transform defines the transform (view x projection) matrix to use
  3195. * @returns the new Vector3
  3196. */
  3197. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param source defines the screen space Vector3 to use
  3201. * @param viewportWidth defines the current width of the viewport
  3202. * @param viewportHeight defines the current height of the viewport
  3203. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3204. * @param view defines the view matrix to use
  3205. * @param projection defines the projection matrix to use
  3206. * @returns the new Vector3
  3207. */
  3208. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3209. /**
  3210. * Unproject from screen space to object space
  3211. * @param source defines the screen space Vector3 to use
  3212. * @param viewportWidth defines the current width of the viewport
  3213. * @param viewportHeight defines the current height of the viewport
  3214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3215. * @param view defines the view matrix to use
  3216. * @param projection defines the projection matrix to use
  3217. * @param result defines the Vector3 where to store the result
  3218. */
  3219. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3220. /**
  3221. * Unproject from screen space to object space
  3222. * @param sourceX defines the screen space x coordinate to use
  3223. * @param sourceY defines the screen space y coordinate to use
  3224. * @param sourceZ defines the screen space z coordinate to use
  3225. * @param viewportWidth defines the current width of the viewport
  3226. * @param viewportHeight defines the current height of the viewport
  3227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3228. * @param view defines the view matrix to use
  3229. * @param projection defines the projection matrix to use
  3230. * @param result defines the Vector3 where to store the result
  3231. */
  3232. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3233. /**
  3234. * Gets the minimal coordinate values between two Vector3
  3235. * @param left defines the first operand
  3236. * @param right defines the second operand
  3237. * @returns the new Vector3
  3238. */
  3239. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3240. /**
  3241. * Gets the maximal coordinate values between two Vector3
  3242. * @param left defines the first operand
  3243. * @param right defines the second operand
  3244. * @returns the new Vector3
  3245. */
  3246. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3247. /**
  3248. * Returns the distance between the vectors "value1" and "value2"
  3249. * @param value1 defines the first operand
  3250. * @param value2 defines the second operand
  3251. * @returns the distance
  3252. */
  3253. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3254. /**
  3255. * Returns the squared distance between the vectors "value1" and "value2"
  3256. * @param value1 defines the first operand
  3257. * @param value2 defines the second operand
  3258. * @returns the squared distance
  3259. */
  3260. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3261. /**
  3262. * Returns a new Vector3 located at the center between "value1" and "value2"
  3263. * @param value1 defines the first operand
  3264. * @param value2 defines the second operand
  3265. * @returns the new Vector3
  3266. */
  3267. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3268. /**
  3269. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3270. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3271. * to something in order to rotate it from its local system to the given target system
  3272. * Note: axis1, axis2 and axis3 are normalized during this operation
  3273. * @param axis1 defines the first axis
  3274. * @param axis2 defines the second axis
  3275. * @param axis3 defines the third axis
  3276. * @returns a new Vector3
  3277. */
  3278. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3279. /**
  3280. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3281. * @param axis1 defines the first axis
  3282. * @param axis2 defines the second axis
  3283. * @param axis3 defines the third axis
  3284. * @param ref defines the Vector3 where to store the result
  3285. */
  3286. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3287. }
  3288. /**
  3289. * Vector4 class created for EulerAngle class conversion to Quaternion
  3290. */
  3291. export class Vector4 {
  3292. /** x value of the vector */
  3293. x: number;
  3294. /** y value of the vector */
  3295. y: number;
  3296. /** z value of the vector */
  3297. z: number;
  3298. /** w value of the vector */
  3299. w: number;
  3300. /**
  3301. * Creates a Vector4 object from the given floats.
  3302. * @param x x value of the vector
  3303. * @param y y value of the vector
  3304. * @param z z value of the vector
  3305. * @param w w value of the vector
  3306. */
  3307. constructor(
  3308. /** x value of the vector */
  3309. x: number,
  3310. /** y value of the vector */
  3311. y: number,
  3312. /** z value of the vector */
  3313. z: number,
  3314. /** w value of the vector */
  3315. w: number);
  3316. /**
  3317. * Returns the string with the Vector4 coordinates.
  3318. * @returns a string containing all the vector values
  3319. */
  3320. toString(): string;
  3321. /**
  3322. * Returns the string "Vector4".
  3323. * @returns "Vector4"
  3324. */
  3325. getClassName(): string;
  3326. /**
  3327. * Returns the Vector4 hash code.
  3328. * @returns a unique hash code
  3329. */
  3330. getHashCode(): number;
  3331. /**
  3332. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3333. * @returns the resulting array
  3334. */
  3335. asArray(): number[];
  3336. /**
  3337. * Populates the given array from the given index with the Vector4 coordinates.
  3338. * @param array array to populate
  3339. * @param index index of the array to start at (default: 0)
  3340. * @returns the Vector4.
  3341. */
  3342. toArray(array: FloatArray, index?: number): Vector4;
  3343. /**
  3344. * Update the current vector from an array
  3345. * @param array defines the destination array
  3346. * @param index defines the offset in the destination array
  3347. * @returns the current Vector3
  3348. */
  3349. fromArray(array: FloatArray, index?: number): Vector4;
  3350. /**
  3351. * Adds the given vector to the current Vector4.
  3352. * @param otherVector the vector to add
  3353. * @returns the updated Vector4.
  3354. */
  3355. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3356. /**
  3357. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3358. * @param otherVector the vector to add
  3359. * @returns the resulting vector
  3360. */
  3361. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3362. /**
  3363. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3364. * @param otherVector the vector to add
  3365. * @param result the vector to store the result
  3366. * @returns the current Vector4.
  3367. */
  3368. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3369. /**
  3370. * Subtract in place the given vector from the current Vector4.
  3371. * @param otherVector the vector to subtract
  3372. * @returns the updated Vector4.
  3373. */
  3374. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3375. /**
  3376. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3377. * @param otherVector the vector to add
  3378. * @returns the new vector with the result
  3379. */
  3380. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3381. /**
  3382. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3383. * @param otherVector the vector to subtract
  3384. * @param result the vector to store the result
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3390. */
  3391. /**
  3392. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3393. * @param x value to subtract
  3394. * @param y value to subtract
  3395. * @param z value to subtract
  3396. * @param w value to subtract
  3397. * @returns new vector containing the result
  3398. */
  3399. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3400. /**
  3401. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3402. * @param x value to subtract
  3403. * @param y value to subtract
  3404. * @param z value to subtract
  3405. * @param w value to subtract
  3406. * @param result the vector to store the result in
  3407. * @returns the current Vector4.
  3408. */
  3409. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3412. * @returns a new vector with the negated values
  3413. */
  3414. negate(): Vector4;
  3415. /**
  3416. * Negate this vector in place
  3417. * @returns this
  3418. */
  3419. negateInPlace(): Vector4;
  3420. /**
  3421. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3422. * @param result defines the Vector3 object where to store the result
  3423. * @returns the current Vector4
  3424. */
  3425. negateToRef(result: Vector4): Vector4;
  3426. /**
  3427. * Multiplies the current Vector4 coordinates by scale (float).
  3428. * @param scale the number to scale with
  3429. * @returns the updated Vector4.
  3430. */
  3431. scaleInPlace(scale: number): Vector4;
  3432. /**
  3433. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3434. * @param scale the number to scale with
  3435. * @returns a new vector with the result
  3436. */
  3437. scale(scale: number): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3440. * @param scale the number to scale with
  3441. * @param result a vector to store the result in
  3442. * @returns the current Vector4.
  3443. */
  3444. scaleToRef(scale: number, result: Vector4): Vector4;
  3445. /**
  3446. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3447. * @param scale defines the scale factor
  3448. * @param result defines the Vector4 object where to store the result
  3449. * @returns the unmodified current Vector4
  3450. */
  3451. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3452. /**
  3453. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3454. * @param otherVector the vector to compare against
  3455. * @returns true if they are equal
  3456. */
  3457. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3458. /**
  3459. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3460. * @param otherVector vector to compare against
  3461. * @param epsilon (Default: very small number)
  3462. * @returns true if they are equal
  3463. */
  3464. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3465. /**
  3466. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3467. * @param x x value to compare against
  3468. * @param y y value to compare against
  3469. * @param z z value to compare against
  3470. * @param w w value to compare against
  3471. * @returns true if equal
  3472. */
  3473. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3474. /**
  3475. * Multiplies in place the current Vector4 by the given one.
  3476. * @param otherVector vector to multiple with
  3477. * @returns the updated Vector4.
  3478. */
  3479. multiplyInPlace(otherVector: Vector4): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3482. * @param otherVector vector to multiple with
  3483. * @returns resulting new vector
  3484. */
  3485. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3488. * @param otherVector vector to multiple with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3495. * @param x x value multiply with
  3496. * @param y y value multiply with
  3497. * @param z z value multiply with
  3498. * @param w w value multiply with
  3499. * @returns resulting new vector
  3500. */
  3501. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3502. /**
  3503. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3504. * @param otherVector vector to devide with
  3505. * @returns resulting new vector
  3506. */
  3507. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3508. /**
  3509. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3510. * @param otherVector vector to devide with
  3511. * @param result vector to store the result
  3512. * @returns the current Vector4.
  3513. */
  3514. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3515. /**
  3516. * Divides the current Vector3 coordinates by the given ones.
  3517. * @param otherVector vector to devide with
  3518. * @returns the updated Vector3.
  3519. */
  3520. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3523. * @param other defines the second operand
  3524. * @returns the current updated Vector4
  3525. */
  3526. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3527. /**
  3528. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3529. * @param other defines the second operand
  3530. * @returns the current updated Vector4
  3531. */
  3532. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Gets a new Vector4 from current Vector4 floored values
  3535. * @returns a new Vector4
  3536. */
  3537. floor(): Vector4;
  3538. /**
  3539. * Gets a new Vector4 from current Vector3 floored values
  3540. * @returns a new Vector4
  3541. */
  3542. fract(): Vector4;
  3543. /**
  3544. * Returns the Vector4 length (float).
  3545. * @returns the length
  3546. */
  3547. length(): number;
  3548. /**
  3549. * Returns the Vector4 squared length (float).
  3550. * @returns the length squared
  3551. */
  3552. lengthSquared(): number;
  3553. /**
  3554. * Normalizes in place the Vector4.
  3555. * @returns the updated Vector4.
  3556. */
  3557. normalize(): Vector4;
  3558. /**
  3559. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3560. * @returns this converted to a new vector3
  3561. */
  3562. toVector3(): Vector3;
  3563. /**
  3564. * Returns a new Vector4 copied from the current one.
  3565. * @returns the new cloned vector
  3566. */
  3567. clone(): Vector4;
  3568. /**
  3569. * Updates the current Vector4 with the given one coordinates.
  3570. * @param source the source vector to copy from
  3571. * @returns the updated Vector4.
  3572. */
  3573. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3574. /**
  3575. * Updates the current Vector4 coordinates with the given floats.
  3576. * @param x float to copy from
  3577. * @param y float to copy from
  3578. * @param z float to copy from
  3579. * @param w float to copy from
  3580. * @returns the updated Vector4.
  3581. */
  3582. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3583. /**
  3584. * Updates the current Vector4 coordinates with the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @returns the updated Vector4.
  3590. */
  3591. set(x: number, y: number, z: number, w: number): Vector4;
  3592. /**
  3593. * Copies the given float to the current Vector3 coordinates
  3594. * @param v defines the x, y, z and w coordinates of the operand
  3595. * @returns the current updated Vector3
  3596. */
  3597. setAll(v: number): Vector4;
  3598. /**
  3599. * Returns a new Vector4 set from the starting index of the given array.
  3600. * @param array the array to pull values from
  3601. * @param offset the offset into the array to start at
  3602. * @returns the new vector
  3603. */
  3604. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3605. /**
  3606. * Updates the given vector "result" from the starting index of the given array.
  3607. * @param array the array to pull values from
  3608. * @param offset the offset into the array to start at
  3609. * @param result the vector to store the result in
  3610. */
  3611. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3612. /**
  3613. * Updates the given vector "result" from the starting index of the given Float32Array.
  3614. * @param array the array to pull values from
  3615. * @param offset the offset into the array to start at
  3616. * @param result the vector to store the result in
  3617. */
  3618. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3619. /**
  3620. * Updates the given vector "result" coordinates from the given floats.
  3621. * @param x float to set from
  3622. * @param y float to set from
  3623. * @param z float to set from
  3624. * @param w float to set from
  3625. * @param result the vector to the floats in
  3626. */
  3627. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3628. /**
  3629. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3630. * @returns the new vector
  3631. */
  3632. static Zero(): Vector4;
  3633. /**
  3634. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3635. * @returns the new vector
  3636. */
  3637. static One(): Vector4;
  3638. /**
  3639. * Returns a new normalized Vector4 from the given one.
  3640. * @param vector the vector to normalize
  3641. * @returns the vector
  3642. */
  3643. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Updates the given vector "result" from the normalization of the given one.
  3646. * @param vector the vector to normalize
  3647. * @param result the vector to store the result in
  3648. */
  3649. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3650. /**
  3651. * Returns a vector with the minimum values from the left and right vectors
  3652. * @param left left vector to minimize
  3653. * @param right right vector to minimize
  3654. * @returns a new vector with the minimum of the left and right vector values
  3655. */
  3656. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3657. /**
  3658. * Returns a vector with the maximum values from the left and right vectors
  3659. * @param left left vector to maximize
  3660. * @param right right vector to maximize
  3661. * @returns a new vector with the maximum of the left and right vector values
  3662. */
  3663. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3664. /**
  3665. * Returns the distance (float) between the vectors "value1" and "value2".
  3666. * @param value1 value to calulate the distance between
  3667. * @param value2 value to calulate the distance between
  3668. * @return the distance between the two vectors
  3669. */
  3670. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3671. /**
  3672. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3673. * @param value1 value to calulate the distance between
  3674. * @param value2 value to calulate the distance between
  3675. * @return the distance between the two vectors squared
  3676. */
  3677. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3678. /**
  3679. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3680. * @param value1 value to calulate the center between
  3681. * @param value2 value to calulate the center between
  3682. * @return the center between the two vectors
  3683. */
  3684. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3685. /**
  3686. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3687. * This methods computes transformed normalized direction vectors only.
  3688. * @param vector the vector to transform
  3689. * @param transformation the transformation matrix to apply
  3690. * @returns the new vector
  3691. */
  3692. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3693. /**
  3694. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3695. * This methods computes transformed normalized direction vectors only.
  3696. * @param vector the vector to transform
  3697. * @param transformation the transformation matrix to apply
  3698. * @param result the vector to store the result in
  3699. */
  3700. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3701. /**
  3702. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3703. * This methods computes transformed normalized direction vectors only.
  3704. * @param x value to transform
  3705. * @param y value to transform
  3706. * @param z value to transform
  3707. * @param w value to transform
  3708. * @param transformation the transformation matrix to apply
  3709. * @param result the vector to store the results in
  3710. */
  3711. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3712. /**
  3713. * Creates a new Vector4 from a Vector3
  3714. * @param source defines the source data
  3715. * @param w defines the 4th component (default is 0)
  3716. * @returns a new Vector4
  3717. */
  3718. static FromVector3(source: Vector3, w?: number): Vector4;
  3719. }
  3720. /**
  3721. * Class used to store quaternion data
  3722. * @see https://en.wikipedia.org/wiki/Quaternion
  3723. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3724. */
  3725. export class Quaternion {
  3726. /** @hidden */
  3727. _x: number;
  3728. /** @hidden */
  3729. _y: number;
  3730. /** @hidden */
  3731. _z: number;
  3732. /** @hidden */
  3733. _w: number;
  3734. /** @hidden */
  3735. _isDirty: boolean;
  3736. /** Gets or sets the x coordinate */
  3737. get x(): number;
  3738. set x(value: number);
  3739. /** Gets or sets the y coordinate */
  3740. get y(): number;
  3741. set y(value: number);
  3742. /** Gets or sets the z coordinate */
  3743. get z(): number;
  3744. set z(value: number);
  3745. /** Gets or sets the w coordinate */
  3746. get w(): number;
  3747. set w(value: number);
  3748. /**
  3749. * Creates a new Quaternion from the given floats
  3750. * @param x defines the first component (0 by default)
  3751. * @param y defines the second component (0 by default)
  3752. * @param z defines the third component (0 by default)
  3753. * @param w defines the fourth component (1.0 by default)
  3754. */
  3755. constructor(x?: number, y?: number, z?: number, w?: number);
  3756. /**
  3757. * Gets a string representation for the current quaternion
  3758. * @returns a string with the Quaternion coordinates
  3759. */
  3760. toString(): string;
  3761. /**
  3762. * Gets the class name of the quaternion
  3763. * @returns the string "Quaternion"
  3764. */
  3765. getClassName(): string;
  3766. /**
  3767. * Gets a hash code for this quaternion
  3768. * @returns the quaternion hash code
  3769. */
  3770. getHashCode(): number;
  3771. /**
  3772. * Copy the quaternion to an array
  3773. * @returns a new array populated with 4 elements from the quaternion coordinates
  3774. */
  3775. asArray(): number[];
  3776. /**
  3777. * Check if two quaternions are equals
  3778. * @param otherQuaternion defines the second operand
  3779. * @return true if the current quaternion and the given one coordinates are strictly equals
  3780. */
  3781. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3782. /**
  3783. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3784. * @param otherQuaternion defines the other quaternion
  3785. * @param epsilon defines the minimal distance to consider equality
  3786. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3787. */
  3788. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3789. /**
  3790. * Clone the current quaternion
  3791. * @returns a new quaternion copied from the current one
  3792. */
  3793. clone(): Quaternion;
  3794. /**
  3795. * Copy a quaternion to the current one
  3796. * @param other defines the other quaternion
  3797. * @returns the updated current quaternion
  3798. */
  3799. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3800. /**
  3801. * Updates the current quaternion with the given float coordinates
  3802. * @param x defines the x coordinate
  3803. * @param y defines the y coordinate
  3804. * @param z defines the z coordinate
  3805. * @param w defines the w coordinate
  3806. * @returns the updated current quaternion
  3807. */
  3808. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3809. /**
  3810. * Updates the current quaternion from the given float coordinates
  3811. * @param x defines the x coordinate
  3812. * @param y defines the y coordinate
  3813. * @param z defines the z coordinate
  3814. * @param w defines the w coordinate
  3815. * @returns the updated current quaternion
  3816. */
  3817. set(x: number, y: number, z: number, w: number): Quaternion;
  3818. /**
  3819. * Adds two quaternions
  3820. * @param other defines the second operand
  3821. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3822. */
  3823. add(other: DeepImmutable<Quaternion>): Quaternion;
  3824. /**
  3825. * Add a quaternion to the current one
  3826. * @param other defines the quaternion to add
  3827. * @returns the current quaternion
  3828. */
  3829. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3830. /**
  3831. * Subtract two quaternions
  3832. * @param other defines the second operand
  3833. * @returns a new quaternion as the subtraction result of the given one from the current one
  3834. */
  3835. subtract(other: Quaternion): Quaternion;
  3836. /**
  3837. * Multiplies the current quaternion by a scale factor
  3838. * @param value defines the scale factor
  3839. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3840. */
  3841. scale(value: number): Quaternion;
  3842. /**
  3843. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3844. * @param scale defines the scale factor
  3845. * @param result defines the Quaternion object where to store the result
  3846. * @returns the unmodified current quaternion
  3847. */
  3848. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3849. /**
  3850. * Multiplies in place the current quaternion by a scale factor
  3851. * @param value defines the scale factor
  3852. * @returns the current modified quaternion
  3853. */
  3854. scaleInPlace(value: number): Quaternion;
  3855. /**
  3856. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3857. * @param scale defines the scale factor
  3858. * @param result defines the Quaternion object where to store the result
  3859. * @returns the unmodified current quaternion
  3860. */
  3861. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3862. /**
  3863. * Multiplies two quaternions
  3864. * @param q1 defines the second operand
  3865. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3866. */
  3867. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3868. /**
  3869. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3870. * @param q1 defines the second operand
  3871. * @param result defines the target quaternion
  3872. * @returns the current quaternion
  3873. */
  3874. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3875. /**
  3876. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3877. * @param q1 defines the second operand
  3878. * @returns the currentupdated quaternion
  3879. */
  3880. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3881. /**
  3882. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3883. * @param ref defines the target quaternion
  3884. * @returns the current quaternion
  3885. */
  3886. conjugateToRef(ref: Quaternion): Quaternion;
  3887. /**
  3888. * Conjugates in place (1-q) the current quaternion
  3889. * @returns the current updated quaternion
  3890. */
  3891. conjugateInPlace(): Quaternion;
  3892. /**
  3893. * Conjugates in place (1-q) the current quaternion
  3894. * @returns a new quaternion
  3895. */
  3896. conjugate(): Quaternion;
  3897. /**
  3898. * Gets length of current quaternion
  3899. * @returns the quaternion length (float)
  3900. */
  3901. length(): number;
  3902. /**
  3903. * Normalize in place the current quaternion
  3904. * @returns the current updated quaternion
  3905. */
  3906. normalize(): Quaternion;
  3907. /**
  3908. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3909. * @param order is a reserved parameter and is ignored for now
  3910. * @returns a new Vector3 containing the Euler angles
  3911. */
  3912. toEulerAngles(order?: string): Vector3;
  3913. /**
  3914. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3915. * @param result defines the vector which will be filled with the Euler angles
  3916. * @returns the current unchanged quaternion
  3917. */
  3918. toEulerAnglesToRef(result: Vector3): Quaternion;
  3919. /**
  3920. * Updates the given rotation matrix with the current quaternion values
  3921. * @param result defines the target matrix
  3922. * @returns the current unchanged quaternion
  3923. */
  3924. toRotationMatrix(result: Matrix): Quaternion;
  3925. /**
  3926. * Updates the current quaternion from the given rotation matrix values
  3927. * @param matrix defines the source matrix
  3928. * @returns the current updated quaternion
  3929. */
  3930. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3931. /**
  3932. * Creates a new quaternion from a rotation matrix
  3933. * @param matrix defines the source matrix
  3934. * @returns a new quaternion created from the given rotation matrix values
  3935. */
  3936. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3937. /**
  3938. * Updates the given quaternion with the given rotation matrix values
  3939. * @param matrix defines the source matrix
  3940. * @param result defines the target quaternion
  3941. */
  3942. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3943. /**
  3944. * Returns the dot product (float) between the quaternions "left" and "right"
  3945. * @param left defines the left operand
  3946. * @param right defines the right operand
  3947. * @returns the dot product
  3948. */
  3949. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3950. /**
  3951. * Checks if the two quaternions are close to each other
  3952. * @param quat0 defines the first quaternion to check
  3953. * @param quat1 defines the second quaternion to check
  3954. * @returns true if the two quaternions are close to each other
  3955. */
  3956. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3957. /**
  3958. * Creates an empty quaternion
  3959. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3960. */
  3961. static Zero(): Quaternion;
  3962. /**
  3963. * Inverse a given quaternion
  3964. * @param q defines the source quaternion
  3965. * @returns a new quaternion as the inverted current quaternion
  3966. */
  3967. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3968. /**
  3969. * Inverse a given quaternion
  3970. * @param q defines the source quaternion
  3971. * @param result the quaternion the result will be stored in
  3972. * @returns the result quaternion
  3973. */
  3974. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3975. /**
  3976. * Creates an identity quaternion
  3977. * @returns the identity quaternion
  3978. */
  3979. static Identity(): Quaternion;
  3980. /**
  3981. * Gets a boolean indicating if the given quaternion is identity
  3982. * @param quaternion defines the quaternion to check
  3983. * @returns true if the quaternion is identity
  3984. */
  3985. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3986. /**
  3987. * Creates a quaternion from a rotation around an axis
  3988. * @param axis defines the axis to use
  3989. * @param angle defines the angle to use
  3990. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3991. */
  3992. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3993. /**
  3994. * Creates a rotation around an axis and stores it into the given quaternion
  3995. * @param axis defines the axis to use
  3996. * @param angle defines the angle to use
  3997. * @param result defines the target quaternion
  3998. * @returns the target quaternion
  3999. */
  4000. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4001. /**
  4002. * Creates a new quaternion from data stored into an array
  4003. * @param array defines the data source
  4004. * @param offset defines the offset in the source array where the data starts
  4005. * @returns a new quaternion
  4006. */
  4007. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4008. /**
  4009. * Updates the given quaternion "result" from the starting index of the given array.
  4010. * @param array the array to pull values from
  4011. * @param offset the offset into the array to start at
  4012. * @param result the quaternion to store the result in
  4013. */
  4014. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4015. /**
  4016. * Create a quaternion from Euler rotation angles
  4017. * @param x Pitch
  4018. * @param y Yaw
  4019. * @param z Roll
  4020. * @returns the new Quaternion
  4021. */
  4022. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4023. /**
  4024. * Updates a quaternion from Euler rotation angles
  4025. * @param x Pitch
  4026. * @param y Yaw
  4027. * @param z Roll
  4028. * @param result the quaternion to store the result
  4029. * @returns the updated quaternion
  4030. */
  4031. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4032. /**
  4033. * Create a quaternion from Euler rotation vector
  4034. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4035. * @returns the new Quaternion
  4036. */
  4037. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4038. /**
  4039. * Updates a quaternion from Euler rotation vector
  4040. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4041. * @param result the quaternion to store the result
  4042. * @returns the updated quaternion
  4043. */
  4044. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4045. /**
  4046. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4047. * @param yaw defines the rotation around Y axis
  4048. * @param pitch defines the rotation around X axis
  4049. * @param roll defines the rotation around Z axis
  4050. * @returns the new quaternion
  4051. */
  4052. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4053. /**
  4054. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4055. * @param yaw defines the rotation around Y axis
  4056. * @param pitch defines the rotation around X axis
  4057. * @param roll defines the rotation around Z axis
  4058. * @param result defines the target quaternion
  4059. */
  4060. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4061. /**
  4062. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4063. * @param alpha defines the rotation around first axis
  4064. * @param beta defines the rotation around second axis
  4065. * @param gamma defines the rotation around third axis
  4066. * @returns the new quaternion
  4067. */
  4068. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4069. /**
  4070. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4071. * @param alpha defines the rotation around first axis
  4072. * @param beta defines the rotation around second axis
  4073. * @param gamma defines the rotation around third axis
  4074. * @param result defines the target quaternion
  4075. */
  4076. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4077. /**
  4078. * 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)
  4079. * @param axis1 defines the first axis
  4080. * @param axis2 defines the second axis
  4081. * @param axis3 defines the third axis
  4082. * @returns the new quaternion
  4083. */
  4084. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4085. /**
  4086. * 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
  4087. * @param axis1 defines the first axis
  4088. * @param axis2 defines the second axis
  4089. * @param axis3 defines the third axis
  4090. * @param ref defines the target quaternion
  4091. */
  4092. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4093. /**
  4094. * Interpolates between two quaternions
  4095. * @param left defines first quaternion
  4096. * @param right defines second quaternion
  4097. * @param amount defines the gradient to use
  4098. * @returns the new interpolated quaternion
  4099. */
  4100. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4101. /**
  4102. * Interpolates between two quaternions and stores it into a target quaternion
  4103. * @param left defines first quaternion
  4104. * @param right defines second quaternion
  4105. * @param amount defines the gradient to use
  4106. * @param result defines the target quaternion
  4107. */
  4108. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4109. /**
  4110. * Interpolate between two quaternions using Hermite interpolation
  4111. * @param value1 defines first quaternion
  4112. * @param tangent1 defines the incoming tangent
  4113. * @param value2 defines second quaternion
  4114. * @param tangent2 defines the outgoing tangent
  4115. * @param amount defines the target quaternion
  4116. * @returns the new interpolated quaternion
  4117. */
  4118. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4119. }
  4120. /**
  4121. * Class used to store matrix data (4x4)
  4122. */
  4123. export class Matrix {
  4124. /**
  4125. * Gets the precision of matrix computations
  4126. */
  4127. static get Use64Bits(): boolean;
  4128. private static _updateFlagSeed;
  4129. private static _identityReadOnly;
  4130. private _isIdentity;
  4131. private _isIdentityDirty;
  4132. private _isIdentity3x2;
  4133. private _isIdentity3x2Dirty;
  4134. /**
  4135. * Gets the update flag of the matrix which is an unique number for the matrix.
  4136. * It will be incremented every time the matrix data change.
  4137. * You can use it to speed the comparison between two versions of the same matrix.
  4138. */
  4139. updateFlag: number;
  4140. private readonly _m;
  4141. /**
  4142. * Gets the internal data of the matrix
  4143. */
  4144. get m(): DeepImmutable<Float32Array | Array<number>>;
  4145. /** @hidden */
  4146. _markAsUpdated(): void;
  4147. /** @hidden */
  4148. private _updateIdentityStatus;
  4149. /**
  4150. * Creates an empty matrix (filled with zeros)
  4151. */
  4152. constructor();
  4153. /**
  4154. * Check if the current matrix is identity
  4155. * @returns true is the matrix is the identity matrix
  4156. */
  4157. isIdentity(): boolean;
  4158. /**
  4159. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4160. * @returns true is the matrix is the identity matrix
  4161. */
  4162. isIdentityAs3x2(): boolean;
  4163. /**
  4164. * Gets the determinant of the matrix
  4165. * @returns the matrix determinant
  4166. */
  4167. determinant(): number;
  4168. /**
  4169. * Returns the matrix as a Float32Array or Array<number>
  4170. * @returns the matrix underlying array
  4171. */
  4172. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4173. /**
  4174. * Returns the matrix as a Float32Array or Array<number>
  4175. * @returns the matrix underlying array.
  4176. */
  4177. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4178. /**
  4179. * Inverts the current matrix in place
  4180. * @returns the current inverted matrix
  4181. */
  4182. invert(): Matrix;
  4183. /**
  4184. * Sets all the matrix elements to zero
  4185. * @returns the current matrix
  4186. */
  4187. reset(): Matrix;
  4188. /**
  4189. * Adds the current matrix with a second one
  4190. * @param other defines the matrix to add
  4191. * @returns a new matrix as the addition of the current matrix and the given one
  4192. */
  4193. add(other: DeepImmutable<Matrix>): Matrix;
  4194. /**
  4195. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4196. * @param other defines the matrix to add
  4197. * @param result defines the target matrix
  4198. * @returns the current matrix
  4199. */
  4200. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4201. /**
  4202. * Adds in place the given matrix to the current matrix
  4203. * @param other defines the second operand
  4204. * @returns the current updated matrix
  4205. */
  4206. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4207. /**
  4208. * Sets the given matrix to the current inverted Matrix
  4209. * @param other defines the target matrix
  4210. * @returns the unmodified current matrix
  4211. */
  4212. invertToRef(other: Matrix): Matrix;
  4213. /**
  4214. * add a value at the specified position in the current Matrix
  4215. * @param index the index of the value within the matrix. between 0 and 15.
  4216. * @param value the value to be added
  4217. * @returns the current updated matrix
  4218. */
  4219. addAtIndex(index: number, value: number): Matrix;
  4220. /**
  4221. * mutiply the specified position in the current Matrix by a value
  4222. * @param index the index of the value within the matrix. between 0 and 15.
  4223. * @param value the value to be added
  4224. * @returns the current updated matrix
  4225. */
  4226. multiplyAtIndex(index: number, value: number): Matrix;
  4227. /**
  4228. * Inserts the translation vector (using 3 floats) in the current matrix
  4229. * @param x defines the 1st component of the translation
  4230. * @param y defines the 2nd component of the translation
  4231. * @param z defines the 3rd component of the translation
  4232. * @returns the current updated matrix
  4233. */
  4234. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4235. /**
  4236. * Adds the translation vector (using 3 floats) in the current matrix
  4237. * @param x defines the 1st component of the translation
  4238. * @param y defines the 2nd component of the translation
  4239. * @param z defines the 3rd component of the translation
  4240. * @returns the current updated matrix
  4241. */
  4242. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4243. /**
  4244. * Inserts the translation vector in the current matrix
  4245. * @param vector3 defines the translation to insert
  4246. * @returns the current updated matrix
  4247. */
  4248. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4249. /**
  4250. * Gets the translation value of the current matrix
  4251. * @returns a new Vector3 as the extracted translation from the matrix
  4252. */
  4253. getTranslation(): Vector3;
  4254. /**
  4255. * Fill a Vector3 with the extracted translation from the matrix
  4256. * @param result defines the Vector3 where to store the translation
  4257. * @returns the current matrix
  4258. */
  4259. getTranslationToRef(result: Vector3): Matrix;
  4260. /**
  4261. * Remove rotation and scaling part from the matrix
  4262. * @returns the updated matrix
  4263. */
  4264. removeRotationAndScaling(): Matrix;
  4265. /**
  4266. * Multiply two matrices
  4267. * @param other defines the second operand
  4268. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4269. */
  4270. multiply(other: DeepImmutable<Matrix>): Matrix;
  4271. /**
  4272. * Copy the current matrix from the given one
  4273. * @param other defines the source matrix
  4274. * @returns the current updated matrix
  4275. */
  4276. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Populates the given array from the starting index with the current matrix values
  4279. * @param array defines the target array
  4280. * @param offset defines the offset in the target array where to start storing values
  4281. * @returns the current matrix
  4282. */
  4283. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4284. /**
  4285. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4286. * @param other defines the second operand
  4287. * @param result defines the matrix where to store the multiplication
  4288. * @returns the current matrix
  4289. */
  4290. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4291. /**
  4292. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4293. * @param other defines the second operand
  4294. * @param result defines the array where to store the multiplication
  4295. * @param offset defines the offset in the target array where to start storing values
  4296. * @returns the current matrix
  4297. */
  4298. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4299. /**
  4300. * Check equality between this matrix and a second one
  4301. * @param value defines the second matrix to compare
  4302. * @returns true is the current matrix and the given one values are strictly equal
  4303. */
  4304. equals(value: DeepImmutable<Matrix>): boolean;
  4305. /**
  4306. * Clone the current matrix
  4307. * @returns a new matrix from the current matrix
  4308. */
  4309. clone(): Matrix;
  4310. /**
  4311. * Returns the name of the current matrix class
  4312. * @returns the string "Matrix"
  4313. */
  4314. getClassName(): string;
  4315. /**
  4316. * Gets the hash code of the current matrix
  4317. * @returns the hash code
  4318. */
  4319. getHashCode(): number;
  4320. /**
  4321. * Decomposes the current Matrix into a translation, rotation and scaling components
  4322. * @param scale defines the scale vector3 given as a reference to update
  4323. * @param rotation defines the rotation quaternion given as a reference to update
  4324. * @param translation defines the translation vector3 given as a reference to update
  4325. * @returns true if operation was successful
  4326. */
  4327. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4328. /**
  4329. * Gets specific row of the matrix
  4330. * @param index defines the number of the row to get
  4331. * @returns the index-th row of the current matrix as a new Vector4
  4332. */
  4333. getRow(index: number): Nullable<Vector4>;
  4334. /**
  4335. * Sets the index-th row of the current matrix to the vector4 values
  4336. * @param index defines the number of the row to set
  4337. * @param row defines the target vector4
  4338. * @returns the updated current matrix
  4339. */
  4340. setRow(index: number, row: Vector4): Matrix;
  4341. /**
  4342. * Compute the transpose of the matrix
  4343. * @returns the new transposed matrix
  4344. */
  4345. transpose(): Matrix;
  4346. /**
  4347. * Compute the transpose of the matrix and store it in a given matrix
  4348. * @param result defines the target matrix
  4349. * @returns the current matrix
  4350. */
  4351. transposeToRef(result: Matrix): Matrix;
  4352. /**
  4353. * Sets the index-th row of the current matrix with the given 4 x float values
  4354. * @param index defines the row index
  4355. * @param x defines the x component to set
  4356. * @param y defines the y component to set
  4357. * @param z defines the z component to set
  4358. * @param w defines the w component to set
  4359. * @returns the updated current matrix
  4360. */
  4361. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4362. /**
  4363. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4364. * @param scale defines the scale factor
  4365. * @returns a new matrix
  4366. */
  4367. scale(scale: number): Matrix;
  4368. /**
  4369. * Scale the current matrix values by a factor to a given result matrix
  4370. * @param scale defines the scale factor
  4371. * @param result defines the matrix to store the result
  4372. * @returns the current matrix
  4373. */
  4374. scaleToRef(scale: number, result: Matrix): Matrix;
  4375. /**
  4376. * Scale the current matrix values by a factor and add the result to a given matrix
  4377. * @param scale defines the scale factor
  4378. * @param result defines the Matrix to store the result
  4379. * @returns the current matrix
  4380. */
  4381. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4382. /**
  4383. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4384. * @param ref matrix to store the result
  4385. */
  4386. toNormalMatrix(ref: Matrix): void;
  4387. /**
  4388. * Gets only rotation part of the current matrix
  4389. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4390. */
  4391. getRotationMatrix(): Matrix;
  4392. /**
  4393. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4394. * @param result defines the target matrix to store data to
  4395. * @returns the current matrix
  4396. */
  4397. getRotationMatrixToRef(result: Matrix): Matrix;
  4398. /**
  4399. * Toggles model matrix from being right handed to left handed in place and vice versa
  4400. */
  4401. toggleModelMatrixHandInPlace(): void;
  4402. /**
  4403. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4404. */
  4405. toggleProjectionMatrixHandInPlace(): void;
  4406. /**
  4407. * Creates a matrix from an array
  4408. * @param array defines the source array
  4409. * @param offset defines an offset in the source array
  4410. * @returns a new Matrix set from the starting index of the given array
  4411. */
  4412. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4413. /**
  4414. * Copy the content of an array into a given matrix
  4415. * @param array defines the source array
  4416. * @param offset defines an offset in the source array
  4417. * @param result defines the target matrix
  4418. */
  4419. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4420. /**
  4421. * Stores an array into a matrix after having multiplied each component by a given factor
  4422. * @param array defines the source array
  4423. * @param offset defines the offset in the source array
  4424. * @param scale defines the scaling factor
  4425. * @param result defines the target matrix
  4426. */
  4427. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4428. /**
  4429. * Gets an identity matrix that must not be updated
  4430. */
  4431. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4432. /**
  4433. * Stores a list of values (16) inside a given matrix
  4434. * @param initialM11 defines 1st value of 1st row
  4435. * @param initialM12 defines 2nd value of 1st row
  4436. * @param initialM13 defines 3rd value of 1st row
  4437. * @param initialM14 defines 4th value of 1st row
  4438. * @param initialM21 defines 1st value of 2nd row
  4439. * @param initialM22 defines 2nd value of 2nd row
  4440. * @param initialM23 defines 3rd value of 2nd row
  4441. * @param initialM24 defines 4th value of 2nd row
  4442. * @param initialM31 defines 1st value of 3rd row
  4443. * @param initialM32 defines 2nd value of 3rd row
  4444. * @param initialM33 defines 3rd value of 3rd row
  4445. * @param initialM34 defines 4th value of 3rd row
  4446. * @param initialM41 defines 1st value of 4th row
  4447. * @param initialM42 defines 2nd value of 4th row
  4448. * @param initialM43 defines 3rd value of 4th row
  4449. * @param initialM44 defines 4th value of 4th row
  4450. * @param result defines the target matrix
  4451. */
  4452. 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;
  4453. /**
  4454. * Creates new matrix from a list of values (16)
  4455. * @param initialM11 defines 1st value of 1st row
  4456. * @param initialM12 defines 2nd value of 1st row
  4457. * @param initialM13 defines 3rd value of 1st row
  4458. * @param initialM14 defines 4th value of 1st row
  4459. * @param initialM21 defines 1st value of 2nd row
  4460. * @param initialM22 defines 2nd value of 2nd row
  4461. * @param initialM23 defines 3rd value of 2nd row
  4462. * @param initialM24 defines 4th value of 2nd row
  4463. * @param initialM31 defines 1st value of 3rd row
  4464. * @param initialM32 defines 2nd value of 3rd row
  4465. * @param initialM33 defines 3rd value of 3rd row
  4466. * @param initialM34 defines 4th value of 3rd row
  4467. * @param initialM41 defines 1st value of 4th row
  4468. * @param initialM42 defines 2nd value of 4th row
  4469. * @param initialM43 defines 3rd value of 4th row
  4470. * @param initialM44 defines 4th value of 4th row
  4471. * @returns the new matrix
  4472. */
  4473. 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;
  4474. /**
  4475. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4476. * @param scale defines the scale vector3
  4477. * @param rotation defines the rotation quaternion
  4478. * @param translation defines the translation vector3
  4479. * @returns a new matrix
  4480. */
  4481. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4482. /**
  4483. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4484. * @param scale defines the scale vector3
  4485. * @param rotation defines the rotation quaternion
  4486. * @param translation defines the translation vector3
  4487. * @param result defines the target matrix
  4488. */
  4489. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4490. /**
  4491. * Creates a new identity matrix
  4492. * @returns a new identity matrix
  4493. */
  4494. static Identity(): Matrix;
  4495. /**
  4496. * Creates a new identity matrix and stores the result in a given matrix
  4497. * @param result defines the target matrix
  4498. */
  4499. static IdentityToRef(result: Matrix): void;
  4500. /**
  4501. * Creates a new zero matrix
  4502. * @returns a new zero matrix
  4503. */
  4504. static Zero(): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the X axis
  4507. * @param angle defines the angle (in radians) to use
  4508. * @return the new matrix
  4509. */
  4510. static RotationX(angle: number): Matrix;
  4511. /**
  4512. * Creates a new matrix as the invert of a given matrix
  4513. * @param source defines the source matrix
  4514. * @returns the new matrix
  4515. */
  4516. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4519. * @param angle defines the angle (in radians) to use
  4520. * @param result defines the target matrix
  4521. */
  4522. static RotationXToRef(angle: number, result: Matrix): void;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Y axis
  4525. * @param angle defines the angle (in radians) to use
  4526. * @return the new matrix
  4527. */
  4528. static RotationY(angle: number): Matrix;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4531. * @param angle defines the angle (in radians) to use
  4532. * @param result defines the target matrix
  4533. */
  4534. static RotationYToRef(angle: number, result: Matrix): void;
  4535. /**
  4536. * Creates a new rotation matrix for "angle" radians around the Z axis
  4537. * @param angle defines the angle (in radians) to use
  4538. * @return the new matrix
  4539. */
  4540. static RotationZ(angle: number): Matrix;
  4541. /**
  4542. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4543. * @param angle defines the angle (in radians) to use
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationZToRef(angle: number, result: Matrix): void;
  4547. /**
  4548. * Creates a new rotation matrix for "angle" radians around the given axis
  4549. * @param axis defines the axis to use
  4550. * @param angle defines the angle (in radians) to use
  4551. * @return the new matrix
  4552. */
  4553. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4554. /**
  4555. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4556. * @param axis defines the axis to use
  4557. * @param angle defines the angle (in radians) to use
  4558. * @param result defines the target matrix
  4559. */
  4560. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4561. /**
  4562. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4563. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4564. * @param from defines the vector to align
  4565. * @param to defines the vector to align to
  4566. * @param result defines the target matrix
  4567. */
  4568. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4569. /**
  4570. * Creates a rotation matrix
  4571. * @param yaw defines the yaw angle in radians (Y axis)
  4572. * @param pitch defines the pitch angle in radians (X axis)
  4573. * @param roll defines the roll angle in radians (Z axis)
  4574. * @returns the new rotation matrix
  4575. */
  4576. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4577. /**
  4578. * Creates a rotation matrix and stores it in a given matrix
  4579. * @param yaw defines the yaw angle in radians (Y axis)
  4580. * @param pitch defines the pitch angle in radians (X axis)
  4581. * @param roll defines the roll angle in radians (Z axis)
  4582. * @param result defines the target matrix
  4583. */
  4584. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4585. /**
  4586. * Creates a scaling matrix
  4587. * @param x defines the scale factor on X axis
  4588. * @param y defines the scale factor on Y axis
  4589. * @param z defines the scale factor on Z axis
  4590. * @returns the new matrix
  4591. */
  4592. static Scaling(x: number, y: number, z: number): Matrix;
  4593. /**
  4594. * Creates a scaling matrix and stores it in a given matrix
  4595. * @param x defines the scale factor on X axis
  4596. * @param y defines the scale factor on Y axis
  4597. * @param z defines the scale factor on Z axis
  4598. * @param result defines the target matrix
  4599. */
  4600. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4601. /**
  4602. * Creates a translation matrix
  4603. * @param x defines the translation on X axis
  4604. * @param y defines the translation on Y axis
  4605. * @param z defines the translationon Z axis
  4606. * @returns the new matrix
  4607. */
  4608. static Translation(x: number, y: number, z: number): Matrix;
  4609. /**
  4610. * Creates a translation matrix and stores it in a given matrix
  4611. * @param x defines the translation on X axis
  4612. * @param y defines the translation on Y axis
  4613. * @param z defines the translationon Z axis
  4614. * @param result defines the target matrix
  4615. */
  4616. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4617. /**
  4618. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4619. * @param startValue defines the start value
  4620. * @param endValue defines the end value
  4621. * @param gradient defines the gradient factor
  4622. * @returns the new matrix
  4623. */
  4624. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4625. /**
  4626. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4627. * @param startValue defines the start value
  4628. * @param endValue defines the end value
  4629. * @param gradient defines the gradient factor
  4630. * @param result defines the Matrix object where to store data
  4631. */
  4632. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4633. /**
  4634. * Builds a new matrix whose values are computed by:
  4635. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4636. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4637. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4638. * @param startValue defines the first matrix
  4639. * @param endValue defines the second matrix
  4640. * @param gradient defines the gradient between the two matrices
  4641. * @returns the new matrix
  4642. */
  4643. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4644. /**
  4645. * Update a matrix to values which are computed by:
  4646. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4647. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4648. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4649. * @param startValue defines the first matrix
  4650. * @param endValue defines the second matrix
  4651. * @param gradient defines the gradient between the two matrices
  4652. * @param result defines the target matrix
  4653. */
  4654. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4673. /**
  4674. * 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"
  4675. * This function works in right handed mode
  4676. * @param eye defines the final position of the entity
  4677. * @param target defines where the entity should look at
  4678. * @param up defines the up vector for the entity
  4679. * @returns the new matrix
  4680. */
  4681. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4682. /**
  4683. * 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".
  4684. * This function works in right handed mode
  4685. * @param eye defines the final position of the entity
  4686. * @param target defines where the entity should look at
  4687. * @param up defines the up vector for the entity
  4688. * @param result defines the target matrix
  4689. */
  4690. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4691. /**
  4692. * Create a left-handed orthographic projection matrix
  4693. * @param width defines the viewport width
  4694. * @param height defines the viewport height
  4695. * @param znear defines the near clip plane
  4696. * @param zfar defines the far clip plane
  4697. * @returns a new matrix as a left-handed orthographic projection matrix
  4698. */
  4699. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4700. /**
  4701. * Store a left-handed orthographic projection to a given matrix
  4702. * @param width defines the viewport width
  4703. * @param height defines the viewport height
  4704. * @param znear defines the near clip plane
  4705. * @param zfar defines the far clip plane
  4706. * @param result defines the target matrix
  4707. */
  4708. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4709. /**
  4710. * Create a left-handed orthographic projection matrix
  4711. * @param left defines the viewport left coordinate
  4712. * @param right defines the viewport right coordinate
  4713. * @param bottom defines the viewport bottom coordinate
  4714. * @param top defines the viewport top coordinate
  4715. * @param znear defines the near clip plane
  4716. * @param zfar defines the far clip plane
  4717. * @returns a new matrix as a left-handed orthographic projection matrix
  4718. */
  4719. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a left-handed orthographic projection into a given matrix
  4722. * @param left defines the viewport left coordinate
  4723. * @param right defines the viewport right coordinate
  4724. * @param bottom defines the viewport bottom coordinate
  4725. * @param top defines the viewport top coordinate
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. */
  4730. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4731. /**
  4732. * Creates a right-handed orthographic projection matrix
  4733. * @param left defines the viewport left coordinate
  4734. * @param right defines the viewport right coordinate
  4735. * @param bottom defines the viewport bottom coordinate
  4736. * @param top defines the viewport top coordinate
  4737. * @param znear defines the near clip plane
  4738. * @param zfar defines the far clip plane
  4739. * @returns a new matrix as a right-handed orthographic projection matrix
  4740. */
  4741. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4742. /**
  4743. * Stores a right-handed orthographic projection into a given matrix
  4744. * @param left defines the viewport left coordinate
  4745. * @param right defines the viewport right coordinate
  4746. * @param bottom defines the viewport bottom coordinate
  4747. * @param top defines the viewport top coordinate
  4748. * @param znear defines the near clip plane
  4749. * @param zfar defines the far clip plane
  4750. * @param result defines the target matrix
  4751. */
  4752. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4753. /**
  4754. * Creates a left-handed perspective projection matrix
  4755. * @param width defines the viewport width
  4756. * @param height defines the viewport height
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @returns a new matrix as a left-handed perspective projection matrix
  4760. */
  4761. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4762. /**
  4763. * Creates a left-handed perspective projection matrix
  4764. * @param fov defines the horizontal field of view
  4765. * @param aspect defines the aspect ratio
  4766. * @param znear defines the near clip plane
  4767. * @param zfar defines the far clip plane
  4768. * @returns a new matrix as a left-handed perspective projection matrix
  4769. */
  4770. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4771. /**
  4772. * Stores a left-handed perspective projection into a given matrix
  4773. * @param fov defines the horizontal field of view
  4774. * @param aspect defines the aspect ratio
  4775. * @param znear defines the near clip plane
  4776. * @param zfar defines the far clip plane
  4777. * @param result defines the target matrix
  4778. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4779. */
  4780. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4781. /**
  4782. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4783. * @param fov defines the horizontal field of view
  4784. * @param aspect defines the aspect ratio
  4785. * @param znear defines the near clip plane
  4786. * @param zfar not used as infinity is used as far clip
  4787. * @param result defines the target matrix
  4788. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4789. */
  4790. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4791. /**
  4792. * Creates a right-handed perspective projection matrix
  4793. * @param fov defines the horizontal field of view
  4794. * @param aspect defines the aspect ratio
  4795. * @param znear defines the near clip plane
  4796. * @param zfar defines the far clip plane
  4797. * @returns a new matrix as a right-handed perspective projection matrix
  4798. */
  4799. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4800. /**
  4801. * Stores a right-handed perspective projection into a given matrix
  4802. * @param fov defines the horizontal field of view
  4803. * @param aspect defines the aspect ratio
  4804. * @param znear defines the near clip plane
  4805. * @param zfar defines the far clip plane
  4806. * @param result defines the target matrix
  4807. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4808. */
  4809. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4810. /**
  4811. * Stores a right-handed perspective projection into a given matrix
  4812. * @param fov defines the horizontal field of view
  4813. * @param aspect defines the aspect ratio
  4814. * @param znear defines the near clip plane
  4815. * @param zfar not used as infinity is used as far clip
  4816. * @param result defines the target matrix
  4817. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4818. */
  4819. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4820. /**
  4821. * Stores a perspective projection for WebVR info a given matrix
  4822. * @param fov defines the field of view
  4823. * @param znear defines the near clip plane
  4824. * @param zfar defines the far clip plane
  4825. * @param result defines the target matrix
  4826. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4827. */
  4828. static PerspectiveFovWebVRToRef(fov: {
  4829. upDegrees: number;
  4830. downDegrees: number;
  4831. leftDegrees: number;
  4832. rightDegrees: number;
  4833. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4834. /**
  4835. * Computes a complete transformation matrix
  4836. * @param viewport defines the viewport to use
  4837. * @param world defines the world matrix
  4838. * @param view defines the view matrix
  4839. * @param projection defines the projection matrix
  4840. * @param zmin defines the near clip plane
  4841. * @param zmax defines the far clip plane
  4842. * @returns the transformation matrix
  4843. */
  4844. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4845. /**
  4846. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4847. * @param matrix defines the matrix to use
  4848. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4849. */
  4850. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4851. /**
  4852. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4853. * @param matrix defines the matrix to use
  4854. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4855. */
  4856. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4857. /**
  4858. * Compute the transpose of a given matrix
  4859. * @param matrix defines the matrix to transpose
  4860. * @returns the new matrix
  4861. */
  4862. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4863. /**
  4864. * Compute the transpose of a matrix and store it in a target matrix
  4865. * @param matrix defines the matrix to transpose
  4866. * @param result defines the target matrix
  4867. */
  4868. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4869. /**
  4870. * Computes a reflection matrix from a plane
  4871. * @param plane defines the reflection plane
  4872. * @returns a new matrix
  4873. */
  4874. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4875. /**
  4876. * Computes a reflection matrix from a plane
  4877. * @param plane defines the reflection plane
  4878. * @param result defines the target matrix
  4879. */
  4880. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4881. /**
  4882. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4883. * @param xaxis defines the value of the 1st axis
  4884. * @param yaxis defines the value of the 2nd axis
  4885. * @param zaxis defines the value of the 3rd axis
  4886. * @param result defines the target matrix
  4887. */
  4888. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4889. /**
  4890. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4891. * @param quat defines the quaternion to use
  4892. * @param result defines the target matrix
  4893. */
  4894. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4895. }
  4896. /**
  4897. * @hidden
  4898. */
  4899. export class TmpVectors {
  4900. static Vector2: Vector2[];
  4901. static Vector3: Vector3[];
  4902. static Vector4: Vector4[];
  4903. static Quaternion: Quaternion[];
  4904. static Matrix: Matrix[];
  4905. }
  4906. }
  4907. declare module "babylonjs/Maths/math.path" {
  4908. import { DeepImmutable, Nullable } from "babylonjs/types";
  4909. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4910. /**
  4911. * Defines potential orientation for back face culling
  4912. */
  4913. export enum Orientation {
  4914. /**
  4915. * Clockwise
  4916. */
  4917. CW = 0,
  4918. /** Counter clockwise */
  4919. CCW = 1
  4920. }
  4921. /** Class used to represent a Bezier curve */
  4922. export class BezierCurve {
  4923. /**
  4924. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4925. * @param t defines the time
  4926. * @param x1 defines the left coordinate on X axis
  4927. * @param y1 defines the left coordinate on Y axis
  4928. * @param x2 defines the right coordinate on X axis
  4929. * @param y2 defines the right coordinate on Y axis
  4930. * @returns the interpolated value
  4931. */
  4932. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4933. }
  4934. /**
  4935. * Defines angle representation
  4936. */
  4937. export class Angle {
  4938. private _radians;
  4939. /**
  4940. * Creates an Angle object of "radians" radians (float).
  4941. * @param radians the angle in radians
  4942. */
  4943. constructor(radians: number);
  4944. /**
  4945. * Get value in degrees
  4946. * @returns the Angle value in degrees (float)
  4947. */
  4948. degrees(): number;
  4949. /**
  4950. * Get value in radians
  4951. * @returns the Angle value in radians (float)
  4952. */
  4953. radians(): number;
  4954. /**
  4955. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4956. * @param a defines first point as the origin
  4957. * @param b defines point
  4958. * @returns a new Angle
  4959. */
  4960. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4961. /**
  4962. * Gets a new Angle object from the given float in radians
  4963. * @param radians defines the angle value in radians
  4964. * @returns a new Angle
  4965. */
  4966. static FromRadians(radians: number): Angle;
  4967. /**
  4968. * Gets a new Angle object from the given float in degrees
  4969. * @param degrees defines the angle value in degrees
  4970. * @returns a new Angle
  4971. */
  4972. static FromDegrees(degrees: number): Angle;
  4973. }
  4974. /**
  4975. * This represents an arc in a 2d space.
  4976. */
  4977. export class Arc2 {
  4978. /** Defines the start point of the arc */
  4979. startPoint: Vector2;
  4980. /** Defines the mid point of the arc */
  4981. midPoint: Vector2;
  4982. /** Defines the end point of the arc */
  4983. endPoint: Vector2;
  4984. /**
  4985. * Defines the center point of the arc.
  4986. */
  4987. centerPoint: Vector2;
  4988. /**
  4989. * Defines the radius of the arc.
  4990. */
  4991. radius: number;
  4992. /**
  4993. * Defines the angle of the arc (from mid point to end point).
  4994. */
  4995. angle: Angle;
  4996. /**
  4997. * Defines the start angle of the arc (from start point to middle point).
  4998. */
  4999. startAngle: Angle;
  5000. /**
  5001. * Defines the orientation of the arc (clock wise/counter clock wise).
  5002. */
  5003. orientation: Orientation;
  5004. /**
  5005. * Creates an Arc object from the three given points : start, middle and end.
  5006. * @param startPoint Defines the start point of the arc
  5007. * @param midPoint Defines the midlle point of the arc
  5008. * @param endPoint Defines the end point of the arc
  5009. */
  5010. constructor(
  5011. /** Defines the start point of the arc */
  5012. startPoint: Vector2,
  5013. /** Defines the mid point of the arc */
  5014. midPoint: Vector2,
  5015. /** Defines the end point of the arc */
  5016. endPoint: Vector2);
  5017. }
  5018. /**
  5019. * Represents a 2D path made up of multiple 2D points
  5020. */
  5021. export class Path2 {
  5022. private _points;
  5023. private _length;
  5024. /**
  5025. * If the path start and end point are the same
  5026. */
  5027. closed: boolean;
  5028. /**
  5029. * Creates a Path2 object from the starting 2D coordinates x and y.
  5030. * @param x the starting points x value
  5031. * @param y the starting points y value
  5032. */
  5033. constructor(x: number, y: number);
  5034. /**
  5035. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5036. * @param x the added points x value
  5037. * @param y the added points y value
  5038. * @returns the updated Path2.
  5039. */
  5040. addLineTo(x: number, y: number): Path2;
  5041. /**
  5042. * 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.
  5043. * @param midX middle point x value
  5044. * @param midY middle point y value
  5045. * @param endX end point x value
  5046. * @param endY end point y value
  5047. * @param numberOfSegments (default: 36)
  5048. * @returns the updated Path2.
  5049. */
  5050. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5051. /**
  5052. * Closes the Path2.
  5053. * @returns the Path2.
  5054. */
  5055. close(): Path2;
  5056. /**
  5057. * Gets the sum of the distance between each sequential point in the path
  5058. * @returns the Path2 total length (float).
  5059. */
  5060. length(): number;
  5061. /**
  5062. * Gets the points which construct the path
  5063. * @returns the Path2 internal array of points.
  5064. */
  5065. getPoints(): Vector2[];
  5066. /**
  5067. * Retreives the point at the distance aways from the starting point
  5068. * @param normalizedLengthPosition the length along the path to retreive the point from
  5069. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5070. */
  5071. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5072. /**
  5073. * Creates a new path starting from an x and y position
  5074. * @param x starting x value
  5075. * @param y starting y value
  5076. * @returns a new Path2 starting at the coordinates (x, y).
  5077. */
  5078. static StartingAt(x: number, y: number): Path2;
  5079. }
  5080. /**
  5081. * Represents a 3D path made up of multiple 3D points
  5082. */
  5083. export class Path3D {
  5084. /**
  5085. * an array of Vector3, the curve axis of the Path3D
  5086. */
  5087. path: Vector3[];
  5088. private _curve;
  5089. private _distances;
  5090. private _tangents;
  5091. private _normals;
  5092. private _binormals;
  5093. private _raw;
  5094. private _alignTangentsWithPath;
  5095. private readonly _pointAtData;
  5096. /**
  5097. * new Path3D(path, normal, raw)
  5098. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5099. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5100. * @param path an array of Vector3, the curve axis of the Path3D
  5101. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5102. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5103. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5104. */
  5105. constructor(
  5106. /**
  5107. * an array of Vector3, the curve axis of the Path3D
  5108. */
  5109. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5110. /**
  5111. * Returns the Path3D array of successive Vector3 designing its curve.
  5112. * @returns the Path3D array of successive Vector3 designing its curve.
  5113. */
  5114. getCurve(): Vector3[];
  5115. /**
  5116. * Returns the Path3D array of successive Vector3 designing its curve.
  5117. * @returns the Path3D array of successive Vector3 designing its curve.
  5118. */
  5119. getPoints(): Vector3[];
  5120. /**
  5121. * @returns the computed length (float) of the path.
  5122. */
  5123. length(): number;
  5124. /**
  5125. * Returns an array populated with tangent vectors on each Path3D curve point.
  5126. * @returns an array populated with tangent vectors on each Path3D curve point.
  5127. */
  5128. getTangents(): Vector3[];
  5129. /**
  5130. * Returns an array populated with normal vectors on each Path3D curve point.
  5131. * @returns an array populated with normal vectors on each Path3D curve point.
  5132. */
  5133. getNormals(): Vector3[];
  5134. /**
  5135. * Returns an array populated with binormal vectors on each Path3D curve point.
  5136. * @returns an array populated with binormal vectors on each Path3D curve point.
  5137. */
  5138. getBinormals(): Vector3[];
  5139. /**
  5140. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5141. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5142. */
  5143. getDistances(): number[];
  5144. /**
  5145. * Returns an interpolated point along this path
  5146. * @param position the position of the point along this path, from 0.0 to 1.0
  5147. * @returns a new Vector3 as the point
  5148. */
  5149. getPointAt(position: number): Vector3;
  5150. /**
  5151. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5152. * @param position the position of the point along this path, from 0.0 to 1.0
  5153. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5154. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5155. */
  5156. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5157. /**
  5158. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5159. * @param position the position of the point along this path, from 0.0 to 1.0
  5160. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5161. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5162. */
  5163. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5164. /**
  5165. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5166. * @param position the position of the point along this path, from 0.0 to 1.0
  5167. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5168. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5169. */
  5170. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5171. /**
  5172. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5173. * @param position the position of the point along this path, from 0.0 to 1.0
  5174. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5175. */
  5176. getDistanceAt(position: number): number;
  5177. /**
  5178. * Returns the array index of the previous point of an interpolated point along this path
  5179. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5180. * @returns the array index
  5181. */
  5182. getPreviousPointIndexAt(position: number): number;
  5183. /**
  5184. * 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)
  5185. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5186. * @returns the sub position
  5187. */
  5188. getSubPositionAt(position: number): number;
  5189. /**
  5190. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5191. * @param target the vector of which to get the closest position to
  5192. * @returns the position of the closest virtual point on this path to the target vector
  5193. */
  5194. getClosestPositionTo(target: Vector3): number;
  5195. /**
  5196. * Returns a sub path (slice) of this path
  5197. * @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
  5198. * @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
  5199. * @returns a sub path (slice) of this path
  5200. */
  5201. slice(start?: number, end?: number): Path3D;
  5202. /**
  5203. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5204. * @param path path which all values are copied into the curves points
  5205. * @param firstNormal which should be projected onto the curve
  5206. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5207. * @returns the same object updated.
  5208. */
  5209. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5210. private _compute;
  5211. private _getFirstNonNullVector;
  5212. private _getLastNonNullVector;
  5213. private _normalVector;
  5214. /**
  5215. * Updates the point at data for an interpolated point along this curve
  5216. * @param position the position of the point along this curve, from 0.0 to 1.0
  5217. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5218. * @returns the (updated) point at data
  5219. */
  5220. private _updatePointAtData;
  5221. /**
  5222. * Updates the point at data from the specified parameters
  5223. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5224. * @param point the interpolated point
  5225. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5226. */
  5227. private _setPointAtData;
  5228. /**
  5229. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5230. */
  5231. private _updateInterpolationMatrix;
  5232. }
  5233. /**
  5234. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5235. * A Curve3 is designed from a series of successive Vector3.
  5236. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5237. */
  5238. export class Curve3 {
  5239. private _points;
  5240. private _length;
  5241. /**
  5242. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5243. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5244. * @param v1 (Vector3) the control point
  5245. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5246. * @param nbPoints (integer) the wanted number of points in the curve
  5247. * @returns the created Curve3
  5248. */
  5249. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5250. /**
  5251. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5252. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5253. * @param v1 (Vector3) the first control point
  5254. * @param v2 (Vector3) the second control point
  5255. * @param v3 (Vector3) the end point of the Cubic Bezier
  5256. * @param nbPoints (integer) the wanted number of points in the curve
  5257. * @returns the created Curve3
  5258. */
  5259. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5260. /**
  5261. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5262. * @param p1 (Vector3) the origin point of the Hermite Spline
  5263. * @param t1 (Vector3) the tangent vector at the origin point
  5264. * @param p2 (Vector3) the end point of the Hermite Spline
  5265. * @param t2 (Vector3) the tangent vector at the end point
  5266. * @param nbPoints (integer) the wanted number of points in the curve
  5267. * @returns the created Curve3
  5268. */
  5269. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5270. /**
  5271. * Returns a Curve3 object along a CatmullRom Spline curve :
  5272. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5273. * @param nbPoints (integer) the wanted number of points between each curve control points
  5274. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5275. * @returns the created Curve3
  5276. */
  5277. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5278. /**
  5279. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5280. * A Curve3 is designed from a series of successive Vector3.
  5281. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5282. * @param points points which make up the curve
  5283. */
  5284. constructor(points: Vector3[]);
  5285. /**
  5286. * @returns the Curve3 stored array of successive Vector3
  5287. */
  5288. getPoints(): Vector3[];
  5289. /**
  5290. * @returns the computed length (float) of the curve.
  5291. */
  5292. length(): number;
  5293. /**
  5294. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5295. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5296. * curveA and curveB keep unchanged.
  5297. * @param curve the curve to continue from this curve
  5298. * @returns the newly constructed curve
  5299. */
  5300. continue(curve: DeepImmutable<Curve3>): Curve3;
  5301. private _computeLength;
  5302. }
  5303. }
  5304. declare module "babylonjs/Animations/easing" {
  5305. /**
  5306. * This represents the main contract an easing function should follow.
  5307. * Easing functions are used throughout the animation system.
  5308. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5309. */
  5310. export interface IEasingFunction {
  5311. /**
  5312. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5313. * of the easing function.
  5314. * The link below provides some of the most common examples of easing functions.
  5315. * @see https://easings.net/
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Base class used for every default easing function.
  5323. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5324. */
  5325. export class EasingFunction implements IEasingFunction {
  5326. /**
  5327. * Interpolation follows the mathematical formula associated with the easing function.
  5328. */
  5329. static readonly EASINGMODE_EASEIN: number;
  5330. /**
  5331. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5332. */
  5333. static readonly EASINGMODE_EASEOUT: number;
  5334. /**
  5335. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5336. */
  5337. static readonly EASINGMODE_EASEINOUT: number;
  5338. private _easingMode;
  5339. /**
  5340. * Sets the easing mode of the current function.
  5341. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5342. */
  5343. setEasingMode(easingMode: number): void;
  5344. /**
  5345. * Gets the current easing mode.
  5346. * @returns the easing mode
  5347. */
  5348. getEasingMode(): number;
  5349. /**
  5350. * @hidden
  5351. */
  5352. easeInCore(gradient: number): number;
  5353. /**
  5354. * Given an input gradient between 0 and 1, this returns the corresponding value
  5355. * of the easing function.
  5356. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5357. * @returns the corresponding value on the curve defined by the easing function
  5358. */
  5359. ease(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with a circle shape (see link below).
  5363. * @see https://easings.net/#easeInCirc
  5364. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class CircleEase extends EasingFunction implements IEasingFunction {
  5367. /** @hidden */
  5368. easeInCore(gradient: number): number;
  5369. }
  5370. /**
  5371. * Easing function with a ease back shape (see link below).
  5372. * @see https://easings.net/#easeInBack
  5373. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5374. */
  5375. export class BackEase extends EasingFunction implements IEasingFunction {
  5376. /** Defines the amplitude of the function */
  5377. amplitude: number;
  5378. /**
  5379. * Instantiates a back ease easing
  5380. * @see https://easings.net/#easeInBack
  5381. * @param amplitude Defines the amplitude of the function
  5382. */
  5383. constructor(
  5384. /** Defines the amplitude of the function */
  5385. amplitude?: number);
  5386. /** @hidden */
  5387. easeInCore(gradient: number): number;
  5388. }
  5389. /**
  5390. * Easing function with a bouncing shape (see link below).
  5391. * @see https://easings.net/#easeInBounce
  5392. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5393. */
  5394. export class BounceEase extends EasingFunction implements IEasingFunction {
  5395. /** Defines the number of bounces */
  5396. bounces: number;
  5397. /** Defines the amplitude of the bounce */
  5398. bounciness: number;
  5399. /**
  5400. * Instantiates a bounce easing
  5401. * @see https://easings.net/#easeInBounce
  5402. * @param bounces Defines the number of bounces
  5403. * @param bounciness Defines the amplitude of the bounce
  5404. */
  5405. constructor(
  5406. /** Defines the number of bounces */
  5407. bounces?: number,
  5408. /** Defines the amplitude of the bounce */
  5409. bounciness?: number);
  5410. /** @hidden */
  5411. easeInCore(gradient: number): number;
  5412. }
  5413. /**
  5414. * Easing function with a power of 3 shape (see link below).
  5415. * @see https://easings.net/#easeInCubic
  5416. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5417. */
  5418. export class CubicEase extends EasingFunction implements IEasingFunction {
  5419. /** @hidden */
  5420. easeInCore(gradient: number): number;
  5421. }
  5422. /**
  5423. * Easing function with an elastic shape (see link below).
  5424. * @see https://easings.net/#easeInElastic
  5425. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5426. */
  5427. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5428. /** Defines the number of oscillations*/
  5429. oscillations: number;
  5430. /** Defines the amplitude of the oscillations*/
  5431. springiness: number;
  5432. /**
  5433. * Instantiates an elastic easing function
  5434. * @see https://easings.net/#easeInElastic
  5435. * @param oscillations Defines the number of oscillations
  5436. * @param springiness Defines the amplitude of the oscillations
  5437. */
  5438. constructor(
  5439. /** Defines the number of oscillations*/
  5440. oscillations?: number,
  5441. /** Defines the amplitude of the oscillations*/
  5442. springiness?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with an exponential shape (see link below).
  5448. * @see https://easings.net/#easeInExpo
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5452. /** Defines the exponent of the function */
  5453. exponent: number;
  5454. /**
  5455. * Instantiates an exponential easing function
  5456. * @see https://easings.net/#easeInExpo
  5457. * @param exponent Defines the exponent of the function
  5458. */
  5459. constructor(
  5460. /** Defines the exponent of the function */
  5461. exponent?: number);
  5462. /** @hidden */
  5463. easeInCore(gradient: number): number;
  5464. }
  5465. /**
  5466. * Easing function with a power shape (see link below).
  5467. * @see https://easings.net/#easeInQuad
  5468. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5469. */
  5470. export class PowerEase extends EasingFunction implements IEasingFunction {
  5471. /** Defines the power of the function */
  5472. power: number;
  5473. /**
  5474. * Instantiates an power base easing function
  5475. * @see https://easings.net/#easeInQuad
  5476. * @param power Defines the power of the function
  5477. */
  5478. constructor(
  5479. /** Defines the power of the function */
  5480. power?: number);
  5481. /** @hidden */
  5482. easeInCore(gradient: number): number;
  5483. }
  5484. /**
  5485. * Easing function with a power of 2 shape (see link below).
  5486. * @see https://easings.net/#easeInQuad
  5487. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5488. */
  5489. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. /**
  5494. * Easing function with a power of 4 shape (see link below).
  5495. * @see https://easings.net/#easeInQuart
  5496. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5497. */
  5498. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5499. /** @hidden */
  5500. easeInCore(gradient: number): number;
  5501. }
  5502. /**
  5503. * Easing function with a power of 5 shape (see link below).
  5504. * @see https://easings.net/#easeInQuint
  5505. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5506. */
  5507. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5508. /** @hidden */
  5509. easeInCore(gradient: number): number;
  5510. }
  5511. /**
  5512. * Easing function with a sin shape (see link below).
  5513. * @see https://easings.net/#easeInSine
  5514. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5515. */
  5516. export class SineEase extends EasingFunction implements IEasingFunction {
  5517. /** @hidden */
  5518. easeInCore(gradient: number): number;
  5519. }
  5520. /**
  5521. * Easing function with a bezier shape (see link below).
  5522. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5523. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5524. */
  5525. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5526. /** Defines the x component of the start tangent in the bezier curve */
  5527. x1: number;
  5528. /** Defines the y component of the start tangent in the bezier curve */
  5529. y1: number;
  5530. /** Defines the x component of the end tangent in the bezier curve */
  5531. x2: number;
  5532. /** Defines the y component of the end tangent in the bezier curve */
  5533. y2: number;
  5534. /**
  5535. * Instantiates a bezier function
  5536. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5537. * @param x1 Defines the x component of the start tangent in the bezier curve
  5538. * @param y1 Defines the y component of the start tangent in the bezier curve
  5539. * @param x2 Defines the x component of the end tangent in the bezier curve
  5540. * @param y2 Defines the y component of the end tangent in the bezier curve
  5541. */
  5542. constructor(
  5543. /** Defines the x component of the start tangent in the bezier curve */
  5544. x1?: number,
  5545. /** Defines the y component of the start tangent in the bezier curve */
  5546. y1?: number,
  5547. /** Defines the x component of the end tangent in the bezier curve */
  5548. x2?: number,
  5549. /** Defines the y component of the end tangent in the bezier curve */
  5550. y2?: number);
  5551. /** @hidden */
  5552. easeInCore(gradient: number): number;
  5553. }
  5554. }
  5555. declare module "babylonjs/Maths/math.color" {
  5556. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5557. /**
  5558. * Class used to hold a RBG color
  5559. */
  5560. export class Color3 {
  5561. /**
  5562. * Defines the red component (between 0 and 1, default is 0)
  5563. */
  5564. r: number;
  5565. /**
  5566. * Defines the green component (between 0 and 1, default is 0)
  5567. */
  5568. g: number;
  5569. /**
  5570. * Defines the blue component (between 0 and 1, default is 0)
  5571. */
  5572. b: number;
  5573. /**
  5574. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5575. * @param r defines the red component (between 0 and 1, default is 0)
  5576. * @param g defines the green component (between 0 and 1, default is 0)
  5577. * @param b defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. constructor(
  5580. /**
  5581. * Defines the red component (between 0 and 1, default is 0)
  5582. */
  5583. r?: number,
  5584. /**
  5585. * Defines the green component (between 0 and 1, default is 0)
  5586. */
  5587. g?: number,
  5588. /**
  5589. * Defines the blue component (between 0 and 1, default is 0)
  5590. */
  5591. b?: number);
  5592. /**
  5593. * Creates a string with the Color3 current values
  5594. * @returns the string representation of the Color3 object
  5595. */
  5596. toString(): string;
  5597. /**
  5598. * Returns the string "Color3"
  5599. * @returns "Color3"
  5600. */
  5601. getClassName(): string;
  5602. /**
  5603. * Compute the Color3 hash code
  5604. * @returns an unique number that can be used to hash Color3 objects
  5605. */
  5606. getHashCode(): number;
  5607. /**
  5608. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5609. * @param array defines the array where to store the r,g,b components
  5610. * @param index defines an optional index in the target array to define where to start storing values
  5611. * @returns the current Color3 object
  5612. */
  5613. toArray(array: FloatArray, index?: number): Color3;
  5614. /**
  5615. * Update the current color with values stored in an array from the starting index of the given array
  5616. * @param array defines the source array
  5617. * @param offset defines an offset in the source array
  5618. * @returns the current Color3 object
  5619. */
  5620. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5621. /**
  5622. * Returns a new Color4 object from the current Color3 and the given alpha
  5623. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5624. * @returns a new Color4 object
  5625. */
  5626. toColor4(alpha?: number): Color4;
  5627. /**
  5628. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5629. * @returns the new array
  5630. */
  5631. asArray(): number[];
  5632. /**
  5633. * Returns the luminance value
  5634. * @returns a float value
  5635. */
  5636. toLuminance(): number;
  5637. /**
  5638. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5639. * @param otherColor defines the second operand
  5640. * @returns the new Color3 object
  5641. */
  5642. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5643. /**
  5644. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5645. * @param otherColor defines the second operand
  5646. * @param result defines the Color3 object where to store the result
  5647. * @returns the current Color3
  5648. */
  5649. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5650. /**
  5651. * Determines equality between Color3 objects
  5652. * @param otherColor defines the second operand
  5653. * @returns true if the rgb values are equal to the given ones
  5654. */
  5655. equals(otherColor: DeepImmutable<Color3>): boolean;
  5656. /**
  5657. * Determines equality between the current Color3 object and a set of r,b,g values
  5658. * @param r defines the red component to check
  5659. * @param g defines the green component to check
  5660. * @param b defines the blue component to check
  5661. * @returns true if the rgb values are equal to the given ones
  5662. */
  5663. equalsFloats(r: number, g: number, b: number): boolean;
  5664. /**
  5665. * Multiplies in place each rgb value by scale
  5666. * @param scale defines the scaling factor
  5667. * @returns the updated Color3
  5668. */
  5669. scale(scale: number): Color3;
  5670. /**
  5671. * Multiplies the rgb values by scale and stores the result into "result"
  5672. * @param scale defines the scaling factor
  5673. * @param result defines the Color3 object where to store the result
  5674. * @returns the unmodified current Color3
  5675. */
  5676. scaleToRef(scale: number, result: Color3): Color3;
  5677. /**
  5678. * Scale the current Color3 values by a factor and add the result to a given Color3
  5679. * @param scale defines the scale factor
  5680. * @param result defines color to store the result into
  5681. * @returns the unmodified current Color3
  5682. */
  5683. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5684. /**
  5685. * Clamps the rgb values by the min and max values and stores the result into "result"
  5686. * @param min defines minimum clamping value (default is 0)
  5687. * @param max defines maximum clamping value (default is 1)
  5688. * @param result defines color to store the result into
  5689. * @returns the original Color3
  5690. */
  5691. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5692. /**
  5693. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5694. * @param otherColor defines the second operand
  5695. * @returns the new Color3
  5696. */
  5697. add(otherColor: DeepImmutable<Color3>): Color3;
  5698. /**
  5699. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5700. * @param otherColor defines the second operand
  5701. * @param result defines Color3 object to store the result into
  5702. * @returns the unmodified current Color3
  5703. */
  5704. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5705. /**
  5706. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5707. * @param otherColor defines the second operand
  5708. * @returns the new Color3
  5709. */
  5710. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5711. /**
  5712. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5713. * @param otherColor defines the second operand
  5714. * @param result defines Color3 object to store the result into
  5715. * @returns the unmodified current Color3
  5716. */
  5717. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5718. /**
  5719. * Copy the current object
  5720. * @returns a new Color3 copied the current one
  5721. */
  5722. clone(): Color3;
  5723. /**
  5724. * Copies the rgb values from the source in the current Color3
  5725. * @param source defines the source Color3 object
  5726. * @returns the updated Color3 object
  5727. */
  5728. copyFrom(source: DeepImmutable<Color3>): Color3;
  5729. /**
  5730. * Updates the Color3 rgb values from the given floats
  5731. * @param r defines the red component to read from
  5732. * @param g defines the green component to read from
  5733. * @param b defines the blue component to read from
  5734. * @returns the current Color3 object
  5735. */
  5736. copyFromFloats(r: number, g: number, b: number): Color3;
  5737. /**
  5738. * Updates the Color3 rgb values from the given floats
  5739. * @param r defines the red component to read from
  5740. * @param g defines the green component to read from
  5741. * @param b defines the blue component to read from
  5742. * @returns the current Color3 object
  5743. */
  5744. set(r: number, g: number, b: number): Color3;
  5745. /**
  5746. * Compute the Color3 hexadecimal code as a string
  5747. * @returns a string containing the hexadecimal representation of the Color3 object
  5748. */
  5749. toHexString(): string;
  5750. /**
  5751. * Computes a new Color3 converted from the current one to linear space
  5752. * @returns a new Color3 object
  5753. */
  5754. toLinearSpace(): Color3;
  5755. /**
  5756. * Converts current color in rgb space to HSV values
  5757. * @returns a new color3 representing the HSV values
  5758. */
  5759. toHSV(): Color3;
  5760. /**
  5761. * Converts current color in rgb space to HSV values
  5762. * @param result defines the Color3 where to store the HSV values
  5763. */
  5764. toHSVToRef(result: Color3): void;
  5765. /**
  5766. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5767. * @param convertedColor defines the Color3 object where to store the linear space version
  5768. * @returns the unmodified Color3
  5769. */
  5770. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5771. /**
  5772. * Computes a new Color3 converted from the current one to gamma space
  5773. * @returns a new Color3 object
  5774. */
  5775. toGammaSpace(): Color3;
  5776. /**
  5777. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5778. * @param convertedColor defines the Color3 object where to store the gamma space version
  5779. * @returns the unmodified Color3
  5780. */
  5781. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5782. private static _BlackReadOnly;
  5783. /**
  5784. * Convert Hue, saturation and value to a Color3 (RGB)
  5785. * @param hue defines the hue
  5786. * @param saturation defines the saturation
  5787. * @param value defines the value
  5788. * @param result defines the Color3 where to store the RGB values
  5789. */
  5790. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5791. /**
  5792. * Creates a new Color3 from the string containing valid hexadecimal values
  5793. * @param hex defines a string containing valid hexadecimal values
  5794. * @returns a new Color3 object
  5795. */
  5796. static FromHexString(hex: string): Color3;
  5797. /**
  5798. * Creates a new Color3 from the starting index of the given array
  5799. * @param array defines the source array
  5800. * @param offset defines an offset in the source array
  5801. * @returns a new Color3 object
  5802. */
  5803. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5804. /**
  5805. * Creates a new Color3 from the starting index element of the given array
  5806. * @param array defines the source array to read from
  5807. * @param offset defines the offset in the source array
  5808. * @param result defines the target Color3 object
  5809. */
  5810. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5811. /**
  5812. * Creates a new Color3 from integer values (< 256)
  5813. * @param r defines the red component to read from (value between 0 and 255)
  5814. * @param g defines the green component to read from (value between 0 and 255)
  5815. * @param b defines the blue component to read from (value between 0 and 255)
  5816. * @returns a new Color3 object
  5817. */
  5818. static FromInts(r: number, g: number, b: number): Color3;
  5819. /**
  5820. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5821. * @param start defines the start Color3 value
  5822. * @param end defines the end Color3 value
  5823. * @param amount defines the gradient value between start and end
  5824. * @returns a new Color3 object
  5825. */
  5826. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5827. /**
  5828. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5829. * @param left defines the start value
  5830. * @param right defines the end value
  5831. * @param amount defines the gradient factor
  5832. * @param result defines the Color3 object where to store the result
  5833. */
  5834. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5835. /**
  5836. * Returns a Color3 value containing a red color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Red(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a green color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Green(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a blue color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Blue(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a black color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Black(): Color3;
  5855. /**
  5856. * Gets a Color3 value containing a black color that must not be updated
  5857. */
  5858. static get BlackReadOnly(): DeepImmutable<Color3>;
  5859. /**
  5860. * Returns a Color3 value containing a white color
  5861. * @returns a new Color3 object
  5862. */
  5863. static White(): Color3;
  5864. /**
  5865. * Returns a Color3 value containing a purple color
  5866. * @returns a new Color3 object
  5867. */
  5868. static Purple(): Color3;
  5869. /**
  5870. * Returns a Color3 value containing a magenta color
  5871. * @returns a new Color3 object
  5872. */
  5873. static Magenta(): Color3;
  5874. /**
  5875. * Returns a Color3 value containing a yellow color
  5876. * @returns a new Color3 object
  5877. */
  5878. static Yellow(): Color3;
  5879. /**
  5880. * Returns a Color3 value containing a gray color
  5881. * @returns a new Color3 object
  5882. */
  5883. static Gray(): Color3;
  5884. /**
  5885. * Returns a Color3 value containing a teal color
  5886. * @returns a new Color3 object
  5887. */
  5888. static Teal(): Color3;
  5889. /**
  5890. * Returns a Color3 value containing a random color
  5891. * @returns a new Color3 object
  5892. */
  5893. static Random(): Color3;
  5894. }
  5895. /**
  5896. * Class used to hold a RBGA color
  5897. */
  5898. export class Color4 {
  5899. /**
  5900. * Defines the red component (between 0 and 1, default is 0)
  5901. */
  5902. r: number;
  5903. /**
  5904. * Defines the green component (between 0 and 1, default is 0)
  5905. */
  5906. g: number;
  5907. /**
  5908. * Defines the blue component (between 0 and 1, default is 0)
  5909. */
  5910. b: number;
  5911. /**
  5912. * Defines the alpha component (between 0 and 1, default is 1)
  5913. */
  5914. a: number;
  5915. /**
  5916. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5917. * @param r defines the red component (between 0 and 1, default is 0)
  5918. * @param g defines the green component (between 0 and 1, default is 0)
  5919. * @param b defines the blue component (between 0 and 1, default is 0)
  5920. * @param a defines the alpha component (between 0 and 1, default is 1)
  5921. */
  5922. constructor(
  5923. /**
  5924. * Defines the red component (between 0 and 1, default is 0)
  5925. */
  5926. r?: number,
  5927. /**
  5928. * Defines the green component (between 0 and 1, default is 0)
  5929. */
  5930. g?: number,
  5931. /**
  5932. * Defines the blue component (between 0 and 1, default is 0)
  5933. */
  5934. b?: number,
  5935. /**
  5936. * Defines the alpha component (between 0 and 1, default is 1)
  5937. */
  5938. a?: number);
  5939. /**
  5940. * Adds in place the given Color4 values to the current Color4 object
  5941. * @param right defines the second operand
  5942. * @returns the current updated Color4 object
  5943. */
  5944. addInPlace(right: DeepImmutable<Color4>): Color4;
  5945. /**
  5946. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5947. * @returns the new array
  5948. */
  5949. asArray(): number[];
  5950. /**
  5951. * Stores from the starting index in the given array the Color4 successive values
  5952. * @param array defines the array where to store the r,g,b components
  5953. * @param index defines an optional index in the target array to define where to start storing values
  5954. * @returns the current Color4 object
  5955. */
  5956. toArray(array: number[], index?: number): Color4;
  5957. /**
  5958. * Update the current color with values stored in an array from the starting index of the given array
  5959. * @param array defines the source array
  5960. * @param offset defines an offset in the source array
  5961. * @returns the current Color4 object
  5962. */
  5963. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5964. /**
  5965. * Determines equality between Color4 objects
  5966. * @param otherColor defines the second operand
  5967. * @returns true if the rgba values are equal to the given ones
  5968. */
  5969. equals(otherColor: DeepImmutable<Color4>): boolean;
  5970. /**
  5971. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5972. * @param right defines the second operand
  5973. * @returns a new Color4 object
  5974. */
  5975. add(right: DeepImmutable<Color4>): Color4;
  5976. /**
  5977. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5978. * @param right defines the second operand
  5979. * @returns a new Color4 object
  5980. */
  5981. subtract(right: DeepImmutable<Color4>): Color4;
  5982. /**
  5983. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5984. * @param right defines the second operand
  5985. * @param result defines the Color4 object where to store the result
  5986. * @returns the current Color4 object
  5987. */
  5988. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5989. /**
  5990. * Creates a new Color4 with the current Color4 values multiplied by scale
  5991. * @param scale defines the scaling factor to apply
  5992. * @returns a new Color4 object
  5993. */
  5994. scale(scale: number): Color4;
  5995. /**
  5996. * Multiplies the current Color4 values by scale and stores the result in "result"
  5997. * @param scale defines the scaling factor to apply
  5998. * @param result defines the Color4 object where to store the result
  5999. * @returns the current unmodified Color4
  6000. */
  6001. scaleToRef(scale: number, result: Color4): Color4;
  6002. /**
  6003. * Scale the current Color4 values by a factor and add the result to a given Color4
  6004. * @param scale defines the scale factor
  6005. * @param result defines the Color4 object where to store the result
  6006. * @returns the unmodified current Color4
  6007. */
  6008. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6009. /**
  6010. * Clamps the rgb values by the min and max values and stores the result into "result"
  6011. * @param min defines minimum clamping value (default is 0)
  6012. * @param max defines maximum clamping value (default is 1)
  6013. * @param result defines color to store the result into.
  6014. * @returns the cuurent Color4
  6015. */
  6016. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6017. /**
  6018. * Multipy an Color4 value by another and return a new Color4 object
  6019. * @param color defines the Color4 value to multiply by
  6020. * @returns a new Color4 object
  6021. */
  6022. multiply(color: Color4): Color4;
  6023. /**
  6024. * Multipy a Color4 value by another and push the result in a reference value
  6025. * @param color defines the Color4 value to multiply by
  6026. * @param result defines the Color4 to fill the result in
  6027. * @returns the result Color4
  6028. */
  6029. multiplyToRef(color: Color4, result: Color4): Color4;
  6030. /**
  6031. * Creates a string with the Color4 current values
  6032. * @returns the string representation of the Color4 object
  6033. */
  6034. toString(): string;
  6035. /**
  6036. * Returns the string "Color4"
  6037. * @returns "Color4"
  6038. */
  6039. getClassName(): string;
  6040. /**
  6041. * Compute the Color4 hash code
  6042. * @returns an unique number that can be used to hash Color4 objects
  6043. */
  6044. getHashCode(): number;
  6045. /**
  6046. * Creates a new Color4 copied from the current one
  6047. * @returns a new Color4 object
  6048. */
  6049. clone(): Color4;
  6050. /**
  6051. * Copies the given Color4 values into the current one
  6052. * @param source defines the source Color4 object
  6053. * @returns the current updated Color4 object
  6054. */
  6055. copyFrom(source: Color4): Color4;
  6056. /**
  6057. * Copies the given float values into the current one
  6058. * @param r defines the red component to read from
  6059. * @param g defines the green component to read from
  6060. * @param b defines the blue component to read from
  6061. * @param a defines the alpha component to read from
  6062. * @returns the current updated Color4 object
  6063. */
  6064. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6065. /**
  6066. * Copies the given float values into the current one
  6067. * @param r defines the red component to read from
  6068. * @param g defines the green component to read from
  6069. * @param b defines the blue component to read from
  6070. * @param a defines the alpha component to read from
  6071. * @returns the current updated Color4 object
  6072. */
  6073. set(r: number, g: number, b: number, a: number): Color4;
  6074. /**
  6075. * Compute the Color4 hexadecimal code as a string
  6076. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6077. * @returns a string containing the hexadecimal representation of the Color4 object
  6078. */
  6079. toHexString(returnAsColor3?: boolean): string;
  6080. /**
  6081. * Computes a new Color4 converted from the current one to linear space
  6082. * @returns a new Color4 object
  6083. */
  6084. toLinearSpace(): Color4;
  6085. /**
  6086. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6087. * @param convertedColor defines the Color4 object where to store the linear space version
  6088. * @returns the unmodified Color4
  6089. */
  6090. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6091. /**
  6092. * Computes a new Color4 converted from the current one to gamma space
  6093. * @returns a new Color4 object
  6094. */
  6095. toGammaSpace(): Color4;
  6096. /**
  6097. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6098. * @param convertedColor defines the Color4 object where to store the gamma space version
  6099. * @returns the unmodified Color4
  6100. */
  6101. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6102. /**
  6103. * Creates a new Color4 from the string containing valid hexadecimal values
  6104. * @param hex defines a string containing valid hexadecimal values
  6105. * @returns a new Color4 object
  6106. */
  6107. static FromHexString(hex: string): Color4;
  6108. /**
  6109. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6110. * @param left defines the start value
  6111. * @param right defines the end value
  6112. * @param amount defines the gradient factor
  6113. * @returns a new Color4 object
  6114. */
  6115. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6116. /**
  6117. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6118. * @param left defines the start value
  6119. * @param right defines the end value
  6120. * @param amount defines the gradient factor
  6121. * @param result defines the Color4 object where to store data
  6122. */
  6123. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6124. /**
  6125. * Creates a new Color4 from a Color3 and an alpha value
  6126. * @param color3 defines the source Color3 to read from
  6127. * @param alpha defines the alpha component (1.0 by default)
  6128. * @returns a new Color4 object
  6129. */
  6130. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6131. /**
  6132. * Creates a new Color4 from the starting index element of the given array
  6133. * @param array defines the source array to read from
  6134. * @param offset defines the offset in the source array
  6135. * @returns a new Color4 object
  6136. */
  6137. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6138. /**
  6139. * Creates a new Color4 from the starting index element of the given array
  6140. * @param array defines the source array to read from
  6141. * @param offset defines the offset in the source array
  6142. * @param result defines the target Color4 object
  6143. */
  6144. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6145. /**
  6146. * Creates a new Color3 from integer values (< 256)
  6147. * @param r defines the red component to read from (value between 0 and 255)
  6148. * @param g defines the green component to read from (value between 0 and 255)
  6149. * @param b defines the blue component to read from (value between 0 and 255)
  6150. * @param a defines the alpha component to read from (value between 0 and 255)
  6151. * @returns a new Color3 object
  6152. */
  6153. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6154. /**
  6155. * Check the content of a given array and convert it to an array containing RGBA data
  6156. * If the original array was already containing count * 4 values then it is returned directly
  6157. * @param colors defines the array to check
  6158. * @param count defines the number of RGBA data to expect
  6159. * @returns an array containing count * 4 values (RGBA)
  6160. */
  6161. static CheckColors4(colors: number[], count: number): number[];
  6162. }
  6163. /**
  6164. * @hidden
  6165. */
  6166. export class TmpColors {
  6167. static Color3: Color3[];
  6168. static Color4: Color4[];
  6169. }
  6170. }
  6171. declare module "babylonjs/Animations/animationKey" {
  6172. /**
  6173. * Defines an interface which represents an animation key frame
  6174. */
  6175. export interface IAnimationKey {
  6176. /**
  6177. * Frame of the key frame
  6178. */
  6179. frame: number;
  6180. /**
  6181. * Value at the specifies key frame
  6182. */
  6183. value: any;
  6184. /**
  6185. * The input tangent for the cubic hermite spline
  6186. */
  6187. inTangent?: any;
  6188. /**
  6189. * The output tangent for the cubic hermite spline
  6190. */
  6191. outTangent?: any;
  6192. /**
  6193. * The animation interpolation type
  6194. */
  6195. interpolation?: AnimationKeyInterpolation;
  6196. }
  6197. /**
  6198. * Enum for the animation key frame interpolation type
  6199. */
  6200. export enum AnimationKeyInterpolation {
  6201. /**
  6202. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6203. */
  6204. STEP = 1
  6205. }
  6206. }
  6207. declare module "babylonjs/Animations/animationRange" {
  6208. /**
  6209. * Represents the range of an animation
  6210. */
  6211. export class AnimationRange {
  6212. /**The name of the animation range**/
  6213. name: string;
  6214. /**The starting frame of the animation */
  6215. from: number;
  6216. /**The ending frame of the animation*/
  6217. to: number;
  6218. /**
  6219. * Initializes the range of an animation
  6220. * @param name The name of the animation range
  6221. * @param from The starting frame of the animation
  6222. * @param to The ending frame of the animation
  6223. */
  6224. constructor(
  6225. /**The name of the animation range**/
  6226. name: string,
  6227. /**The starting frame of the animation */
  6228. from: number,
  6229. /**The ending frame of the animation*/
  6230. to: number);
  6231. /**
  6232. * Makes a copy of the animation range
  6233. * @returns A copy of the animation range
  6234. */
  6235. clone(): AnimationRange;
  6236. }
  6237. }
  6238. declare module "babylonjs/Animations/animationEvent" {
  6239. /**
  6240. * Composed of a frame, and an action function
  6241. */
  6242. export class AnimationEvent {
  6243. /** The frame for which the event is triggered **/
  6244. frame: number;
  6245. /** The event to perform when triggered **/
  6246. action: (currentFrame: number) => void;
  6247. /** Specifies if the event should be triggered only once**/
  6248. onlyOnce?: boolean | undefined;
  6249. /**
  6250. * Specifies if the animation event is done
  6251. */
  6252. isDone: boolean;
  6253. /**
  6254. * Initializes the animation event
  6255. * @param frame The frame for which the event is triggered
  6256. * @param action The event to perform when triggered
  6257. * @param onlyOnce Specifies if the event should be triggered only once
  6258. */
  6259. constructor(
  6260. /** The frame for which the event is triggered **/
  6261. frame: number,
  6262. /** The event to perform when triggered **/
  6263. action: (currentFrame: number) => void,
  6264. /** Specifies if the event should be triggered only once**/
  6265. onlyOnce?: boolean | undefined);
  6266. /** @hidden */
  6267. _clone(): AnimationEvent;
  6268. }
  6269. }
  6270. declare module "babylonjs/Behaviors/behavior" {
  6271. import { Nullable } from "babylonjs/types";
  6272. /**
  6273. * Interface used to define a behavior
  6274. */
  6275. export interface Behavior<T> {
  6276. /** gets or sets behavior's name */
  6277. name: string;
  6278. /**
  6279. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6280. */
  6281. init(): void;
  6282. /**
  6283. * Called when the behavior is attached to a target
  6284. * @param target defines the target where the behavior is attached to
  6285. */
  6286. attach(target: T): void;
  6287. /**
  6288. * Called when the behavior is detached from its target
  6289. */
  6290. detach(): void;
  6291. }
  6292. /**
  6293. * Interface implemented by classes supporting behaviors
  6294. */
  6295. export interface IBehaviorAware<T> {
  6296. /**
  6297. * Attach a behavior
  6298. * @param behavior defines the behavior to attach
  6299. * @returns the current host
  6300. */
  6301. addBehavior(behavior: Behavior<T>): T;
  6302. /**
  6303. * Remove a behavior from the current object
  6304. * @param behavior defines the behavior to detach
  6305. * @returns the current host
  6306. */
  6307. removeBehavior(behavior: Behavior<T>): T;
  6308. /**
  6309. * Gets a behavior using its name to search
  6310. * @param name defines the name to search
  6311. * @returns the behavior or null if not found
  6312. */
  6313. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6314. }
  6315. }
  6316. declare module "babylonjs/Misc/smartArray" {
  6317. /**
  6318. * Defines an array and its length.
  6319. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6320. */
  6321. export interface ISmartArrayLike<T> {
  6322. /**
  6323. * The data of the array.
  6324. */
  6325. data: Array<T>;
  6326. /**
  6327. * The active length of the array.
  6328. */
  6329. length: number;
  6330. }
  6331. /**
  6332. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6333. */
  6334. export class SmartArray<T> implements ISmartArrayLike<T> {
  6335. /**
  6336. * The full set of data from the array.
  6337. */
  6338. data: Array<T>;
  6339. /**
  6340. * The active length of the array.
  6341. */
  6342. length: number;
  6343. protected _id: number;
  6344. /**
  6345. * Instantiates a Smart Array.
  6346. * @param capacity defines the default capacity of the array.
  6347. */
  6348. constructor(capacity: number);
  6349. /**
  6350. * Pushes a value at the end of the active data.
  6351. * @param value defines the object to push in the array.
  6352. */
  6353. push(value: T): void;
  6354. /**
  6355. * Iterates over the active data and apply the lambda to them.
  6356. * @param func defines the action to apply on each value.
  6357. */
  6358. forEach(func: (content: T) => void): void;
  6359. /**
  6360. * Sorts the full sets of data.
  6361. * @param compareFn defines the comparison function to apply.
  6362. */
  6363. sort(compareFn: (a: T, b: T) => number): void;
  6364. /**
  6365. * Resets the active data to an empty array.
  6366. */
  6367. reset(): void;
  6368. /**
  6369. * Releases all the data from the array as well as the array.
  6370. */
  6371. dispose(): void;
  6372. /**
  6373. * Concats the active data with a given array.
  6374. * @param array defines the data to concatenate with.
  6375. */
  6376. concat(array: any): void;
  6377. /**
  6378. * Returns the position of a value in the active data.
  6379. * @param value defines the value to find the index for
  6380. * @returns the index if found in the active data otherwise -1
  6381. */
  6382. indexOf(value: T): number;
  6383. /**
  6384. * Returns whether an element is part of the active data.
  6385. * @param value defines the value to look for
  6386. * @returns true if found in the active data otherwise false
  6387. */
  6388. contains(value: T): boolean;
  6389. private static _GlobalId;
  6390. }
  6391. /**
  6392. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6393. * The data in this array can only be present once
  6394. */
  6395. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6396. private _duplicateId;
  6397. /**
  6398. * Pushes a value at the end of the active data.
  6399. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6400. * @param value defines the object to push in the array.
  6401. */
  6402. push(value: T): void;
  6403. /**
  6404. * Pushes a value at the end of the active data.
  6405. * If the data is already present, it won t be added again
  6406. * @param value defines the object to push in the array.
  6407. * @returns true if added false if it was already present
  6408. */
  6409. pushNoDuplicate(value: T): boolean;
  6410. /**
  6411. * Resets the active data to an empty array.
  6412. */
  6413. reset(): void;
  6414. /**
  6415. * Concats the active data with a given array.
  6416. * This ensures no dupplicate will be present in the result.
  6417. * @param array defines the data to concatenate with.
  6418. */
  6419. concatWithNoDuplicate(array: any): void;
  6420. }
  6421. }
  6422. declare module "babylonjs/Cameras/cameraInputsManager" {
  6423. import { Nullable } from "babylonjs/types";
  6424. import { Camera } from "babylonjs/Cameras/camera";
  6425. /**
  6426. * @ignore
  6427. * This is a list of all the different input types that are available in the application.
  6428. * Fo instance: ArcRotateCameraGamepadInput...
  6429. */
  6430. export var CameraInputTypes: {};
  6431. /**
  6432. * This is the contract to implement in order to create a new input class.
  6433. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6434. */
  6435. export interface ICameraInput<TCamera extends Camera> {
  6436. /**
  6437. * Defines the camera the input is attached to.
  6438. */
  6439. camera: Nullable<TCamera>;
  6440. /**
  6441. * Gets the class name of the current intput.
  6442. * @returns the class name
  6443. */
  6444. getClassName(): string;
  6445. /**
  6446. * Get the friendly name associated with the input class.
  6447. * @returns the input friendly name
  6448. */
  6449. getSimpleName(): string;
  6450. /**
  6451. * Attach the input controls to a specific dom element to get the input from.
  6452. * @param element Defines the element the controls should be listened from
  6453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6454. */
  6455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6456. /**
  6457. * Detach the current controls from the specified dom element.
  6458. * @param element Defines the element to stop listening the inputs from
  6459. */
  6460. detachControl(element: Nullable<HTMLElement>): void;
  6461. /**
  6462. * Update the current camera state depending on the inputs that have been used this frame.
  6463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6464. */
  6465. checkInputs?: () => void;
  6466. }
  6467. /**
  6468. * Represents a map of input types to input instance or input index to input instance.
  6469. */
  6470. export interface CameraInputsMap<TCamera extends Camera> {
  6471. /**
  6472. * Accessor to the input by input type.
  6473. */
  6474. [name: string]: ICameraInput<TCamera>;
  6475. /**
  6476. * Accessor to the input by input index.
  6477. */
  6478. [idx: number]: ICameraInput<TCamera>;
  6479. }
  6480. /**
  6481. * This represents the input manager used within a camera.
  6482. * It helps dealing with all the different kind of input attached to a camera.
  6483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6484. */
  6485. export class CameraInputsManager<TCamera extends Camera> {
  6486. /**
  6487. * Defines the list of inputs attahed to the camera.
  6488. */
  6489. attached: CameraInputsMap<TCamera>;
  6490. /**
  6491. * Defines the dom element the camera is collecting inputs from.
  6492. * This is null if the controls have not been attached.
  6493. */
  6494. attachedElement: Nullable<HTMLElement>;
  6495. /**
  6496. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. noPreventDefault: boolean;
  6499. /**
  6500. * Defined the camera the input manager belongs to.
  6501. */
  6502. camera: TCamera;
  6503. /**
  6504. * Update the current camera state depending on the inputs that have been used this frame.
  6505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6506. */
  6507. checkInputs: () => void;
  6508. /**
  6509. * Instantiate a new Camera Input Manager.
  6510. * @param camera Defines the camera the input manager blongs to
  6511. */
  6512. constructor(camera: TCamera);
  6513. /**
  6514. * Add an input method to a camera
  6515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6516. * @param input camera input method
  6517. */
  6518. add(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Remove a specific input method from a camera
  6521. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6522. * @param inputToRemove camera input method
  6523. */
  6524. remove(inputToRemove: ICameraInput<TCamera>): void;
  6525. /**
  6526. * Remove a specific input type from a camera
  6527. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6528. * @param inputType the type of the input to remove
  6529. */
  6530. removeByType(inputType: string): void;
  6531. private _addCheckInputs;
  6532. /**
  6533. * Attach the input controls to the currently attached dom element to listen the events from.
  6534. * @param input Defines the input to attach
  6535. */
  6536. attachInput(input: ICameraInput<TCamera>): void;
  6537. /**
  6538. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6539. * @param element Defines the dom element to collect the events from
  6540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6541. */
  6542. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6543. /**
  6544. * Detach the current manager inputs controls from a specific dom element.
  6545. * @param element Defines the dom element to collect the events from
  6546. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6547. */
  6548. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6549. /**
  6550. * Rebuild the dynamic inputCheck function from the current list of
  6551. * defined inputs in the manager.
  6552. */
  6553. rebuildInputCheck(): void;
  6554. /**
  6555. * Remove all attached input methods from a camera
  6556. */
  6557. clear(): void;
  6558. /**
  6559. * Serialize the current input manager attached to a camera.
  6560. * This ensures than once parsed,
  6561. * the input associated to the camera will be identical to the current ones
  6562. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6563. */
  6564. serialize(serializedCamera: any): void;
  6565. /**
  6566. * Parses an input manager serialized JSON to restore the previous list of inputs
  6567. * and states associated to a camera.
  6568. * @param parsedCamera Defines the JSON to parse
  6569. */
  6570. parse(parsedCamera: any): void;
  6571. }
  6572. }
  6573. declare module "babylonjs/Meshes/buffer" {
  6574. import { Nullable, DataArray } from "babylonjs/types";
  6575. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6576. /**
  6577. * Class used to store data that will be store in GPU memory
  6578. */
  6579. export class Buffer {
  6580. private _engine;
  6581. private _buffer;
  6582. /** @hidden */
  6583. _data: Nullable<DataArray>;
  6584. private _updatable;
  6585. private _instanced;
  6586. private _divisor;
  6587. /**
  6588. * Gets the byte stride.
  6589. */
  6590. readonly byteStride: number;
  6591. /**
  6592. * Constructor
  6593. * @param engine the engine
  6594. * @param data the data to use for this buffer
  6595. * @param updatable whether the data is updatable
  6596. * @param stride the stride (optional)
  6597. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param useBytes set to true if the stride in in bytes (optional)
  6600. * @param divisor sets an optional divisor for instances (1 by default)
  6601. */
  6602. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6603. /**
  6604. * Create a new VertexBuffer based on the current buffer
  6605. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6606. * @param offset defines offset in the buffer (0 by default)
  6607. * @param size defines the size in floats of attributes (position is 3 for instance)
  6608. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6609. * @param instanced defines if the vertex buffer contains indexed data
  6610. * @param useBytes defines if the offset and stride are in bytes *
  6611. * @param divisor sets an optional divisor for instances (1 by default)
  6612. * @returns the new vertex buffer
  6613. */
  6614. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6615. /**
  6616. * Gets a boolean indicating if the Buffer is updatable?
  6617. * @returns true if the buffer is updatable
  6618. */
  6619. isUpdatable(): boolean;
  6620. /**
  6621. * Gets current buffer's data
  6622. * @returns a DataArray or null
  6623. */
  6624. getData(): Nullable<DataArray>;
  6625. /**
  6626. * Gets underlying native buffer
  6627. * @returns underlying native buffer
  6628. */
  6629. getBuffer(): Nullable<DataBuffer>;
  6630. /**
  6631. * Gets the stride in float32 units (i.e. byte stride / 4).
  6632. * May not be an integer if the byte stride is not divisible by 4.
  6633. * @returns the stride in float32 units
  6634. * @deprecated Please use byteStride instead.
  6635. */
  6636. getStrideSize(): number;
  6637. /**
  6638. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6639. * @param data defines the data to store
  6640. */
  6641. create(data?: Nullable<DataArray>): void;
  6642. /** @hidden */
  6643. _rebuild(): void;
  6644. /**
  6645. * Update current buffer data
  6646. * @param data defines the data to store
  6647. */
  6648. update(data: DataArray): void;
  6649. /**
  6650. * Updates the data directly.
  6651. * @param data the new data
  6652. * @param offset the new offset
  6653. * @param vertexCount the vertex count (optional)
  6654. * @param useBytes set to true if the offset is in bytes
  6655. */
  6656. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6657. /**
  6658. * Release all resources
  6659. */
  6660. dispose(): void;
  6661. }
  6662. /**
  6663. * Specialized buffer used to store vertex data
  6664. */
  6665. export class VertexBuffer {
  6666. /** @hidden */
  6667. _buffer: Buffer;
  6668. private _kind;
  6669. private _size;
  6670. private _ownsBuffer;
  6671. private _instanced;
  6672. private _instanceDivisor;
  6673. /**
  6674. * The byte type.
  6675. */
  6676. static readonly BYTE: number;
  6677. /**
  6678. * The unsigned byte type.
  6679. */
  6680. static readonly UNSIGNED_BYTE: number;
  6681. /**
  6682. * The short type.
  6683. */
  6684. static readonly SHORT: number;
  6685. /**
  6686. * The unsigned short type.
  6687. */
  6688. static readonly UNSIGNED_SHORT: number;
  6689. /**
  6690. * The integer type.
  6691. */
  6692. static readonly INT: number;
  6693. /**
  6694. * The unsigned integer type.
  6695. */
  6696. static readonly UNSIGNED_INT: number;
  6697. /**
  6698. * The float type.
  6699. */
  6700. static readonly FLOAT: number;
  6701. /**
  6702. * Gets or sets the instance divisor when in instanced mode
  6703. */
  6704. get instanceDivisor(): number;
  6705. set instanceDivisor(value: number);
  6706. /**
  6707. * Gets the byte stride.
  6708. */
  6709. readonly byteStride: number;
  6710. /**
  6711. * Gets the byte offset.
  6712. */
  6713. readonly byteOffset: number;
  6714. /**
  6715. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6716. */
  6717. readonly normalized: boolean;
  6718. /**
  6719. * Gets the data type of each component in the array.
  6720. */
  6721. readonly type: number;
  6722. /**
  6723. * Constructor
  6724. * @param engine the engine
  6725. * @param data the data to use for this vertex buffer
  6726. * @param kind the vertex buffer kind
  6727. * @param updatable whether the data is updatable
  6728. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6729. * @param stride the stride (optional)
  6730. * @param instanced whether the buffer is instanced (optional)
  6731. * @param offset the offset of the data (optional)
  6732. * @param size the number of components (optional)
  6733. * @param type the type of the component (optional)
  6734. * @param normalized whether the data contains normalized data (optional)
  6735. * @param useBytes set to true if stride and offset are in bytes (optional)
  6736. * @param divisor defines the instance divisor to use (1 by default)
  6737. */
  6738. 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);
  6739. /** @hidden */
  6740. _rebuild(): void;
  6741. /**
  6742. * Returns the kind of the VertexBuffer (string)
  6743. * @returns a string
  6744. */
  6745. getKind(): string;
  6746. /**
  6747. * Gets a boolean indicating if the VertexBuffer is updatable?
  6748. * @returns true if the buffer is updatable
  6749. */
  6750. isUpdatable(): boolean;
  6751. /**
  6752. * Gets current buffer's data
  6753. * @returns a DataArray or null
  6754. */
  6755. getData(): Nullable<DataArray>;
  6756. /**
  6757. * Gets underlying native buffer
  6758. * @returns underlying native buffer
  6759. */
  6760. getBuffer(): Nullable<DataBuffer>;
  6761. /**
  6762. * Gets the stride in float32 units (i.e. byte stride / 4).
  6763. * May not be an integer if the byte stride is not divisible by 4.
  6764. * @returns the stride in float32 units
  6765. * @deprecated Please use byteStride instead.
  6766. */
  6767. getStrideSize(): number;
  6768. /**
  6769. * Returns the offset as a multiple of the type byte length.
  6770. * @returns the offset in bytes
  6771. * @deprecated Please use byteOffset instead.
  6772. */
  6773. getOffset(): number;
  6774. /**
  6775. * Returns the number of components per vertex attribute (integer)
  6776. * @returns the size in float
  6777. */
  6778. getSize(): number;
  6779. /**
  6780. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6781. * @returns true if this buffer is instanced
  6782. */
  6783. getIsInstanced(): boolean;
  6784. /**
  6785. * Returns the instancing divisor, zero for non-instanced (integer).
  6786. * @returns a number
  6787. */
  6788. getInstanceDivisor(): number;
  6789. /**
  6790. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6791. * @param data defines the data to store
  6792. */
  6793. create(data?: DataArray): void;
  6794. /**
  6795. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6796. * This function will create a new buffer if the current one is not updatable
  6797. * @param data defines the data to store
  6798. */
  6799. update(data: DataArray): void;
  6800. /**
  6801. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6802. * Returns the directly updated WebGLBuffer.
  6803. * @param data the new data
  6804. * @param offset the new offset
  6805. * @param useBytes set to true if the offset is in bytes
  6806. */
  6807. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6808. /**
  6809. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6810. */
  6811. dispose(): void;
  6812. /**
  6813. * Enumerates each value of this vertex buffer as numbers.
  6814. * @param count the number of values to enumerate
  6815. * @param callback the callback function called for each value
  6816. */
  6817. forEach(count: number, callback: (value: number, index: number) => void): void;
  6818. /**
  6819. * Positions
  6820. */
  6821. static readonly PositionKind: string;
  6822. /**
  6823. * Normals
  6824. */
  6825. static readonly NormalKind: string;
  6826. /**
  6827. * Tangents
  6828. */
  6829. static readonly TangentKind: string;
  6830. /**
  6831. * Texture coordinates
  6832. */
  6833. static readonly UVKind: string;
  6834. /**
  6835. * Texture coordinates 2
  6836. */
  6837. static readonly UV2Kind: string;
  6838. /**
  6839. * Texture coordinates 3
  6840. */
  6841. static readonly UV3Kind: string;
  6842. /**
  6843. * Texture coordinates 4
  6844. */
  6845. static readonly UV4Kind: string;
  6846. /**
  6847. * Texture coordinates 5
  6848. */
  6849. static readonly UV5Kind: string;
  6850. /**
  6851. * Texture coordinates 6
  6852. */
  6853. static readonly UV6Kind: string;
  6854. /**
  6855. * Colors
  6856. */
  6857. static readonly ColorKind: string;
  6858. /**
  6859. * Matrix indices (for bones)
  6860. */
  6861. static readonly MatricesIndicesKind: string;
  6862. /**
  6863. * Matrix weights (for bones)
  6864. */
  6865. static readonly MatricesWeightsKind: string;
  6866. /**
  6867. * Additional matrix indices (for bones)
  6868. */
  6869. static readonly MatricesIndicesExtraKind: string;
  6870. /**
  6871. * Additional matrix weights (for bones)
  6872. */
  6873. static readonly MatricesWeightsExtraKind: string;
  6874. /**
  6875. * Deduces the stride given a kind.
  6876. * @param kind The kind string to deduce
  6877. * @returns The deduced stride
  6878. */
  6879. static DeduceStride(kind: string): number;
  6880. /**
  6881. * Gets the byte length of the given type.
  6882. * @param type the type
  6883. * @returns the number of bytes
  6884. */
  6885. static GetTypeByteLength(type: number): number;
  6886. /**
  6887. * Enumerates each value of the given parameters as numbers.
  6888. * @param data the data to enumerate
  6889. * @param byteOffset the byte offset of the data
  6890. * @param byteStride the byte stride of the data
  6891. * @param componentCount the number of components per element
  6892. * @param componentType the type of the component
  6893. * @param count the number of values to enumerate
  6894. * @param normalized whether the data is normalized
  6895. * @param callback the callback function called for each value
  6896. */
  6897. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6898. private static _GetFloatValue;
  6899. }
  6900. }
  6901. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6902. import { Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { Mesh } from "babylonjs/Meshes/mesh";
  6904. /**
  6905. * The options Interface for creating a Capsule Mesh
  6906. */
  6907. export interface ICreateCapsuleOptions {
  6908. /** The Orientation of the capsule. Default : Vector3.Up() */
  6909. orientation?: Vector3;
  6910. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6911. subdivisions: number;
  6912. /** Number of cylindrical segments on the capsule. */
  6913. tessellation: number;
  6914. /** Height or Length of the capsule. */
  6915. height: number;
  6916. /** Radius of the capsule. */
  6917. radius: number;
  6918. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6919. capSubdivisions: number;
  6920. /** Overwrite for the top radius. */
  6921. radiusTop?: number;
  6922. /** Overwrite for the bottom radius. */
  6923. radiusBottom?: number;
  6924. /** Overwrite for the top capSubdivisions. */
  6925. topCapSubdivisions?: number;
  6926. /** Overwrite for the bottom capSubdivisions. */
  6927. bottomCapSubdivisions?: number;
  6928. }
  6929. /**
  6930. * Class containing static functions to help procedurally build meshes
  6931. */
  6932. export class CapsuleBuilder {
  6933. /**
  6934. * Creates a capsule or a pill mesh
  6935. * @param name defines the name of the mesh
  6936. * @param options The constructors options.
  6937. * @param scene The scene the mesh is scoped to.
  6938. * @returns Capsule Mesh
  6939. */
  6940. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/intersectionInfo" {
  6944. import { Nullable } from "babylonjs/types";
  6945. /**
  6946. * @hidden
  6947. */
  6948. export class IntersectionInfo {
  6949. bu: Nullable<number>;
  6950. bv: Nullable<number>;
  6951. distance: number;
  6952. faceId: number;
  6953. subMeshId: number;
  6954. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6955. }
  6956. }
  6957. declare module "babylonjs/Culling/boundingSphere" {
  6958. import { DeepImmutable } from "babylonjs/types";
  6959. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6960. import { Plane } from "babylonjs/Maths/math.plane";
  6961. /**
  6962. * Class used to store bounding sphere information
  6963. */
  6964. export class BoundingSphere {
  6965. /**
  6966. * Gets the center of the bounding sphere in local space
  6967. */
  6968. readonly center: Vector3;
  6969. /**
  6970. * Radius of the bounding sphere in local space
  6971. */
  6972. radius: number;
  6973. /**
  6974. * Gets the center of the bounding sphere in world space
  6975. */
  6976. readonly centerWorld: Vector3;
  6977. /**
  6978. * Radius of the bounding sphere in world space
  6979. */
  6980. radiusWorld: number;
  6981. /**
  6982. * Gets the minimum vector in local space
  6983. */
  6984. readonly minimum: Vector3;
  6985. /**
  6986. * Gets the maximum vector in local space
  6987. */
  6988. readonly maximum: Vector3;
  6989. private _worldMatrix;
  6990. private static readonly TmpVector3;
  6991. /**
  6992. * Creates a new bounding sphere
  6993. * @param min defines the minimum vector (in local space)
  6994. * @param max defines the maximum vector (in local space)
  6995. * @param worldMatrix defines the new world matrix
  6996. */
  6997. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6998. /**
  6999. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7000. * @param min defines the new minimum vector (in local space)
  7001. * @param max defines the new maximum vector (in local space)
  7002. * @param worldMatrix defines the new world matrix
  7003. */
  7004. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7005. /**
  7006. * Scale the current bounding sphere by applying a scale factor
  7007. * @param factor defines the scale factor to apply
  7008. * @returns the current bounding box
  7009. */
  7010. scale(factor: number): BoundingSphere;
  7011. /**
  7012. * Gets the world matrix of the bounding box
  7013. * @returns a matrix
  7014. */
  7015. getWorldMatrix(): DeepImmutable<Matrix>;
  7016. /** @hidden */
  7017. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7018. /**
  7019. * Tests if the bounding sphere is intersecting the frustum planes
  7020. * @param frustumPlanes defines the frustum planes to test
  7021. * @returns true if there is an intersection
  7022. */
  7023. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7024. /**
  7025. * Tests if the bounding sphere center is in between the frustum planes.
  7026. * Used for optimistic fast inclusion.
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if the sphere center is in between the frustum planes
  7029. */
  7030. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding sphere
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding sphere
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Checks if two sphere intersct
  7039. * @param sphere0 sphere 0
  7040. * @param sphere1 sphere 1
  7041. * @returns true if the speres intersect
  7042. */
  7043. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingBox" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7050. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. /**
  7053. * Class used to store bounding box information
  7054. */
  7055. export class BoundingBox implements ICullable {
  7056. /**
  7057. * Gets the 8 vectors representing the bounding box in local space
  7058. */
  7059. readonly vectors: Vector3[];
  7060. /**
  7061. * Gets the center of the bounding box in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Gets the center of the bounding box in world space
  7066. */
  7067. readonly centerWorld: Vector3;
  7068. /**
  7069. * Gets the extend size in local space
  7070. */
  7071. readonly extendSize: Vector3;
  7072. /**
  7073. * Gets the extend size in world space
  7074. */
  7075. readonly extendSizeWorld: Vector3;
  7076. /**
  7077. * Gets the OBB (object bounding box) directions
  7078. */
  7079. readonly directions: Vector3[];
  7080. /**
  7081. * Gets the 8 vectors representing the bounding box in world space
  7082. */
  7083. readonly vectorsWorld: Vector3[];
  7084. /**
  7085. * Gets the minimum vector in world space
  7086. */
  7087. readonly minimumWorld: Vector3;
  7088. /**
  7089. * Gets the maximum vector in world space
  7090. */
  7091. readonly maximumWorld: Vector3;
  7092. /**
  7093. * Gets the minimum vector in local space
  7094. */
  7095. readonly minimum: Vector3;
  7096. /**
  7097. * Gets the maximum vector in local space
  7098. */
  7099. readonly maximum: Vector3;
  7100. private _worldMatrix;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * @hidden
  7104. */
  7105. _tag: number;
  7106. /**
  7107. * Creates a new bounding box
  7108. * @param min defines the minimum vector (in local space)
  7109. * @param max defines the maximum vector (in local space)
  7110. * @param worldMatrix defines the new world matrix
  7111. */
  7112. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7113. /**
  7114. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7115. * @param min defines the new minimum vector (in local space)
  7116. * @param max defines the new maximum vector (in local space)
  7117. * @param worldMatrix defines the new world matrix
  7118. */
  7119. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Scale the current bounding box by applying a scale factor
  7122. * @param factor defines the scale factor to apply
  7123. * @returns the current bounding box
  7124. */
  7125. scale(factor: number): BoundingBox;
  7126. /**
  7127. * Gets the world matrix of the bounding box
  7128. * @returns a matrix
  7129. */
  7130. getWorldMatrix(): DeepImmutable<Matrix>;
  7131. /** @hidden */
  7132. _update(world: DeepImmutable<Matrix>): void;
  7133. /**
  7134. * Tests if the bounding box is intersecting the frustum planes
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7139. /**
  7140. * Tests if the bounding box is entirely inside the frustum planes
  7141. * @param frustumPlanes defines the frustum planes to test
  7142. * @returns true if there is an inclusion
  7143. */
  7144. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7145. /**
  7146. * Tests if a point is inside the bounding box
  7147. * @param point defines the point to test
  7148. * @returns true if the point is inside the bounding box
  7149. */
  7150. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7151. /**
  7152. * Tests if the bounding box intersects with a bounding sphere
  7153. * @param sphere defines the sphere to test
  7154. * @returns true if there is an intersection
  7155. */
  7156. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7157. /**
  7158. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7159. * @param min defines the min vector to use
  7160. * @param max defines the max vector to use
  7161. * @returns true if there is an intersection
  7162. */
  7163. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7164. /**
  7165. * Tests if two bounding boxes are intersections
  7166. * @param box0 defines the first box to test
  7167. * @param box1 defines the second box to test
  7168. * @returns true if there is an intersection
  7169. */
  7170. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7171. /**
  7172. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7173. * @param minPoint defines the minimum vector of the bounding box
  7174. * @param maxPoint defines the maximum vector of the bounding box
  7175. * @param sphereCenter defines the sphere center
  7176. * @param sphereRadius defines the sphere radius
  7177. * @returns true if there is an intersection
  7178. */
  7179. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7180. /**
  7181. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7182. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7183. * @param frustumPlanes defines the frustum planes to test
  7184. * @return true if there is an inclusion
  7185. */
  7186. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7187. /**
  7188. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7189. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7190. * @param frustumPlanes defines the frustum planes to test
  7191. * @return true if there is an intersection
  7192. */
  7193. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7194. }
  7195. }
  7196. declare module "babylonjs/Collisions/collider" {
  7197. import { Nullable, IndicesArray } from "babylonjs/types";
  7198. import { Vector3 } from "babylonjs/Maths/math.vector";
  7199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7200. import { Plane } from "babylonjs/Maths/math.plane";
  7201. /** @hidden */
  7202. export class Collider {
  7203. /** Define if a collision was found */
  7204. collisionFound: boolean;
  7205. /**
  7206. * Define last intersection point in local space
  7207. */
  7208. intersectionPoint: Vector3;
  7209. /**
  7210. * Define last collided mesh
  7211. */
  7212. collidedMesh: Nullable<AbstractMesh>;
  7213. private _collisionPoint;
  7214. private _planeIntersectionPoint;
  7215. private _tempVector;
  7216. private _tempVector2;
  7217. private _tempVector3;
  7218. private _tempVector4;
  7219. private _edge;
  7220. private _baseToVertex;
  7221. private _destinationPoint;
  7222. private _slidePlaneNormal;
  7223. private _displacementVector;
  7224. /** @hidden */
  7225. _radius: Vector3;
  7226. /** @hidden */
  7227. _retry: number;
  7228. private _velocity;
  7229. private _basePoint;
  7230. private _epsilon;
  7231. /** @hidden */
  7232. _velocityWorldLength: number;
  7233. /** @hidden */
  7234. _basePointWorld: Vector3;
  7235. private _velocityWorld;
  7236. private _normalizedVelocity;
  7237. /** @hidden */
  7238. _initialVelocity: Vector3;
  7239. /** @hidden */
  7240. _initialPosition: Vector3;
  7241. private _nearestDistance;
  7242. private _collisionMask;
  7243. get collisionMask(): number;
  7244. set collisionMask(mask: number);
  7245. /**
  7246. * Gets the plane normal used to compute the sliding response (in local space)
  7247. */
  7248. get slidePlaneNormal(): Vector3;
  7249. /** @hidden */
  7250. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7251. /** @hidden */
  7252. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7253. /** @hidden */
  7254. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7255. /** @hidden */
  7256. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7257. /** @hidden */
  7258. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7259. /** @hidden */
  7260. _getResponse(pos: Vector3, vel: Vector3): void;
  7261. }
  7262. }
  7263. declare module "babylonjs/Culling/boundingInfo" {
  7264. import { DeepImmutable } from "babylonjs/types";
  7265. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7266. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7267. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7268. import { Plane } from "babylonjs/Maths/math.plane";
  7269. import { Collider } from "babylonjs/Collisions/collider";
  7270. /**
  7271. * Interface for cullable objects
  7272. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7273. */
  7274. export interface ICullable {
  7275. /**
  7276. * Checks if the object or part of the object is in the frustum
  7277. * @param frustumPlanes Camera near/planes
  7278. * @returns true if the object is in frustum otherwise false
  7279. */
  7280. isInFrustum(frustumPlanes: Plane[]): boolean;
  7281. /**
  7282. * Checks if a cullable object (mesh...) is in the camera frustum
  7283. * Unlike isInFrustum this cheks the full bounding box
  7284. * @param frustumPlanes Camera near/planes
  7285. * @returns true if the object is in frustum otherwise false
  7286. */
  7287. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7288. }
  7289. /**
  7290. * Info for a bounding data of a mesh
  7291. */
  7292. export class BoundingInfo implements ICullable {
  7293. /**
  7294. * Bounding box for the mesh
  7295. */
  7296. readonly boundingBox: BoundingBox;
  7297. /**
  7298. * Bounding sphere for the mesh
  7299. */
  7300. readonly boundingSphere: BoundingSphere;
  7301. private _isLocked;
  7302. private static readonly TmpVector3;
  7303. /**
  7304. * Constructs bounding info
  7305. * @param minimum min vector of the bounding box/sphere
  7306. * @param maximum max vector of the bounding box/sphere
  7307. * @param worldMatrix defines the new world matrix
  7308. */
  7309. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7310. /**
  7311. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7312. * @param min defines the new minimum vector (in local space)
  7313. * @param max defines the new maximum vector (in local space)
  7314. * @param worldMatrix defines the new world matrix
  7315. */
  7316. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * min vector of the bounding box/sphere
  7319. */
  7320. get minimum(): Vector3;
  7321. /**
  7322. * max vector of the bounding box/sphere
  7323. */
  7324. get maximum(): Vector3;
  7325. /**
  7326. * If the info is locked and won't be updated to avoid perf overhead
  7327. */
  7328. get isLocked(): boolean;
  7329. set isLocked(value: boolean);
  7330. /**
  7331. * Updates the bounding sphere and box
  7332. * @param world world matrix to be used to update
  7333. */
  7334. update(world: DeepImmutable<Matrix>): void;
  7335. /**
  7336. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7337. * @param center New center of the bounding info
  7338. * @param extend New extend of the bounding info
  7339. * @returns the current bounding info
  7340. */
  7341. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7342. /**
  7343. * Scale the current bounding info by applying a scale factor
  7344. * @param factor defines the scale factor to apply
  7345. * @returns the current bounding info
  7346. */
  7347. scale(factor: number): BoundingInfo;
  7348. /**
  7349. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7350. * @param frustumPlanes defines the frustum to test
  7351. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7352. * @returns true if the bounding info is in the frustum planes
  7353. */
  7354. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7355. /**
  7356. * Gets the world distance between the min and max points of the bounding box
  7357. */
  7358. get diagonalLength(): number;
  7359. /**
  7360. * Checks if a cullable object (mesh...) is in the camera frustum
  7361. * Unlike isInFrustum this cheks the full bounding box
  7362. * @param frustumPlanes Camera near/planes
  7363. * @returns true if the object is in frustum otherwise false
  7364. */
  7365. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7366. /** @hidden */
  7367. _checkCollision(collider: Collider): boolean;
  7368. /**
  7369. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7370. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7371. * @param point the point to check intersection with
  7372. * @returns if the point intersects
  7373. */
  7374. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7375. /**
  7376. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7378. * @param boundingInfo the bounding info to check intersection with
  7379. * @param precise if the intersection should be done using OBB
  7380. * @returns if the bounding info intersects
  7381. */
  7382. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7383. }
  7384. }
  7385. declare module "babylonjs/Maths/math.functions" {
  7386. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7387. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7388. /**
  7389. * Extracts minimum and maximum values from a list of indexed positions
  7390. * @param positions defines the positions to use
  7391. * @param indices defines the indices to the positions
  7392. * @param indexStart defines the start index
  7393. * @param indexCount defines the end index
  7394. * @param bias defines bias value to add to the result
  7395. * @return minimum and maximum values
  7396. */
  7397. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7398. minimum: Vector3;
  7399. maximum: Vector3;
  7400. };
  7401. /**
  7402. * Extracts minimum and maximum values from a list of positions
  7403. * @param positions defines the positions to use
  7404. * @param start defines the start index in the positions array
  7405. * @param count defines the number of positions to handle
  7406. * @param bias defines bias value to add to the result
  7407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7408. * @return minimum and maximum values
  7409. */
  7410. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7411. minimum: Vector3;
  7412. maximum: Vector3;
  7413. };
  7414. }
  7415. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7416. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7417. /** @hidden */
  7418. export class WebGLDataBuffer extends DataBuffer {
  7419. private _buffer;
  7420. constructor(resource: WebGLBuffer);
  7421. get underlyingResource(): any;
  7422. }
  7423. }
  7424. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7425. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7426. import { Nullable } from "babylonjs/types";
  7427. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7428. /** @hidden */
  7429. export class WebGLPipelineContext implements IPipelineContext {
  7430. engine: ThinEngine;
  7431. program: Nullable<WebGLProgram>;
  7432. context?: WebGLRenderingContext;
  7433. vertexShader?: WebGLShader;
  7434. fragmentShader?: WebGLShader;
  7435. isParallelCompiled: boolean;
  7436. onCompiled?: () => void;
  7437. transformFeedback?: WebGLTransformFeedback | null;
  7438. vertexCompilationError: Nullable<string>;
  7439. fragmentCompilationError: Nullable<string>;
  7440. programLinkError: Nullable<string>;
  7441. programValidationError: Nullable<string>;
  7442. get isAsync(): boolean;
  7443. get isReady(): boolean;
  7444. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7445. _getVertexShaderCode(): string | null;
  7446. _getFragmentShaderCode(): string | null;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7450. import { FloatArray, Nullable } from "babylonjs/types";
  7451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7452. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7453. module "babylonjs/Engines/thinEngine" {
  7454. interface ThinEngine {
  7455. /**
  7456. * Create an uniform buffer
  7457. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7458. * @param elements defines the content of the uniform buffer
  7459. * @returns the webGL uniform buffer
  7460. */
  7461. createUniformBuffer(elements: FloatArray): DataBuffer;
  7462. /**
  7463. * Create a dynamic uniform buffer
  7464. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7465. * @param elements defines the content of the uniform buffer
  7466. * @returns the webGL uniform buffer
  7467. */
  7468. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7469. /**
  7470. * Update an existing uniform buffer
  7471. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7472. * @param uniformBuffer defines the target uniform buffer
  7473. * @param elements defines the content to update
  7474. * @param offset defines the offset in the uniform buffer where update should start
  7475. * @param count defines the size of the data to update
  7476. */
  7477. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7478. /**
  7479. * Bind an uniform buffer to the current webGL context
  7480. * @param buffer defines the buffer to bind
  7481. */
  7482. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7483. /**
  7484. * Bind a buffer to the current webGL context at a given location
  7485. * @param buffer defines the buffer to bind
  7486. * @param location defines the index where to bind the buffer
  7487. */
  7488. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7489. /**
  7490. * Bind a specific block at a given index in a specific shader program
  7491. * @param pipelineContext defines the pipeline context to use
  7492. * @param blockName defines the block name
  7493. * @param index defines the index where to bind the block
  7494. */
  7495. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7496. }
  7497. }
  7498. }
  7499. declare module "babylonjs/Materials/uniformBuffer" {
  7500. import { Nullable, FloatArray } from "babylonjs/types";
  7501. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7502. import { Engine } from "babylonjs/Engines/engine";
  7503. import { Effect } from "babylonjs/Materials/effect";
  7504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7505. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7506. import { Color3 } from "babylonjs/Maths/math.color";
  7507. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7508. /**
  7509. * Uniform buffer objects.
  7510. *
  7511. * Handles blocks of uniform on the GPU.
  7512. *
  7513. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7514. *
  7515. * For more information, please refer to :
  7516. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7517. */
  7518. export class UniformBuffer {
  7519. private _engine;
  7520. private _buffer;
  7521. private _data;
  7522. private _bufferData;
  7523. private _dynamic?;
  7524. private _uniformLocations;
  7525. private _uniformSizes;
  7526. private _uniformLocationPointer;
  7527. private _needSync;
  7528. private _noUBO;
  7529. private _currentEffect;
  7530. /** @hidden */
  7531. _alreadyBound: boolean;
  7532. private static _MAX_UNIFORM_SIZE;
  7533. private static _tempBuffer;
  7534. /**
  7535. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7540. /**
  7541. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7546. /**
  7547. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7552. /**
  7553. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7558. /**
  7559. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7564. /**
  7565. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7570. /**
  7571. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7576. /**
  7577. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7582. /**
  7583. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7584. * This is dynamic to allow compat with webgl 1 and 2.
  7585. * You will need to pass the name of the uniform as well as the value.
  7586. */
  7587. updateVector4: (name: string, vector: Vector4) => void;
  7588. /**
  7589. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7590. * This is dynamic to allow compat with webgl 1 and 2.
  7591. * You will need to pass the name of the uniform as well as the value.
  7592. */
  7593. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7594. /**
  7595. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7596. * This is dynamic to allow compat with webgl 1 and 2.
  7597. * You will need to pass the name of the uniform as well as the value.
  7598. */
  7599. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7600. /**
  7601. * Instantiates a new Uniform buffer objects.
  7602. *
  7603. * Handles blocks of uniform on the GPU.
  7604. *
  7605. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7606. *
  7607. * For more information, please refer to :
  7608. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7609. * @param engine Define the engine the buffer is associated with
  7610. * @param data Define the data contained in the buffer
  7611. * @param dynamic Define if the buffer is updatable
  7612. */
  7613. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7614. /**
  7615. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7616. * or just falling back on setUniformXXX calls.
  7617. */
  7618. get useUbo(): boolean;
  7619. /**
  7620. * Indicates if the WebGL underlying uniform buffer is in sync
  7621. * with the javascript cache data.
  7622. */
  7623. get isSync(): boolean;
  7624. /**
  7625. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7626. * Also, a dynamic UniformBuffer will disable cache verification and always
  7627. * update the underlying WebGL uniform buffer to the GPU.
  7628. * @returns if Dynamic, otherwise false
  7629. */
  7630. isDynamic(): boolean;
  7631. /**
  7632. * The data cache on JS side.
  7633. * @returns the underlying data as a float array
  7634. */
  7635. getData(): Float32Array;
  7636. /**
  7637. * The underlying WebGL Uniform buffer.
  7638. * @returns the webgl buffer
  7639. */
  7640. getBuffer(): Nullable<DataBuffer>;
  7641. /**
  7642. * std140 layout specifies how to align data within an UBO structure.
  7643. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7644. * for specs.
  7645. */
  7646. private _fillAlignment;
  7647. /**
  7648. * Adds an uniform in the buffer.
  7649. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7650. * for the layout to be correct !
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param size Data size, or data directly.
  7653. */
  7654. addUniform(name: string, size: number | number[]): void;
  7655. /**
  7656. * Adds a Matrix 4x4 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. * @param mat A 4x4 matrix.
  7659. */
  7660. addMatrix(name: string, mat: Matrix): void;
  7661. /**
  7662. * Adds a vec2 to the uniform buffer.
  7663. * @param name Name of the uniform, as used in the uniform block in the shader.
  7664. * @param x Define the x component value of the vec2
  7665. * @param y Define the y component value of the vec2
  7666. */
  7667. addFloat2(name: string, x: number, y: number): void;
  7668. /**
  7669. * Adds a vec3 to the uniform buffer.
  7670. * @param name Name of the uniform, as used in the uniform block in the shader.
  7671. * @param x Define the x component value of the vec3
  7672. * @param y Define the y component value of the vec3
  7673. * @param z Define the z component value of the vec3
  7674. */
  7675. addFloat3(name: string, x: number, y: number, z: number): void;
  7676. /**
  7677. * Adds a vec3 to the uniform buffer.
  7678. * @param name Name of the uniform, as used in the uniform block in the shader.
  7679. * @param color Define the vec3 from a Color
  7680. */
  7681. addColor3(name: string, color: Color3): void;
  7682. /**
  7683. * Adds a vec4 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. * @param color Define the rgb components from a Color
  7686. * @param alpha Define the a component of the vec4
  7687. */
  7688. addColor4(name: string, color: Color3, alpha: number): void;
  7689. /**
  7690. * Adds a vec3 to the uniform buffer.
  7691. * @param name Name of the uniform, as used in the uniform block in the shader.
  7692. * @param vector Define the vec3 components from a Vector
  7693. */
  7694. addVector3(name: string, vector: Vector3): void;
  7695. /**
  7696. * Adds a Matrix 3x3 to the uniform buffer.
  7697. * @param name Name of the uniform, as used in the uniform block in the shader.
  7698. */
  7699. addMatrix3x3(name: string): void;
  7700. /**
  7701. * Adds a Matrix 2x2 to the uniform buffer.
  7702. * @param name Name of the uniform, as used in the uniform block in the shader.
  7703. */
  7704. addMatrix2x2(name: string): void;
  7705. /**
  7706. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7707. */
  7708. create(): void;
  7709. /** @hidden */
  7710. _rebuild(): void;
  7711. /**
  7712. * Updates the WebGL Uniform Buffer on the GPU.
  7713. * If the `dynamic` flag is set to true, no cache comparison is done.
  7714. * Otherwise, the buffer will be updated only if the cache differs.
  7715. */
  7716. update(): void;
  7717. /**
  7718. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7719. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7720. * @param data Define the flattened data
  7721. * @param size Define the size of the data.
  7722. */
  7723. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7724. private _valueCache;
  7725. private _cacheMatrix;
  7726. private _updateMatrix3x3ForUniform;
  7727. private _updateMatrix3x3ForEffect;
  7728. private _updateMatrix2x2ForEffect;
  7729. private _updateMatrix2x2ForUniform;
  7730. private _updateFloatForEffect;
  7731. private _updateFloatForUniform;
  7732. private _updateFloat2ForEffect;
  7733. private _updateFloat2ForUniform;
  7734. private _updateFloat3ForEffect;
  7735. private _updateFloat3ForUniform;
  7736. private _updateFloat4ForEffect;
  7737. private _updateFloat4ForUniform;
  7738. private _updateMatrixForEffect;
  7739. private _updateMatrixForUniform;
  7740. private _updateVector3ForEffect;
  7741. private _updateVector3ForUniform;
  7742. private _updateVector4ForEffect;
  7743. private _updateVector4ForUniform;
  7744. private _updateColor3ForEffect;
  7745. private _updateColor3ForUniform;
  7746. private _updateColor4ForEffect;
  7747. private _updateColor4ForUniform;
  7748. /**
  7749. * Sets a sampler uniform on the effect.
  7750. * @param name Define the name of the sampler.
  7751. * @param texture Define the texture to set in the sampler
  7752. */
  7753. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7754. /**
  7755. * Directly updates the value of the uniform in the cache AND on the GPU.
  7756. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7757. * @param data Define the flattened data
  7758. */
  7759. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7760. /**
  7761. * Binds this uniform buffer to an effect.
  7762. * @param effect Define the effect to bind the buffer to
  7763. * @param name Name of the uniform block in the shader.
  7764. */
  7765. bindToEffect(effect: Effect, name: string): void;
  7766. /**
  7767. * Disposes the uniform buffer.
  7768. */
  7769. dispose(): void;
  7770. }
  7771. }
  7772. declare module "babylonjs/Misc/iInspectable" {
  7773. /**
  7774. * Enum that determines the text-wrapping mode to use.
  7775. */
  7776. export enum InspectableType {
  7777. /**
  7778. * Checkbox for booleans
  7779. */
  7780. Checkbox = 0,
  7781. /**
  7782. * Sliders for numbers
  7783. */
  7784. Slider = 1,
  7785. /**
  7786. * Vector3
  7787. */
  7788. Vector3 = 2,
  7789. /**
  7790. * Quaternions
  7791. */
  7792. Quaternion = 3,
  7793. /**
  7794. * Color3
  7795. */
  7796. Color3 = 4,
  7797. /**
  7798. * String
  7799. */
  7800. String = 5
  7801. }
  7802. /**
  7803. * Interface used to define custom inspectable properties.
  7804. * This interface is used by the inspector to display custom property grids
  7805. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7806. */
  7807. export interface IInspectable {
  7808. /**
  7809. * Gets the label to display
  7810. */
  7811. label: string;
  7812. /**
  7813. * Gets the name of the property to edit
  7814. */
  7815. propertyName: string;
  7816. /**
  7817. * Gets the type of the editor to use
  7818. */
  7819. type: InspectableType;
  7820. /**
  7821. * Gets the minimum value of the property when using in "slider" mode
  7822. */
  7823. min?: number;
  7824. /**
  7825. * Gets the maximum value of the property when using in "slider" mode
  7826. */
  7827. max?: number;
  7828. /**
  7829. * Gets the setp to use when using in "slider" mode
  7830. */
  7831. step?: number;
  7832. }
  7833. }
  7834. declare module "babylonjs/Misc/timingTools" {
  7835. /**
  7836. * Class used to provide helper for timing
  7837. */
  7838. export class TimingTools {
  7839. /**
  7840. * Polyfill for setImmediate
  7841. * @param action defines the action to execute after the current execution block
  7842. */
  7843. static SetImmediate(action: () => void): void;
  7844. }
  7845. }
  7846. declare module "babylonjs/Misc/instantiationTools" {
  7847. /**
  7848. * Class used to enable instatition of objects by class name
  7849. */
  7850. export class InstantiationTools {
  7851. /**
  7852. * Use this object to register external classes like custom textures or material
  7853. * to allow the laoders to instantiate them
  7854. */
  7855. static RegisteredExternalClasses: {
  7856. [key: string]: Object;
  7857. };
  7858. /**
  7859. * Tries to instantiate a new object from a given class name
  7860. * @param className defines the class name to instantiate
  7861. * @returns the new object or null if the system was not able to do the instantiation
  7862. */
  7863. static Instantiate(className: string): any;
  7864. }
  7865. }
  7866. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7867. /**
  7868. * Define options used to create a depth texture
  7869. */
  7870. export class DepthTextureCreationOptions {
  7871. /** Specifies whether or not a stencil should be allocated in the texture */
  7872. generateStencil?: boolean;
  7873. /** Specifies whether or not bilinear filtering is enable on the texture */
  7874. bilinearFiltering?: boolean;
  7875. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7876. comparisonFunction?: number;
  7877. /** Specifies if the created texture is a cube texture */
  7878. isCube?: boolean;
  7879. }
  7880. }
  7881. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7883. import { Nullable } from "babylonjs/types";
  7884. import { Scene } from "babylonjs/scene";
  7885. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7886. module "babylonjs/Engines/thinEngine" {
  7887. interface ThinEngine {
  7888. /**
  7889. * Creates a depth stencil cube texture.
  7890. * This is only available in WebGL 2.
  7891. * @param size The size of face edge in the cube texture.
  7892. * @param options The options defining the cube texture.
  7893. * @returns The cube texture
  7894. */
  7895. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7896. /**
  7897. * Creates a cube texture
  7898. * @param rootUrl defines the url where the files to load is located
  7899. * @param scene defines the current scene
  7900. * @param files defines the list of files to load (1 per face)
  7901. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7902. * @param onLoad defines an optional callback raised when the texture is loaded
  7903. * @param onError defines an optional callback raised if there is an issue to load the texture
  7904. * @param format defines the format of the data
  7905. * @param forcedExtension defines the extension to use to pick the right loader
  7906. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7907. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7908. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7909. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7910. * @param loaderOptions options to be passed to the loader
  7911. * @returns the cube texture as an InternalTexture
  7912. */
  7913. 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>, loaderOptions: any): InternalTexture;
  7914. /**
  7915. * Creates a cube texture
  7916. * @param rootUrl defines the url where the files to load is located
  7917. * @param scene defines the current scene
  7918. * @param files defines the list of files to load (1 per face)
  7919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7920. * @param onLoad defines an optional callback raised when the texture is loaded
  7921. * @param onError defines an optional callback raised if there is an issue to load the texture
  7922. * @param format defines the format of the data
  7923. * @param forcedExtension defines the extension to use to pick the right loader
  7924. * @returns the cube texture as an InternalTexture
  7925. */
  7926. 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;
  7927. /**
  7928. * Creates a cube texture
  7929. * @param rootUrl defines the url where the files to load is located
  7930. * @param scene defines the current scene
  7931. * @param files defines the list of files to load (1 per face)
  7932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7933. * @param onLoad defines an optional callback raised when the texture is loaded
  7934. * @param onError defines an optional callback raised if there is an issue to load the texture
  7935. * @param format defines the format of the data
  7936. * @param forcedExtension defines the extension to use to pick the right loader
  7937. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7938. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7939. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7940. * @returns the cube texture as an InternalTexture
  7941. */
  7942. 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;
  7943. /** @hidden */
  7944. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7945. /** @hidden */
  7946. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7947. /** @hidden */
  7948. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7949. /** @hidden */
  7950. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7951. /**
  7952. * @hidden
  7953. */
  7954. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7955. }
  7956. }
  7957. }
  7958. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7959. import { Nullable } from "babylonjs/types";
  7960. import { Scene } from "babylonjs/scene";
  7961. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7963. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7964. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7965. import { Observable } from "babylonjs/Misc/observable";
  7966. /**
  7967. * Class for creating a cube texture
  7968. */
  7969. export class CubeTexture extends BaseTexture {
  7970. private _delayedOnLoad;
  7971. /**
  7972. * Observable triggered once the texture has been loaded.
  7973. */
  7974. onLoadObservable: Observable<CubeTexture>;
  7975. /**
  7976. * The url of the texture
  7977. */
  7978. url: string;
  7979. /**
  7980. * Gets or sets the center of the bounding box associated with the cube texture.
  7981. * It must define where the camera used to render the texture was set
  7982. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7983. */
  7984. boundingBoxPosition: Vector3;
  7985. private _boundingBoxSize;
  7986. /**
  7987. * Gets or sets the size of the bounding box associated with the cube texture
  7988. * When defined, the cubemap will switch to local mode
  7989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7990. * @example https://www.babylonjs-playground.com/#RNASML
  7991. */
  7992. set boundingBoxSize(value: Vector3);
  7993. /**
  7994. * Returns the bounding box size
  7995. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7996. */
  7997. get boundingBoxSize(): Vector3;
  7998. protected _rotationY: number;
  7999. /**
  8000. * Sets texture matrix rotation angle around Y axis in radians.
  8001. */
  8002. set rotationY(value: number);
  8003. /**
  8004. * Gets texture matrix rotation angle around Y axis radians.
  8005. */
  8006. get rotationY(): number;
  8007. /**
  8008. * Are mip maps generated for this texture or not.
  8009. */
  8010. get noMipmap(): boolean;
  8011. private _noMipmap;
  8012. private _files;
  8013. protected _forcedExtension: Nullable<string>;
  8014. private _extensions;
  8015. private _textureMatrix;
  8016. private _format;
  8017. private _createPolynomials;
  8018. private _loaderOptions;
  8019. /**
  8020. * Creates a cube texture from an array of image urls
  8021. * @param files defines an array of image urls
  8022. * @param scene defines the hosting scene
  8023. * @param noMipmap specifies if mip maps are not used
  8024. * @returns a cube texture
  8025. */
  8026. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8027. /**
  8028. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8029. * @param url defines the url of the prefiltered texture
  8030. * @param scene defines the scene the texture is attached to
  8031. * @param forcedExtension defines the extension of the file if different from the url
  8032. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8033. * @return the prefiltered texture
  8034. */
  8035. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8036. /**
  8037. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8038. * as prefiltered data.
  8039. * @param rootUrl defines the url of the texture or the root name of the six images
  8040. * @param null defines the scene or engine the texture is attached to
  8041. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8042. * @param noMipmap defines if mipmaps should be created or not
  8043. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8044. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8045. * @param onError defines a callback triggered in case of error during load
  8046. * @param format defines the internal format to use for the texture once loaded
  8047. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8048. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8049. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8050. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8051. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8052. * @param loaderOptions options to be passed to the loader
  8053. * @return the cube texture
  8054. */
  8055. 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, loaderOptions?: any);
  8056. /**
  8057. * Get the current class name of the texture useful for serialization or dynamic coding.
  8058. * @returns "CubeTexture"
  8059. */
  8060. getClassName(): string;
  8061. /**
  8062. * Update the url (and optional buffer) of this texture if url was null during construction.
  8063. * @param url the url of the texture
  8064. * @param forcedExtension defines the extension to use
  8065. * @param onLoad callback called when the texture is loaded (defaults to null)
  8066. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8067. */
  8068. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8069. /**
  8070. * Delays loading of the cube texture
  8071. * @param forcedExtension defines the extension to use
  8072. */
  8073. delayLoad(forcedExtension?: string): void;
  8074. /**
  8075. * Returns the reflection texture matrix
  8076. * @returns the reflection texture matrix
  8077. */
  8078. getReflectionTextureMatrix(): Matrix;
  8079. /**
  8080. * Sets the reflection texture matrix
  8081. * @param value Reflection texture matrix
  8082. */
  8083. setReflectionTextureMatrix(value: Matrix): void;
  8084. /**
  8085. * Parses text to create a cube texture
  8086. * @param parsedTexture define the serialized text to read from
  8087. * @param scene defines the hosting scene
  8088. * @param rootUrl defines the root url of the cube texture
  8089. * @returns a cube texture
  8090. */
  8091. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8092. /**
  8093. * Makes a clone, or deep copy, of the cube texture
  8094. * @returns a new cube texture
  8095. */
  8096. clone(): CubeTexture;
  8097. }
  8098. }
  8099. declare module "babylonjs/Materials/materialDefines" {
  8100. /**
  8101. * Manages the defines for the Material
  8102. */
  8103. export class MaterialDefines {
  8104. /** @hidden */
  8105. protected _keys: string[];
  8106. private _isDirty;
  8107. /** @hidden */
  8108. _renderId: number;
  8109. /** @hidden */
  8110. _areLightsDirty: boolean;
  8111. /** @hidden */
  8112. _areLightsDisposed: boolean;
  8113. /** @hidden */
  8114. _areAttributesDirty: boolean;
  8115. /** @hidden */
  8116. _areTexturesDirty: boolean;
  8117. /** @hidden */
  8118. _areFresnelDirty: boolean;
  8119. /** @hidden */
  8120. _areMiscDirty: boolean;
  8121. /** @hidden */
  8122. _arePrePassDirty: boolean;
  8123. /** @hidden */
  8124. _areImageProcessingDirty: boolean;
  8125. /** @hidden */
  8126. _normals: boolean;
  8127. /** @hidden */
  8128. _uvs: boolean;
  8129. /** @hidden */
  8130. _needNormals: boolean;
  8131. /** @hidden */
  8132. _needUVs: boolean;
  8133. [id: string]: any;
  8134. /**
  8135. * Specifies if the material needs to be re-calculated
  8136. */
  8137. get isDirty(): boolean;
  8138. /**
  8139. * Marks the material to indicate that it has been re-calculated
  8140. */
  8141. markAsProcessed(): void;
  8142. /**
  8143. * Marks the material to indicate that it needs to be re-calculated
  8144. */
  8145. markAsUnprocessed(): void;
  8146. /**
  8147. * Marks the material to indicate all of its defines need to be re-calculated
  8148. */
  8149. markAllAsDirty(): void;
  8150. /**
  8151. * Marks the material to indicate that image processing needs to be re-calculated
  8152. */
  8153. markAsImageProcessingDirty(): void;
  8154. /**
  8155. * Marks the material to indicate the lights need to be re-calculated
  8156. * @param disposed Defines whether the light is dirty due to dispose or not
  8157. */
  8158. markAsLightDirty(disposed?: boolean): void;
  8159. /**
  8160. * Marks the attribute state as changed
  8161. */
  8162. markAsAttributesDirty(): void;
  8163. /**
  8164. * Marks the texture state as changed
  8165. */
  8166. markAsTexturesDirty(): void;
  8167. /**
  8168. * Marks the fresnel state as changed
  8169. */
  8170. markAsFresnelDirty(): void;
  8171. /**
  8172. * Marks the misc state as changed
  8173. */
  8174. markAsMiscDirty(): void;
  8175. /**
  8176. * Marks the prepass state as changed
  8177. */
  8178. markAsPrePassDirty(): void;
  8179. /**
  8180. * Rebuilds the material defines
  8181. */
  8182. rebuild(): void;
  8183. /**
  8184. * Specifies if two material defines are equal
  8185. * @param other - A material define instance to compare to
  8186. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8187. */
  8188. isEqual(other: MaterialDefines): boolean;
  8189. /**
  8190. * Clones this instance's defines to another instance
  8191. * @param other - material defines to clone values to
  8192. */
  8193. cloneTo(other: MaterialDefines): void;
  8194. /**
  8195. * Resets the material define values
  8196. */
  8197. reset(): void;
  8198. /**
  8199. * Converts the material define values to a string
  8200. * @returns - String of material define information
  8201. */
  8202. toString(): string;
  8203. }
  8204. }
  8205. declare module "babylonjs/Materials/colorCurves" {
  8206. import { Effect } from "babylonjs/Materials/effect";
  8207. /**
  8208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8210. * 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;
  8211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8212. */
  8213. export class ColorCurves {
  8214. private _dirty;
  8215. private _tempColor;
  8216. private _globalCurve;
  8217. private _highlightsCurve;
  8218. private _midtonesCurve;
  8219. private _shadowsCurve;
  8220. private _positiveCurve;
  8221. private _negativeCurve;
  8222. private _globalHue;
  8223. private _globalDensity;
  8224. private _globalSaturation;
  8225. private _globalExposure;
  8226. /**
  8227. * Gets the global Hue value.
  8228. * 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).
  8229. */
  8230. get globalHue(): number;
  8231. /**
  8232. * Sets the global Hue value.
  8233. * 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).
  8234. */
  8235. set globalHue(value: number);
  8236. /**
  8237. * Gets the global Density value.
  8238. * 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.
  8239. * Values less than zero provide a filter of opposite hue.
  8240. */
  8241. get globalDensity(): number;
  8242. /**
  8243. * Sets the global Density value.
  8244. * 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.
  8245. * Values less than zero provide a filter of opposite hue.
  8246. */
  8247. set globalDensity(value: number);
  8248. /**
  8249. * Gets the global Saturation value.
  8250. * 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.
  8251. */
  8252. get globalSaturation(): number;
  8253. /**
  8254. * Sets the global Saturation value.
  8255. * 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.
  8256. */
  8257. set globalSaturation(value: number);
  8258. /**
  8259. * Gets the global Exposure value.
  8260. * 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.
  8261. */
  8262. get globalExposure(): number;
  8263. /**
  8264. * Sets the global Exposure value.
  8265. * 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.
  8266. */
  8267. set globalExposure(value: number);
  8268. private _highlightsHue;
  8269. private _highlightsDensity;
  8270. private _highlightsSaturation;
  8271. private _highlightsExposure;
  8272. /**
  8273. * Gets the highlights Hue value.
  8274. * 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).
  8275. */
  8276. get highlightsHue(): number;
  8277. /**
  8278. * Sets the highlights Hue value.
  8279. * 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).
  8280. */
  8281. set highlightsHue(value: number);
  8282. /**
  8283. * Gets the highlights Density value.
  8284. * 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.
  8285. * Values less than zero provide a filter of opposite hue.
  8286. */
  8287. get highlightsDensity(): number;
  8288. /**
  8289. * Sets the highlights Density value.
  8290. * 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.
  8291. * Values less than zero provide a filter of opposite hue.
  8292. */
  8293. set highlightsDensity(value: number);
  8294. /**
  8295. * Gets the highlights Saturation value.
  8296. * 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.
  8297. */
  8298. get highlightsSaturation(): number;
  8299. /**
  8300. * Sets the highlights Saturation value.
  8301. * 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.
  8302. */
  8303. set highlightsSaturation(value: number);
  8304. /**
  8305. * Gets the highlights Exposure value.
  8306. * 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.
  8307. */
  8308. get highlightsExposure(): number;
  8309. /**
  8310. * Sets the highlights Exposure value.
  8311. * 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.
  8312. */
  8313. set highlightsExposure(value: number);
  8314. private _midtonesHue;
  8315. private _midtonesDensity;
  8316. private _midtonesSaturation;
  8317. private _midtonesExposure;
  8318. /**
  8319. * Gets the midtones Hue value.
  8320. * 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).
  8321. */
  8322. get midtonesHue(): number;
  8323. /**
  8324. * Sets the midtones Hue value.
  8325. * 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).
  8326. */
  8327. set midtonesHue(value: number);
  8328. /**
  8329. * Gets the midtones Density value.
  8330. * 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.
  8331. * Values less than zero provide a filter of opposite hue.
  8332. */
  8333. get midtonesDensity(): number;
  8334. /**
  8335. * Sets the midtones Density value.
  8336. * 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.
  8337. * Values less than zero provide a filter of opposite hue.
  8338. */
  8339. set midtonesDensity(value: number);
  8340. /**
  8341. * Gets the midtones Saturation value.
  8342. * 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.
  8343. */
  8344. get midtonesSaturation(): number;
  8345. /**
  8346. * Sets the midtones Saturation value.
  8347. * 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.
  8348. */
  8349. set midtonesSaturation(value: number);
  8350. /**
  8351. * Gets the midtones Exposure value.
  8352. * 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.
  8353. */
  8354. get midtonesExposure(): number;
  8355. /**
  8356. * Sets the midtones Exposure value.
  8357. * 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.
  8358. */
  8359. set midtonesExposure(value: number);
  8360. private _shadowsHue;
  8361. private _shadowsDensity;
  8362. private _shadowsSaturation;
  8363. private _shadowsExposure;
  8364. /**
  8365. * Gets the shadows Hue value.
  8366. * 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).
  8367. */
  8368. get shadowsHue(): number;
  8369. /**
  8370. * Sets the shadows Hue value.
  8371. * 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).
  8372. */
  8373. set shadowsHue(value: number);
  8374. /**
  8375. * Gets the shadows Density value.
  8376. * 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.
  8377. * Values less than zero provide a filter of opposite hue.
  8378. */
  8379. get shadowsDensity(): number;
  8380. /**
  8381. * Sets the shadows Density value.
  8382. * 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.
  8383. * Values less than zero provide a filter of opposite hue.
  8384. */
  8385. set shadowsDensity(value: number);
  8386. /**
  8387. * Gets the shadows Saturation value.
  8388. * 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.
  8389. */
  8390. get shadowsSaturation(): number;
  8391. /**
  8392. * Sets the shadows Saturation value.
  8393. * 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.
  8394. */
  8395. set shadowsSaturation(value: number);
  8396. /**
  8397. * Gets the shadows Exposure value.
  8398. * 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.
  8399. */
  8400. get shadowsExposure(): number;
  8401. /**
  8402. * Sets the shadows Exposure value.
  8403. * 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.
  8404. */
  8405. set shadowsExposure(value: number);
  8406. /**
  8407. * Returns the class name
  8408. * @returns The class name
  8409. */
  8410. getClassName(): string;
  8411. /**
  8412. * Binds the color curves to the shader.
  8413. * @param colorCurves The color curve to bind
  8414. * @param effect The effect to bind to
  8415. * @param positiveUniform The positive uniform shader parameter
  8416. * @param neutralUniform The neutral uniform shader parameter
  8417. * @param negativeUniform The negative uniform shader parameter
  8418. */
  8419. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8420. /**
  8421. * Prepare the list of uniforms associated with the ColorCurves effects.
  8422. * @param uniformsList The list of uniforms used in the effect
  8423. */
  8424. static PrepareUniforms(uniformsList: string[]): void;
  8425. /**
  8426. * Returns color grading data based on a hue, density, saturation and exposure value.
  8427. * @param filterHue The hue of the color filter.
  8428. * @param filterDensity The density of the color filter.
  8429. * @param saturation The saturation.
  8430. * @param exposure The exposure.
  8431. * @param result The result data container.
  8432. */
  8433. private getColorGradingDataToRef;
  8434. /**
  8435. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8436. * @param value The input slider value in range [-100,100].
  8437. * @returns Adjusted value.
  8438. */
  8439. private static applyColorGradingSliderNonlinear;
  8440. /**
  8441. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8442. * @param hue The hue (H) input.
  8443. * @param saturation The saturation (S) input.
  8444. * @param brightness The brightness (B) input.
  8445. * @result An RGBA color represented as Vector4.
  8446. */
  8447. private static fromHSBToRef;
  8448. /**
  8449. * Returns a value clamped between min and max
  8450. * @param value The value to clamp
  8451. * @param min The minimum of value
  8452. * @param max The maximum of value
  8453. * @returns The clamped value.
  8454. */
  8455. private static clamp;
  8456. /**
  8457. * Clones the current color curve instance.
  8458. * @return The cloned curves
  8459. */
  8460. clone(): ColorCurves;
  8461. /**
  8462. * Serializes the current color curve instance to a json representation.
  8463. * @return a JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Parses the color curve from a json representation.
  8468. * @param source the JSON source to parse
  8469. * @return The parsed curves
  8470. */
  8471. static Parse(source: any): ColorCurves;
  8472. }
  8473. }
  8474. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8475. import { Observable } from "babylonjs/Misc/observable";
  8476. import { Nullable } from "babylonjs/types";
  8477. import { Color4 } from "babylonjs/Maths/math.color";
  8478. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8479. import { Effect } from "babylonjs/Materials/effect";
  8480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8481. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8482. /**
  8483. * Interface to follow in your material defines to integrate easily the
  8484. * Image proccessing functions.
  8485. * @hidden
  8486. */
  8487. export interface IImageProcessingConfigurationDefines {
  8488. IMAGEPROCESSING: boolean;
  8489. VIGNETTE: boolean;
  8490. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8491. VIGNETTEBLENDMODEOPAQUE: boolean;
  8492. TONEMAPPING: boolean;
  8493. TONEMAPPING_ACES: boolean;
  8494. CONTRAST: boolean;
  8495. EXPOSURE: boolean;
  8496. COLORCURVES: boolean;
  8497. COLORGRADING: boolean;
  8498. COLORGRADING3D: boolean;
  8499. SAMPLER3DGREENDEPTH: boolean;
  8500. SAMPLER3DBGRMAP: boolean;
  8501. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8502. }
  8503. /**
  8504. * @hidden
  8505. */
  8506. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8507. IMAGEPROCESSING: boolean;
  8508. VIGNETTE: boolean;
  8509. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8510. VIGNETTEBLENDMODEOPAQUE: boolean;
  8511. TONEMAPPING: boolean;
  8512. TONEMAPPING_ACES: boolean;
  8513. CONTRAST: boolean;
  8514. COLORCURVES: boolean;
  8515. COLORGRADING: boolean;
  8516. COLORGRADING3D: boolean;
  8517. SAMPLER3DGREENDEPTH: boolean;
  8518. SAMPLER3DBGRMAP: boolean;
  8519. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8520. EXPOSURE: boolean;
  8521. constructor();
  8522. }
  8523. /**
  8524. * This groups together the common properties used for image processing either in direct forward pass
  8525. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8526. * or not.
  8527. */
  8528. export class ImageProcessingConfiguration {
  8529. /**
  8530. * Default tone mapping applied in BabylonJS.
  8531. */
  8532. static readonly TONEMAPPING_STANDARD: number;
  8533. /**
  8534. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8535. * to other engines rendering to increase portability.
  8536. */
  8537. static readonly TONEMAPPING_ACES: number;
  8538. /**
  8539. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8540. */
  8541. colorCurves: Nullable<ColorCurves>;
  8542. private _colorCurvesEnabled;
  8543. /**
  8544. * Gets wether the color curves effect is enabled.
  8545. */
  8546. get colorCurvesEnabled(): boolean;
  8547. /**
  8548. * Sets wether the color curves effect is enabled.
  8549. */
  8550. set colorCurvesEnabled(value: boolean);
  8551. private _colorGradingTexture;
  8552. /**
  8553. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8554. */
  8555. get colorGradingTexture(): Nullable<BaseTexture>;
  8556. /**
  8557. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8558. */
  8559. set colorGradingTexture(value: Nullable<BaseTexture>);
  8560. private _colorGradingEnabled;
  8561. /**
  8562. * Gets wether the color grading effect is enabled.
  8563. */
  8564. get colorGradingEnabled(): boolean;
  8565. /**
  8566. * Sets wether the color grading effect is enabled.
  8567. */
  8568. set colorGradingEnabled(value: boolean);
  8569. private _colorGradingWithGreenDepth;
  8570. /**
  8571. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8572. */
  8573. get colorGradingWithGreenDepth(): boolean;
  8574. /**
  8575. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8576. */
  8577. set colorGradingWithGreenDepth(value: boolean);
  8578. private _colorGradingBGR;
  8579. /**
  8580. * Gets wether the color grading texture contains BGR values.
  8581. */
  8582. get colorGradingBGR(): boolean;
  8583. /**
  8584. * Sets wether the color grading texture contains BGR values.
  8585. */
  8586. set colorGradingBGR(value: boolean);
  8587. /** @hidden */
  8588. _exposure: number;
  8589. /**
  8590. * Gets the Exposure used in the effect.
  8591. */
  8592. get exposure(): number;
  8593. /**
  8594. * Sets the Exposure used in the effect.
  8595. */
  8596. set exposure(value: number);
  8597. private _toneMappingEnabled;
  8598. /**
  8599. * Gets wether the tone mapping effect is enabled.
  8600. */
  8601. get toneMappingEnabled(): boolean;
  8602. /**
  8603. * Sets wether the tone mapping effect is enabled.
  8604. */
  8605. set toneMappingEnabled(value: boolean);
  8606. private _toneMappingType;
  8607. /**
  8608. * Gets the type of tone mapping effect.
  8609. */
  8610. get toneMappingType(): number;
  8611. /**
  8612. * Sets the type of tone mapping effect used in BabylonJS.
  8613. */
  8614. set toneMappingType(value: number);
  8615. protected _contrast: number;
  8616. /**
  8617. * Gets the contrast used in the effect.
  8618. */
  8619. get contrast(): number;
  8620. /**
  8621. * Sets the contrast used in the effect.
  8622. */
  8623. set contrast(value: number);
  8624. /**
  8625. * Vignette stretch size.
  8626. */
  8627. vignetteStretch: number;
  8628. /**
  8629. * Vignette centre X Offset.
  8630. */
  8631. vignetteCentreX: number;
  8632. /**
  8633. * Vignette centre Y Offset.
  8634. */
  8635. vignetteCentreY: number;
  8636. /**
  8637. * Vignette weight or intensity of the vignette effect.
  8638. */
  8639. vignetteWeight: number;
  8640. /**
  8641. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8642. * if vignetteEnabled is set to true.
  8643. */
  8644. vignetteColor: Color4;
  8645. /**
  8646. * Camera field of view used by the Vignette effect.
  8647. */
  8648. vignetteCameraFov: number;
  8649. private _vignetteBlendMode;
  8650. /**
  8651. * Gets the vignette blend mode allowing different kind of effect.
  8652. */
  8653. get vignetteBlendMode(): number;
  8654. /**
  8655. * Sets the vignette blend mode allowing different kind of effect.
  8656. */
  8657. set vignetteBlendMode(value: number);
  8658. private _vignetteEnabled;
  8659. /**
  8660. * Gets wether the vignette effect is enabled.
  8661. */
  8662. get vignetteEnabled(): boolean;
  8663. /**
  8664. * Sets wether the vignette effect is enabled.
  8665. */
  8666. set vignetteEnabled(value: boolean);
  8667. private _applyByPostProcess;
  8668. /**
  8669. * Gets wether the image processing is applied through a post process or not.
  8670. */
  8671. get applyByPostProcess(): boolean;
  8672. /**
  8673. * Sets wether the image processing is applied through a post process or not.
  8674. */
  8675. set applyByPostProcess(value: boolean);
  8676. private _isEnabled;
  8677. /**
  8678. * Gets wether the image processing is enabled or not.
  8679. */
  8680. get isEnabled(): boolean;
  8681. /**
  8682. * Sets wether the image processing is enabled or not.
  8683. */
  8684. set isEnabled(value: boolean);
  8685. /**
  8686. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8687. */
  8688. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8689. /**
  8690. * Method called each time the image processing information changes requires to recompile the effect.
  8691. */
  8692. protected _updateParameters(): void;
  8693. /**
  8694. * Gets the current class name.
  8695. * @return "ImageProcessingConfiguration"
  8696. */
  8697. getClassName(): string;
  8698. /**
  8699. * Prepare the list of uniforms associated with the Image Processing effects.
  8700. * @param uniforms The list of uniforms used in the effect
  8701. * @param defines the list of defines currently in use
  8702. */
  8703. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8704. /**
  8705. * Prepare the list of samplers associated with the Image Processing effects.
  8706. * @param samplersList The list of uniforms used in the effect
  8707. * @param defines the list of defines currently in use
  8708. */
  8709. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8710. /**
  8711. * Prepare the list of defines associated to the shader.
  8712. * @param defines the list of defines to complete
  8713. * @param forPostProcess Define if we are currently in post process mode or not
  8714. */
  8715. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8716. /**
  8717. * Returns true if all the image processing information are ready.
  8718. * @returns True if ready, otherwise, false
  8719. */
  8720. isReady(): boolean;
  8721. /**
  8722. * Binds the image processing to the shader.
  8723. * @param effect The effect to bind to
  8724. * @param overrideAspectRatio Override the aspect ratio of the effect
  8725. */
  8726. bind(effect: Effect, overrideAspectRatio?: number): void;
  8727. /**
  8728. * Clones the current image processing instance.
  8729. * @return The cloned image processing
  8730. */
  8731. clone(): ImageProcessingConfiguration;
  8732. /**
  8733. * Serializes the current image processing instance to a json representation.
  8734. * @return a JSON representation
  8735. */
  8736. serialize(): any;
  8737. /**
  8738. * Parses the image processing from a json representation.
  8739. * @param source the JSON source to parse
  8740. * @return The parsed image processing
  8741. */
  8742. static Parse(source: any): ImageProcessingConfiguration;
  8743. private static _VIGNETTEMODE_MULTIPLY;
  8744. private static _VIGNETTEMODE_OPAQUE;
  8745. /**
  8746. * Used to apply the vignette as a mix with the pixel color.
  8747. */
  8748. static get VIGNETTEMODE_MULTIPLY(): number;
  8749. /**
  8750. * Used to apply the vignette as a replacement of the pixel color.
  8751. */
  8752. static get VIGNETTEMODE_OPAQUE(): number;
  8753. }
  8754. }
  8755. declare module "babylonjs/Shaders/postprocess.vertex" {
  8756. /** @hidden */
  8757. export var postprocessVertexShader: {
  8758. name: string;
  8759. shader: string;
  8760. };
  8761. }
  8762. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8764. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8765. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8766. /**
  8767. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8768. */
  8769. export type RenderTargetTextureSize = number | {
  8770. width: number;
  8771. height: number;
  8772. layers?: number;
  8773. };
  8774. module "babylonjs/Engines/thinEngine" {
  8775. interface ThinEngine {
  8776. /**
  8777. * Creates a new render target texture
  8778. * @param size defines the size of the texture
  8779. * @param options defines the options used to create the texture
  8780. * @returns a new render target texture stored in an InternalTexture
  8781. */
  8782. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8783. /**
  8784. * Creates a depth stencil texture.
  8785. * This is only available in WebGL 2 or with the depth texture extension available.
  8786. * @param size The size of face edge in the texture.
  8787. * @param options The options defining the texture.
  8788. * @returns The texture
  8789. */
  8790. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8791. /** @hidden */
  8792. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8793. }
  8794. }
  8795. }
  8796. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8797. /**
  8798. * Defines the kind of connection point for node based material
  8799. */
  8800. export enum NodeMaterialBlockConnectionPointTypes {
  8801. /** Float */
  8802. Float = 1,
  8803. /** Int */
  8804. Int = 2,
  8805. /** Vector2 */
  8806. Vector2 = 4,
  8807. /** Vector3 */
  8808. Vector3 = 8,
  8809. /** Vector4 */
  8810. Vector4 = 16,
  8811. /** Color3 */
  8812. Color3 = 32,
  8813. /** Color4 */
  8814. Color4 = 64,
  8815. /** Matrix */
  8816. Matrix = 128,
  8817. /** Custom object */
  8818. Object = 256,
  8819. /** Detect type based on connection */
  8820. AutoDetect = 1024,
  8821. /** Output type that will be defined by input type */
  8822. BasedOnInput = 2048
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8826. /**
  8827. * Enum used to define the target of a block
  8828. */
  8829. export enum NodeMaterialBlockTargets {
  8830. /** Vertex shader */
  8831. Vertex = 1,
  8832. /** Fragment shader */
  8833. Fragment = 2,
  8834. /** Neutral */
  8835. Neutral = 4,
  8836. /** Vertex and Fragment */
  8837. VertexAndFragment = 3
  8838. }
  8839. }
  8840. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8841. /**
  8842. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8843. */
  8844. export enum NodeMaterialBlockConnectionPointMode {
  8845. /** Value is an uniform */
  8846. Uniform = 0,
  8847. /** Value is a mesh attribute */
  8848. Attribute = 1,
  8849. /** Value is a varying between vertex and fragment shaders */
  8850. Varying = 2,
  8851. /** Mode is undefined */
  8852. Undefined = 3
  8853. }
  8854. }
  8855. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8856. /**
  8857. * Enum used to define system values e.g. values automatically provided by the system
  8858. */
  8859. export enum NodeMaterialSystemValues {
  8860. /** World */
  8861. World = 1,
  8862. /** View */
  8863. View = 2,
  8864. /** Projection */
  8865. Projection = 3,
  8866. /** ViewProjection */
  8867. ViewProjection = 4,
  8868. /** WorldView */
  8869. WorldView = 5,
  8870. /** WorldViewProjection */
  8871. WorldViewProjection = 6,
  8872. /** CameraPosition */
  8873. CameraPosition = 7,
  8874. /** Fog Color */
  8875. FogColor = 8,
  8876. /** Delta time */
  8877. DeltaTime = 9
  8878. }
  8879. }
  8880. declare module "babylonjs/Maths/math.axis" {
  8881. import { Vector3 } from "babylonjs/Maths/math.vector";
  8882. /** Defines supported spaces */
  8883. export enum Space {
  8884. /** Local (object) space */
  8885. LOCAL = 0,
  8886. /** World space */
  8887. WORLD = 1,
  8888. /** Bone space */
  8889. BONE = 2
  8890. }
  8891. /** Defines the 3 main axes */
  8892. export class Axis {
  8893. /** X axis */
  8894. static X: Vector3;
  8895. /** Y axis */
  8896. static Y: Vector3;
  8897. /** Z axis */
  8898. static Z: Vector3;
  8899. }
  8900. }
  8901. declare module "babylonjs/Maths/math.frustum" {
  8902. import { Matrix } from "babylonjs/Maths/math.vector";
  8903. import { DeepImmutable } from "babylonjs/types";
  8904. import { Plane } from "babylonjs/Maths/math.plane";
  8905. /**
  8906. * Represents a camera frustum
  8907. */
  8908. export class Frustum {
  8909. /**
  8910. * Gets the planes representing the frustum
  8911. * @param transform matrix to be applied to the returned planes
  8912. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8913. */
  8914. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8915. /**
  8916. * Gets the near frustum plane transformed by the transform matrix
  8917. * @param transform transformation matrix to be applied to the resulting frustum plane
  8918. * @param frustumPlane the resuling frustum plane
  8919. */
  8920. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8921. /**
  8922. * Gets the far frustum plane transformed by the transform matrix
  8923. * @param transform transformation matrix to be applied to the resulting frustum plane
  8924. * @param frustumPlane the resuling frustum plane
  8925. */
  8926. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8927. /**
  8928. * Gets the left frustum plane transformed by the transform matrix
  8929. * @param transform transformation matrix to be applied to the resulting frustum plane
  8930. * @param frustumPlane the resuling frustum plane
  8931. */
  8932. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8933. /**
  8934. * Gets the right frustum plane transformed by the transform matrix
  8935. * @param transform transformation matrix to be applied to the resulting frustum plane
  8936. * @param frustumPlane the resuling frustum plane
  8937. */
  8938. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8939. /**
  8940. * Gets the top frustum plane transformed by the transform matrix
  8941. * @param transform transformation matrix to be applied to the resulting frustum plane
  8942. * @param frustumPlane the resuling frustum plane
  8943. */
  8944. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8945. /**
  8946. * Gets the bottom frustum plane transformed by the transform matrix
  8947. * @param transform transformation matrix to be applied to the resulting frustum plane
  8948. * @param frustumPlane the resuling frustum plane
  8949. */
  8950. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8951. /**
  8952. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8953. * @param transform transformation matrix to be applied to the resulting frustum planes
  8954. * @param frustumPlanes the resuling frustum planes
  8955. */
  8956. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math.size" {
  8960. /**
  8961. * Interface for the size containing width and height
  8962. */
  8963. export interface ISize {
  8964. /**
  8965. * Width
  8966. */
  8967. width: number;
  8968. /**
  8969. * Heighht
  8970. */
  8971. height: number;
  8972. }
  8973. /**
  8974. * Size containing widht and height
  8975. */
  8976. export class Size implements ISize {
  8977. /**
  8978. * Width
  8979. */
  8980. width: number;
  8981. /**
  8982. * Height
  8983. */
  8984. height: number;
  8985. /**
  8986. * Creates a Size object from the given width and height (floats).
  8987. * @param width width of the new size
  8988. * @param height height of the new size
  8989. */
  8990. constructor(width: number, height: number);
  8991. /**
  8992. * Returns a string with the Size width and height
  8993. * @returns a string with the Size width and height
  8994. */
  8995. toString(): string;
  8996. /**
  8997. * "Size"
  8998. * @returns the string "Size"
  8999. */
  9000. getClassName(): string;
  9001. /**
  9002. * Returns the Size hash code.
  9003. * @returns a hash code for a unique width and height
  9004. */
  9005. getHashCode(): number;
  9006. /**
  9007. * Updates the current size from the given one.
  9008. * @param src the given size
  9009. */
  9010. copyFrom(src: Size): void;
  9011. /**
  9012. * Updates in place the current Size from the given floats.
  9013. * @param width width of the new size
  9014. * @param height height of the new size
  9015. * @returns the updated Size.
  9016. */
  9017. copyFromFloats(width: number, height: number): Size;
  9018. /**
  9019. * Updates in place the current Size from the given floats.
  9020. * @param width width to set
  9021. * @param height height to set
  9022. * @returns the updated Size.
  9023. */
  9024. set(width: number, height: number): Size;
  9025. /**
  9026. * Multiplies the width and height by numbers
  9027. * @param w factor to multiple the width by
  9028. * @param h factor to multiple the height by
  9029. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9030. */
  9031. multiplyByFloats(w: number, h: number): Size;
  9032. /**
  9033. * Clones the size
  9034. * @returns a new Size copied from the given one.
  9035. */
  9036. clone(): Size;
  9037. /**
  9038. * True if the current Size and the given one width and height are strictly equal.
  9039. * @param other the other size to compare against
  9040. * @returns True if the current Size and the given one width and height are strictly equal.
  9041. */
  9042. equals(other: Size): boolean;
  9043. /**
  9044. * The surface of the Size : width * height (float).
  9045. */
  9046. get surface(): number;
  9047. /**
  9048. * Create a new size of zero
  9049. * @returns a new Size set to (0.0, 0.0)
  9050. */
  9051. static Zero(): Size;
  9052. /**
  9053. * Sums the width and height of two sizes
  9054. * @param otherSize size to add to this size
  9055. * @returns a new Size set as the addition result of the current Size and the given one.
  9056. */
  9057. add(otherSize: Size): Size;
  9058. /**
  9059. * Subtracts the width and height of two
  9060. * @param otherSize size to subtract to this size
  9061. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9062. */
  9063. subtract(otherSize: Size): Size;
  9064. /**
  9065. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9066. * @param start starting size to lerp between
  9067. * @param end end size to lerp between
  9068. * @param amount amount to lerp between the start and end values
  9069. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9070. */
  9071. static Lerp(start: Size, end: Size, amount: number): Size;
  9072. }
  9073. }
  9074. declare module "babylonjs/Maths/math.vertexFormat" {
  9075. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9076. /**
  9077. * Contains position and normal vectors for a vertex
  9078. */
  9079. export class PositionNormalVertex {
  9080. /** the position of the vertex (defaut: 0,0,0) */
  9081. position: Vector3;
  9082. /** the normal of the vertex (defaut: 0,1,0) */
  9083. normal: Vector3;
  9084. /**
  9085. * Creates a PositionNormalVertex
  9086. * @param position the position of the vertex (defaut: 0,0,0)
  9087. * @param normal the normal of the vertex (defaut: 0,1,0)
  9088. */
  9089. constructor(
  9090. /** the position of the vertex (defaut: 0,0,0) */
  9091. position?: Vector3,
  9092. /** the normal of the vertex (defaut: 0,1,0) */
  9093. normal?: Vector3);
  9094. /**
  9095. * Clones the PositionNormalVertex
  9096. * @returns the cloned PositionNormalVertex
  9097. */
  9098. clone(): PositionNormalVertex;
  9099. }
  9100. /**
  9101. * Contains position, normal and uv vectors for a vertex
  9102. */
  9103. export class PositionNormalTextureVertex {
  9104. /** the position of the vertex (defaut: 0,0,0) */
  9105. position: Vector3;
  9106. /** the normal of the vertex (defaut: 0,1,0) */
  9107. normal: Vector3;
  9108. /** the uv of the vertex (default: 0,0) */
  9109. uv: Vector2;
  9110. /**
  9111. * Creates a PositionNormalTextureVertex
  9112. * @param position the position of the vertex (defaut: 0,0,0)
  9113. * @param normal the normal of the vertex (defaut: 0,1,0)
  9114. * @param uv the uv of the vertex (default: 0,0)
  9115. */
  9116. constructor(
  9117. /** the position of the vertex (defaut: 0,0,0) */
  9118. position?: Vector3,
  9119. /** the normal of the vertex (defaut: 0,1,0) */
  9120. normal?: Vector3,
  9121. /** the uv of the vertex (default: 0,0) */
  9122. uv?: Vector2);
  9123. /**
  9124. * Clones the PositionNormalTextureVertex
  9125. * @returns the cloned PositionNormalTextureVertex
  9126. */
  9127. clone(): PositionNormalTextureVertex;
  9128. }
  9129. }
  9130. declare module "babylonjs/Maths/math" {
  9131. export * from "babylonjs/Maths/math.axis";
  9132. export * from "babylonjs/Maths/math.color";
  9133. export * from "babylonjs/Maths/math.constants";
  9134. export * from "babylonjs/Maths/math.frustum";
  9135. export * from "babylonjs/Maths/math.path";
  9136. export * from "babylonjs/Maths/math.plane";
  9137. export * from "babylonjs/Maths/math.size";
  9138. export * from "babylonjs/Maths/math.vector";
  9139. export * from "babylonjs/Maths/math.vertexFormat";
  9140. export * from "babylonjs/Maths/math.viewport";
  9141. }
  9142. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9143. /**
  9144. * Enum defining the type of animations supported by InputBlock
  9145. */
  9146. export enum AnimatedInputBlockTypes {
  9147. /** No animation */
  9148. None = 0,
  9149. /** Time based animation. Will only work for floats */
  9150. Time = 1
  9151. }
  9152. }
  9153. declare module "babylonjs/Lights/shadowLight" {
  9154. import { Camera } from "babylonjs/Cameras/camera";
  9155. import { Scene } from "babylonjs/scene";
  9156. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9158. import { Light } from "babylonjs/Lights/light";
  9159. /**
  9160. * Interface describing all the common properties and methods a shadow light needs to implement.
  9161. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9162. * as well as binding the different shadow properties to the effects.
  9163. */
  9164. export interface IShadowLight extends Light {
  9165. /**
  9166. * The light id in the scene (used in scene.findLighById for instance)
  9167. */
  9168. id: string;
  9169. /**
  9170. * The position the shdow will be casted from.
  9171. */
  9172. position: Vector3;
  9173. /**
  9174. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9175. */
  9176. direction: Vector3;
  9177. /**
  9178. * The transformed position. Position of the light in world space taking parenting in account.
  9179. */
  9180. transformedPosition: Vector3;
  9181. /**
  9182. * The transformed direction. Direction of the light in world space taking parenting in account.
  9183. */
  9184. transformedDirection: Vector3;
  9185. /**
  9186. * The friendly name of the light in the scene.
  9187. */
  9188. name: string;
  9189. /**
  9190. * Defines the shadow projection clipping minimum z value.
  9191. */
  9192. shadowMinZ: number;
  9193. /**
  9194. * Defines the shadow projection clipping maximum z value.
  9195. */
  9196. shadowMaxZ: number;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Gets the scene the light belongs to.
  9204. * @returns The scene
  9205. */
  9206. getScene(): Scene;
  9207. /**
  9208. * Callback defining a custom Projection Matrix Builder.
  9209. * This can be used to override the default projection matrix computation.
  9210. */
  9211. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9212. /**
  9213. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9214. * @param matrix The materix to updated with the projection information
  9215. * @param viewMatrix The transform matrix of the light
  9216. * @param renderList The list of mesh to render in the map
  9217. * @returns The current light
  9218. */
  9219. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9220. /**
  9221. * Gets the current depth scale used in ESM.
  9222. * @returns The scale
  9223. */
  9224. getDepthScale(): number;
  9225. /**
  9226. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9227. * @returns true if a cube texture needs to be use
  9228. */
  9229. needCube(): boolean;
  9230. /**
  9231. * Detects if the projection matrix requires to be recomputed this frame.
  9232. * @returns true if it requires to be recomputed otherwise, false.
  9233. */
  9234. needProjectionMatrixCompute(): boolean;
  9235. /**
  9236. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9237. */
  9238. forceProjectionMatrixCompute(): void;
  9239. /**
  9240. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9243. */
  9244. getShadowDirection(faceIndex?: number): Vector3;
  9245. /**
  9246. * Gets the minZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the min for
  9248. * @returns the depth min z
  9249. */
  9250. getDepthMinZ(activeCamera: Camera): number;
  9251. /**
  9252. * Gets the maxZ used for shadow according to both the scene and the light.
  9253. * @param activeCamera The camera we are returning the max for
  9254. * @returns the depth max z
  9255. */
  9256. getDepthMaxZ(activeCamera: Camera): number;
  9257. }
  9258. /**
  9259. * Base implementation IShadowLight
  9260. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9261. */
  9262. export abstract class ShadowLight extends Light implements IShadowLight {
  9263. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9264. protected _position: Vector3;
  9265. protected _setPosition(value: Vector3): void;
  9266. /**
  9267. * Sets the position the shadow will be casted from. Also use as the light position for both
  9268. * point and spot lights.
  9269. */
  9270. get position(): Vector3;
  9271. /**
  9272. * Sets the position the shadow will be casted from. Also use as the light position for both
  9273. * point and spot lights.
  9274. */
  9275. set position(value: Vector3);
  9276. protected _direction: Vector3;
  9277. protected _setDirection(value: Vector3): void;
  9278. /**
  9279. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9280. * Also use as the light direction on spot and directional lights.
  9281. */
  9282. get direction(): Vector3;
  9283. /**
  9284. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9285. * Also use as the light direction on spot and directional lights.
  9286. */
  9287. set direction(value: Vector3);
  9288. protected _shadowMinZ: number;
  9289. /**
  9290. * Gets the shadow projection clipping minimum z value.
  9291. */
  9292. get shadowMinZ(): number;
  9293. /**
  9294. * Sets the shadow projection clipping minimum z value.
  9295. */
  9296. set shadowMinZ(value: number);
  9297. protected _shadowMaxZ: number;
  9298. /**
  9299. * Sets the shadow projection clipping maximum z value.
  9300. */
  9301. get shadowMaxZ(): number;
  9302. /**
  9303. * Gets the shadow projection clipping maximum z value.
  9304. */
  9305. set shadowMaxZ(value: number);
  9306. /**
  9307. * Callback defining a custom Projection Matrix Builder.
  9308. * This can be used to override the default projection matrix computation.
  9309. */
  9310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9311. /**
  9312. * The transformed position. Position of the light in world space taking parenting in account.
  9313. */
  9314. transformedPosition: Vector3;
  9315. /**
  9316. * The transformed direction. Direction of the light in world space taking parenting in account.
  9317. */
  9318. transformedDirection: Vector3;
  9319. private _needProjectionMatrixCompute;
  9320. /**
  9321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9323. */
  9324. computeTransformedInformation(): boolean;
  9325. /**
  9326. * Return the depth scale used for the shadow map.
  9327. * @returns the depth scale.
  9328. */
  9329. getDepthScale(): number;
  9330. /**
  9331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9334. */
  9335. getShadowDirection(faceIndex?: number): Vector3;
  9336. /**
  9337. * Returns the ShadowLight absolute position in the World.
  9338. * @returns the position vector in world space
  9339. */
  9340. getAbsolutePosition(): Vector3;
  9341. /**
  9342. * Sets the ShadowLight direction toward the passed target.
  9343. * @param target The point to target in local space
  9344. * @returns the updated ShadowLight direction
  9345. */
  9346. setDirectionToTarget(target: Vector3): Vector3;
  9347. /**
  9348. * Returns the light rotation in euler definition.
  9349. * @returns the x y z rotation in local space.
  9350. */
  9351. getRotation(): Vector3;
  9352. /**
  9353. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9354. * @returns true if a cube texture needs to be use
  9355. */
  9356. needCube(): boolean;
  9357. /**
  9358. * Detects if the projection matrix requires to be recomputed this frame.
  9359. * @returns true if it requires to be recomputed otherwise, false.
  9360. */
  9361. needProjectionMatrixCompute(): boolean;
  9362. /**
  9363. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9364. */
  9365. forceProjectionMatrixCompute(): void;
  9366. /** @hidden */
  9367. _initCache(): void;
  9368. /** @hidden */
  9369. _isSynchronized(): boolean;
  9370. /**
  9371. * Computes the world matrix of the node
  9372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9373. * @returns the world matrix
  9374. */
  9375. computeWorldMatrix(force?: boolean): Matrix;
  9376. /**
  9377. * Gets the minZ used for shadow according to both the scene and the light.
  9378. * @param activeCamera The camera we are returning the min for
  9379. * @returns the depth min z
  9380. */
  9381. getDepthMinZ(activeCamera: Camera): number;
  9382. /**
  9383. * Gets the maxZ used for shadow according to both the scene and the light.
  9384. * @param activeCamera The camera we are returning the max for
  9385. * @returns the depth max z
  9386. */
  9387. getDepthMaxZ(activeCamera: Camera): number;
  9388. /**
  9389. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9390. * @param matrix The materix to updated with the projection information
  9391. * @param viewMatrix The transform matrix of the light
  9392. * @param renderList The list of mesh to render in the map
  9393. * @returns The current light
  9394. */
  9395. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9396. }
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9399. /** @hidden */
  9400. export var packingFunctions: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9406. /** @hidden */
  9407. export var bayerDitherFunctions: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9413. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9414. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9415. /** @hidden */
  9416. export var shadowMapFragmentDeclaration: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9422. /** @hidden */
  9423. export var clipPlaneFragmentDeclaration: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9429. /** @hidden */
  9430. export var clipPlaneFragment: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9436. /** @hidden */
  9437. export var shadowMapFragment: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9443. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9445. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9446. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9447. /** @hidden */
  9448. export var shadowMapPixelShader: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9454. /** @hidden */
  9455. export var bonesDeclaration: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9461. /** @hidden */
  9462. export var morphTargetsVertexGlobalDeclaration: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9468. /** @hidden */
  9469. export var morphTargetsVertexDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9475. /** @hidden */
  9476. export var instancesDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9482. /** @hidden */
  9483. export var helperFunctions: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9489. /** @hidden */
  9490. export var shadowMapVertexDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9496. /** @hidden */
  9497. export var clipPlaneVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9503. /** @hidden */
  9504. export var morphTargetsVertex: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9510. /** @hidden */
  9511. export var instancesVertex: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9517. /** @hidden */
  9518. export var bonesVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9524. /** @hidden */
  9525. export var shadowMapVertexNormalBias: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9531. /** @hidden */
  9532. export var shadowMapVertexMetric: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9538. /** @hidden */
  9539. export var clipPlaneVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9548. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9550. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9551. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9553. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9554. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9555. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9556. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9558. /** @hidden */
  9559. export var shadowMapVertexShader: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9565. /** @hidden */
  9566. export var depthBoxBlurPixelShader: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9572. /** @hidden */
  9573. export var shadowMapFragmentSoftTransparentShadow: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Materials/effectFallbacks" {
  9579. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9580. import { Effect } from "babylonjs/Materials/effect";
  9581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9582. /**
  9583. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9584. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9585. */
  9586. export class EffectFallbacks implements IEffectFallbacks {
  9587. private _defines;
  9588. private _currentRank;
  9589. private _maxRank;
  9590. private _mesh;
  9591. /**
  9592. * Removes the fallback from the bound mesh.
  9593. */
  9594. unBindMesh(): void;
  9595. /**
  9596. * Adds a fallback on the specified property.
  9597. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9598. * @param define The name of the define in the shader
  9599. */
  9600. addFallback(rank: number, define: string): void;
  9601. /**
  9602. * Sets the mesh to use CPU skinning when needing to fallback.
  9603. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9604. * @param mesh The mesh to use the fallbacks.
  9605. */
  9606. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9607. /**
  9608. * Checks to see if more fallbacks are still availible.
  9609. */
  9610. get hasMoreFallbacks(): boolean;
  9611. /**
  9612. * Removes the defines that should be removed when falling back.
  9613. * @param currentDefines defines the current define statements for the shader.
  9614. * @param effect defines the current effect we try to compile
  9615. * @returns The resulting defines with defines of the current rank removed.
  9616. */
  9617. reduce(currentDefines: string, effect: Effect): string;
  9618. }
  9619. }
  9620. declare module "babylonjs/Actions/action" {
  9621. import { Observable } from "babylonjs/Misc/observable";
  9622. import { Condition } from "babylonjs/Actions/condition";
  9623. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9624. import { Nullable } from "babylonjs/types";
  9625. import { Scene } from "babylonjs/scene";
  9626. import { ActionManager } from "babylonjs/Actions/actionManager";
  9627. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9628. import { Node } from "babylonjs/node";
  9629. /**
  9630. * Interface used to define Action
  9631. */
  9632. export interface IAction {
  9633. /**
  9634. * Trigger for the action
  9635. */
  9636. trigger: number;
  9637. /** Options of the trigger */
  9638. triggerOptions: any;
  9639. /**
  9640. * Gets the trigger parameters
  9641. * @returns the trigger parameters
  9642. */
  9643. getTriggerParameter(): any;
  9644. /**
  9645. * Internal only - executes current action event
  9646. * @hidden
  9647. */
  9648. _executeCurrent(evt?: ActionEvent): void;
  9649. /**
  9650. * Serialize placeholder for child classes
  9651. * @param parent of child
  9652. * @returns the serialized object
  9653. */
  9654. serialize(parent: any): any;
  9655. /**
  9656. * Internal only
  9657. * @hidden
  9658. */
  9659. _prepare(): void;
  9660. /**
  9661. * Internal only - manager for action
  9662. * @hidden
  9663. */
  9664. _actionManager: Nullable<AbstractActionManager>;
  9665. /**
  9666. * Adds action to chain of actions, may be a DoNothingAction
  9667. * @param action defines the next action to execute
  9668. * @returns The action passed in
  9669. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9670. */
  9671. then(action: IAction): IAction;
  9672. }
  9673. /**
  9674. * The action to be carried out following a trigger
  9675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9676. */
  9677. export class Action implements IAction {
  9678. /** the trigger, with or without parameters, for the action */
  9679. triggerOptions: any;
  9680. /**
  9681. * Trigger for the action
  9682. */
  9683. trigger: number;
  9684. /**
  9685. * Internal only - manager for action
  9686. * @hidden
  9687. */
  9688. _actionManager: ActionManager;
  9689. private _nextActiveAction;
  9690. private _child;
  9691. private _condition?;
  9692. private _triggerParameter;
  9693. /**
  9694. * An event triggered prior to action being executed.
  9695. */
  9696. onBeforeExecuteObservable: Observable<Action>;
  9697. /**
  9698. * Creates a new Action
  9699. * @param triggerOptions the trigger, with or without parameters, for the action
  9700. * @param condition an optional determinant of action
  9701. */
  9702. constructor(
  9703. /** the trigger, with or without parameters, for the action */
  9704. triggerOptions: any, condition?: Condition);
  9705. /**
  9706. * Internal only
  9707. * @hidden
  9708. */
  9709. _prepare(): void;
  9710. /**
  9711. * Gets the trigger parameters
  9712. * @returns the trigger parameters
  9713. */
  9714. getTriggerParameter(): any;
  9715. /**
  9716. * Internal only - executes current action event
  9717. * @hidden
  9718. */
  9719. _executeCurrent(evt?: ActionEvent): void;
  9720. /**
  9721. * Execute placeholder for child classes
  9722. * @param evt optional action event
  9723. */
  9724. execute(evt?: ActionEvent): void;
  9725. /**
  9726. * Skips to next active action
  9727. */
  9728. skipToNextActiveAction(): void;
  9729. /**
  9730. * Adds action to chain of actions, may be a DoNothingAction
  9731. * @param action defines the next action to execute
  9732. * @returns The action passed in
  9733. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9734. */
  9735. then(action: Action): Action;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. _getProperty(propertyPath: string): string;
  9741. /**
  9742. * Internal only
  9743. * @hidden
  9744. */
  9745. _getEffectiveTarget(target: any, propertyPath: string): any;
  9746. /**
  9747. * Serialize placeholder for child classes
  9748. * @param parent of child
  9749. * @returns the serialized object
  9750. */
  9751. serialize(parent: any): any;
  9752. /**
  9753. * Internal only called by serialize
  9754. * @hidden
  9755. */
  9756. protected _serialize(serializedAction: any, parent?: any): any;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. static _SerializeValueAsString: (value: any) => string;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. static _GetTargetProperty: (target: Scene | Node) => {
  9767. name: string;
  9768. targetType: string;
  9769. value: string;
  9770. };
  9771. }
  9772. }
  9773. declare module "babylonjs/Actions/condition" {
  9774. import { ActionManager } from "babylonjs/Actions/actionManager";
  9775. /**
  9776. * A Condition applied to an Action
  9777. */
  9778. export class Condition {
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. _evaluationId: number;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. _currentResult: boolean;
  9794. /**
  9795. * Creates a new Condition
  9796. * @param actionManager the manager of the action the condition is applied to
  9797. */
  9798. constructor(actionManager: ActionManager);
  9799. /**
  9800. * Check if the current condition is valid
  9801. * @returns a boolean
  9802. */
  9803. isValid(): boolean;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. _getProperty(propertyPath: string): string;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. _getEffectiveTarget(target: any, propertyPath: string): any;
  9814. /**
  9815. * Serialize placeholder for child classes
  9816. * @returns the serialized object
  9817. */
  9818. serialize(): any;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. protected _serialize(serializedCondition: any): any;
  9824. }
  9825. /**
  9826. * Defines specific conditional operators as extensions of Condition
  9827. */
  9828. export class ValueCondition extends Condition {
  9829. /** path to specify the property of the target the conditional operator uses */
  9830. propertyPath: string;
  9831. /** the value compared by the conditional operator against the current value of the property */
  9832. value: any;
  9833. /** the conditional operator, default ValueCondition.IsEqual */
  9834. operator: number;
  9835. /**
  9836. * Internal only
  9837. * @hidden
  9838. */
  9839. private static _IsEqual;
  9840. /**
  9841. * Internal only
  9842. * @hidden
  9843. */
  9844. private static _IsDifferent;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private static _IsGreater;
  9850. /**
  9851. * Internal only
  9852. * @hidden
  9853. */
  9854. private static _IsLesser;
  9855. /**
  9856. * returns the number for IsEqual
  9857. */
  9858. static get IsEqual(): number;
  9859. /**
  9860. * Returns the number for IsDifferent
  9861. */
  9862. static get IsDifferent(): number;
  9863. /**
  9864. * Returns the number for IsGreater
  9865. */
  9866. static get IsGreater(): number;
  9867. /**
  9868. * Returns the number for IsLesser
  9869. */
  9870. static get IsLesser(): number;
  9871. /**
  9872. * Internal only The action manager for the condition
  9873. * @hidden
  9874. */
  9875. _actionManager: ActionManager;
  9876. /**
  9877. * Internal only
  9878. * @hidden
  9879. */
  9880. private _target;
  9881. /**
  9882. * Internal only
  9883. * @hidden
  9884. */
  9885. private _effectiveTarget;
  9886. /**
  9887. * Internal only
  9888. * @hidden
  9889. */
  9890. private _property;
  9891. /**
  9892. * Creates a new ValueCondition
  9893. * @param actionManager manager for the action the condition applies to
  9894. * @param target for the action
  9895. * @param propertyPath path to specify the property of the target the conditional operator uses
  9896. * @param value the value compared by the conditional operator against the current value of the property
  9897. * @param operator the conditional operator, default ValueCondition.IsEqual
  9898. */
  9899. constructor(actionManager: ActionManager, target: any,
  9900. /** path to specify the property of the target the conditional operator uses */
  9901. propertyPath: string,
  9902. /** the value compared by the conditional operator against the current value of the property */
  9903. value: any,
  9904. /** the conditional operator, default ValueCondition.IsEqual */
  9905. operator?: number);
  9906. /**
  9907. * Compares the given value with the property value for the specified conditional operator
  9908. * @returns the result of the comparison
  9909. */
  9910. isValid(): boolean;
  9911. /**
  9912. * Serialize the ValueCondition into a JSON compatible object
  9913. * @returns serialization object
  9914. */
  9915. serialize(): any;
  9916. /**
  9917. * Gets the name of the conditional operator for the ValueCondition
  9918. * @param operator the conditional operator
  9919. * @returns the name
  9920. */
  9921. static GetOperatorName(operator: number): string;
  9922. }
  9923. /**
  9924. * Defines a predicate condition as an extension of Condition
  9925. */
  9926. export class PredicateCondition extends Condition {
  9927. /** defines the predicate function used to validate the condition */
  9928. predicate: () => boolean;
  9929. /**
  9930. * Internal only - manager for action
  9931. * @hidden
  9932. */
  9933. _actionManager: ActionManager;
  9934. /**
  9935. * Creates a new PredicateCondition
  9936. * @param actionManager manager for the action the condition applies to
  9937. * @param predicate defines the predicate function used to validate the condition
  9938. */
  9939. constructor(actionManager: ActionManager,
  9940. /** defines the predicate function used to validate the condition */
  9941. predicate: () => boolean);
  9942. /**
  9943. * @returns the validity of the predicate condition
  9944. */
  9945. isValid(): boolean;
  9946. }
  9947. /**
  9948. * Defines a state condition as an extension of Condition
  9949. */
  9950. export class StateCondition extends Condition {
  9951. /** Value to compare with target state */
  9952. value: string;
  9953. /**
  9954. * Internal only - manager for action
  9955. * @hidden
  9956. */
  9957. _actionManager: ActionManager;
  9958. /**
  9959. * Internal only
  9960. * @hidden
  9961. */
  9962. private _target;
  9963. /**
  9964. * Creates a new StateCondition
  9965. * @param actionManager manager for the action the condition applies to
  9966. * @param target of the condition
  9967. * @param value to compare with target state
  9968. */
  9969. constructor(actionManager: ActionManager, target: any,
  9970. /** Value to compare with target state */
  9971. value: string);
  9972. /**
  9973. * Gets a boolean indicating if the current condition is met
  9974. * @returns the validity of the state
  9975. */
  9976. isValid(): boolean;
  9977. /**
  9978. * Serialize the StateCondition into a JSON compatible object
  9979. * @returns serialization object
  9980. */
  9981. serialize(): any;
  9982. }
  9983. }
  9984. declare module "babylonjs/Actions/directActions" {
  9985. import { Action } from "babylonjs/Actions/action";
  9986. import { Condition } from "babylonjs/Actions/condition";
  9987. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9988. /**
  9989. * This defines an action responsible to toggle a boolean once triggered.
  9990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9991. */
  9992. export class SwitchBooleanAction extends Action {
  9993. /**
  9994. * The path to the boolean property in the target object
  9995. */
  9996. propertyPath: string;
  9997. private _target;
  9998. private _effectiveTarget;
  9999. private _property;
  10000. /**
  10001. * Instantiate the action
  10002. * @param triggerOptions defines the trigger options
  10003. * @param target defines the object containing the boolean
  10004. * @param propertyPath defines the path to the boolean property in the target object
  10005. * @param condition defines the trigger related conditions
  10006. */
  10007. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10008. /** @hidden */
  10009. _prepare(): void;
  10010. /**
  10011. * Execute the action toggle the boolean value.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible to set a the state field of the target
  10023. * to a desired value once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class SetStateAction extends Action {
  10027. /**
  10028. * The value to store in the state field.
  10029. */
  10030. value: string;
  10031. private _target;
  10032. /**
  10033. * Instantiate the action
  10034. * @param triggerOptions defines the trigger options
  10035. * @param target defines the object containing the state property
  10036. * @param value defines the value to store in the state field
  10037. * @param condition defines the trigger related conditions
  10038. */
  10039. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10040. /**
  10041. * Execute the action and store the value on the target state property.
  10042. */
  10043. execute(): void;
  10044. /**
  10045. * Serializes the actions and its related information.
  10046. * @param parent defines the object to serialize in
  10047. * @returns the serialized object
  10048. */
  10049. serialize(parent: any): any;
  10050. }
  10051. /**
  10052. * This defines an action responsible to set a property of the target
  10053. * to a desired value once triggered.
  10054. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10055. */
  10056. export class SetValueAction extends Action {
  10057. /**
  10058. * The path of the property to set in the target.
  10059. */
  10060. propertyPath: string;
  10061. /**
  10062. * The value to set in the property
  10063. */
  10064. value: any;
  10065. private _target;
  10066. private _effectiveTarget;
  10067. private _property;
  10068. /**
  10069. * Instantiate the action
  10070. * @param triggerOptions defines the trigger options
  10071. * @param target defines the object containing the property
  10072. * @param propertyPath defines the path of the property to set in the target
  10073. * @param value defines the value to set in the property
  10074. * @param condition defines the trigger related conditions
  10075. */
  10076. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10077. /** @hidden */
  10078. _prepare(): void;
  10079. /**
  10080. * Execute the action and set the targetted property to the desired value.
  10081. */
  10082. execute(): void;
  10083. /**
  10084. * Serializes the actions and its related information.
  10085. * @param parent defines the object to serialize in
  10086. * @returns the serialized object
  10087. */
  10088. serialize(parent: any): any;
  10089. }
  10090. /**
  10091. * This defines an action responsible to increment the target value
  10092. * to a desired value once triggered.
  10093. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10094. */
  10095. export class IncrementValueAction extends Action {
  10096. /**
  10097. * The path of the property to increment in the target.
  10098. */
  10099. propertyPath: string;
  10100. /**
  10101. * The value we should increment the property by.
  10102. */
  10103. value: any;
  10104. private _target;
  10105. private _effectiveTarget;
  10106. private _property;
  10107. /**
  10108. * Instantiate the action
  10109. * @param triggerOptions defines the trigger options
  10110. * @param target defines the object containing the property
  10111. * @param propertyPath defines the path of the property to increment in the target
  10112. * @param value defines the value value we should increment the property by
  10113. * @param condition defines the trigger related conditions
  10114. */
  10115. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10116. /** @hidden */
  10117. _prepare(): void;
  10118. /**
  10119. * Execute the action and increment the target of the value amount.
  10120. */
  10121. execute(): void;
  10122. /**
  10123. * Serializes the actions and its related information.
  10124. * @param parent defines the object to serialize in
  10125. * @returns the serialized object
  10126. */
  10127. serialize(parent: any): any;
  10128. }
  10129. /**
  10130. * This defines an action responsible to start an animation once triggered.
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10132. */
  10133. export class PlayAnimationAction extends Action {
  10134. /**
  10135. * Where the animation should start (animation frame)
  10136. */
  10137. from: number;
  10138. /**
  10139. * Where the animation should stop (animation frame)
  10140. */
  10141. to: number;
  10142. /**
  10143. * Define if the animation should loop or stop after the first play.
  10144. */
  10145. loop?: boolean;
  10146. private _target;
  10147. /**
  10148. * Instantiate the action
  10149. * @param triggerOptions defines the trigger options
  10150. * @param target defines the target animation or animation name
  10151. * @param from defines from where the animation should start (animation frame)
  10152. * @param end defines where the animation should stop (animation frame)
  10153. * @param loop defines if the animation should loop or stop after the first play
  10154. * @param condition defines the trigger related conditions
  10155. */
  10156. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10157. /** @hidden */
  10158. _prepare(): void;
  10159. /**
  10160. * Execute the action and play the animation.
  10161. */
  10162. execute(): void;
  10163. /**
  10164. * Serializes the actions and its related information.
  10165. * @param parent defines the object to serialize in
  10166. * @returns the serialized object
  10167. */
  10168. serialize(parent: any): any;
  10169. }
  10170. /**
  10171. * This defines an action responsible to stop an animation once triggered.
  10172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10173. */
  10174. export class StopAnimationAction extends Action {
  10175. private _target;
  10176. /**
  10177. * Instantiate the action
  10178. * @param triggerOptions defines the trigger options
  10179. * @param target defines the target animation or animation name
  10180. * @param condition defines the trigger related conditions
  10181. */
  10182. constructor(triggerOptions: any, target: any, condition?: Condition);
  10183. /** @hidden */
  10184. _prepare(): void;
  10185. /**
  10186. * Execute the action and stop the animation.
  10187. */
  10188. execute(): void;
  10189. /**
  10190. * Serializes the actions and its related information.
  10191. * @param parent defines the object to serialize in
  10192. * @returns the serialized object
  10193. */
  10194. serialize(parent: any): any;
  10195. }
  10196. /**
  10197. * This defines an action responsible that does nothing once triggered.
  10198. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10199. */
  10200. export class DoNothingAction extends Action {
  10201. /**
  10202. * Instantiate the action
  10203. * @param triggerOptions defines the trigger options
  10204. * @param condition defines the trigger related conditions
  10205. */
  10206. constructor(triggerOptions?: any, condition?: Condition);
  10207. /**
  10208. * Execute the action and do nothing.
  10209. */
  10210. execute(): void;
  10211. /**
  10212. * Serializes the actions and its related information.
  10213. * @param parent defines the object to serialize in
  10214. * @returns the serialized object
  10215. */
  10216. serialize(parent: any): any;
  10217. }
  10218. /**
  10219. * This defines an action responsible to trigger several actions once triggered.
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10221. */
  10222. export class CombineAction extends Action {
  10223. /**
  10224. * The list of aggregated animations to run.
  10225. */
  10226. children: Action[];
  10227. /**
  10228. * Instantiate the action
  10229. * @param triggerOptions defines the trigger options
  10230. * @param children defines the list of aggregated animations to run
  10231. * @param condition defines the trigger related conditions
  10232. */
  10233. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10234. /** @hidden */
  10235. _prepare(): void;
  10236. /**
  10237. * Execute the action and executes all the aggregated actions.
  10238. */
  10239. execute(evt: ActionEvent): void;
  10240. /**
  10241. * Serializes the actions and its related information.
  10242. * @param parent defines the object to serialize in
  10243. * @returns the serialized object
  10244. */
  10245. serialize(parent: any): any;
  10246. }
  10247. /**
  10248. * This defines an action responsible to run code (external event) once triggered.
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10250. */
  10251. export class ExecuteCodeAction extends Action {
  10252. /**
  10253. * The callback function to run.
  10254. */
  10255. func: (evt: ActionEvent) => void;
  10256. /**
  10257. * Instantiate the action
  10258. * @param triggerOptions defines the trigger options
  10259. * @param func defines the callback function to run
  10260. * @param condition defines the trigger related conditions
  10261. */
  10262. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10263. /**
  10264. * Execute the action and run the attached code.
  10265. */
  10266. execute(evt: ActionEvent): void;
  10267. }
  10268. /**
  10269. * This defines an action responsible to set the parent property of the target once triggered.
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10271. */
  10272. export class SetParentAction extends Action {
  10273. private _parent;
  10274. private _target;
  10275. /**
  10276. * Instantiate the action
  10277. * @param triggerOptions defines the trigger options
  10278. * @param target defines the target containing the parent property
  10279. * @param parent defines from where the animation should start (animation frame)
  10280. * @param condition defines the trigger related conditions
  10281. */
  10282. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10283. /** @hidden */
  10284. _prepare(): void;
  10285. /**
  10286. * Execute the action and set the parent property.
  10287. */
  10288. execute(): void;
  10289. /**
  10290. * Serializes the actions and its related information.
  10291. * @param parent defines the object to serialize in
  10292. * @returns the serialized object
  10293. */
  10294. serialize(parent: any): any;
  10295. }
  10296. }
  10297. declare module "babylonjs/Actions/actionManager" {
  10298. import { Nullable } from "babylonjs/types";
  10299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10300. import { Scene } from "babylonjs/scene";
  10301. import { IAction } from "babylonjs/Actions/action";
  10302. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10303. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10304. /**
  10305. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10306. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10308. */
  10309. export class ActionManager extends AbstractActionManager {
  10310. /**
  10311. * Nothing
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly NothingTrigger: number;
  10315. /**
  10316. * On pick
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnPickTrigger: number;
  10320. /**
  10321. * On left pick
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnLeftPickTrigger: number;
  10325. /**
  10326. * On right pick
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnRightPickTrigger: number;
  10330. /**
  10331. * On center pick
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnCenterPickTrigger: number;
  10335. /**
  10336. * On pick down
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnPickDownTrigger: number;
  10340. /**
  10341. * On double pick
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnDoublePickTrigger: number;
  10345. /**
  10346. * On pick up
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnPickUpTrigger: number;
  10350. /**
  10351. * On pick out.
  10352. * This trigger will only be raised if you also declared a OnPickDown
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnPickOutTrigger: number;
  10356. /**
  10357. * On long press
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnLongPressTrigger: number;
  10361. /**
  10362. * On pointer over
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnPointerOverTrigger: number;
  10366. /**
  10367. * On pointer out
  10368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10369. */
  10370. static readonly OnPointerOutTrigger: number;
  10371. /**
  10372. * On every frame
  10373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10374. */
  10375. static readonly OnEveryFrameTrigger: number;
  10376. /**
  10377. * On intersection enter
  10378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10379. */
  10380. static readonly OnIntersectionEnterTrigger: number;
  10381. /**
  10382. * On intersection exit
  10383. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10384. */
  10385. static readonly OnIntersectionExitTrigger: number;
  10386. /**
  10387. * On key down
  10388. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10389. */
  10390. static readonly OnKeyDownTrigger: number;
  10391. /**
  10392. * On key up
  10393. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10394. */
  10395. static readonly OnKeyUpTrigger: number;
  10396. private _scene;
  10397. /**
  10398. * Creates a new action manager
  10399. * @param scene defines the hosting scene
  10400. */
  10401. constructor(scene: Scene);
  10402. /**
  10403. * Releases all associated resources
  10404. */
  10405. dispose(): void;
  10406. /**
  10407. * Gets hosting scene
  10408. * @returns the hosting scene
  10409. */
  10410. getScene(): Scene;
  10411. /**
  10412. * Does this action manager handles actions of any of the given triggers
  10413. * @param triggers defines the triggers to be tested
  10414. * @return a boolean indicating whether one (or more) of the triggers is handled
  10415. */
  10416. hasSpecificTriggers(triggers: number[]): boolean;
  10417. /**
  10418. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10419. * speed.
  10420. * @param triggerA defines the trigger to be tested
  10421. * @param triggerB defines the trigger to be tested
  10422. * @return a boolean indicating whether one (or more) of the triggers is handled
  10423. */
  10424. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10425. /**
  10426. * Does this action manager handles actions of a given trigger
  10427. * @param trigger defines the trigger to be tested
  10428. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10429. * @return whether the trigger is handled
  10430. */
  10431. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10432. /**
  10433. * Does this action manager has pointer triggers
  10434. */
  10435. get hasPointerTriggers(): boolean;
  10436. /**
  10437. * Does this action manager has pick triggers
  10438. */
  10439. get hasPickTriggers(): boolean;
  10440. /**
  10441. * Registers an action to this action manager
  10442. * @param action defines the action to be registered
  10443. * @return the action amended (prepared) after registration
  10444. */
  10445. registerAction(action: IAction): Nullable<IAction>;
  10446. /**
  10447. * Unregisters an action to this action manager
  10448. * @param action defines the action to be unregistered
  10449. * @return a boolean indicating whether the action has been unregistered
  10450. */
  10451. unregisterAction(action: IAction): Boolean;
  10452. /**
  10453. * Process a specific trigger
  10454. * @param trigger defines the trigger to process
  10455. * @param evt defines the event details to be processed
  10456. */
  10457. processTrigger(trigger: number, evt?: IActionEvent): void;
  10458. /** @hidden */
  10459. _getEffectiveTarget(target: any, propertyPath: string): any;
  10460. /** @hidden */
  10461. _getProperty(propertyPath: string): string;
  10462. /**
  10463. * Serialize this manager to a JSON object
  10464. * @param name defines the property name to store this manager
  10465. * @returns a JSON representation of this manager
  10466. */
  10467. serialize(name: string): any;
  10468. /**
  10469. * Creates a new ActionManager from a JSON data
  10470. * @param parsedActions defines the JSON data to read from
  10471. * @param object defines the hosting mesh
  10472. * @param scene defines the hosting scene
  10473. */
  10474. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10475. /**
  10476. * Get a trigger name by index
  10477. * @param trigger defines the trigger index
  10478. * @returns a trigger name
  10479. */
  10480. static GetTriggerName(trigger: number): string;
  10481. }
  10482. }
  10483. declare module "babylonjs/Sprites/sprite" {
  10484. import { Vector3 } from "babylonjs/Maths/math.vector";
  10485. import { Nullable } from "babylonjs/types";
  10486. import { ActionManager } from "babylonjs/Actions/actionManager";
  10487. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10488. import { Color4 } from "babylonjs/Maths/math.color";
  10489. import { Observable } from "babylonjs/Misc/observable";
  10490. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10491. import { Animation } from "babylonjs/Animations/animation";
  10492. /**
  10493. * Class used to represent a sprite
  10494. * @see https://doc.babylonjs.com/babylon101/sprites
  10495. */
  10496. export class Sprite implements IAnimatable {
  10497. /** defines the name */
  10498. name: string;
  10499. /** Gets or sets the current world position */
  10500. position: Vector3;
  10501. /** Gets or sets the main color */
  10502. color: Color4;
  10503. /** Gets or sets the width */
  10504. width: number;
  10505. /** Gets or sets the height */
  10506. height: number;
  10507. /** Gets or sets rotation angle */
  10508. angle: number;
  10509. /** Gets or sets the cell index in the sprite sheet */
  10510. cellIndex: number;
  10511. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10512. cellRef: string;
  10513. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10514. invertU: boolean;
  10515. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10516. invertV: boolean;
  10517. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10518. disposeWhenFinishedAnimating: boolean;
  10519. /** Gets the list of attached animations */
  10520. animations: Nullable<Array<Animation>>;
  10521. /** Gets or sets a boolean indicating if the sprite can be picked */
  10522. isPickable: boolean;
  10523. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10524. useAlphaForPicking: boolean;
  10525. /** @hidden */
  10526. _xOffset: number;
  10527. /** @hidden */
  10528. _yOffset: number;
  10529. /** @hidden */
  10530. _xSize: number;
  10531. /** @hidden */
  10532. _ySize: number;
  10533. /**
  10534. * Gets or sets the associated action manager
  10535. */
  10536. actionManager: Nullable<ActionManager>;
  10537. /**
  10538. * An event triggered when the control has been disposed
  10539. */
  10540. onDisposeObservable: Observable<Sprite>;
  10541. private _animationStarted;
  10542. private _loopAnimation;
  10543. private _fromIndex;
  10544. private _toIndex;
  10545. private _delay;
  10546. private _direction;
  10547. private _manager;
  10548. private _time;
  10549. private _onAnimationEnd;
  10550. /**
  10551. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10552. */
  10553. isVisible: boolean;
  10554. /**
  10555. * Gets or sets the sprite size
  10556. */
  10557. get size(): number;
  10558. set size(value: number);
  10559. /**
  10560. * Returns a boolean indicating if the animation is started
  10561. */
  10562. get animationStarted(): boolean;
  10563. /**
  10564. * Gets or sets the unique id of the sprite
  10565. */
  10566. uniqueId: number;
  10567. /**
  10568. * Gets the manager of this sprite
  10569. */
  10570. get manager(): ISpriteManager;
  10571. /**
  10572. * Creates a new Sprite
  10573. * @param name defines the name
  10574. * @param manager defines the manager
  10575. */
  10576. constructor(
  10577. /** defines the name */
  10578. name: string, manager: ISpriteManager);
  10579. /**
  10580. * Returns the string "Sprite"
  10581. * @returns "Sprite"
  10582. */
  10583. getClassName(): string;
  10584. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10585. get fromIndex(): number;
  10586. set fromIndex(value: number);
  10587. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10588. get toIndex(): number;
  10589. set toIndex(value: number);
  10590. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10591. get loopAnimation(): boolean;
  10592. set loopAnimation(value: boolean);
  10593. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10594. get delay(): number;
  10595. set delay(value: number);
  10596. /**
  10597. * Starts an animation
  10598. * @param from defines the initial key
  10599. * @param to defines the end key
  10600. * @param loop defines if the animation must loop
  10601. * @param delay defines the start delay (in ms)
  10602. * @param onAnimationEnd defines a callback to call when animation ends
  10603. */
  10604. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10605. /** Stops current animation (if any) */
  10606. stopAnimation(): void;
  10607. /** @hidden */
  10608. _animate(deltaTime: number): void;
  10609. /** Release associated resources */
  10610. dispose(): void;
  10611. /**
  10612. * Serializes the sprite to a JSON object
  10613. * @returns the JSON object
  10614. */
  10615. serialize(): any;
  10616. /**
  10617. * Parses a JSON object to create a new sprite
  10618. * @param parsedSprite The JSON object to parse
  10619. * @param manager defines the hosting manager
  10620. * @returns the new sprite
  10621. */
  10622. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10623. }
  10624. }
  10625. declare module "babylonjs/Collisions/pickingInfo" {
  10626. import { Nullable } from "babylonjs/types";
  10627. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10629. import { Sprite } from "babylonjs/Sprites/sprite";
  10630. import { Ray } from "babylonjs/Culling/ray";
  10631. /**
  10632. * Information about the result of picking within a scene
  10633. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10634. */
  10635. export class PickingInfo {
  10636. /** @hidden */
  10637. _pickingUnavailable: boolean;
  10638. /**
  10639. * If the pick collided with an object
  10640. */
  10641. hit: boolean;
  10642. /**
  10643. * Distance away where the pick collided
  10644. */
  10645. distance: number;
  10646. /**
  10647. * The location of pick collision
  10648. */
  10649. pickedPoint: Nullable<Vector3>;
  10650. /**
  10651. * The mesh corresponding the the pick collision
  10652. */
  10653. pickedMesh: Nullable<AbstractMesh>;
  10654. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10655. bu: number;
  10656. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10657. bv: number;
  10658. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10659. faceId: number;
  10660. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10661. subMeshFaceId: number;
  10662. /** Id of the the submesh that was picked */
  10663. subMeshId: number;
  10664. /** If a sprite was picked, this will be the sprite the pick collided with */
  10665. pickedSprite: Nullable<Sprite>;
  10666. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10667. thinInstanceIndex: number;
  10668. /**
  10669. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10670. */
  10671. originMesh: Nullable<AbstractMesh>;
  10672. /**
  10673. * The ray that was used to perform the picking.
  10674. */
  10675. ray: Nullable<Ray>;
  10676. /**
  10677. * Gets the normal correspodning to the face the pick collided with
  10678. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10679. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10680. * @returns The normal correspodning to the face the pick collided with
  10681. */
  10682. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10683. /**
  10684. * Gets the texture coordinates of where the pick occured
  10685. * @returns the vector containing the coordnates of the texture
  10686. */
  10687. getTextureCoordinates(): Nullable<Vector2>;
  10688. }
  10689. }
  10690. declare module "babylonjs/Culling/ray" {
  10691. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10692. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10694. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10695. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10696. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10697. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10698. import { Plane } from "babylonjs/Maths/math.plane";
  10699. /**
  10700. * Class representing a ray with position and direction
  10701. */
  10702. export class Ray {
  10703. /** origin point */
  10704. origin: Vector3;
  10705. /** direction */
  10706. direction: Vector3;
  10707. /** length of the ray */
  10708. length: number;
  10709. private static readonly _TmpVector3;
  10710. private _tmpRay;
  10711. /**
  10712. * Creates a new ray
  10713. * @param origin origin point
  10714. * @param direction direction
  10715. * @param length length of the ray
  10716. */
  10717. constructor(
  10718. /** origin point */
  10719. origin: Vector3,
  10720. /** direction */
  10721. direction: Vector3,
  10722. /** length of the ray */
  10723. length?: number);
  10724. /**
  10725. * Checks if the ray intersects a box
  10726. * This does not account for the ray lenght by design to improve perfs.
  10727. * @param minimum bound of the box
  10728. * @param maximum bound of the box
  10729. * @param intersectionTreshold extra extend to be added to the box in all direction
  10730. * @returns if the box was hit
  10731. */
  10732. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10733. /**
  10734. * Checks if the ray intersects a box
  10735. * This does not account for the ray lenght by design to improve perfs.
  10736. * @param box the bounding box to check
  10737. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10738. * @returns if the box was hit
  10739. */
  10740. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10741. /**
  10742. * If the ray hits a sphere
  10743. * @param sphere the bounding sphere to check
  10744. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10745. * @returns true if it hits the sphere
  10746. */
  10747. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10748. /**
  10749. * If the ray hits a triange
  10750. * @param vertex0 triangle vertex
  10751. * @param vertex1 triangle vertex
  10752. * @param vertex2 triangle vertex
  10753. * @returns intersection information if hit
  10754. */
  10755. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10756. /**
  10757. * Checks if ray intersects a plane
  10758. * @param plane the plane to check
  10759. * @returns the distance away it was hit
  10760. */
  10761. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10762. /**
  10763. * Calculate the intercept of a ray on a given axis
  10764. * @param axis to check 'x' | 'y' | 'z'
  10765. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10766. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10767. */
  10768. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10769. /**
  10770. * Checks if ray intersects a mesh
  10771. * @param mesh the mesh to check
  10772. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10773. * @returns picking info of the intersecton
  10774. */
  10775. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10776. /**
  10777. * Checks if ray intersects a mesh
  10778. * @param meshes the meshes to check
  10779. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10780. * @param results array to store result in
  10781. * @returns Array of picking infos
  10782. */
  10783. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10784. private _comparePickingInfo;
  10785. private static smallnum;
  10786. private static rayl;
  10787. /**
  10788. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10789. * @param sega the first point of the segment to test the intersection against
  10790. * @param segb the second point of the segment to test the intersection against
  10791. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10792. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10793. */
  10794. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10795. /**
  10796. * Update the ray from viewport position
  10797. * @param x position
  10798. * @param y y position
  10799. * @param viewportWidth viewport width
  10800. * @param viewportHeight viewport height
  10801. * @param world world matrix
  10802. * @param view view matrix
  10803. * @param projection projection matrix
  10804. * @returns this ray updated
  10805. */
  10806. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10807. /**
  10808. * Creates a ray with origin and direction of 0,0,0
  10809. * @returns the new ray
  10810. */
  10811. static Zero(): Ray;
  10812. /**
  10813. * Creates a new ray from screen space and viewport
  10814. * @param x position
  10815. * @param y y position
  10816. * @param viewportWidth viewport width
  10817. * @param viewportHeight viewport height
  10818. * @param world world matrix
  10819. * @param view view matrix
  10820. * @param projection projection matrix
  10821. * @returns new ray
  10822. */
  10823. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10824. /**
  10825. * 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
  10826. * transformed to the given world matrix.
  10827. * @param origin The origin point
  10828. * @param end The end point
  10829. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10830. * @returns the new ray
  10831. */
  10832. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10833. /**
  10834. * Transforms a ray by a matrix
  10835. * @param ray ray to transform
  10836. * @param matrix matrix to apply
  10837. * @returns the resulting new ray
  10838. */
  10839. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10840. /**
  10841. * Transforms a ray by a matrix
  10842. * @param ray ray to transform
  10843. * @param matrix matrix to apply
  10844. * @param result ray to store result in
  10845. */
  10846. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10847. /**
  10848. * Unproject a ray from screen space to object space
  10849. * @param sourceX defines the screen space x coordinate to use
  10850. * @param sourceY defines the screen space y coordinate to use
  10851. * @param viewportWidth defines the current width of the viewport
  10852. * @param viewportHeight defines the current height of the viewport
  10853. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10854. * @param view defines the view matrix to use
  10855. * @param projection defines the projection matrix to use
  10856. */
  10857. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10858. }
  10859. /**
  10860. * Type used to define predicate used to select faces when a mesh intersection is detected
  10861. */
  10862. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10863. module "babylonjs/scene" {
  10864. interface Scene {
  10865. /** @hidden */
  10866. _tempPickingRay: Nullable<Ray>;
  10867. /** @hidden */
  10868. _cachedRayForTransform: Ray;
  10869. /** @hidden */
  10870. _pickWithRayInverseMatrix: Matrix;
  10871. /** @hidden */
  10872. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10873. /** @hidden */
  10874. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10875. /** @hidden */
  10876. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10877. }
  10878. }
  10879. }
  10880. declare module "babylonjs/sceneComponent" {
  10881. import { Scene } from "babylonjs/scene";
  10882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10883. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10884. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10885. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10886. import { Nullable } from "babylonjs/types";
  10887. import { Camera } from "babylonjs/Cameras/camera";
  10888. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10889. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10890. import { AbstractScene } from "babylonjs/abstractScene";
  10891. import { Mesh } from "babylonjs/Meshes/mesh";
  10892. /**
  10893. * Groups all the scene component constants in one place to ease maintenance.
  10894. * @hidden
  10895. */
  10896. export class SceneComponentConstants {
  10897. static readonly NAME_EFFECTLAYER: string;
  10898. static readonly NAME_LAYER: string;
  10899. static readonly NAME_LENSFLARESYSTEM: string;
  10900. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10901. static readonly NAME_PARTICLESYSTEM: string;
  10902. static readonly NAME_GAMEPAD: string;
  10903. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10904. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10905. static readonly NAME_PREPASSRENDERER: string;
  10906. static readonly NAME_DEPTHRENDERER: string;
  10907. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10908. static readonly NAME_SPRITE: string;
  10909. static readonly NAME_SUBSURFACE: string;
  10910. static readonly NAME_OUTLINERENDERER: string;
  10911. static readonly NAME_PROCEDURALTEXTURE: string;
  10912. static readonly NAME_SHADOWGENERATOR: string;
  10913. static readonly NAME_OCTREE: string;
  10914. static readonly NAME_PHYSICSENGINE: string;
  10915. static readonly NAME_AUDIO: string;
  10916. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10917. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10918. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10919. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10920. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10921. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10922. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10923. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10924. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10925. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10926. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10927. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10928. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10929. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10930. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10931. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10932. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10933. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10934. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10935. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10936. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10937. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10938. static readonly STEP_AFTERRENDER_AUDIO: number;
  10939. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10940. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10941. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10942. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10943. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10944. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10945. static readonly STEP_POINTERMOVE_SPRITE: number;
  10946. static readonly STEP_POINTERDOWN_SPRITE: number;
  10947. static readonly STEP_POINTERUP_SPRITE: number;
  10948. }
  10949. /**
  10950. * This represents a scene component.
  10951. *
  10952. * This is used to decouple the dependency the scene is having on the different workloads like
  10953. * layers, post processes...
  10954. */
  10955. export interface ISceneComponent {
  10956. /**
  10957. * The name of the component. Each component must have a unique name.
  10958. */
  10959. name: string;
  10960. /**
  10961. * The scene the component belongs to.
  10962. */
  10963. scene: Scene;
  10964. /**
  10965. * Register the component to one instance of a scene.
  10966. */
  10967. register(): void;
  10968. /**
  10969. * Rebuilds the elements related to this component in case of
  10970. * context lost for instance.
  10971. */
  10972. rebuild(): void;
  10973. /**
  10974. * Disposes the component and the associated ressources.
  10975. */
  10976. dispose(): void;
  10977. }
  10978. /**
  10979. * This represents a SERIALIZABLE scene component.
  10980. *
  10981. * This extends Scene Component to add Serialization methods on top.
  10982. */
  10983. export interface ISceneSerializableComponent extends ISceneComponent {
  10984. /**
  10985. * Adds all the elements from the container to the scene
  10986. * @param container the container holding the elements
  10987. */
  10988. addFromContainer(container: AbstractScene): void;
  10989. /**
  10990. * Removes all the elements in the container from the scene
  10991. * @param container contains the elements to remove
  10992. * @param dispose if the removed element should be disposed (default: false)
  10993. */
  10994. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10995. /**
  10996. * Serializes the component data to the specified json object
  10997. * @param serializationObject The object to serialize to
  10998. */
  10999. serialize(serializationObject: any): void;
  11000. }
  11001. /**
  11002. * Strong typing of a Mesh related stage step action
  11003. */
  11004. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11005. /**
  11006. * Strong typing of a Evaluate Sub Mesh related stage step action
  11007. */
  11008. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11009. /**
  11010. * Strong typing of a Active Mesh related stage step action
  11011. */
  11012. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11013. /**
  11014. * Strong typing of a Camera related stage step action
  11015. */
  11016. export type CameraStageAction = (camera: Camera) => void;
  11017. /**
  11018. * Strong typing of a Camera Frame buffer related stage step action
  11019. */
  11020. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11021. /**
  11022. * Strong typing of a Render Target related stage step action
  11023. */
  11024. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11025. /**
  11026. * Strong typing of a RenderingGroup related stage step action
  11027. */
  11028. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11029. /**
  11030. * Strong typing of a Mesh Render related stage step action
  11031. */
  11032. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11033. /**
  11034. * Strong typing of a simple stage step action
  11035. */
  11036. export type SimpleStageAction = () => void;
  11037. /**
  11038. * Strong typing of a render target action.
  11039. */
  11040. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11041. /**
  11042. * Strong typing of a pointer move action.
  11043. */
  11044. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11045. /**
  11046. * Strong typing of a pointer up/down action.
  11047. */
  11048. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11049. /**
  11050. * Representation of a stage in the scene (Basically a list of ordered steps)
  11051. * @hidden
  11052. */
  11053. export class Stage<T extends Function> extends Array<{
  11054. index: number;
  11055. component: ISceneComponent;
  11056. action: T;
  11057. }> {
  11058. /**
  11059. * Hide ctor from the rest of the world.
  11060. * @param items The items to add.
  11061. */
  11062. private constructor();
  11063. /**
  11064. * Creates a new Stage.
  11065. * @returns A new instance of a Stage
  11066. */
  11067. static Create<T extends Function>(): Stage<T>;
  11068. /**
  11069. * Registers a step in an ordered way in the targeted stage.
  11070. * @param index Defines the position to register the step in
  11071. * @param component Defines the component attached to the step
  11072. * @param action Defines the action to launch during the step
  11073. */
  11074. registerStep(index: number, component: ISceneComponent, action: T): void;
  11075. /**
  11076. * Clears all the steps from the stage.
  11077. */
  11078. clear(): void;
  11079. }
  11080. }
  11081. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11082. import { Nullable } from "babylonjs/types";
  11083. import { Observable } from "babylonjs/Misc/observable";
  11084. import { Scene } from "babylonjs/scene";
  11085. import { Sprite } from "babylonjs/Sprites/sprite";
  11086. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11087. import { Ray } from "babylonjs/Culling/ray";
  11088. import { Camera } from "babylonjs/Cameras/camera";
  11089. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11090. import { ISceneComponent } from "babylonjs/sceneComponent";
  11091. module "babylonjs/scene" {
  11092. interface Scene {
  11093. /** @hidden */
  11094. _pointerOverSprite: Nullable<Sprite>;
  11095. /** @hidden */
  11096. _pickedDownSprite: Nullable<Sprite>;
  11097. /** @hidden */
  11098. _tempSpritePickingRay: Nullable<Ray>;
  11099. /**
  11100. * All of the sprite managers added to this scene
  11101. * @see https://doc.babylonjs.com/babylon101/sprites
  11102. */
  11103. spriteManagers: Array<ISpriteManager>;
  11104. /**
  11105. * An event triggered when sprites rendering is about to start
  11106. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11107. */
  11108. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11109. /**
  11110. * An event triggered when sprites rendering is done
  11111. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11112. */
  11113. onAfterSpritesRenderingObservable: Observable<Scene>;
  11114. /** @hidden */
  11115. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11116. /** Launch a ray to try to pick a sprite in the scene
  11117. * @param x position on screen
  11118. * @param y position on screen
  11119. * @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
  11120. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11121. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11122. * @returns a PickingInfo
  11123. */
  11124. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11125. /** Use the given ray to pick a sprite in the scene
  11126. * @param ray The ray (in world space) to use to pick meshes
  11127. * @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
  11128. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11129. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11130. * @returns a PickingInfo
  11131. */
  11132. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11133. /** @hidden */
  11134. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11135. /** Launch a ray to try to pick sprites in the scene
  11136. * @param x position on screen
  11137. * @param y position on screen
  11138. * @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
  11139. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11140. * @returns a PickingInfo array
  11141. */
  11142. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11143. /** Use the given ray to pick sprites in the scene
  11144. * @param ray The ray (in world space) to use to pick meshes
  11145. * @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
  11146. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11147. * @returns a PickingInfo array
  11148. */
  11149. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11150. /**
  11151. * Force the sprite under the pointer
  11152. * @param sprite defines the sprite to use
  11153. */
  11154. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11155. /**
  11156. * Gets the sprite under the pointer
  11157. * @returns a Sprite or null if no sprite is under the pointer
  11158. */
  11159. getPointerOverSprite(): Nullable<Sprite>;
  11160. }
  11161. }
  11162. /**
  11163. * Defines the sprite scene component responsible to manage sprites
  11164. * in a given scene.
  11165. */
  11166. export class SpriteSceneComponent implements ISceneComponent {
  11167. /**
  11168. * The component name helpfull to identify the component in the list of scene components.
  11169. */
  11170. readonly name: string;
  11171. /**
  11172. * The scene the component belongs to.
  11173. */
  11174. scene: Scene;
  11175. /** @hidden */
  11176. private _spritePredicate;
  11177. /**
  11178. * Creates a new instance of the component for the given scene
  11179. * @param scene Defines the scene to register the component in
  11180. */
  11181. constructor(scene: Scene);
  11182. /**
  11183. * Registers the component in a given scene
  11184. */
  11185. register(): void;
  11186. /**
  11187. * Rebuilds the elements related to this component in case of
  11188. * context lost for instance.
  11189. */
  11190. rebuild(): void;
  11191. /**
  11192. * Disposes the component and the associated ressources.
  11193. */
  11194. dispose(): void;
  11195. private _pickSpriteButKeepRay;
  11196. private _pointerMove;
  11197. private _pointerDown;
  11198. private _pointerUp;
  11199. }
  11200. }
  11201. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11202. /** @hidden */
  11203. export var fogFragmentDeclaration: {
  11204. name: string;
  11205. shader: string;
  11206. };
  11207. }
  11208. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11209. /** @hidden */
  11210. export var fogFragment: {
  11211. name: string;
  11212. shader: string;
  11213. };
  11214. }
  11215. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11216. /** @hidden */
  11217. export var imageProcessingCompatibility: {
  11218. name: string;
  11219. shader: string;
  11220. };
  11221. }
  11222. declare module "babylonjs/Shaders/sprites.fragment" {
  11223. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11224. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11225. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11226. /** @hidden */
  11227. export var spritesPixelShader: {
  11228. name: string;
  11229. shader: string;
  11230. };
  11231. }
  11232. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11233. /** @hidden */
  11234. export var fogVertexDeclaration: {
  11235. name: string;
  11236. shader: string;
  11237. };
  11238. }
  11239. declare module "babylonjs/Shaders/sprites.vertex" {
  11240. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11241. /** @hidden */
  11242. export var spritesVertexShader: {
  11243. name: string;
  11244. shader: string;
  11245. };
  11246. }
  11247. declare module "babylonjs/Sprites/spriteManager" {
  11248. import { IDisposable, Scene } from "babylonjs/scene";
  11249. import { Nullable } from "babylonjs/types";
  11250. import { Observable } from "babylonjs/Misc/observable";
  11251. import { Sprite } from "babylonjs/Sprites/sprite";
  11252. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11253. import { Camera } from "babylonjs/Cameras/camera";
  11254. import { Texture } from "babylonjs/Materials/Textures/texture";
  11255. import "babylonjs/Shaders/sprites.fragment";
  11256. import "babylonjs/Shaders/sprites.vertex";
  11257. import { Ray } from "babylonjs/Culling/ray";
  11258. /**
  11259. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11260. */
  11261. export interface ISpriteManager extends IDisposable {
  11262. /**
  11263. * Gets manager's name
  11264. */
  11265. name: string;
  11266. /**
  11267. * Restricts the camera to viewing objects with the same layerMask.
  11268. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11269. */
  11270. layerMask: number;
  11271. /**
  11272. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11273. */
  11274. isPickable: boolean;
  11275. /**
  11276. * Gets the hosting scene
  11277. */
  11278. scene: Scene;
  11279. /**
  11280. * Specifies the rendering group id for this mesh (0 by default)
  11281. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11282. */
  11283. renderingGroupId: number;
  11284. /**
  11285. * Defines the list of sprites managed by the manager.
  11286. */
  11287. sprites: Array<Sprite>;
  11288. /**
  11289. * Gets or sets the spritesheet texture
  11290. */
  11291. texture: Texture;
  11292. /** Defines the default width of a cell in the spritesheet */
  11293. cellWidth: number;
  11294. /** Defines the default height of a cell in the spritesheet */
  11295. cellHeight: number;
  11296. /**
  11297. * Tests the intersection of a sprite with a specific ray.
  11298. * @param ray The ray we are sending to test the collision
  11299. * @param camera The camera space we are sending rays in
  11300. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11301. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11302. * @returns picking info or null.
  11303. */
  11304. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11305. /**
  11306. * Intersects the sprites with a ray
  11307. * @param ray defines the ray to intersect with
  11308. * @param camera defines the current active camera
  11309. * @param predicate defines a predicate used to select candidate sprites
  11310. * @returns null if no hit or a PickingInfo array
  11311. */
  11312. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11313. /**
  11314. * Renders the list of sprites on screen.
  11315. */
  11316. render(): void;
  11317. }
  11318. /**
  11319. * Class used to manage multiple sprites on the same spritesheet
  11320. * @see https://doc.babylonjs.com/babylon101/sprites
  11321. */
  11322. export class SpriteManager implements ISpriteManager {
  11323. /** defines the manager's name */
  11324. name: string;
  11325. /** Define the Url to load snippets */
  11326. static SnippetUrl: string;
  11327. /** Snippet ID if the manager was created from the snippet server */
  11328. snippetId: string;
  11329. /** Gets the list of sprites */
  11330. sprites: Sprite[];
  11331. /** Gets or sets the rendering group id (0 by default) */
  11332. renderingGroupId: number;
  11333. /** Gets or sets camera layer mask */
  11334. layerMask: number;
  11335. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11336. fogEnabled: boolean;
  11337. /** Gets or sets a boolean indicating if the sprites are pickable */
  11338. isPickable: boolean;
  11339. /** Defines the default width of a cell in the spritesheet */
  11340. cellWidth: number;
  11341. /** Defines the default height of a cell in the spritesheet */
  11342. cellHeight: number;
  11343. /** Associative array from JSON sprite data file */
  11344. private _cellData;
  11345. /** Array of sprite names from JSON sprite data file */
  11346. private _spriteMap;
  11347. /** True when packed cell data from JSON file is ready*/
  11348. private _packedAndReady;
  11349. private _textureContent;
  11350. private _useInstancing;
  11351. /**
  11352. * An event triggered when the manager is disposed.
  11353. */
  11354. onDisposeObservable: Observable<SpriteManager>;
  11355. private _onDisposeObserver;
  11356. /**
  11357. * Callback called when the manager is disposed
  11358. */
  11359. set onDispose(callback: () => void);
  11360. private _capacity;
  11361. private _fromPacked;
  11362. private _spriteTexture;
  11363. private _epsilon;
  11364. private _scene;
  11365. private _vertexData;
  11366. private _buffer;
  11367. private _vertexBuffers;
  11368. private _spriteBuffer;
  11369. private _indexBuffer;
  11370. private _effectBase;
  11371. private _effectFog;
  11372. private _vertexBufferSize;
  11373. /**
  11374. * Gets or sets the unique id of the sprite
  11375. */
  11376. uniqueId: number;
  11377. /**
  11378. * Gets the array of sprites
  11379. */
  11380. get children(): Sprite[];
  11381. /**
  11382. * Gets the hosting scene
  11383. */
  11384. get scene(): Scene;
  11385. /**
  11386. * Gets the capacity of the manager
  11387. */
  11388. get capacity(): number;
  11389. /**
  11390. * Gets or sets the spritesheet texture
  11391. */
  11392. get texture(): Texture;
  11393. set texture(value: Texture);
  11394. private _blendMode;
  11395. /**
  11396. * Blend mode use to render the particle, it can be any of
  11397. * the static Constants.ALPHA_x properties provided in this class.
  11398. * Default value is Constants.ALPHA_COMBINE
  11399. */
  11400. get blendMode(): number;
  11401. set blendMode(blendMode: number);
  11402. /** Disables writing to the depth buffer when rendering the sprites.
  11403. * It can be handy to disable depth writing when using textures without alpha channel
  11404. * and setting some specific blend modes.
  11405. */
  11406. disableDepthWrite: boolean;
  11407. /**
  11408. * Creates a new sprite manager
  11409. * @param name defines the manager's name
  11410. * @param imgUrl defines the sprite sheet url
  11411. * @param capacity defines the maximum allowed number of sprites
  11412. * @param cellSize defines the size of a sprite cell
  11413. * @param scene defines the hosting scene
  11414. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11415. * @param samplingMode defines the smapling mode to use with spritesheet
  11416. * @param fromPacked set to false; do not alter
  11417. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11418. */
  11419. constructor(
  11420. /** defines the manager's name */
  11421. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11422. /**
  11423. * Returns the string "SpriteManager"
  11424. * @returns "SpriteManager"
  11425. */
  11426. getClassName(): string;
  11427. private _makePacked;
  11428. private _appendSpriteVertex;
  11429. private _checkTextureAlpha;
  11430. /**
  11431. * Intersects the sprites with a ray
  11432. * @param ray defines the ray to intersect with
  11433. * @param camera defines the current active camera
  11434. * @param predicate defines a predicate used to select candidate sprites
  11435. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11436. * @returns null if no hit or a PickingInfo
  11437. */
  11438. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11439. /**
  11440. * Intersects the sprites with a ray
  11441. * @param ray defines the ray to intersect with
  11442. * @param camera defines the current active camera
  11443. * @param predicate defines a predicate used to select candidate sprites
  11444. * @returns null if no hit or a PickingInfo array
  11445. */
  11446. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11447. /**
  11448. * Render all child sprites
  11449. */
  11450. render(): void;
  11451. /**
  11452. * Release associated resources
  11453. */
  11454. dispose(): void;
  11455. /**
  11456. * Serializes the sprite manager to a JSON object
  11457. * @param serializeTexture defines if the texture must be serialized as well
  11458. * @returns the JSON object
  11459. */
  11460. serialize(serializeTexture?: boolean): any;
  11461. /**
  11462. * Parses a JSON object to create a new sprite manager.
  11463. * @param parsedManager The JSON object to parse
  11464. * @param scene The scene to create the sprite managerin
  11465. * @param rootUrl The root url to use to load external dependencies like texture
  11466. * @returns the new sprite manager
  11467. */
  11468. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11469. /**
  11470. * Creates a sprite manager from a snippet saved in a remote file
  11471. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11472. * @param url defines the url to load from
  11473. * @param scene defines the hosting scene
  11474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11475. * @returns a promise that will resolve to the new sprite manager
  11476. */
  11477. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11478. /**
  11479. * Creates a sprite manager from a snippet saved by the sprite editor
  11480. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11481. * @param scene defines the hosting scene
  11482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11483. * @returns a promise that will resolve to the new sprite manager
  11484. */
  11485. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11486. }
  11487. }
  11488. declare module "babylonjs/Misc/gradients" {
  11489. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11490. /** Interface used by value gradients (color, factor, ...) */
  11491. export interface IValueGradient {
  11492. /**
  11493. * Gets or sets the gradient value (between 0 and 1)
  11494. */
  11495. gradient: number;
  11496. }
  11497. /** Class used to store color4 gradient */
  11498. export class ColorGradient implements IValueGradient {
  11499. /**
  11500. * Gets or sets the gradient value (between 0 and 1)
  11501. */
  11502. gradient: number;
  11503. /**
  11504. * Gets or sets first associated color
  11505. */
  11506. color1: Color4;
  11507. /**
  11508. * Gets or sets second associated color
  11509. */
  11510. color2?: Color4 | undefined;
  11511. /**
  11512. * Creates a new color4 gradient
  11513. * @param gradient gets or sets the gradient value (between 0 and 1)
  11514. * @param color1 gets or sets first associated color
  11515. * @param color2 gets or sets first second color
  11516. */
  11517. constructor(
  11518. /**
  11519. * Gets or sets the gradient value (between 0 and 1)
  11520. */
  11521. gradient: number,
  11522. /**
  11523. * Gets or sets first associated color
  11524. */
  11525. color1: Color4,
  11526. /**
  11527. * Gets or sets second associated color
  11528. */
  11529. color2?: Color4 | undefined);
  11530. /**
  11531. * Will get a color picked randomly between color1 and color2.
  11532. * If color2 is undefined then color1 will be used
  11533. * @param result defines the target Color4 to store the result in
  11534. */
  11535. getColorToRef(result: Color4): void;
  11536. }
  11537. /** Class used to store color 3 gradient */
  11538. export class Color3Gradient implements IValueGradient {
  11539. /**
  11540. * Gets or sets the gradient value (between 0 and 1)
  11541. */
  11542. gradient: number;
  11543. /**
  11544. * Gets or sets the associated color
  11545. */
  11546. color: Color3;
  11547. /**
  11548. * Creates a new color3 gradient
  11549. * @param gradient gets or sets the gradient value (between 0 and 1)
  11550. * @param color gets or sets associated color
  11551. */
  11552. constructor(
  11553. /**
  11554. * Gets or sets the gradient value (between 0 and 1)
  11555. */
  11556. gradient: number,
  11557. /**
  11558. * Gets or sets the associated color
  11559. */
  11560. color: Color3);
  11561. }
  11562. /** Class used to store factor gradient */
  11563. export class FactorGradient implements IValueGradient {
  11564. /**
  11565. * Gets or sets the gradient value (between 0 and 1)
  11566. */
  11567. gradient: number;
  11568. /**
  11569. * Gets or sets first associated factor
  11570. */
  11571. factor1: number;
  11572. /**
  11573. * Gets or sets second associated factor
  11574. */
  11575. factor2?: number | undefined;
  11576. /**
  11577. * Creates a new factor gradient
  11578. * @param gradient gets or sets the gradient value (between 0 and 1)
  11579. * @param factor1 gets or sets first associated factor
  11580. * @param factor2 gets or sets second associated factor
  11581. */
  11582. constructor(
  11583. /**
  11584. * Gets or sets the gradient value (between 0 and 1)
  11585. */
  11586. gradient: number,
  11587. /**
  11588. * Gets or sets first associated factor
  11589. */
  11590. factor1: number,
  11591. /**
  11592. * Gets or sets second associated factor
  11593. */
  11594. factor2?: number | undefined);
  11595. /**
  11596. * Will get a number picked randomly between factor1 and factor2.
  11597. * If factor2 is undefined then factor1 will be used
  11598. * @returns the picked number
  11599. */
  11600. getFactor(): number;
  11601. }
  11602. /**
  11603. * Helper used to simplify some generic gradient tasks
  11604. */
  11605. export class GradientHelper {
  11606. /**
  11607. * Gets the current gradient from an array of IValueGradient
  11608. * @param ratio defines the current ratio to get
  11609. * @param gradients defines the array of IValueGradient
  11610. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11611. */
  11612. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11613. }
  11614. }
  11615. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11616. import { Nullable } from "babylonjs/types";
  11617. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11618. import { Scene } from "babylonjs/scene";
  11619. module "babylonjs/Engines/thinEngine" {
  11620. interface ThinEngine {
  11621. /**
  11622. * Creates a raw texture
  11623. * @param data defines the data to store in the texture
  11624. * @param width defines the width of the texture
  11625. * @param height defines the height of the texture
  11626. * @param format defines the format of the data
  11627. * @param generateMipMaps defines if the engine should generate the mip levels
  11628. * @param invertY defines if data must be stored with Y axis inverted
  11629. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11630. * @param compression defines the compression used (null by default)
  11631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11632. * @returns the raw texture inside an InternalTexture
  11633. */
  11634. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11635. /**
  11636. * Update a raw texture
  11637. * @param texture defines the texture to update
  11638. * @param data defines the data to store in the texture
  11639. * @param format defines the format of the data
  11640. * @param invertY defines if data must be stored with Y axis inverted
  11641. */
  11642. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11643. /**
  11644. * Update a raw texture
  11645. * @param texture defines the texture to update
  11646. * @param data defines the data to store in the texture
  11647. * @param format defines the format of the data
  11648. * @param invertY defines if data must be stored with Y axis inverted
  11649. * @param compression defines the compression used (null by default)
  11650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11651. */
  11652. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11653. /**
  11654. * Creates a new raw cube texture
  11655. * @param data defines the array of data to use to create each face
  11656. * @param size defines the size of the textures
  11657. * @param format defines the format of the data
  11658. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11659. * @param generateMipMaps defines if the engine should generate the mip levels
  11660. * @param invertY defines if data must be stored with Y axis inverted
  11661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11662. * @param compression defines the compression used (null by default)
  11663. * @returns the cube texture as an InternalTexture
  11664. */
  11665. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11666. /**
  11667. * Update a raw cube texture
  11668. * @param texture defines the texture to udpdate
  11669. * @param data defines the data to store
  11670. * @param format defines the data format
  11671. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11672. * @param invertY defines if data must be stored with Y axis inverted
  11673. */
  11674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11675. /**
  11676. * Update a raw cube texture
  11677. * @param texture defines the texture to udpdate
  11678. * @param data defines the data to store
  11679. * @param format defines the data format
  11680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11681. * @param invertY defines if data must be stored with Y axis inverted
  11682. * @param compression defines the compression used (null by default)
  11683. */
  11684. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11685. /**
  11686. * Update a raw cube texture
  11687. * @param texture defines the texture to udpdate
  11688. * @param data defines the data to store
  11689. * @param format defines the data format
  11690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11691. * @param invertY defines if data must be stored with Y axis inverted
  11692. * @param compression defines the compression used (null by default)
  11693. * @param level defines which level of the texture to update
  11694. */
  11695. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11696. /**
  11697. * Creates a new raw cube texture from a specified url
  11698. * @param url defines the url where the data is located
  11699. * @param scene defines the current scene
  11700. * @param size defines the size of the textures
  11701. * @param format defines the format of the data
  11702. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11703. * @param noMipmap defines if the engine should avoid generating the mip levels
  11704. * @param callback defines a callback used to extract texture data from loaded data
  11705. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11706. * @param onLoad defines a callback called when texture is loaded
  11707. * @param onError defines a callback called if there is an error
  11708. * @returns the cube texture as an InternalTexture
  11709. */
  11710. 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;
  11711. /**
  11712. * Creates a new raw cube texture from a specified url
  11713. * @param url defines the url where the data is located
  11714. * @param scene defines the current scene
  11715. * @param size defines the size of the textures
  11716. * @param format defines the format of the data
  11717. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11718. * @param noMipmap defines if the engine should avoid generating the mip levels
  11719. * @param callback defines a callback used to extract texture data from loaded data
  11720. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11721. * @param onLoad defines a callback called when texture is loaded
  11722. * @param onError defines a callback called if there is an error
  11723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11724. * @param invertY defines if data must be stored with Y axis inverted
  11725. * @returns the cube texture as an InternalTexture
  11726. */
  11727. 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;
  11728. /**
  11729. * Creates a new raw 3D texture
  11730. * @param data defines the data used to create the texture
  11731. * @param width defines the width of the texture
  11732. * @param height defines the height of the texture
  11733. * @param depth defines the depth of the texture
  11734. * @param format defines the format of the texture
  11735. * @param generateMipMaps defines if the engine must generate mip levels
  11736. * @param invertY defines if data must be stored with Y axis inverted
  11737. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11738. * @param compression defines the compressed used (can be null)
  11739. * @param textureType defines the compressed used (can be null)
  11740. * @returns a new raw 3D texture (stored in an InternalTexture)
  11741. */
  11742. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11743. /**
  11744. * Update a raw 3D texture
  11745. * @param texture defines the texture to update
  11746. * @param data defines the data to store
  11747. * @param format defines the data format
  11748. * @param invertY defines if data must be stored with Y axis inverted
  11749. */
  11750. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11751. /**
  11752. * Update a raw 3D texture
  11753. * @param texture defines the texture to update
  11754. * @param data defines the data to store
  11755. * @param format defines the data format
  11756. * @param invertY defines if data must be stored with Y axis inverted
  11757. * @param compression defines the used compression (can be null)
  11758. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11759. */
  11760. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11761. /**
  11762. * Creates a new raw 2D array texture
  11763. * @param data defines the data used to create the texture
  11764. * @param width defines the width of the texture
  11765. * @param height defines the height of the texture
  11766. * @param depth defines the number of layers of the texture
  11767. * @param format defines the format of the texture
  11768. * @param generateMipMaps defines if the engine must generate mip levels
  11769. * @param invertY defines if data must be stored with Y axis inverted
  11770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11771. * @param compression defines the compressed used (can be null)
  11772. * @param textureType defines the compressed used (can be null)
  11773. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11774. */
  11775. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11776. /**
  11777. * Update a raw 2D array texture
  11778. * @param texture defines the texture to update
  11779. * @param data defines the data to store
  11780. * @param format defines the data format
  11781. * @param invertY defines if data must be stored with Y axis inverted
  11782. */
  11783. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11784. /**
  11785. * Update a raw 2D array texture
  11786. * @param texture defines the texture to update
  11787. * @param data defines the data to store
  11788. * @param format defines the data format
  11789. * @param invertY defines if data must be stored with Y axis inverted
  11790. * @param compression defines the used compression (can be null)
  11791. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11792. */
  11793. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11794. }
  11795. }
  11796. }
  11797. declare module "babylonjs/Materials/Textures/rawTexture" {
  11798. import { Texture } from "babylonjs/Materials/Textures/texture";
  11799. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11800. import { Nullable } from "babylonjs/types";
  11801. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11802. import { Scene } from "babylonjs/scene";
  11803. /**
  11804. * Raw texture can help creating a texture directly from an array of data.
  11805. * This can be super useful if you either get the data from an uncompressed source or
  11806. * if you wish to create your texture pixel by pixel.
  11807. */
  11808. export class RawTexture extends Texture {
  11809. /**
  11810. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11811. */
  11812. format: number;
  11813. /**
  11814. * Instantiates a new RawTexture.
  11815. * Raw texture can help creating a texture directly from an array of data.
  11816. * This can be super useful if you either get the data from an uncompressed source or
  11817. * if you wish to create your texture pixel by pixel.
  11818. * @param data define the array of data to use to create the texture
  11819. * @param width define the width of the texture
  11820. * @param height define the height of the texture
  11821. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11822. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11823. * @param generateMipMaps define whether mip maps should be generated or not
  11824. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11825. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11826. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11827. */
  11828. constructor(data: ArrayBufferView, width: number, height: number,
  11829. /**
  11830. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11831. */
  11832. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11833. /**
  11834. * Updates the texture underlying data.
  11835. * @param data Define the new data of the texture
  11836. */
  11837. update(data: ArrayBufferView): void;
  11838. /**
  11839. * Creates a luminance texture from some data.
  11840. * @param data Define the texture data
  11841. * @param width Define the width of the texture
  11842. * @param height Define the height of the texture
  11843. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11844. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11845. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11846. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11847. * @returns the luminance texture
  11848. */
  11849. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11850. /**
  11851. * Creates a luminance alpha texture from some data.
  11852. * @param data Define the texture data
  11853. * @param width Define the width of the texture
  11854. * @param height Define the height of the texture
  11855. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11856. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11857. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11858. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11859. * @returns the luminance alpha texture
  11860. */
  11861. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11862. /**
  11863. * Creates an alpha texture from some data.
  11864. * @param data Define the texture data
  11865. * @param width Define the width of the texture
  11866. * @param height Define the height of the texture
  11867. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11868. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11869. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11870. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11871. * @returns the alpha texture
  11872. */
  11873. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11874. /**
  11875. * Creates a RGB texture from some data.
  11876. * @param data Define the texture data
  11877. * @param width Define the width of the texture
  11878. * @param height Define the height of the texture
  11879. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11880. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11881. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11882. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11883. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11884. * @returns the RGB alpha texture
  11885. */
  11886. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11887. /**
  11888. * Creates a RGBA texture from some data.
  11889. * @param data Define the texture data
  11890. * @param width Define the width of the texture
  11891. * @param height Define the height of the texture
  11892. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11893. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11894. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11895. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11896. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11897. * @returns the RGBA texture
  11898. */
  11899. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11900. /**
  11901. * Creates a R texture from some data.
  11902. * @param data Define the texture data
  11903. * @param width Define the width of the texture
  11904. * @param height Define the height of the texture
  11905. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11910. * @returns the R texture
  11911. */
  11912. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11913. }
  11914. }
  11915. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11916. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11917. import { IndicesArray, DataArray } from "babylonjs/types";
  11918. module "babylonjs/Engines/thinEngine" {
  11919. interface ThinEngine {
  11920. /**
  11921. * Update a dynamic index buffer
  11922. * @param indexBuffer defines the target index buffer
  11923. * @param indices defines the data to update
  11924. * @param offset defines the offset in the target index buffer where update should start
  11925. */
  11926. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11927. /**
  11928. * Updates a dynamic vertex buffer.
  11929. * @param vertexBuffer the vertex buffer to update
  11930. * @param data the data used to update the vertex buffer
  11931. * @param byteOffset the byte offset of the data
  11932. * @param byteLength the byte length of the data
  11933. */
  11934. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11935. }
  11936. }
  11937. }
  11938. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11939. import { Scene } from "babylonjs/scene";
  11940. import { ISceneComponent } from "babylonjs/sceneComponent";
  11941. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11942. module "babylonjs/abstractScene" {
  11943. interface AbstractScene {
  11944. /**
  11945. * The list of procedural textures added to the scene
  11946. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11947. */
  11948. proceduralTextures: Array<ProceduralTexture>;
  11949. }
  11950. }
  11951. /**
  11952. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11953. * in a given scene.
  11954. */
  11955. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11956. /**
  11957. * The component name helpfull to identify the component in the list of scene components.
  11958. */
  11959. readonly name: string;
  11960. /**
  11961. * The scene the component belongs to.
  11962. */
  11963. scene: Scene;
  11964. /**
  11965. * Creates a new instance of the component for the given scene
  11966. * @param scene Defines the scene to register the component in
  11967. */
  11968. constructor(scene: Scene);
  11969. /**
  11970. * Registers the component in a given scene
  11971. */
  11972. register(): void;
  11973. /**
  11974. * Rebuilds the elements related to this component in case of
  11975. * context lost for instance.
  11976. */
  11977. rebuild(): void;
  11978. /**
  11979. * Disposes the component and the associated ressources.
  11980. */
  11981. dispose(): void;
  11982. private _beforeClear;
  11983. }
  11984. }
  11985. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11986. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11987. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11988. module "babylonjs/Engines/thinEngine" {
  11989. interface ThinEngine {
  11990. /**
  11991. * Creates a new render target cube texture
  11992. * @param size defines the size of the texture
  11993. * @param options defines the options used to create the texture
  11994. * @returns a new render target cube texture stored in an InternalTexture
  11995. */
  11996. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11997. }
  11998. }
  11999. }
  12000. declare module "babylonjs/Shaders/procedural.vertex" {
  12001. /** @hidden */
  12002. export var proceduralVertexShader: {
  12003. name: string;
  12004. shader: string;
  12005. };
  12006. }
  12007. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12008. import { Observable } from "babylonjs/Misc/observable";
  12009. import { Nullable } from "babylonjs/types";
  12010. import { Scene } from "babylonjs/scene";
  12011. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12012. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12013. import { Effect } from "babylonjs/Materials/effect";
  12014. import { Texture } from "babylonjs/Materials/Textures/texture";
  12015. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12016. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12017. import "babylonjs/Shaders/procedural.vertex";
  12018. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12019. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12020. /**
  12021. * 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.
  12022. * This is the base class of any Procedural texture and contains most of the shareable code.
  12023. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12024. */
  12025. export class ProceduralTexture extends Texture {
  12026. /**
  12027. * Define if the texture is enabled or not (disabled texture will not render)
  12028. */
  12029. isEnabled: boolean;
  12030. /**
  12031. * Define if the texture must be cleared before rendering (default is true)
  12032. */
  12033. autoClear: boolean;
  12034. /**
  12035. * Callback called when the texture is generated
  12036. */
  12037. onGenerated: () => void;
  12038. /**
  12039. * Event raised when the texture is generated
  12040. */
  12041. onGeneratedObservable: Observable<ProceduralTexture>;
  12042. /**
  12043. * Event raised before the texture is generated
  12044. */
  12045. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12046. /**
  12047. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12048. */
  12049. nodeMaterialSource: Nullable<NodeMaterial>;
  12050. /** @hidden */
  12051. _generateMipMaps: boolean;
  12052. /** @hidden **/
  12053. _effect: Effect;
  12054. /** @hidden */
  12055. _textures: {
  12056. [key: string]: Texture;
  12057. };
  12058. /** @hidden */
  12059. protected _fallbackTexture: Nullable<Texture>;
  12060. private _size;
  12061. private _currentRefreshId;
  12062. private _frameId;
  12063. private _refreshRate;
  12064. private _vertexBuffers;
  12065. private _indexBuffer;
  12066. private _uniforms;
  12067. private _samplers;
  12068. private _fragment;
  12069. private _floats;
  12070. private _ints;
  12071. private _floatsArrays;
  12072. private _colors3;
  12073. private _colors4;
  12074. private _vectors2;
  12075. private _vectors3;
  12076. private _matrices;
  12077. private _fallbackTextureUsed;
  12078. private _fullEngine;
  12079. private _cachedDefines;
  12080. private _contentUpdateId;
  12081. private _contentData;
  12082. /**
  12083. * Instantiates a new procedural texture.
  12084. * 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.
  12085. * This is the base class of any Procedural texture and contains most of the shareable code.
  12086. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12087. * @param name Define the name of the texture
  12088. * @param size Define the size of the texture to create
  12089. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12090. * @param scene Define the scene the texture belongs to
  12091. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12092. * @param generateMipMaps Define if the texture should creates mip maps or not
  12093. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12094. * @param textureType The FBO internal texture type
  12095. */
  12096. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12097. /**
  12098. * The effect that is created when initializing the post process.
  12099. * @returns The created effect corresponding the the postprocess.
  12100. */
  12101. getEffect(): Effect;
  12102. /**
  12103. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12104. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12105. */
  12106. getContent(): Nullable<ArrayBufferView>;
  12107. private _createIndexBuffer;
  12108. /** @hidden */
  12109. _rebuild(): void;
  12110. /**
  12111. * Resets the texture in order to recreate its associated resources.
  12112. * This can be called in case of context loss
  12113. */
  12114. reset(): void;
  12115. protected _getDefines(): string;
  12116. /**
  12117. * Is the texture ready to be used ? (rendered at least once)
  12118. * @returns true if ready, otherwise, false.
  12119. */
  12120. isReady(): boolean;
  12121. /**
  12122. * Resets the refresh counter of the texture and start bak from scratch.
  12123. * Could be useful to regenerate the texture if it is setup to render only once.
  12124. */
  12125. resetRefreshCounter(): void;
  12126. /**
  12127. * Set the fragment shader to use in order to render the texture.
  12128. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12129. */
  12130. setFragment(fragment: any): void;
  12131. /**
  12132. * Define the refresh rate of the texture or the rendering frequency.
  12133. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12134. */
  12135. get refreshRate(): number;
  12136. set refreshRate(value: number);
  12137. /** @hidden */
  12138. _shouldRender(): boolean;
  12139. /**
  12140. * Get the size the texture is rendering at.
  12141. * @returns the size (on cube texture it is always squared)
  12142. */
  12143. getRenderSize(): RenderTargetTextureSize;
  12144. /**
  12145. * Resize the texture to new value.
  12146. * @param size Define the new size the texture should have
  12147. * @param generateMipMaps Define whether the new texture should create mip maps
  12148. */
  12149. resize(size: number, generateMipMaps: boolean): void;
  12150. private _checkUniform;
  12151. /**
  12152. * Set a texture in the shader program used to render.
  12153. * @param name Define the name of the uniform samplers as defined in the shader
  12154. * @param texture Define the texture to bind to this sampler
  12155. * @return the texture itself allowing "fluent" like uniform updates
  12156. */
  12157. setTexture(name: string, texture: Texture): ProceduralTexture;
  12158. /**
  12159. * Set a float in the shader.
  12160. * @param name Define the name of the uniform as defined in the shader
  12161. * @param value Define the value to give to the uniform
  12162. * @return the texture itself allowing "fluent" like uniform updates
  12163. */
  12164. setFloat(name: string, value: number): ProceduralTexture;
  12165. /**
  12166. * Set a int in the shader.
  12167. * @param name Define the name of the uniform as defined in the shader
  12168. * @param value Define the value to give to the uniform
  12169. * @return the texture itself allowing "fluent" like uniform updates
  12170. */
  12171. setInt(name: string, value: number): ProceduralTexture;
  12172. /**
  12173. * Set an array of floats in the shader.
  12174. * @param name Define the name of the uniform as defined in the shader
  12175. * @param value Define the value to give to the uniform
  12176. * @return the texture itself allowing "fluent" like uniform updates
  12177. */
  12178. setFloats(name: string, value: number[]): ProceduralTexture;
  12179. /**
  12180. * Set a vec3 in the shader from a Color3.
  12181. * @param name Define the name of the uniform as defined in the shader
  12182. * @param value Define the value to give to the uniform
  12183. * @return the texture itself allowing "fluent" like uniform updates
  12184. */
  12185. setColor3(name: string, value: Color3): ProceduralTexture;
  12186. /**
  12187. * Set a vec4 in the shader from a Color4.
  12188. * @param name Define the name of the uniform as defined in the shader
  12189. * @param value Define the value to give to the uniform
  12190. * @return the texture itself allowing "fluent" like uniform updates
  12191. */
  12192. setColor4(name: string, value: Color4): ProceduralTexture;
  12193. /**
  12194. * Set a vec2 in the shader from a Vector2.
  12195. * @param name Define the name of the uniform as defined in the shader
  12196. * @param value Define the value to give to the uniform
  12197. * @return the texture itself allowing "fluent" like uniform updates
  12198. */
  12199. setVector2(name: string, value: Vector2): ProceduralTexture;
  12200. /**
  12201. * Set a vec3 in the shader from a Vector3.
  12202. * @param name Define the name of the uniform as defined in the shader
  12203. * @param value Define the value to give to the uniform
  12204. * @return the texture itself allowing "fluent" like uniform updates
  12205. */
  12206. setVector3(name: string, value: Vector3): ProceduralTexture;
  12207. /**
  12208. * Set a mat4 in the shader from a MAtrix.
  12209. * @param name Define the name of the uniform as defined in the shader
  12210. * @param value Define the value to give to the uniform
  12211. * @return the texture itself allowing "fluent" like uniform updates
  12212. */
  12213. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12214. /**
  12215. * Render the texture to its associated render target.
  12216. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12217. */
  12218. render(useCameraPostProcess?: boolean): void;
  12219. /**
  12220. * Clone the texture.
  12221. * @returns the cloned texture
  12222. */
  12223. clone(): ProceduralTexture;
  12224. /**
  12225. * Dispose the texture and release its asoociated resources.
  12226. */
  12227. dispose(): void;
  12228. }
  12229. }
  12230. declare module "babylonjs/Particles/baseParticleSystem" {
  12231. import { Nullable } from "babylonjs/types";
  12232. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12234. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12235. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12236. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12238. import { Color4 } from "babylonjs/Maths/math.color";
  12239. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12240. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12241. import { Animation } from "babylonjs/Animations/animation";
  12242. import { Scene } from "babylonjs/scene";
  12243. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12244. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12245. /**
  12246. * This represents the base class for particle system in Babylon.
  12247. * 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.
  12248. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12249. * @example https://doc.babylonjs.com/babylon101/particles
  12250. */
  12251. export class BaseParticleSystem {
  12252. /**
  12253. * Source color is added to the destination color without alpha affecting the result
  12254. */
  12255. static BLENDMODE_ONEONE: number;
  12256. /**
  12257. * Blend current color and particle color using particle’s alpha
  12258. */
  12259. static BLENDMODE_STANDARD: number;
  12260. /**
  12261. * Add current color and particle color multiplied by particle’s alpha
  12262. */
  12263. static BLENDMODE_ADD: number;
  12264. /**
  12265. * Multiply current color with particle color
  12266. */
  12267. static BLENDMODE_MULTIPLY: number;
  12268. /**
  12269. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12270. */
  12271. static BLENDMODE_MULTIPLYADD: number;
  12272. /**
  12273. * List of animations used by the particle system.
  12274. */
  12275. animations: Animation[];
  12276. /**
  12277. * Gets or sets the unique id of the particle system
  12278. */
  12279. uniqueId: number;
  12280. /**
  12281. * The id of the Particle system.
  12282. */
  12283. id: string;
  12284. /**
  12285. * The friendly name of the Particle system.
  12286. */
  12287. name: string;
  12288. /**
  12289. * Snippet ID if the particle system was created from the snippet server
  12290. */
  12291. snippetId: string;
  12292. /**
  12293. * The rendering group used by the Particle system to chose when to render.
  12294. */
  12295. renderingGroupId: number;
  12296. /**
  12297. * The emitter represents the Mesh or position we are attaching the particle system to.
  12298. */
  12299. emitter: Nullable<AbstractMesh | Vector3>;
  12300. /**
  12301. * The maximum number of particles to emit per frame
  12302. */
  12303. emitRate: number;
  12304. /**
  12305. * If you want to launch only a few particles at once, that can be done, as well.
  12306. */
  12307. manualEmitCount: number;
  12308. /**
  12309. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12310. */
  12311. updateSpeed: number;
  12312. /**
  12313. * The amount of time the particle system is running (depends of the overall update speed).
  12314. */
  12315. targetStopDuration: number;
  12316. /**
  12317. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12318. */
  12319. disposeOnStop: boolean;
  12320. /**
  12321. * Minimum power of emitting particles.
  12322. */
  12323. minEmitPower: number;
  12324. /**
  12325. * Maximum power of emitting particles.
  12326. */
  12327. maxEmitPower: number;
  12328. /**
  12329. * Minimum life time of emitting particles.
  12330. */
  12331. minLifeTime: number;
  12332. /**
  12333. * Maximum life time of emitting particles.
  12334. */
  12335. maxLifeTime: number;
  12336. /**
  12337. * Minimum Size of emitting particles.
  12338. */
  12339. minSize: number;
  12340. /**
  12341. * Maximum Size of emitting particles.
  12342. */
  12343. maxSize: number;
  12344. /**
  12345. * Minimum scale of emitting particles on X axis.
  12346. */
  12347. minScaleX: number;
  12348. /**
  12349. * Maximum scale of emitting particles on X axis.
  12350. */
  12351. maxScaleX: number;
  12352. /**
  12353. * Minimum scale of emitting particles on Y axis.
  12354. */
  12355. minScaleY: number;
  12356. /**
  12357. * Maximum scale of emitting particles on Y axis.
  12358. */
  12359. maxScaleY: number;
  12360. /**
  12361. * Gets or sets the minimal initial rotation in radians.
  12362. */
  12363. minInitialRotation: number;
  12364. /**
  12365. * Gets or sets the maximal initial rotation in radians.
  12366. */
  12367. maxInitialRotation: number;
  12368. /**
  12369. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12370. */
  12371. minAngularSpeed: number;
  12372. /**
  12373. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12374. */
  12375. maxAngularSpeed: number;
  12376. /**
  12377. * The texture used to render each particle. (this can be a spritesheet)
  12378. */
  12379. particleTexture: Nullable<BaseTexture>;
  12380. /**
  12381. * The layer mask we are rendering the particles through.
  12382. */
  12383. layerMask: number;
  12384. /**
  12385. * This can help using your own shader to render the particle system.
  12386. * The according effect will be created
  12387. */
  12388. customShader: any;
  12389. /**
  12390. * By default particle system starts as soon as they are created. This prevents the
  12391. * automatic start to happen and let you decide when to start emitting particles.
  12392. */
  12393. preventAutoStart: boolean;
  12394. private _noiseTexture;
  12395. /**
  12396. * Gets or sets a texture used to add random noise to particle positions
  12397. */
  12398. get noiseTexture(): Nullable<ProceduralTexture>;
  12399. set noiseTexture(value: Nullable<ProceduralTexture>);
  12400. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12401. noiseStrength: Vector3;
  12402. /**
  12403. * Callback triggered when the particle animation is ending.
  12404. */
  12405. onAnimationEnd: Nullable<() => void>;
  12406. /**
  12407. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12408. */
  12409. blendMode: number;
  12410. /**
  12411. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12412. * to override the particles.
  12413. */
  12414. forceDepthWrite: boolean;
  12415. /** 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 */
  12416. preWarmCycles: number;
  12417. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12418. preWarmStepOffset: number;
  12419. /**
  12420. * 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)
  12421. */
  12422. spriteCellChangeSpeed: number;
  12423. /**
  12424. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12425. */
  12426. startSpriteCellID: number;
  12427. /**
  12428. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12429. */
  12430. endSpriteCellID: number;
  12431. /**
  12432. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12433. */
  12434. spriteCellWidth: number;
  12435. /**
  12436. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12437. */
  12438. spriteCellHeight: number;
  12439. /**
  12440. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12441. */
  12442. spriteRandomStartCell: boolean;
  12443. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12444. translationPivot: Vector2;
  12445. /** @hidden */
  12446. protected _isAnimationSheetEnabled: boolean;
  12447. /**
  12448. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12449. */
  12450. beginAnimationOnStart: boolean;
  12451. /**
  12452. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12453. */
  12454. beginAnimationFrom: number;
  12455. /**
  12456. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12457. */
  12458. beginAnimationTo: number;
  12459. /**
  12460. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12461. */
  12462. beginAnimationLoop: boolean;
  12463. /**
  12464. * Gets or sets a world offset applied to all particles
  12465. */
  12466. worldOffset: Vector3;
  12467. /**
  12468. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12469. */
  12470. get isAnimationSheetEnabled(): boolean;
  12471. set isAnimationSheetEnabled(value: boolean);
  12472. /**
  12473. * Get hosting scene
  12474. * @returns the scene
  12475. */
  12476. getScene(): Nullable<Scene>;
  12477. /**
  12478. * You can use gravity if you want to give an orientation to your particles.
  12479. */
  12480. gravity: Vector3;
  12481. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12482. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12483. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12484. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12485. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12486. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12487. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12488. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12489. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12490. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12491. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12492. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12493. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12494. /**
  12495. * Defines the delay in milliseconds before starting the system (0 by default)
  12496. */
  12497. startDelay: number;
  12498. /**
  12499. * Gets the current list of drag gradients.
  12500. * You must use addDragGradient and removeDragGradient to udpate this list
  12501. * @returns the list of drag gradients
  12502. */
  12503. getDragGradients(): Nullable<Array<FactorGradient>>;
  12504. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12505. limitVelocityDamping: number;
  12506. /**
  12507. * Gets the current list of limit velocity gradients.
  12508. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12509. * @returns the list of limit velocity gradients
  12510. */
  12511. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12512. /**
  12513. * Gets the current list of color gradients.
  12514. * You must use addColorGradient and removeColorGradient to udpate this list
  12515. * @returns the list of color gradients
  12516. */
  12517. getColorGradients(): Nullable<Array<ColorGradient>>;
  12518. /**
  12519. * Gets the current list of size gradients.
  12520. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12521. * @returns the list of size gradients
  12522. */
  12523. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12524. /**
  12525. * Gets the current list of color remap gradients.
  12526. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12527. * @returns the list of color remap gradients
  12528. */
  12529. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12530. /**
  12531. * Gets the current list of alpha remap gradients.
  12532. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12533. * @returns the list of alpha remap gradients
  12534. */
  12535. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12536. /**
  12537. * Gets the current list of life time gradients.
  12538. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12539. * @returns the list of life time gradients
  12540. */
  12541. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12542. /**
  12543. * Gets the current list of angular speed gradients.
  12544. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12545. * @returns the list of angular speed gradients
  12546. */
  12547. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12548. /**
  12549. * Gets the current list of velocity gradients.
  12550. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12551. * @returns the list of velocity gradients
  12552. */
  12553. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12554. /**
  12555. * Gets the current list of start size gradients.
  12556. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12557. * @returns the list of start size gradients
  12558. */
  12559. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12560. /**
  12561. * Gets the current list of emit rate gradients.
  12562. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12563. * @returns the list of emit rate gradients
  12564. */
  12565. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12566. /**
  12567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12568. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12569. */
  12570. get direction1(): Vector3;
  12571. set direction1(value: Vector3);
  12572. /**
  12573. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12574. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12575. */
  12576. get direction2(): Vector3;
  12577. set direction2(value: Vector3);
  12578. /**
  12579. * 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.
  12580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12581. */
  12582. get minEmitBox(): Vector3;
  12583. set minEmitBox(value: Vector3);
  12584. /**
  12585. * 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.
  12586. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12587. */
  12588. get maxEmitBox(): Vector3;
  12589. set maxEmitBox(value: Vector3);
  12590. /**
  12591. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12592. */
  12593. color1: Color4;
  12594. /**
  12595. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12596. */
  12597. color2: Color4;
  12598. /**
  12599. * Color the particle will have at the end of its lifetime
  12600. */
  12601. colorDead: Color4;
  12602. /**
  12603. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12604. */
  12605. textureMask: Color4;
  12606. /**
  12607. * The particle emitter type defines the emitter used by the particle system.
  12608. * It can be for example box, sphere, or cone...
  12609. */
  12610. particleEmitterType: IParticleEmitterType;
  12611. /** @hidden */
  12612. _isSubEmitter: boolean;
  12613. /**
  12614. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12615. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12616. */
  12617. billboardMode: number;
  12618. protected _isBillboardBased: boolean;
  12619. /**
  12620. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12621. */
  12622. get isBillboardBased(): boolean;
  12623. set isBillboardBased(value: boolean);
  12624. /**
  12625. * The scene the particle system belongs to.
  12626. */
  12627. protected _scene: Nullable<Scene>;
  12628. /**
  12629. * The engine the particle system belongs to.
  12630. */
  12631. protected _engine: ThinEngine;
  12632. /**
  12633. * Local cache of defines for image processing.
  12634. */
  12635. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12636. /**
  12637. * Default configuration related to image processing available in the standard Material.
  12638. */
  12639. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12640. /**
  12641. * Gets the image processing configuration used either in this material.
  12642. */
  12643. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12644. /**
  12645. * Sets the Default image processing configuration used either in the this material.
  12646. *
  12647. * If sets to null, the scene one is in use.
  12648. */
  12649. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12650. /**
  12651. * Attaches a new image processing configuration to the Standard Material.
  12652. * @param configuration
  12653. */
  12654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12655. /** @hidden */
  12656. protected _reset(): void;
  12657. /** @hidden */
  12658. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12659. /**
  12660. * Instantiates a particle system.
  12661. * 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.
  12662. * @param name The name of the particle system
  12663. */
  12664. constructor(name: string);
  12665. /**
  12666. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12669. * @returns the emitter
  12670. */
  12671. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12672. /**
  12673. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12674. * @param radius The radius of the hemisphere to emit from
  12675. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12676. * @returns the emitter
  12677. */
  12678. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12679. /**
  12680. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12681. * @param radius The radius of the sphere to emit from
  12682. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12683. * @returns the emitter
  12684. */
  12685. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12686. /**
  12687. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12688. * @param radius The radius of the sphere to emit from
  12689. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12690. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12691. * @returns the emitter
  12692. */
  12693. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12694. /**
  12695. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12696. * @param radius The radius of the emission cylinder
  12697. * @param height The height of the emission cylinder
  12698. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12699. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12700. * @returns the emitter
  12701. */
  12702. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12703. /**
  12704. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12705. * @param radius The radius of the cylinder to emit from
  12706. * @param height The height of the emission cylinder
  12707. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12710. * @returns the emitter
  12711. */
  12712. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12713. /**
  12714. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12715. * @param radius The radius of the cone to emit from
  12716. * @param angle The base angle of the cone
  12717. * @returns the emitter
  12718. */
  12719. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12720. /**
  12721. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12722. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12723. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12724. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12725. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12726. * @returns the emitter
  12727. */
  12728. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12729. }
  12730. }
  12731. declare module "babylonjs/Particles/subEmitter" {
  12732. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12733. import { Scene } from "babylonjs/scene";
  12734. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12735. /**
  12736. * Type of sub emitter
  12737. */
  12738. export enum SubEmitterType {
  12739. /**
  12740. * Attached to the particle over it's lifetime
  12741. */
  12742. ATTACHED = 0,
  12743. /**
  12744. * Created when the particle dies
  12745. */
  12746. END = 1
  12747. }
  12748. /**
  12749. * Sub emitter class used to emit particles from an existing particle
  12750. */
  12751. export class SubEmitter {
  12752. /**
  12753. * the particle system to be used by the sub emitter
  12754. */
  12755. particleSystem: ParticleSystem;
  12756. /**
  12757. * Type of the submitter (Default: END)
  12758. */
  12759. type: SubEmitterType;
  12760. /**
  12761. * 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)
  12762. * Note: This only is supported when using an emitter of type Mesh
  12763. */
  12764. inheritDirection: boolean;
  12765. /**
  12766. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12767. */
  12768. inheritedVelocityAmount: number;
  12769. /**
  12770. * Creates a sub emitter
  12771. * @param particleSystem the particle system to be used by the sub emitter
  12772. */
  12773. constructor(
  12774. /**
  12775. * the particle system to be used by the sub emitter
  12776. */
  12777. particleSystem: ParticleSystem);
  12778. /**
  12779. * Clones the sub emitter
  12780. * @returns the cloned sub emitter
  12781. */
  12782. clone(): SubEmitter;
  12783. /**
  12784. * Serialize current object to a JSON object
  12785. * @returns the serialized object
  12786. */
  12787. serialize(): any;
  12788. /** @hidden */
  12789. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12790. /**
  12791. * Creates a new SubEmitter from a serialized JSON version
  12792. * @param serializationObject defines the JSON object to read from
  12793. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12794. * @param rootUrl defines the rootUrl for data loading
  12795. * @returns a new SubEmitter
  12796. */
  12797. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12798. /** Release associated resources */
  12799. dispose(): void;
  12800. }
  12801. }
  12802. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12803. /** @hidden */
  12804. export var imageProcessingDeclaration: {
  12805. name: string;
  12806. shader: string;
  12807. };
  12808. }
  12809. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12810. /** @hidden */
  12811. export var imageProcessingFunctions: {
  12812. name: string;
  12813. shader: string;
  12814. };
  12815. }
  12816. declare module "babylonjs/Shaders/particles.fragment" {
  12817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12818. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12819. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12820. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12821. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12822. /** @hidden */
  12823. export var particlesPixelShader: {
  12824. name: string;
  12825. shader: string;
  12826. };
  12827. }
  12828. declare module "babylonjs/Shaders/particles.vertex" {
  12829. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12830. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12831. /** @hidden */
  12832. export var particlesVertexShader: {
  12833. name: string;
  12834. shader: string;
  12835. };
  12836. }
  12837. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12838. import { Nullable } from "babylonjs/types";
  12839. import { Plane } from "babylonjs/Maths/math";
  12840. /**
  12841. * Interface used to define entities containing multiple clip planes
  12842. */
  12843. export interface IClipPlanesHolder {
  12844. /**
  12845. * Gets or sets the active clipplane 1
  12846. */
  12847. clipPlane: Nullable<Plane>;
  12848. /**
  12849. * Gets or sets the active clipplane 2
  12850. */
  12851. clipPlane2: Nullable<Plane>;
  12852. /**
  12853. * Gets or sets the active clipplane 3
  12854. */
  12855. clipPlane3: Nullable<Plane>;
  12856. /**
  12857. * Gets or sets the active clipplane 4
  12858. */
  12859. clipPlane4: Nullable<Plane>;
  12860. /**
  12861. * Gets or sets the active clipplane 5
  12862. */
  12863. clipPlane5: Nullable<Plane>;
  12864. /**
  12865. * Gets or sets the active clipplane 6
  12866. */
  12867. clipPlane6: Nullable<Plane>;
  12868. }
  12869. }
  12870. declare module "babylonjs/Materials/thinMaterialHelper" {
  12871. import { Effect } from "babylonjs/Materials/effect";
  12872. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12873. /**
  12874. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12875. *
  12876. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12877. *
  12878. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12879. */
  12880. export class ThinMaterialHelper {
  12881. /**
  12882. * Binds the clip plane information from the holder to the effect.
  12883. * @param effect The effect we are binding the data to
  12884. * @param holder The entity containing the clip plane information
  12885. */
  12886. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12887. }
  12888. }
  12889. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12890. module "babylonjs/Engines/thinEngine" {
  12891. interface ThinEngine {
  12892. /**
  12893. * Sets alpha constants used by some alpha blending modes
  12894. * @param r defines the red component
  12895. * @param g defines the green component
  12896. * @param b defines the blue component
  12897. * @param a defines the alpha component
  12898. */
  12899. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12900. /**
  12901. * Sets the current alpha mode
  12902. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12903. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12904. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12905. */
  12906. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12907. /**
  12908. * Gets the current alpha mode
  12909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12910. * @returns the current alpha mode
  12911. */
  12912. getAlphaMode(): number;
  12913. /**
  12914. * Sets the current alpha equation
  12915. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12916. */
  12917. setAlphaEquation(equation: number): void;
  12918. /**
  12919. * Gets the current alpha equation.
  12920. * @returns the current alpha equation
  12921. */
  12922. getAlphaEquation(): number;
  12923. }
  12924. }
  12925. }
  12926. declare module "babylonjs/Particles/particleSystem" {
  12927. import { Nullable } from "babylonjs/types";
  12928. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12929. import { Observable } from "babylonjs/Misc/observable";
  12930. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12931. import { Effect } from "babylonjs/Materials/effect";
  12932. import { IDisposable } from "babylonjs/scene";
  12933. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12934. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12935. import { Particle } from "babylonjs/Particles/particle";
  12936. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12937. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12938. import "babylonjs/Shaders/particles.fragment";
  12939. import "babylonjs/Shaders/particles.vertex";
  12940. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12941. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12942. import "babylonjs/Engines/Extensions/engine.alpha";
  12943. import { Scene } from "babylonjs/scene";
  12944. /**
  12945. * This represents a particle system in Babylon.
  12946. * 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.
  12947. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12948. * @example https://doc.babylonjs.com/babylon101/particles
  12949. */
  12950. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12951. /**
  12952. * Billboard mode will only apply to Y axis
  12953. */
  12954. static readonly BILLBOARDMODE_Y: number;
  12955. /**
  12956. * Billboard mode will apply to all axes
  12957. */
  12958. static readonly BILLBOARDMODE_ALL: number;
  12959. /**
  12960. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12961. */
  12962. static readonly BILLBOARDMODE_STRETCHED: number;
  12963. /**
  12964. * This function can be defined to provide custom update for active particles.
  12965. * This function will be called instead of regular update (age, position, color, etc.).
  12966. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12967. */
  12968. updateFunction: (particles: Particle[]) => void;
  12969. private _emitterWorldMatrix;
  12970. /**
  12971. * This function can be defined to specify initial direction for every new particle.
  12972. * It by default use the emitterType defined function
  12973. */
  12974. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12975. /**
  12976. * This function can be defined to specify initial position for every new particle.
  12977. * It by default use the emitterType defined function
  12978. */
  12979. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12980. /**
  12981. * @hidden
  12982. */
  12983. _inheritedVelocityOffset: Vector3;
  12984. /**
  12985. * An event triggered when the system is disposed
  12986. */
  12987. onDisposeObservable: Observable<IParticleSystem>;
  12988. /**
  12989. * An event triggered when the system is stopped
  12990. */
  12991. onStoppedObservable: Observable<IParticleSystem>;
  12992. private _onDisposeObserver;
  12993. /**
  12994. * Sets a callback that will be triggered when the system is disposed
  12995. */
  12996. set onDispose(callback: () => void);
  12997. private _particles;
  12998. private _epsilon;
  12999. private _capacity;
  13000. private _stockParticles;
  13001. private _newPartsExcess;
  13002. private _vertexData;
  13003. private _vertexBuffer;
  13004. private _vertexBuffers;
  13005. private _spriteBuffer;
  13006. private _indexBuffer;
  13007. private _effect;
  13008. private _customEffect;
  13009. private _cachedDefines;
  13010. private _scaledColorStep;
  13011. private _colorDiff;
  13012. private _scaledDirection;
  13013. private _scaledGravity;
  13014. private _currentRenderId;
  13015. private _alive;
  13016. private _useInstancing;
  13017. private _vertexArrayObject;
  13018. private _started;
  13019. private _stopped;
  13020. private _actualFrame;
  13021. private _scaledUpdateSpeed;
  13022. private _vertexBufferSize;
  13023. /** @hidden */
  13024. _currentEmitRateGradient: Nullable<FactorGradient>;
  13025. /** @hidden */
  13026. _currentEmitRate1: number;
  13027. /** @hidden */
  13028. _currentEmitRate2: number;
  13029. /** @hidden */
  13030. _currentStartSizeGradient: Nullable<FactorGradient>;
  13031. /** @hidden */
  13032. _currentStartSize1: number;
  13033. /** @hidden */
  13034. _currentStartSize2: number;
  13035. private readonly _rawTextureWidth;
  13036. private _rampGradientsTexture;
  13037. private _useRampGradients;
  13038. /** Gets or sets a matrix to use to compute projection */
  13039. defaultProjectionMatrix: Matrix;
  13040. /** Gets or sets a matrix to use to compute view */
  13041. defaultViewMatrix: Matrix;
  13042. /** Gets or sets a boolean indicating that ramp gradients must be used
  13043. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13044. */
  13045. get useRampGradients(): boolean;
  13046. set useRampGradients(value: boolean);
  13047. /**
  13048. * 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.
  13049. * 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: [])
  13050. */
  13051. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13052. private _subEmitters;
  13053. /**
  13054. * @hidden
  13055. * If the particle systems emitter should be disposed when the particle system is disposed
  13056. */
  13057. _disposeEmitterOnDispose: boolean;
  13058. /**
  13059. * The current active Sub-systems, this property is used by the root particle system only.
  13060. */
  13061. activeSubSystems: Array<ParticleSystem>;
  13062. /**
  13063. * Specifies if the particles are updated in emitter local space or world space
  13064. */
  13065. isLocal: boolean;
  13066. private _rootParticleSystem;
  13067. /**
  13068. * Gets the current list of active particles
  13069. */
  13070. get particles(): Particle[];
  13071. /**
  13072. * Gets the number of particles active at the same time.
  13073. * @returns The number of active particles.
  13074. */
  13075. getActiveCount(): number;
  13076. /**
  13077. * Returns the string "ParticleSystem"
  13078. * @returns a string containing the class name
  13079. */
  13080. getClassName(): string;
  13081. /**
  13082. * Gets a boolean indicating that the system is stopping
  13083. * @returns true if the system is currently stopping
  13084. */
  13085. isStopping(): boolean;
  13086. /**
  13087. * Gets the custom effect used to render the particles
  13088. * @param blendMode Blend mode for which the effect should be retrieved
  13089. * @returns The effect
  13090. */
  13091. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13092. /**
  13093. * Sets the custom effect used to render the particles
  13094. * @param effect The effect to set
  13095. * @param blendMode Blend mode for which the effect should be set
  13096. */
  13097. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13098. /** @hidden */
  13099. private _onBeforeDrawParticlesObservable;
  13100. /**
  13101. * Observable that will be called just before the particles are drawn
  13102. */
  13103. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13104. /**
  13105. * Gets the name of the particle vertex shader
  13106. */
  13107. get vertexShaderName(): string;
  13108. /**
  13109. * Instantiates a particle system.
  13110. * 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.
  13111. * @param name The name of the particle system
  13112. * @param capacity The max number of particles alive at the same time
  13113. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13114. * @param customEffect a custom effect used to change the way particles are rendered by default
  13115. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13116. * @param epsilon Offset used to render the particles
  13117. */
  13118. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13119. private _addFactorGradient;
  13120. private _removeFactorGradient;
  13121. /**
  13122. * Adds a new life time gradient
  13123. * @param gradient defines the gradient to use (between 0 and 1)
  13124. * @param factor defines the life time factor to affect to the specified gradient
  13125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13126. * @returns the current particle system
  13127. */
  13128. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13129. /**
  13130. * Remove a specific life time gradient
  13131. * @param gradient defines the gradient to remove
  13132. * @returns the current particle system
  13133. */
  13134. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13135. /**
  13136. * Adds a new size gradient
  13137. * @param gradient defines the gradient to use (between 0 and 1)
  13138. * @param factor defines the size factor to affect to the specified gradient
  13139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13140. * @returns the current particle system
  13141. */
  13142. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13143. /**
  13144. * Remove a specific size gradient
  13145. * @param gradient defines the gradient to remove
  13146. * @returns the current particle system
  13147. */
  13148. removeSizeGradient(gradient: number): IParticleSystem;
  13149. /**
  13150. * Adds a new color remap gradient
  13151. * @param gradient defines the gradient to use (between 0 and 1)
  13152. * @param min defines the color remap minimal range
  13153. * @param max defines the color remap maximal range
  13154. * @returns the current particle system
  13155. */
  13156. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13157. /**
  13158. * Remove a specific color remap gradient
  13159. * @param gradient defines the gradient to remove
  13160. * @returns the current particle system
  13161. */
  13162. removeColorRemapGradient(gradient: number): IParticleSystem;
  13163. /**
  13164. * Adds a new alpha remap gradient
  13165. * @param gradient defines the gradient to use (between 0 and 1)
  13166. * @param min defines the alpha remap minimal range
  13167. * @param max defines the alpha remap maximal range
  13168. * @returns the current particle system
  13169. */
  13170. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13171. /**
  13172. * Remove a specific alpha remap gradient
  13173. * @param gradient defines the gradient to remove
  13174. * @returns the current particle system
  13175. */
  13176. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13177. /**
  13178. * Adds a new angular speed gradient
  13179. * @param gradient defines the gradient to use (between 0 and 1)
  13180. * @param factor defines the angular speed to affect to the specified gradient
  13181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13182. * @returns the current particle system
  13183. */
  13184. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13185. /**
  13186. * Remove a specific angular speed gradient
  13187. * @param gradient defines the gradient to remove
  13188. * @returns the current particle system
  13189. */
  13190. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13191. /**
  13192. * Adds a new velocity gradient
  13193. * @param gradient defines the gradient to use (between 0 and 1)
  13194. * @param factor defines the velocity to affect to the specified gradient
  13195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13196. * @returns the current particle system
  13197. */
  13198. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13199. /**
  13200. * Remove a specific velocity gradient
  13201. * @param gradient defines the gradient to remove
  13202. * @returns the current particle system
  13203. */
  13204. removeVelocityGradient(gradient: number): IParticleSystem;
  13205. /**
  13206. * Adds a new limit velocity gradient
  13207. * @param gradient defines the gradient to use (between 0 and 1)
  13208. * @param factor defines the limit velocity value to affect to the specified gradient
  13209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13210. * @returns the current particle system
  13211. */
  13212. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13213. /**
  13214. * Remove a specific limit velocity gradient
  13215. * @param gradient defines the gradient to remove
  13216. * @returns the current particle system
  13217. */
  13218. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13219. /**
  13220. * Adds a new drag gradient
  13221. * @param gradient defines the gradient to use (between 0 and 1)
  13222. * @param factor defines the drag value to affect to the specified gradient
  13223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13224. * @returns the current particle system
  13225. */
  13226. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13227. /**
  13228. * Remove a specific drag gradient
  13229. * @param gradient defines the gradient to remove
  13230. * @returns the current particle system
  13231. */
  13232. removeDragGradient(gradient: number): IParticleSystem;
  13233. /**
  13234. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13235. * @param gradient defines the gradient to use (between 0 and 1)
  13236. * @param factor defines the emit rate value to affect to the specified gradient
  13237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13238. * @returns the current particle system
  13239. */
  13240. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13241. /**
  13242. * Remove a specific emit rate gradient
  13243. * @param gradient defines the gradient to remove
  13244. * @returns the current particle system
  13245. */
  13246. removeEmitRateGradient(gradient: number): IParticleSystem;
  13247. /**
  13248. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13249. * @param gradient defines the gradient to use (between 0 and 1)
  13250. * @param factor defines the start size value to affect to the specified gradient
  13251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13252. * @returns the current particle system
  13253. */
  13254. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13255. /**
  13256. * Remove a specific start size gradient
  13257. * @param gradient defines the gradient to remove
  13258. * @returns the current particle system
  13259. */
  13260. removeStartSizeGradient(gradient: number): IParticleSystem;
  13261. private _createRampGradientTexture;
  13262. /**
  13263. * Gets the current list of ramp gradients.
  13264. * You must use addRampGradient and removeRampGradient to udpate this list
  13265. * @returns the list of ramp gradients
  13266. */
  13267. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13268. /** Force the system to rebuild all gradients that need to be resync */
  13269. forceRefreshGradients(): void;
  13270. private _syncRampGradientTexture;
  13271. /**
  13272. * Adds a new ramp gradient used to remap particle colors
  13273. * @param gradient defines the gradient to use (between 0 and 1)
  13274. * @param color defines the color to affect to the specified gradient
  13275. * @returns the current particle system
  13276. */
  13277. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13278. /**
  13279. * Remove a specific ramp gradient
  13280. * @param gradient defines the gradient to remove
  13281. * @returns the current particle system
  13282. */
  13283. removeRampGradient(gradient: number): ParticleSystem;
  13284. /**
  13285. * Adds a new color gradient
  13286. * @param gradient defines the gradient to use (between 0 and 1)
  13287. * @param color1 defines the color to affect to the specified gradient
  13288. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13289. * @returns this particle system
  13290. */
  13291. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13292. /**
  13293. * Remove a specific color gradient
  13294. * @param gradient defines the gradient to remove
  13295. * @returns this particle system
  13296. */
  13297. removeColorGradient(gradient: number): IParticleSystem;
  13298. private _fetchR;
  13299. protected _reset(): void;
  13300. private _resetEffect;
  13301. private _createVertexBuffers;
  13302. private _createIndexBuffer;
  13303. /**
  13304. * Gets the maximum number of particles active at the same time.
  13305. * @returns The max number of active particles.
  13306. */
  13307. getCapacity(): number;
  13308. /**
  13309. * Gets whether there are still active particles in the system.
  13310. * @returns True if it is alive, otherwise false.
  13311. */
  13312. isAlive(): boolean;
  13313. /**
  13314. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13315. * @returns True if it has been started, otherwise false.
  13316. */
  13317. isStarted(): boolean;
  13318. private _prepareSubEmitterInternalArray;
  13319. /**
  13320. * Starts the particle system and begins to emit
  13321. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13322. */
  13323. start(delay?: number): void;
  13324. /**
  13325. * Stops the particle system.
  13326. * @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.
  13327. */
  13328. stop(stopSubEmitters?: boolean): void;
  13329. /**
  13330. * Remove all active particles
  13331. */
  13332. reset(): void;
  13333. /**
  13334. * @hidden (for internal use only)
  13335. */
  13336. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13337. /**
  13338. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13339. * Its lifetime will start back at 0.
  13340. */
  13341. recycleParticle: (particle: Particle) => void;
  13342. private _stopSubEmitters;
  13343. private _createParticle;
  13344. private _removeFromRoot;
  13345. private _emitFromParticle;
  13346. private _update;
  13347. /** @hidden */
  13348. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13349. /** @hidden */
  13350. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13351. /**
  13352. * Fill the defines array according to the current settings of the particle system
  13353. * @param defines Array to be updated
  13354. * @param blendMode blend mode to take into account when updating the array
  13355. */
  13356. fillDefines(defines: Array<string>, blendMode: number): void;
  13357. /**
  13358. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13359. * @param uniforms Uniforms array to fill
  13360. * @param attributes Attributes array to fill
  13361. * @param samplers Samplers array to fill
  13362. */
  13363. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13364. /** @hidden */
  13365. private _getEffect;
  13366. /**
  13367. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13368. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13369. */
  13370. animate(preWarmOnly?: boolean): void;
  13371. private _appendParticleVertices;
  13372. /**
  13373. * Rebuilds the particle system.
  13374. */
  13375. rebuild(): void;
  13376. /**
  13377. * Is this system ready to be used/rendered
  13378. * @return true if the system is ready
  13379. */
  13380. isReady(): boolean;
  13381. private _render;
  13382. /**
  13383. * Renders the particle system in its current state.
  13384. * @returns the current number of particles
  13385. */
  13386. render(): number;
  13387. /**
  13388. * Disposes the particle system and free the associated resources
  13389. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13390. */
  13391. dispose(disposeTexture?: boolean): void;
  13392. /**
  13393. * Clones the particle system.
  13394. * @param name The name of the cloned object
  13395. * @param newEmitter The new emitter to use
  13396. * @returns the cloned particle system
  13397. */
  13398. clone(name: string, newEmitter: any): ParticleSystem;
  13399. /**
  13400. * Serializes the particle system to a JSON object
  13401. * @param serializeTexture defines if the texture must be serialized as well
  13402. * @returns the JSON object
  13403. */
  13404. serialize(serializeTexture?: boolean): any;
  13405. /** @hidden */
  13406. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13407. /** @hidden */
  13408. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13409. /**
  13410. * Parses a JSON object to create a particle system.
  13411. * @param parsedParticleSystem The JSON object to parse
  13412. * @param sceneOrEngine The scene or the engine to create the particle system in
  13413. * @param rootUrl The root url to use to load external dependencies like texture
  13414. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13415. * @returns the Parsed particle system
  13416. */
  13417. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13418. }
  13419. }
  13420. declare module "babylonjs/Particles/particle" {
  13421. import { Nullable } from "babylonjs/types";
  13422. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13423. import { Color4 } from "babylonjs/Maths/math.color";
  13424. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13425. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13426. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13427. /**
  13428. * A particle represents one of the element emitted by a particle system.
  13429. * This is mainly define by its coordinates, direction, velocity and age.
  13430. */
  13431. export class Particle {
  13432. /**
  13433. * The particle system the particle belongs to.
  13434. */
  13435. particleSystem: ParticleSystem;
  13436. private static _Count;
  13437. /**
  13438. * Unique ID of the particle
  13439. */
  13440. id: number;
  13441. /**
  13442. * The world position of the particle in the scene.
  13443. */
  13444. position: Vector3;
  13445. /**
  13446. * The world direction of the particle in the scene.
  13447. */
  13448. direction: Vector3;
  13449. /**
  13450. * The color of the particle.
  13451. */
  13452. color: Color4;
  13453. /**
  13454. * The color change of the particle per step.
  13455. */
  13456. colorStep: Color4;
  13457. /**
  13458. * Defines how long will the life of the particle be.
  13459. */
  13460. lifeTime: number;
  13461. /**
  13462. * The current age of the particle.
  13463. */
  13464. age: number;
  13465. /**
  13466. * The current size of the particle.
  13467. */
  13468. size: number;
  13469. /**
  13470. * The current scale of the particle.
  13471. */
  13472. scale: Vector2;
  13473. /**
  13474. * The current angle of the particle.
  13475. */
  13476. angle: number;
  13477. /**
  13478. * Defines how fast is the angle changing.
  13479. */
  13480. angularSpeed: number;
  13481. /**
  13482. * Defines the cell index used by the particle to be rendered from a sprite.
  13483. */
  13484. cellIndex: number;
  13485. /**
  13486. * The information required to support color remapping
  13487. */
  13488. remapData: Vector4;
  13489. /** @hidden */
  13490. _randomCellOffset?: number;
  13491. /** @hidden */
  13492. _initialDirection: Nullable<Vector3>;
  13493. /** @hidden */
  13494. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13495. /** @hidden */
  13496. _initialStartSpriteCellID: number;
  13497. /** @hidden */
  13498. _initialEndSpriteCellID: number;
  13499. /** @hidden */
  13500. _currentColorGradient: Nullable<ColorGradient>;
  13501. /** @hidden */
  13502. _currentColor1: Color4;
  13503. /** @hidden */
  13504. _currentColor2: Color4;
  13505. /** @hidden */
  13506. _currentSizeGradient: Nullable<FactorGradient>;
  13507. /** @hidden */
  13508. _currentSize1: number;
  13509. /** @hidden */
  13510. _currentSize2: number;
  13511. /** @hidden */
  13512. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13513. /** @hidden */
  13514. _currentAngularSpeed1: number;
  13515. /** @hidden */
  13516. _currentAngularSpeed2: number;
  13517. /** @hidden */
  13518. _currentVelocityGradient: Nullable<FactorGradient>;
  13519. /** @hidden */
  13520. _currentVelocity1: number;
  13521. /** @hidden */
  13522. _currentVelocity2: number;
  13523. /** @hidden */
  13524. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13525. /** @hidden */
  13526. _currentLimitVelocity1: number;
  13527. /** @hidden */
  13528. _currentLimitVelocity2: number;
  13529. /** @hidden */
  13530. _currentDragGradient: Nullable<FactorGradient>;
  13531. /** @hidden */
  13532. _currentDrag1: number;
  13533. /** @hidden */
  13534. _currentDrag2: number;
  13535. /** @hidden */
  13536. _randomNoiseCoordinates1: Vector3;
  13537. /** @hidden */
  13538. _randomNoiseCoordinates2: Vector3;
  13539. /** @hidden */
  13540. _localPosition?: Vector3;
  13541. /**
  13542. * Creates a new instance Particle
  13543. * @param particleSystem the particle system the particle belongs to
  13544. */
  13545. constructor(
  13546. /**
  13547. * The particle system the particle belongs to.
  13548. */
  13549. particleSystem: ParticleSystem);
  13550. private updateCellInfoFromSystem;
  13551. /**
  13552. * Defines how the sprite cell index is updated for the particle
  13553. */
  13554. updateCellIndex(): void;
  13555. /** @hidden */
  13556. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13557. /** @hidden */
  13558. _inheritParticleInfoToSubEmitters(): void;
  13559. /** @hidden */
  13560. _reset(): void;
  13561. /**
  13562. * Copy the properties of particle to another one.
  13563. * @param other the particle to copy the information to.
  13564. */
  13565. copyTo(other: Particle): void;
  13566. }
  13567. }
  13568. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13569. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13570. import { Effect } from "babylonjs/Materials/effect";
  13571. import { Particle } from "babylonjs/Particles/particle";
  13572. import { Nullable } from "babylonjs/types";
  13573. import { Scene } from "babylonjs/scene";
  13574. /**
  13575. * Particle emitter represents a volume emitting particles.
  13576. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13577. */
  13578. export interface IParticleEmitterType {
  13579. /**
  13580. * Called by the particle System when the direction is computed for the created particle.
  13581. * @param worldMatrix is the world matrix of the particle system
  13582. * @param directionToUpdate is the direction vector to update with the result
  13583. * @param particle is the particle we are computed the direction for
  13584. * @param isLocal defines if the direction should be set in local space
  13585. */
  13586. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13587. /**
  13588. * Called by the particle System when the position is computed for the created particle.
  13589. * @param worldMatrix is the world matrix of the particle system
  13590. * @param positionToUpdate is the position vector to update with the result
  13591. * @param particle is the particle we are computed the position for
  13592. * @param isLocal defines if the position should be set in local space
  13593. */
  13594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13595. /**
  13596. * Clones the current emitter and returns a copy of it
  13597. * @returns the new emitter
  13598. */
  13599. clone(): IParticleEmitterType;
  13600. /**
  13601. * Called by the GPUParticleSystem to setup the update shader
  13602. * @param effect defines the update shader
  13603. */
  13604. applyToShader(effect: Effect): void;
  13605. /**
  13606. * Returns a string to use to update the GPU particles update shader
  13607. * @returns the effect defines string
  13608. */
  13609. getEffectDefines(): string;
  13610. /**
  13611. * Returns a string representing the class name
  13612. * @returns a string containing the class name
  13613. */
  13614. getClassName(): string;
  13615. /**
  13616. * Serializes the particle system to a JSON object.
  13617. * @returns the JSON object
  13618. */
  13619. serialize(): any;
  13620. /**
  13621. * Parse properties from a JSON object
  13622. * @param serializationObject defines the JSON object
  13623. * @param scene defines the hosting scene
  13624. */
  13625. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13626. }
  13627. }
  13628. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13629. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13630. import { Effect } from "babylonjs/Materials/effect";
  13631. import { Particle } from "babylonjs/Particles/particle";
  13632. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13633. /**
  13634. * Particle emitter emitting particles from the inside of a box.
  13635. * It emits the particles randomly between 2 given directions.
  13636. */
  13637. export class BoxParticleEmitter implements IParticleEmitterType {
  13638. /**
  13639. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13640. */
  13641. direction1: Vector3;
  13642. /**
  13643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13644. */
  13645. direction2: Vector3;
  13646. /**
  13647. * 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.
  13648. */
  13649. minEmitBox: Vector3;
  13650. /**
  13651. * 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.
  13652. */
  13653. maxEmitBox: Vector3;
  13654. /**
  13655. * Creates a new instance BoxParticleEmitter
  13656. */
  13657. constructor();
  13658. /**
  13659. * Called by the particle System when the direction is computed for the created particle.
  13660. * @param worldMatrix is the world matrix of the particle system
  13661. * @param directionToUpdate is the direction vector to update with the result
  13662. * @param particle is the particle we are computed the direction for
  13663. * @param isLocal defines if the direction should be set in local space
  13664. */
  13665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13666. /**
  13667. * Called by the particle System when the position is computed for the created particle.
  13668. * @param worldMatrix is the world matrix of the particle system
  13669. * @param positionToUpdate is the position vector to update with the result
  13670. * @param particle is the particle we are computed the position for
  13671. * @param isLocal defines if the position should be set in local space
  13672. */
  13673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13674. /**
  13675. * Clones the current emitter and returns a copy of it
  13676. * @returns the new emitter
  13677. */
  13678. clone(): BoxParticleEmitter;
  13679. /**
  13680. * Called by the GPUParticleSystem to setup the update shader
  13681. * @param effect defines the update shader
  13682. */
  13683. applyToShader(effect: Effect): void;
  13684. /**
  13685. * Returns a string to use to update the GPU particles update shader
  13686. * @returns a string containng the defines string
  13687. */
  13688. getEffectDefines(): string;
  13689. /**
  13690. * Returns the string "BoxParticleEmitter"
  13691. * @returns a string containing the class name
  13692. */
  13693. getClassName(): string;
  13694. /**
  13695. * Serializes the particle system to a JSON object.
  13696. * @returns the JSON object
  13697. */
  13698. serialize(): any;
  13699. /**
  13700. * Parse properties from a JSON object
  13701. * @param serializationObject defines the JSON object
  13702. */
  13703. parse(serializationObject: any): void;
  13704. }
  13705. }
  13706. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13707. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13708. import { Effect } from "babylonjs/Materials/effect";
  13709. import { Particle } from "babylonjs/Particles/particle";
  13710. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13711. /**
  13712. * Particle emitter emitting particles from the inside of a cone.
  13713. * It emits the particles alongside the cone volume from the base to the particle.
  13714. * The emission direction might be randomized.
  13715. */
  13716. export class ConeParticleEmitter implements IParticleEmitterType {
  13717. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13718. directionRandomizer: number;
  13719. private _radius;
  13720. private _angle;
  13721. private _height;
  13722. /**
  13723. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13724. */
  13725. radiusRange: number;
  13726. /**
  13727. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13728. */
  13729. heightRange: number;
  13730. /**
  13731. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13732. */
  13733. emitFromSpawnPointOnly: boolean;
  13734. /**
  13735. * Gets or sets the radius of the emission cone
  13736. */
  13737. get radius(): number;
  13738. set radius(value: number);
  13739. /**
  13740. * Gets or sets the angle of the emission cone
  13741. */
  13742. get angle(): number;
  13743. set angle(value: number);
  13744. private _buildHeight;
  13745. /**
  13746. * Creates a new instance ConeParticleEmitter
  13747. * @param radius the radius of the emission cone (1 by default)
  13748. * @param angle the cone base angle (PI by default)
  13749. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13750. */
  13751. constructor(radius?: number, angle?: number,
  13752. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13753. directionRandomizer?: number);
  13754. /**
  13755. * Called by the particle System when the direction is computed for the created particle.
  13756. * @param worldMatrix is the world matrix of the particle system
  13757. * @param directionToUpdate is the direction vector to update with the result
  13758. * @param particle is the particle we are computed the direction for
  13759. * @param isLocal defines if the direction should be set in local space
  13760. */
  13761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13762. /**
  13763. * Called by the particle System when the position is computed for the created particle.
  13764. * @param worldMatrix is the world matrix of the particle system
  13765. * @param positionToUpdate is the position vector to update with the result
  13766. * @param particle is the particle we are computed the position for
  13767. * @param isLocal defines if the position should be set in local space
  13768. */
  13769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13770. /**
  13771. * Clones the current emitter and returns a copy of it
  13772. * @returns the new emitter
  13773. */
  13774. clone(): ConeParticleEmitter;
  13775. /**
  13776. * Called by the GPUParticleSystem to setup the update shader
  13777. * @param effect defines the update shader
  13778. */
  13779. applyToShader(effect: Effect): void;
  13780. /**
  13781. * Returns a string to use to update the GPU particles update shader
  13782. * @returns a string containng the defines string
  13783. */
  13784. getEffectDefines(): string;
  13785. /**
  13786. * Returns the string "ConeParticleEmitter"
  13787. * @returns a string containing the class name
  13788. */
  13789. getClassName(): string;
  13790. /**
  13791. * Serializes the particle system to a JSON object.
  13792. * @returns the JSON object
  13793. */
  13794. serialize(): any;
  13795. /**
  13796. * Parse properties from a JSON object
  13797. * @param serializationObject defines the JSON object
  13798. */
  13799. parse(serializationObject: any): void;
  13800. }
  13801. }
  13802. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13803. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13804. import { Effect } from "babylonjs/Materials/effect";
  13805. import { Particle } from "babylonjs/Particles/particle";
  13806. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13807. /**
  13808. * Particle emitter emitting particles from the inside of a cylinder.
  13809. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13810. */
  13811. export class CylinderParticleEmitter implements IParticleEmitterType {
  13812. /**
  13813. * The radius of the emission cylinder.
  13814. */
  13815. radius: number;
  13816. /**
  13817. * The height of the emission cylinder.
  13818. */
  13819. height: number;
  13820. /**
  13821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13822. */
  13823. radiusRange: number;
  13824. /**
  13825. * How much to randomize the particle direction [0-1].
  13826. */
  13827. directionRandomizer: number;
  13828. /**
  13829. * Creates a new instance CylinderParticleEmitter
  13830. * @param radius the radius of the emission cylinder (1 by default)
  13831. * @param height the height of the emission cylinder (1 by default)
  13832. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13833. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13834. */
  13835. constructor(
  13836. /**
  13837. * The radius of the emission cylinder.
  13838. */
  13839. radius?: number,
  13840. /**
  13841. * The height of the emission cylinder.
  13842. */
  13843. height?: number,
  13844. /**
  13845. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13846. */
  13847. radiusRange?: number,
  13848. /**
  13849. * How much to randomize the particle direction [0-1].
  13850. */
  13851. directionRandomizer?: number);
  13852. /**
  13853. * Called by the particle System when the direction is computed for the created particle.
  13854. * @param worldMatrix is the world matrix of the particle system
  13855. * @param directionToUpdate is the direction vector to update with the result
  13856. * @param particle is the particle we are computed the direction for
  13857. * @param isLocal defines if the direction should be set in local space
  13858. */
  13859. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13860. /**
  13861. * Called by the particle System when the position is computed for the created particle.
  13862. * @param worldMatrix is the world matrix of the particle system
  13863. * @param positionToUpdate is the position vector to update with the result
  13864. * @param particle is the particle we are computed the position for
  13865. * @param isLocal defines if the position should be set in local space
  13866. */
  13867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13868. /**
  13869. * Clones the current emitter and returns a copy of it
  13870. * @returns the new emitter
  13871. */
  13872. clone(): CylinderParticleEmitter;
  13873. /**
  13874. * Called by the GPUParticleSystem to setup the update shader
  13875. * @param effect defines the update shader
  13876. */
  13877. applyToShader(effect: Effect): void;
  13878. /**
  13879. * Returns a string to use to update the GPU particles update shader
  13880. * @returns a string containng the defines string
  13881. */
  13882. getEffectDefines(): string;
  13883. /**
  13884. * Returns the string "CylinderParticleEmitter"
  13885. * @returns a string containing the class name
  13886. */
  13887. getClassName(): string;
  13888. /**
  13889. * Serializes the particle system to a JSON object.
  13890. * @returns the JSON object
  13891. */
  13892. serialize(): any;
  13893. /**
  13894. * Parse properties from a JSON object
  13895. * @param serializationObject defines the JSON object
  13896. */
  13897. parse(serializationObject: any): void;
  13898. }
  13899. /**
  13900. * Particle emitter emitting particles from the inside of a cylinder.
  13901. * It emits the particles randomly between two vectors.
  13902. */
  13903. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13904. /**
  13905. * The min limit of the emission direction.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * The max limit of the emission direction.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Creates a new instance CylinderDirectedParticleEmitter
  13914. * @param radius the radius of the emission cylinder (1 by default)
  13915. * @param height the height of the emission cylinder (1 by default)
  13916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13917. * @param direction1 the min limit of the emission direction (up vector by default)
  13918. * @param direction2 the max limit of the emission direction (up vector by default)
  13919. */
  13920. constructor(radius?: number, height?: number, radiusRange?: number,
  13921. /**
  13922. * The min limit of the emission direction.
  13923. */
  13924. direction1?: Vector3,
  13925. /**
  13926. * The max limit of the emission direction.
  13927. */
  13928. direction2?: Vector3);
  13929. /**
  13930. * Called by the particle System when the direction is computed for the created particle.
  13931. * @param worldMatrix is the world matrix of the particle system
  13932. * @param directionToUpdate is the direction vector to update with the result
  13933. * @param particle is the particle we are computed the direction for
  13934. */
  13935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13936. /**
  13937. * Clones the current emitter and returns a copy of it
  13938. * @returns the new emitter
  13939. */
  13940. clone(): CylinderDirectedParticleEmitter;
  13941. /**
  13942. * Called by the GPUParticleSystem to setup the update shader
  13943. * @param effect defines the update shader
  13944. */
  13945. applyToShader(effect: Effect): void;
  13946. /**
  13947. * Returns a string to use to update the GPU particles update shader
  13948. * @returns a string containng the defines string
  13949. */
  13950. getEffectDefines(): string;
  13951. /**
  13952. * Returns the string "CylinderDirectedParticleEmitter"
  13953. * @returns a string containing the class name
  13954. */
  13955. getClassName(): string;
  13956. /**
  13957. * Serializes the particle system to a JSON object.
  13958. * @returns the JSON object
  13959. */
  13960. serialize(): any;
  13961. /**
  13962. * Parse properties from a JSON object
  13963. * @param serializationObject defines the JSON object
  13964. */
  13965. parse(serializationObject: any): void;
  13966. }
  13967. }
  13968. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13969. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13970. import { Effect } from "babylonjs/Materials/effect";
  13971. import { Particle } from "babylonjs/Particles/particle";
  13972. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13973. /**
  13974. * Particle emitter emitting particles from the inside of a hemisphere.
  13975. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13976. */
  13977. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13978. /**
  13979. * The radius of the emission hemisphere.
  13980. */
  13981. radius: number;
  13982. /**
  13983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13984. */
  13985. radiusRange: number;
  13986. /**
  13987. * How much to randomize the particle direction [0-1].
  13988. */
  13989. directionRandomizer: number;
  13990. /**
  13991. * Creates a new instance HemisphericParticleEmitter
  13992. * @param radius the radius of the emission hemisphere (1 by default)
  13993. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13994. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13995. */
  13996. constructor(
  13997. /**
  13998. * The radius of the emission hemisphere.
  13999. */
  14000. radius?: number,
  14001. /**
  14002. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14003. */
  14004. radiusRange?: number,
  14005. /**
  14006. * How much to randomize the particle direction [0-1].
  14007. */
  14008. directionRandomizer?: number);
  14009. /**
  14010. * Called by the particle System when the direction is computed for the created particle.
  14011. * @param worldMatrix is the world matrix of the particle system
  14012. * @param directionToUpdate is the direction vector to update with the result
  14013. * @param particle is the particle we are computed the direction for
  14014. * @param isLocal defines if the direction should be set in local space
  14015. */
  14016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14017. /**
  14018. * Called by the particle System when the position is computed for the created particle.
  14019. * @param worldMatrix is the world matrix of the particle system
  14020. * @param positionToUpdate is the position vector to update with the result
  14021. * @param particle is the particle we are computed the position for
  14022. * @param isLocal defines if the position should be set in local space
  14023. */
  14024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14025. /**
  14026. * Clones the current emitter and returns a copy of it
  14027. * @returns the new emitter
  14028. */
  14029. clone(): HemisphericParticleEmitter;
  14030. /**
  14031. * Called by the GPUParticleSystem to setup the update shader
  14032. * @param effect defines the update shader
  14033. */
  14034. applyToShader(effect: Effect): void;
  14035. /**
  14036. * Returns a string to use to update the GPU particles update shader
  14037. * @returns a string containng the defines string
  14038. */
  14039. getEffectDefines(): string;
  14040. /**
  14041. * Returns the string "HemisphericParticleEmitter"
  14042. * @returns a string containing the class name
  14043. */
  14044. getClassName(): string;
  14045. /**
  14046. * Serializes the particle system to a JSON object.
  14047. * @returns the JSON object
  14048. */
  14049. serialize(): any;
  14050. /**
  14051. * Parse properties from a JSON object
  14052. * @param serializationObject defines the JSON object
  14053. */
  14054. parse(serializationObject: any): void;
  14055. }
  14056. }
  14057. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14058. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14059. import { Effect } from "babylonjs/Materials/effect";
  14060. import { Particle } from "babylonjs/Particles/particle";
  14061. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14062. /**
  14063. * Particle emitter emitting particles from a point.
  14064. * It emits the particles randomly between 2 given directions.
  14065. */
  14066. export class PointParticleEmitter implements IParticleEmitterType {
  14067. /**
  14068. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14069. */
  14070. direction1: Vector3;
  14071. /**
  14072. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14073. */
  14074. direction2: Vector3;
  14075. /**
  14076. * Creates a new instance PointParticleEmitter
  14077. */
  14078. constructor();
  14079. /**
  14080. * Called by the particle System when the direction is computed for the created particle.
  14081. * @param worldMatrix is the world matrix of the particle system
  14082. * @param directionToUpdate is the direction vector to update with the result
  14083. * @param particle is the particle we are computed the direction for
  14084. * @param isLocal defines if the direction should be set in local space
  14085. */
  14086. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14087. /**
  14088. * Called by the particle System when the position is computed for the created particle.
  14089. * @param worldMatrix is the world matrix of the particle system
  14090. * @param positionToUpdate is the position vector to update with the result
  14091. * @param particle is the particle we are computed the position for
  14092. * @param isLocal defines if the position should be set in local space
  14093. */
  14094. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14095. /**
  14096. * Clones the current emitter and returns a copy of it
  14097. * @returns the new emitter
  14098. */
  14099. clone(): PointParticleEmitter;
  14100. /**
  14101. * Called by the GPUParticleSystem to setup the update shader
  14102. * @param effect defines the update shader
  14103. */
  14104. applyToShader(effect: Effect): void;
  14105. /**
  14106. * Returns a string to use to update the GPU particles update shader
  14107. * @returns a string containng the defines string
  14108. */
  14109. getEffectDefines(): string;
  14110. /**
  14111. * Returns the string "PointParticleEmitter"
  14112. * @returns a string containing the class name
  14113. */
  14114. getClassName(): string;
  14115. /**
  14116. * Serializes the particle system to a JSON object.
  14117. * @returns the JSON object
  14118. */
  14119. serialize(): any;
  14120. /**
  14121. * Parse properties from a JSON object
  14122. * @param serializationObject defines the JSON object
  14123. */
  14124. parse(serializationObject: any): void;
  14125. }
  14126. }
  14127. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14129. import { Effect } from "babylonjs/Materials/effect";
  14130. import { Particle } from "babylonjs/Particles/particle";
  14131. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14132. /**
  14133. * Particle emitter emitting particles from the inside of a sphere.
  14134. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14135. */
  14136. export class SphereParticleEmitter implements IParticleEmitterType {
  14137. /**
  14138. * The radius of the emission sphere.
  14139. */
  14140. radius: number;
  14141. /**
  14142. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14143. */
  14144. radiusRange: number;
  14145. /**
  14146. * How much to randomize the particle direction [0-1].
  14147. */
  14148. directionRandomizer: number;
  14149. /**
  14150. * Creates a new instance SphereParticleEmitter
  14151. * @param radius the radius of the emission sphere (1 by default)
  14152. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14153. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14154. */
  14155. constructor(
  14156. /**
  14157. * The radius of the emission sphere.
  14158. */
  14159. radius?: number,
  14160. /**
  14161. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14162. */
  14163. radiusRange?: number,
  14164. /**
  14165. * How much to randomize the particle direction [0-1].
  14166. */
  14167. directionRandomizer?: number);
  14168. /**
  14169. * Called by the particle System when the direction is computed for the created particle.
  14170. * @param worldMatrix is the world matrix of the particle system
  14171. * @param directionToUpdate is the direction vector to update with the result
  14172. * @param particle is the particle we are computed the direction for
  14173. * @param isLocal defines if the direction should be set in local space
  14174. */
  14175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14176. /**
  14177. * Called by the particle System when the position is computed for the created particle.
  14178. * @param worldMatrix is the world matrix of the particle system
  14179. * @param positionToUpdate is the position vector to update with the result
  14180. * @param particle is the particle we are computed the position for
  14181. * @param isLocal defines if the position should be set in local space
  14182. */
  14183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14184. /**
  14185. * Clones the current emitter and returns a copy of it
  14186. * @returns the new emitter
  14187. */
  14188. clone(): SphereParticleEmitter;
  14189. /**
  14190. * Called by the GPUParticleSystem to setup the update shader
  14191. * @param effect defines the update shader
  14192. */
  14193. applyToShader(effect: Effect): void;
  14194. /**
  14195. * Returns a string to use to update the GPU particles update shader
  14196. * @returns a string containng the defines string
  14197. */
  14198. getEffectDefines(): string;
  14199. /**
  14200. * Returns the string "SphereParticleEmitter"
  14201. * @returns a string containing the class name
  14202. */
  14203. getClassName(): string;
  14204. /**
  14205. * Serializes the particle system to a JSON object.
  14206. * @returns the JSON object
  14207. */
  14208. serialize(): any;
  14209. /**
  14210. * Parse properties from a JSON object
  14211. * @param serializationObject defines the JSON object
  14212. */
  14213. parse(serializationObject: any): void;
  14214. }
  14215. /**
  14216. * Particle emitter emitting particles from the inside of a sphere.
  14217. * It emits the particles randomly between two vectors.
  14218. */
  14219. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14220. /**
  14221. * The min limit of the emission direction.
  14222. */
  14223. direction1: Vector3;
  14224. /**
  14225. * The max limit of the emission direction.
  14226. */
  14227. direction2: Vector3;
  14228. /**
  14229. * Creates a new instance SphereDirectedParticleEmitter
  14230. * @param radius the radius of the emission sphere (1 by default)
  14231. * @param direction1 the min limit of the emission direction (up vector by default)
  14232. * @param direction2 the max limit of the emission direction (up vector by default)
  14233. */
  14234. constructor(radius?: number,
  14235. /**
  14236. * The min limit of the emission direction.
  14237. */
  14238. direction1?: Vector3,
  14239. /**
  14240. * The max limit of the emission direction.
  14241. */
  14242. direction2?: Vector3);
  14243. /**
  14244. * Called by the particle System when the direction is computed for the created particle.
  14245. * @param worldMatrix is the world matrix of the particle system
  14246. * @param directionToUpdate is the direction vector to update with the result
  14247. * @param particle is the particle we are computed the direction for
  14248. */
  14249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14250. /**
  14251. * Clones the current emitter and returns a copy of it
  14252. * @returns the new emitter
  14253. */
  14254. clone(): SphereDirectedParticleEmitter;
  14255. /**
  14256. * Called by the GPUParticleSystem to setup the update shader
  14257. * @param effect defines the update shader
  14258. */
  14259. applyToShader(effect: Effect): void;
  14260. /**
  14261. * Returns a string to use to update the GPU particles update shader
  14262. * @returns a string containng the defines string
  14263. */
  14264. getEffectDefines(): string;
  14265. /**
  14266. * Returns the string "SphereDirectedParticleEmitter"
  14267. * @returns a string containing the class name
  14268. */
  14269. getClassName(): string;
  14270. /**
  14271. * Serializes the particle system to a JSON object.
  14272. * @returns the JSON object
  14273. */
  14274. serialize(): any;
  14275. /**
  14276. * Parse properties from a JSON object
  14277. * @param serializationObject defines the JSON object
  14278. */
  14279. parse(serializationObject: any): void;
  14280. }
  14281. }
  14282. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14283. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14284. import { Effect } from "babylonjs/Materials/effect";
  14285. import { Particle } from "babylonjs/Particles/particle";
  14286. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14287. import { Nullable } from "babylonjs/types";
  14288. /**
  14289. * Particle emitter emitting particles from a custom list of positions.
  14290. */
  14291. export class CustomParticleEmitter implements IParticleEmitterType {
  14292. /**
  14293. * Gets or sets the position generator that will create the inital position of each particle.
  14294. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14295. */
  14296. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14297. /**
  14298. * Gets or sets the destination generator that will create the final destination of each particle.
  14299. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14300. */
  14301. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14302. /**
  14303. * Creates a new instance CustomParticleEmitter
  14304. */
  14305. constructor();
  14306. /**
  14307. * Called by the particle System when the direction is computed for the created particle.
  14308. * @param worldMatrix is the world matrix of the particle system
  14309. * @param directionToUpdate is the direction vector to update with the result
  14310. * @param particle is the particle we are computed the direction for
  14311. * @param isLocal defines if the direction should be set in local space
  14312. */
  14313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14314. /**
  14315. * Called by the particle System when the position is computed for the created particle.
  14316. * @param worldMatrix is the world matrix of the particle system
  14317. * @param positionToUpdate is the position vector to update with the result
  14318. * @param particle is the particle we are computed the position for
  14319. * @param isLocal defines if the position should be set in local space
  14320. */
  14321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14322. /**
  14323. * Clones the current emitter and returns a copy of it
  14324. * @returns the new emitter
  14325. */
  14326. clone(): CustomParticleEmitter;
  14327. /**
  14328. * Called by the GPUParticleSystem to setup the update shader
  14329. * @param effect defines the update shader
  14330. */
  14331. applyToShader(effect: Effect): void;
  14332. /**
  14333. * Returns a string to use to update the GPU particles update shader
  14334. * @returns a string containng the defines string
  14335. */
  14336. getEffectDefines(): string;
  14337. /**
  14338. * Returns the string "PointParticleEmitter"
  14339. * @returns a string containing the class name
  14340. */
  14341. getClassName(): string;
  14342. /**
  14343. * Serializes the particle system to a JSON object.
  14344. * @returns the JSON object
  14345. */
  14346. serialize(): any;
  14347. /**
  14348. * Parse properties from a JSON object
  14349. * @param serializationObject defines the JSON object
  14350. */
  14351. parse(serializationObject: any): void;
  14352. }
  14353. }
  14354. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14355. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14356. import { Effect } from "babylonjs/Materials/effect";
  14357. import { Particle } from "babylonjs/Particles/particle";
  14358. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14359. import { Nullable } from "babylonjs/types";
  14360. import { Scene } from "babylonjs/scene";
  14361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14362. /**
  14363. * Particle emitter emitting particles from the inside of a box.
  14364. * It emits the particles randomly between 2 given directions.
  14365. */
  14366. export class MeshParticleEmitter implements IParticleEmitterType {
  14367. private _indices;
  14368. private _positions;
  14369. private _normals;
  14370. private _storedNormal;
  14371. private _mesh;
  14372. /**
  14373. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14374. */
  14375. direction1: Vector3;
  14376. /**
  14377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14378. */
  14379. direction2: Vector3;
  14380. /**
  14381. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14382. */
  14383. useMeshNormalsForDirection: boolean;
  14384. /** Defines the mesh to use as source */
  14385. get mesh(): Nullable<AbstractMesh>;
  14386. set mesh(value: Nullable<AbstractMesh>);
  14387. /**
  14388. * Creates a new instance MeshParticleEmitter
  14389. * @param mesh defines the mesh to use as source
  14390. */
  14391. constructor(mesh?: Nullable<AbstractMesh>);
  14392. /**
  14393. * Called by the particle System when the direction is computed for the created particle.
  14394. * @param worldMatrix is the world matrix of the particle system
  14395. * @param directionToUpdate is the direction vector to update with the result
  14396. * @param particle is the particle we are computed the direction for
  14397. * @param isLocal defines if the direction should be set in local space
  14398. */
  14399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14400. /**
  14401. * Called by the particle System when the position is computed for the created particle.
  14402. * @param worldMatrix is the world matrix of the particle system
  14403. * @param positionToUpdate is the position vector to update with the result
  14404. * @param particle is the particle we are computed the position for
  14405. * @param isLocal defines if the position should be set in local space
  14406. */
  14407. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14408. /**
  14409. * Clones the current emitter and returns a copy of it
  14410. * @returns the new emitter
  14411. */
  14412. clone(): MeshParticleEmitter;
  14413. /**
  14414. * Called by the GPUParticleSystem to setup the update shader
  14415. * @param effect defines the update shader
  14416. */
  14417. applyToShader(effect: Effect): void;
  14418. /**
  14419. * Returns a string to use to update the GPU particles update shader
  14420. * @returns a string containng the defines string
  14421. */
  14422. getEffectDefines(): string;
  14423. /**
  14424. * Returns the string "BoxParticleEmitter"
  14425. * @returns a string containing the class name
  14426. */
  14427. getClassName(): string;
  14428. /**
  14429. * Serializes the particle system to a JSON object.
  14430. * @returns the JSON object
  14431. */
  14432. serialize(): any;
  14433. /**
  14434. * Parse properties from a JSON object
  14435. * @param serializationObject defines the JSON object
  14436. * @param scene defines the hosting scene
  14437. */
  14438. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14439. }
  14440. }
  14441. declare module "babylonjs/Particles/EmitterTypes/index" {
  14442. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14443. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14444. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14445. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14446. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14447. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14448. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14449. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14450. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14451. }
  14452. declare module "babylonjs/Particles/IParticleSystem" {
  14453. import { Nullable } from "babylonjs/types";
  14454. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14455. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14456. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14457. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14458. import { Scene } from "babylonjs/scene";
  14459. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14460. import { Effect } from "babylonjs/Materials/effect";
  14461. import { Observable } from "babylonjs/Misc/observable";
  14462. import { Animation } from "babylonjs/Animations/animation";
  14463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14464. /**
  14465. * Interface representing a particle system in Babylon.js.
  14466. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14467. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14468. */
  14469. export interface IParticleSystem {
  14470. /**
  14471. * List of animations used by the particle system.
  14472. */
  14473. animations: Animation[];
  14474. /**
  14475. * The id of the Particle system.
  14476. */
  14477. id: string;
  14478. /**
  14479. * The name of the Particle system.
  14480. */
  14481. name: string;
  14482. /**
  14483. * The emitter represents the Mesh or position we are attaching the particle system to.
  14484. */
  14485. emitter: Nullable<AbstractMesh | Vector3>;
  14486. /**
  14487. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14488. */
  14489. isBillboardBased: boolean;
  14490. /**
  14491. * The rendering group used by the Particle system to chose when to render.
  14492. */
  14493. renderingGroupId: number;
  14494. /**
  14495. * The layer mask we are rendering the particles through.
  14496. */
  14497. layerMask: number;
  14498. /**
  14499. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14500. */
  14501. updateSpeed: number;
  14502. /**
  14503. * The amount of time the particle system is running (depends of the overall update speed).
  14504. */
  14505. targetStopDuration: number;
  14506. /**
  14507. * The texture used to render each particle. (this can be a spritesheet)
  14508. */
  14509. particleTexture: Nullable<BaseTexture>;
  14510. /**
  14511. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14512. */
  14513. blendMode: number;
  14514. /**
  14515. * Minimum life time of emitting particles.
  14516. */
  14517. minLifeTime: number;
  14518. /**
  14519. * Maximum life time of emitting particles.
  14520. */
  14521. maxLifeTime: number;
  14522. /**
  14523. * Minimum Size of emitting particles.
  14524. */
  14525. minSize: number;
  14526. /**
  14527. * Maximum Size of emitting particles.
  14528. */
  14529. maxSize: number;
  14530. /**
  14531. * Minimum scale of emitting particles on X axis.
  14532. */
  14533. minScaleX: number;
  14534. /**
  14535. * Maximum scale of emitting particles on X axis.
  14536. */
  14537. maxScaleX: number;
  14538. /**
  14539. * Minimum scale of emitting particles on Y axis.
  14540. */
  14541. minScaleY: number;
  14542. /**
  14543. * Maximum scale of emitting particles on Y axis.
  14544. */
  14545. maxScaleY: number;
  14546. /**
  14547. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14548. */
  14549. color1: Color4;
  14550. /**
  14551. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14552. */
  14553. color2: Color4;
  14554. /**
  14555. * Color the particle will have at the end of its lifetime.
  14556. */
  14557. colorDead: Color4;
  14558. /**
  14559. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14560. */
  14561. emitRate: number;
  14562. /**
  14563. * You can use gravity if you want to give an orientation to your particles.
  14564. */
  14565. gravity: Vector3;
  14566. /**
  14567. * Minimum power of emitting particles.
  14568. */
  14569. minEmitPower: number;
  14570. /**
  14571. * Maximum power of emitting particles.
  14572. */
  14573. maxEmitPower: number;
  14574. /**
  14575. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14576. */
  14577. minAngularSpeed: number;
  14578. /**
  14579. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14580. */
  14581. maxAngularSpeed: number;
  14582. /**
  14583. * Gets or sets the minimal initial rotation in radians.
  14584. */
  14585. minInitialRotation: number;
  14586. /**
  14587. * Gets or sets the maximal initial rotation in radians.
  14588. */
  14589. maxInitialRotation: number;
  14590. /**
  14591. * The particle emitter type defines the emitter used by the particle system.
  14592. * It can be for example box, sphere, or cone...
  14593. */
  14594. particleEmitterType: Nullable<IParticleEmitterType>;
  14595. /**
  14596. * Defines the delay in milliseconds before starting the system (0 by default)
  14597. */
  14598. startDelay: number;
  14599. /**
  14600. * 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
  14601. */
  14602. preWarmCycles: number;
  14603. /**
  14604. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14605. */
  14606. preWarmStepOffset: number;
  14607. /**
  14608. * 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)
  14609. */
  14610. spriteCellChangeSpeed: number;
  14611. /**
  14612. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14613. */
  14614. startSpriteCellID: number;
  14615. /**
  14616. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14617. */
  14618. endSpriteCellID: number;
  14619. /**
  14620. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14621. */
  14622. spriteCellWidth: number;
  14623. /**
  14624. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14625. */
  14626. spriteCellHeight: number;
  14627. /**
  14628. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14629. */
  14630. spriteRandomStartCell: boolean;
  14631. /**
  14632. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14633. */
  14634. isAnimationSheetEnabled: boolean;
  14635. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14636. translationPivot: Vector2;
  14637. /**
  14638. * Gets or sets a texture used to add random noise to particle positions
  14639. */
  14640. noiseTexture: Nullable<BaseTexture>;
  14641. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14642. noiseStrength: Vector3;
  14643. /**
  14644. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14645. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14646. */
  14647. billboardMode: number;
  14648. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14649. limitVelocityDamping: number;
  14650. /**
  14651. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14652. */
  14653. beginAnimationOnStart: boolean;
  14654. /**
  14655. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14656. */
  14657. beginAnimationFrom: number;
  14658. /**
  14659. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14660. */
  14661. beginAnimationTo: number;
  14662. /**
  14663. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14664. */
  14665. beginAnimationLoop: boolean;
  14666. /**
  14667. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14668. */
  14669. disposeOnStop: boolean;
  14670. /**
  14671. * Specifies if the particles are updated in emitter local space or world space
  14672. */
  14673. isLocal: boolean;
  14674. /** Snippet ID if the particle system was created from the snippet server */
  14675. snippetId: string;
  14676. /** Gets or sets a matrix to use to compute projection */
  14677. defaultProjectionMatrix: Matrix;
  14678. /**
  14679. * Gets the maximum number of particles active at the same time.
  14680. * @returns The max number of active particles.
  14681. */
  14682. getCapacity(): number;
  14683. /**
  14684. * Gets the number of particles active at the same time.
  14685. * @returns The number of active particles.
  14686. */
  14687. getActiveCount(): number;
  14688. /**
  14689. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14690. * @returns True if it has been started, otherwise false.
  14691. */
  14692. isStarted(): boolean;
  14693. /**
  14694. * Animates the particle system for this frame.
  14695. */
  14696. animate(): void;
  14697. /**
  14698. * Renders the particle system in its current state.
  14699. * @returns the current number of particles
  14700. */
  14701. render(): number;
  14702. /**
  14703. * Dispose the particle system and frees its associated resources.
  14704. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14705. */
  14706. dispose(disposeTexture?: boolean): void;
  14707. /**
  14708. * An event triggered when the system is disposed
  14709. */
  14710. onDisposeObservable: Observable<IParticleSystem>;
  14711. /**
  14712. * An event triggered when the system is stopped
  14713. */
  14714. onStoppedObservable: Observable<IParticleSystem>;
  14715. /**
  14716. * Clones the particle system.
  14717. * @param name The name of the cloned object
  14718. * @param newEmitter The new emitter to use
  14719. * @returns the cloned particle system
  14720. */
  14721. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14722. /**
  14723. * Serializes the particle system to a JSON object
  14724. * @param serializeTexture defines if the texture must be serialized as well
  14725. * @returns the JSON object
  14726. */
  14727. serialize(serializeTexture: boolean): any;
  14728. /**
  14729. * Rebuild the particle system
  14730. */
  14731. rebuild(): void;
  14732. /** Force the system to rebuild all gradients that need to be resync */
  14733. forceRefreshGradients(): void;
  14734. /**
  14735. * Starts the particle system and begins to emit
  14736. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14737. */
  14738. start(delay?: number): void;
  14739. /**
  14740. * Stops the particle system.
  14741. */
  14742. stop(): void;
  14743. /**
  14744. * Remove all active particles
  14745. */
  14746. reset(): void;
  14747. /**
  14748. * Gets a boolean indicating that the system is stopping
  14749. * @returns true if the system is currently stopping
  14750. */
  14751. isStopping(): boolean;
  14752. /**
  14753. * Is this system ready to be used/rendered
  14754. * @return true if the system is ready
  14755. */
  14756. isReady(): boolean;
  14757. /**
  14758. * Returns the string "ParticleSystem"
  14759. * @returns a string containing the class name
  14760. */
  14761. getClassName(): string;
  14762. /**
  14763. * Gets the custom effect used to render the particles
  14764. * @param blendMode Blend mode for which the effect should be retrieved
  14765. * @returns The effect
  14766. */
  14767. getCustomEffect(blendMode: number): Nullable<Effect>;
  14768. /**
  14769. * Sets the custom effect used to render the particles
  14770. * @param effect The effect to set
  14771. * @param blendMode Blend mode for which the effect should be set
  14772. */
  14773. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14774. /**
  14775. * Fill the defines array according to the current settings of the particle system
  14776. * @param defines Array to be updated
  14777. * @param blendMode blend mode to take into account when updating the array
  14778. */
  14779. fillDefines(defines: Array<string>, blendMode: number): void;
  14780. /**
  14781. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14782. * @param uniforms Uniforms array to fill
  14783. * @param attributes Attributes array to fill
  14784. * @param samplers Samplers array to fill
  14785. */
  14786. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14787. /**
  14788. * Observable that will be called just before the particles are drawn
  14789. */
  14790. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14791. /**
  14792. * Gets the name of the particle vertex shader
  14793. */
  14794. vertexShaderName: string;
  14795. /**
  14796. * Adds a new color gradient
  14797. * @param gradient defines the gradient to use (between 0 and 1)
  14798. * @param color1 defines the color to affect to the specified gradient
  14799. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14800. * @returns the current particle system
  14801. */
  14802. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14803. /**
  14804. * Remove a specific color gradient
  14805. * @param gradient defines the gradient to remove
  14806. * @returns the current particle system
  14807. */
  14808. removeColorGradient(gradient: number): IParticleSystem;
  14809. /**
  14810. * Adds a new size gradient
  14811. * @param gradient defines the gradient to use (between 0 and 1)
  14812. * @param factor defines the size factor to affect to the specified gradient
  14813. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14814. * @returns the current particle system
  14815. */
  14816. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14817. /**
  14818. * Remove a specific size gradient
  14819. * @param gradient defines the gradient to remove
  14820. * @returns the current particle system
  14821. */
  14822. removeSizeGradient(gradient: number): IParticleSystem;
  14823. /**
  14824. * Gets the current list of color gradients.
  14825. * You must use addColorGradient and removeColorGradient to udpate this list
  14826. * @returns the list of color gradients
  14827. */
  14828. getColorGradients(): Nullable<Array<ColorGradient>>;
  14829. /**
  14830. * Gets the current list of size gradients.
  14831. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14832. * @returns the list of size gradients
  14833. */
  14834. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14835. /**
  14836. * Gets the current list of angular speed gradients.
  14837. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14838. * @returns the list of angular speed gradients
  14839. */
  14840. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14841. /**
  14842. * Adds a new angular speed gradient
  14843. * @param gradient defines the gradient to use (between 0 and 1)
  14844. * @param factor defines the angular speed to affect to the specified gradient
  14845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14846. * @returns the current particle system
  14847. */
  14848. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14849. /**
  14850. * Remove a specific angular speed gradient
  14851. * @param gradient defines the gradient to remove
  14852. * @returns the current particle system
  14853. */
  14854. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14855. /**
  14856. * Gets the current list of velocity gradients.
  14857. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14858. * @returns the list of velocity gradients
  14859. */
  14860. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14861. /**
  14862. * Adds a new velocity gradient
  14863. * @param gradient defines the gradient to use (between 0 and 1)
  14864. * @param factor defines the velocity to affect to the specified gradient
  14865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14866. * @returns the current particle system
  14867. */
  14868. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14869. /**
  14870. * Remove a specific velocity gradient
  14871. * @param gradient defines the gradient to remove
  14872. * @returns the current particle system
  14873. */
  14874. removeVelocityGradient(gradient: number): IParticleSystem;
  14875. /**
  14876. * Gets the current list of limit velocity gradients.
  14877. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14878. * @returns the list of limit velocity gradients
  14879. */
  14880. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14881. /**
  14882. * Adds a new limit velocity gradient
  14883. * @param gradient defines the gradient to use (between 0 and 1)
  14884. * @param factor defines the limit velocity to affect to the specified gradient
  14885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14886. * @returns the current particle system
  14887. */
  14888. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14889. /**
  14890. * Remove a specific limit velocity gradient
  14891. * @param gradient defines the gradient to remove
  14892. * @returns the current particle system
  14893. */
  14894. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14895. /**
  14896. * Adds a new drag gradient
  14897. * @param gradient defines the gradient to use (between 0 and 1)
  14898. * @param factor defines the drag to affect to the specified gradient
  14899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14900. * @returns the current particle system
  14901. */
  14902. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14903. /**
  14904. * Remove a specific drag gradient
  14905. * @param gradient defines the gradient to remove
  14906. * @returns the current particle system
  14907. */
  14908. removeDragGradient(gradient: number): IParticleSystem;
  14909. /**
  14910. * Gets the current list of drag gradients.
  14911. * You must use addDragGradient and removeDragGradient to udpate this list
  14912. * @returns the list of drag gradients
  14913. */
  14914. getDragGradients(): Nullable<Array<FactorGradient>>;
  14915. /**
  14916. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14917. * @param gradient defines the gradient to use (between 0 and 1)
  14918. * @param factor defines the emit rate to affect to the specified gradient
  14919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14920. * @returns the current particle system
  14921. */
  14922. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14923. /**
  14924. * Remove a specific emit rate gradient
  14925. * @param gradient defines the gradient to remove
  14926. * @returns the current particle system
  14927. */
  14928. removeEmitRateGradient(gradient: number): IParticleSystem;
  14929. /**
  14930. * Gets the current list of emit rate gradients.
  14931. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14932. * @returns the list of emit rate gradients
  14933. */
  14934. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14935. /**
  14936. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14937. * @param gradient defines the gradient to use (between 0 and 1)
  14938. * @param factor defines the start size to affect to the specified gradient
  14939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14940. * @returns the current particle system
  14941. */
  14942. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14943. /**
  14944. * Remove a specific start size gradient
  14945. * @param gradient defines the gradient to remove
  14946. * @returns the current particle system
  14947. */
  14948. removeStartSizeGradient(gradient: number): IParticleSystem;
  14949. /**
  14950. * Gets the current list of start size gradients.
  14951. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14952. * @returns the list of start size gradients
  14953. */
  14954. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14955. /**
  14956. * Adds a new life time gradient
  14957. * @param gradient defines the gradient to use (between 0 and 1)
  14958. * @param factor defines the life time factor to affect to the specified gradient
  14959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14960. * @returns the current particle system
  14961. */
  14962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14963. /**
  14964. * Remove a specific life time gradient
  14965. * @param gradient defines the gradient to remove
  14966. * @returns the current particle system
  14967. */
  14968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14969. /**
  14970. * Gets the current list of life time gradients.
  14971. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14972. * @returns the list of life time gradients
  14973. */
  14974. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14975. /**
  14976. * Gets the current list of color gradients.
  14977. * You must use addColorGradient and removeColorGradient to udpate this list
  14978. * @returns the list of color gradients
  14979. */
  14980. getColorGradients(): Nullable<Array<ColorGradient>>;
  14981. /**
  14982. * Adds a new ramp gradient used to remap particle colors
  14983. * @param gradient defines the gradient to use (between 0 and 1)
  14984. * @param color defines the color to affect to the specified gradient
  14985. * @returns the current particle system
  14986. */
  14987. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14988. /**
  14989. * Gets the current list of ramp gradients.
  14990. * You must use addRampGradient and removeRampGradient to udpate this list
  14991. * @returns the list of ramp gradients
  14992. */
  14993. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14994. /** Gets or sets a boolean indicating that ramp gradients must be used
  14995. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14996. */
  14997. useRampGradients: boolean;
  14998. /**
  14999. * Adds a new color remap gradient
  15000. * @param gradient defines the gradient to use (between 0 and 1)
  15001. * @param min defines the color remap minimal range
  15002. * @param max defines the color remap maximal range
  15003. * @returns the current particle system
  15004. */
  15005. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15006. /**
  15007. * Gets the current list of color remap gradients.
  15008. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15009. * @returns the list of color remap gradients
  15010. */
  15011. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15012. /**
  15013. * Adds a new alpha remap gradient
  15014. * @param gradient defines the gradient to use (between 0 and 1)
  15015. * @param min defines the alpha remap minimal range
  15016. * @param max defines the alpha remap maximal range
  15017. * @returns the current particle system
  15018. */
  15019. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15020. /**
  15021. * Gets the current list of alpha remap gradients.
  15022. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15023. * @returns the list of alpha remap gradients
  15024. */
  15025. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15026. /**
  15027. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15028. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15029. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15030. * @returns the emitter
  15031. */
  15032. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15033. /**
  15034. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15035. * @param radius The radius of the hemisphere to emit from
  15036. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15037. * @returns the emitter
  15038. */
  15039. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15040. /**
  15041. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15042. * @param radius The radius of the sphere to emit from
  15043. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15044. * @returns the emitter
  15045. */
  15046. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15047. /**
  15048. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15049. * @param radius The radius of the sphere to emit from
  15050. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15051. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15052. * @returns the emitter
  15053. */
  15054. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15055. /**
  15056. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15057. * @param radius The radius of the emission cylinder
  15058. * @param height The height of the emission cylinder
  15059. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15060. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15061. * @returns the emitter
  15062. */
  15063. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15064. /**
  15065. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15066. * @param radius The radius of the cylinder to emit from
  15067. * @param height The height of the emission cylinder
  15068. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15069. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15070. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15071. * @returns the emitter
  15072. */
  15073. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15074. /**
  15075. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15076. * @param radius The radius of the cone to emit from
  15077. * @param angle The base angle of the cone
  15078. * @returns the emitter
  15079. */
  15080. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15081. /**
  15082. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15083. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15084. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15085. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15086. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15087. * @returns the emitter
  15088. */
  15089. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15090. /**
  15091. * Get hosting scene
  15092. * @returns the scene
  15093. */
  15094. getScene(): Nullable<Scene>;
  15095. }
  15096. }
  15097. declare module "babylonjs/Meshes/transformNode" {
  15098. import { DeepImmutable } from "babylonjs/types";
  15099. import { Observable } from "babylonjs/Misc/observable";
  15100. import { Nullable } from "babylonjs/types";
  15101. import { Camera } from "babylonjs/Cameras/camera";
  15102. import { Scene } from "babylonjs/scene";
  15103. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15104. import { Node } from "babylonjs/node";
  15105. import { Bone } from "babylonjs/Bones/bone";
  15106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15107. import { Space } from "babylonjs/Maths/math.axis";
  15108. /**
  15109. * 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.
  15110. * @see https://doc.babylonjs.com/how_to/transformnode
  15111. */
  15112. export class TransformNode extends Node {
  15113. /**
  15114. * Object will not rotate to face the camera
  15115. */
  15116. static BILLBOARDMODE_NONE: number;
  15117. /**
  15118. * Object will rotate to face the camera but only on the x axis
  15119. */
  15120. static BILLBOARDMODE_X: number;
  15121. /**
  15122. * Object will rotate to face the camera but only on the y axis
  15123. */
  15124. static BILLBOARDMODE_Y: number;
  15125. /**
  15126. * Object will rotate to face the camera but only on the z axis
  15127. */
  15128. static BILLBOARDMODE_Z: number;
  15129. /**
  15130. * Object will rotate to face the camera
  15131. */
  15132. static BILLBOARDMODE_ALL: number;
  15133. /**
  15134. * Object will rotate to face the camera's position instead of orientation
  15135. */
  15136. static BILLBOARDMODE_USE_POSITION: number;
  15137. private static _TmpRotation;
  15138. private static _TmpScaling;
  15139. private static _TmpTranslation;
  15140. private _forward;
  15141. private _forwardInverted;
  15142. private _up;
  15143. private _right;
  15144. private _rightInverted;
  15145. private _position;
  15146. private _rotation;
  15147. private _rotationQuaternion;
  15148. protected _scaling: Vector3;
  15149. protected _isDirty: boolean;
  15150. private _transformToBoneReferal;
  15151. private _isAbsoluteSynced;
  15152. private _billboardMode;
  15153. /**
  15154. * Gets or sets the billboard mode. Default is 0.
  15155. *
  15156. * | Value | Type | Description |
  15157. * | --- | --- | --- |
  15158. * | 0 | BILLBOARDMODE_NONE | |
  15159. * | 1 | BILLBOARDMODE_X | |
  15160. * | 2 | BILLBOARDMODE_Y | |
  15161. * | 4 | BILLBOARDMODE_Z | |
  15162. * | 7 | BILLBOARDMODE_ALL | |
  15163. *
  15164. */
  15165. get billboardMode(): number;
  15166. set billboardMode(value: number);
  15167. private _preserveParentRotationForBillboard;
  15168. /**
  15169. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15170. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15171. */
  15172. get preserveParentRotationForBillboard(): boolean;
  15173. set preserveParentRotationForBillboard(value: boolean);
  15174. /**
  15175. * 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
  15176. */
  15177. scalingDeterminant: number;
  15178. private _infiniteDistance;
  15179. /**
  15180. * Gets or sets the distance of the object to max, often used by skybox
  15181. */
  15182. get infiniteDistance(): boolean;
  15183. set infiniteDistance(value: boolean);
  15184. /**
  15185. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15186. * By default the system will update normals to compensate
  15187. */
  15188. ignoreNonUniformScaling: boolean;
  15189. /**
  15190. * 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
  15191. */
  15192. reIntegrateRotationIntoRotationQuaternion: boolean;
  15193. /** @hidden */
  15194. _poseMatrix: Nullable<Matrix>;
  15195. /** @hidden */
  15196. _localMatrix: Matrix;
  15197. private _usePivotMatrix;
  15198. private _absolutePosition;
  15199. private _absoluteScaling;
  15200. private _absoluteRotationQuaternion;
  15201. private _pivotMatrix;
  15202. private _pivotMatrixInverse;
  15203. /** @hidden */
  15204. _postMultiplyPivotMatrix: boolean;
  15205. protected _isWorldMatrixFrozen: boolean;
  15206. /** @hidden */
  15207. _indexInSceneTransformNodesArray: number;
  15208. /**
  15209. * An event triggered after the world matrix is updated
  15210. */
  15211. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15212. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15213. /**
  15214. * Gets a string identifying the name of the class
  15215. * @returns "TransformNode" string
  15216. */
  15217. getClassName(): string;
  15218. /**
  15219. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15220. */
  15221. get position(): Vector3;
  15222. set position(newPosition: Vector3);
  15223. /**
  15224. * 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)).
  15225. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15226. */
  15227. get rotation(): Vector3;
  15228. set rotation(newRotation: Vector3);
  15229. /**
  15230. * 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)).
  15231. */
  15232. get scaling(): Vector3;
  15233. set scaling(newScaling: Vector3);
  15234. /**
  15235. * 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).
  15236. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15237. */
  15238. get rotationQuaternion(): Nullable<Quaternion>;
  15239. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15240. /**
  15241. * The forward direction of that transform in world space.
  15242. */
  15243. get forward(): Vector3;
  15244. /**
  15245. * The up direction of that transform in world space.
  15246. */
  15247. get up(): Vector3;
  15248. /**
  15249. * The right direction of that transform in world space.
  15250. */
  15251. get right(): Vector3;
  15252. /**
  15253. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15254. * @param matrix the matrix to copy the pose from
  15255. * @returns this TransformNode.
  15256. */
  15257. updatePoseMatrix(matrix: Matrix): TransformNode;
  15258. /**
  15259. * Returns the mesh Pose matrix.
  15260. * @returns the pose matrix
  15261. */
  15262. getPoseMatrix(): Matrix;
  15263. /** @hidden */
  15264. _isSynchronized(): boolean;
  15265. /** @hidden */
  15266. _initCache(): void;
  15267. /**
  15268. * Flag the transform node as dirty (Forcing it to update everything)
  15269. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15270. * @returns this transform node
  15271. */
  15272. markAsDirty(property: string): TransformNode;
  15273. /**
  15274. * Returns the current mesh absolute position.
  15275. * Returns a Vector3.
  15276. */
  15277. get absolutePosition(): Vector3;
  15278. /**
  15279. * Returns the current mesh absolute scaling.
  15280. * Returns a Vector3.
  15281. */
  15282. get absoluteScaling(): Vector3;
  15283. /**
  15284. * Returns the current mesh absolute rotation.
  15285. * Returns a Quaternion.
  15286. */
  15287. get absoluteRotationQuaternion(): Quaternion;
  15288. /**
  15289. * Sets a new matrix to apply before all other transformation
  15290. * @param matrix defines the transform matrix
  15291. * @returns the current TransformNode
  15292. */
  15293. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15294. /**
  15295. * Sets a new pivot matrix to the current node
  15296. * @param matrix defines the new pivot matrix to use
  15297. * @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
  15298. * @returns the current TransformNode
  15299. */
  15300. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15301. /**
  15302. * Returns the mesh pivot matrix.
  15303. * Default : Identity.
  15304. * @returns the matrix
  15305. */
  15306. getPivotMatrix(): Matrix;
  15307. /**
  15308. * Instantiate (when possible) or clone that node with its hierarchy
  15309. * @param newParent defines the new parent to use for the instance (or clone)
  15310. * @param options defines options to configure how copy is done
  15311. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15312. * @returns an instance (or a clone) of the current node with its hiearchy
  15313. */
  15314. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15315. doNotInstantiate: boolean;
  15316. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15317. /**
  15318. * Prevents the World matrix to be computed any longer
  15319. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15320. * @returns the TransformNode.
  15321. */
  15322. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15323. /**
  15324. * Allows back the World matrix computation.
  15325. * @returns the TransformNode.
  15326. */
  15327. unfreezeWorldMatrix(): this;
  15328. /**
  15329. * True if the World matrix has been frozen.
  15330. */
  15331. get isWorldMatrixFrozen(): boolean;
  15332. /**
  15333. * Retuns the mesh absolute position in the World.
  15334. * @returns a Vector3.
  15335. */
  15336. getAbsolutePosition(): Vector3;
  15337. /**
  15338. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15339. * @param absolutePosition the absolute position to set
  15340. * @returns the TransformNode.
  15341. */
  15342. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15343. /**
  15344. * Sets the mesh position in its local space.
  15345. * @param vector3 the position to set in localspace
  15346. * @returns the TransformNode.
  15347. */
  15348. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15349. /**
  15350. * Returns the mesh position in the local space from the current World matrix values.
  15351. * @returns a new Vector3.
  15352. */
  15353. getPositionExpressedInLocalSpace(): Vector3;
  15354. /**
  15355. * Translates the mesh along the passed Vector3 in its local space.
  15356. * @param vector3 the distance to translate in localspace
  15357. * @returns the TransformNode.
  15358. */
  15359. locallyTranslate(vector3: Vector3): TransformNode;
  15360. private static _lookAtVectorCache;
  15361. /**
  15362. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15363. * @param targetPoint the position (must be in same space as current mesh) to look at
  15364. * @param yawCor optional yaw (y-axis) correction in radians
  15365. * @param pitchCor optional pitch (x-axis) correction in radians
  15366. * @param rollCor optional roll (z-axis) correction in radians
  15367. * @param space the choosen space of the target
  15368. * @returns the TransformNode.
  15369. */
  15370. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15371. /**
  15372. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15373. * This Vector3 is expressed in the World space.
  15374. * @param localAxis axis to rotate
  15375. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15376. */
  15377. getDirection(localAxis: Vector3): Vector3;
  15378. /**
  15379. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15380. * localAxis is expressed in the mesh local space.
  15381. * result is computed in the Wordl space from the mesh World matrix.
  15382. * @param localAxis axis to rotate
  15383. * @param result the resulting transformnode
  15384. * @returns this TransformNode.
  15385. */
  15386. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15387. /**
  15388. * Sets this transform node rotation to the given local axis.
  15389. * @param localAxis the axis in local space
  15390. * @param yawCor optional yaw (y-axis) correction in radians
  15391. * @param pitchCor optional pitch (x-axis) correction in radians
  15392. * @param rollCor optional roll (z-axis) correction in radians
  15393. * @returns this TransformNode
  15394. */
  15395. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15396. /**
  15397. * Sets a new pivot point to the current node
  15398. * @param point defines the new pivot point to use
  15399. * @param space defines if the point is in world or local space (local by default)
  15400. * @returns the current TransformNode
  15401. */
  15402. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15403. /**
  15404. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15405. * @returns the pivot point
  15406. */
  15407. getPivotPoint(): Vector3;
  15408. /**
  15409. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15410. * @param result the vector3 to store the result
  15411. * @returns this TransformNode.
  15412. */
  15413. getPivotPointToRef(result: Vector3): TransformNode;
  15414. /**
  15415. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15416. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15417. */
  15418. getAbsolutePivotPoint(): Vector3;
  15419. /**
  15420. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15421. * @param result vector3 to store the result
  15422. * @returns this TransformNode.
  15423. */
  15424. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15425. /**
  15426. * Defines the passed node as the parent of the current node.
  15427. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15428. * @see https://doc.babylonjs.com/how_to/parenting
  15429. * @param node the node ot set as the parent
  15430. * @returns this TransformNode.
  15431. */
  15432. setParent(node: Nullable<Node>): TransformNode;
  15433. private _nonUniformScaling;
  15434. /**
  15435. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15436. */
  15437. get nonUniformScaling(): boolean;
  15438. /** @hidden */
  15439. _updateNonUniformScalingState(value: boolean): boolean;
  15440. /**
  15441. * Attach the current TransformNode to another TransformNode associated with a bone
  15442. * @param bone Bone affecting the TransformNode
  15443. * @param affectedTransformNode TransformNode associated with the bone
  15444. * @returns this object
  15445. */
  15446. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15447. /**
  15448. * Detach the transform node if its associated with a bone
  15449. * @returns this object
  15450. */
  15451. detachFromBone(): TransformNode;
  15452. private static _rotationAxisCache;
  15453. /**
  15454. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15455. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15456. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15457. * The passed axis is also normalized.
  15458. * @param axis the axis to rotate around
  15459. * @param amount the amount to rotate in radians
  15460. * @param space Space to rotate in (Default: local)
  15461. * @returns the TransformNode.
  15462. */
  15463. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15464. /**
  15465. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15466. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15467. * The passed axis is also normalized. .
  15468. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15469. * @param point the point to rotate around
  15470. * @param axis the axis to rotate around
  15471. * @param amount the amount to rotate in radians
  15472. * @returns the TransformNode
  15473. */
  15474. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15475. /**
  15476. * Translates the mesh along the axis vector for the passed distance in the given space.
  15477. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15478. * @param axis the axis to translate in
  15479. * @param distance the distance to translate
  15480. * @param space Space to rotate in (Default: local)
  15481. * @returns the TransformNode.
  15482. */
  15483. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15484. /**
  15485. * Adds a rotation step to the mesh current rotation.
  15486. * x, y, z are Euler angles expressed in radians.
  15487. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15488. * This means this rotation is made in the mesh local space only.
  15489. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15490. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15491. * ```javascript
  15492. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15493. * ```
  15494. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15495. * 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.
  15496. * @param x Rotation to add
  15497. * @param y Rotation to add
  15498. * @param z Rotation to add
  15499. * @returns the TransformNode.
  15500. */
  15501. addRotation(x: number, y: number, z: number): TransformNode;
  15502. /**
  15503. * @hidden
  15504. */
  15505. protected _getEffectiveParent(): Nullable<Node>;
  15506. /**
  15507. * Computes the world matrix of the node
  15508. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15509. * @returns the world matrix
  15510. */
  15511. computeWorldMatrix(force?: boolean): Matrix;
  15512. /**
  15513. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15514. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15515. */
  15516. resetLocalMatrix(independentOfChildren?: boolean): void;
  15517. protected _afterComputeWorldMatrix(): void;
  15518. /**
  15519. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15520. * @param func callback function to add
  15521. *
  15522. * @returns the TransformNode.
  15523. */
  15524. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15525. /**
  15526. * Removes a registered callback function.
  15527. * @param func callback function to remove
  15528. * @returns the TransformNode.
  15529. */
  15530. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15531. /**
  15532. * Gets the position of the current mesh in camera space
  15533. * @param camera defines the camera to use
  15534. * @returns a position
  15535. */
  15536. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15537. /**
  15538. * Returns the distance from the mesh to the active camera
  15539. * @param camera defines the camera to use
  15540. * @returns the distance
  15541. */
  15542. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15543. /**
  15544. * Clone the current transform node
  15545. * @param name Name of the new clone
  15546. * @param newParent New parent for the clone
  15547. * @param doNotCloneChildren Do not clone children hierarchy
  15548. * @returns the new transform node
  15549. */
  15550. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15551. /**
  15552. * Serializes the objects information.
  15553. * @param currentSerializationObject defines the object to serialize in
  15554. * @returns the serialized object
  15555. */
  15556. serialize(currentSerializationObject?: any): any;
  15557. /**
  15558. * Returns a new TransformNode object parsed from the source provided.
  15559. * @param parsedTransformNode is the source.
  15560. * @param scene the scne the object belongs to
  15561. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15562. * @returns a new TransformNode object parsed from the source provided.
  15563. */
  15564. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15565. /**
  15566. * Get all child-transformNodes of this node
  15567. * @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
  15568. * @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
  15569. * @returns an array of TransformNode
  15570. */
  15571. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15572. /**
  15573. * Releases resources associated with this transform node.
  15574. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15575. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15576. */
  15577. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15578. /**
  15579. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15580. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15581. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15582. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15583. * @returns the current mesh
  15584. */
  15585. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15586. private _syncAbsoluteScalingAndRotation;
  15587. }
  15588. }
  15589. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15590. /**
  15591. * Class used to override all child animations of a given target
  15592. */
  15593. export class AnimationPropertiesOverride {
  15594. /**
  15595. * Gets or sets a value indicating if animation blending must be used
  15596. */
  15597. enableBlending: boolean;
  15598. /**
  15599. * Gets or sets the blending speed to use when enableBlending is true
  15600. */
  15601. blendingSpeed: number;
  15602. /**
  15603. * Gets or sets the default loop mode to use
  15604. */
  15605. loopMode: number;
  15606. }
  15607. }
  15608. declare module "babylonjs/Bones/bone" {
  15609. import { Skeleton } from "babylonjs/Bones/skeleton";
  15610. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15611. import { Nullable } from "babylonjs/types";
  15612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15614. import { Node } from "babylonjs/node";
  15615. import { Space } from "babylonjs/Maths/math.axis";
  15616. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15617. /**
  15618. * Class used to store bone information
  15619. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15620. */
  15621. export class Bone extends Node {
  15622. /**
  15623. * defines the bone name
  15624. */
  15625. name: string;
  15626. private static _tmpVecs;
  15627. private static _tmpQuat;
  15628. private static _tmpMats;
  15629. /**
  15630. * Gets the list of child bones
  15631. */
  15632. children: Bone[];
  15633. /** Gets the animations associated with this bone */
  15634. animations: import("babylonjs/Animations/animation").Animation[];
  15635. /**
  15636. * Gets or sets bone length
  15637. */
  15638. length: number;
  15639. /**
  15640. * @hidden Internal only
  15641. * Set this value to map this bone to a different index in the transform matrices
  15642. * Set this value to -1 to exclude the bone from the transform matrices
  15643. */
  15644. _index: Nullable<number>;
  15645. private _skeleton;
  15646. private _localMatrix;
  15647. private _restPose;
  15648. private _bindPose;
  15649. private _baseMatrix;
  15650. private _absoluteTransform;
  15651. private _invertedAbsoluteTransform;
  15652. private _parent;
  15653. private _scalingDeterminant;
  15654. private _worldTransform;
  15655. private _localScaling;
  15656. private _localRotation;
  15657. private _localPosition;
  15658. private _needToDecompose;
  15659. private _needToCompose;
  15660. /** @hidden */
  15661. _linkedTransformNode: Nullable<TransformNode>;
  15662. /** @hidden */
  15663. _waitingTransformNodeId: Nullable<string>;
  15664. /** @hidden */
  15665. get _matrix(): Matrix;
  15666. /** @hidden */
  15667. set _matrix(value: Matrix);
  15668. /**
  15669. * Create a new bone
  15670. * @param name defines the bone name
  15671. * @param skeleton defines the parent skeleton
  15672. * @param parentBone defines the parent (can be null if the bone is the root)
  15673. * @param localMatrix defines the local matrix
  15674. * @param restPose defines the rest pose matrix
  15675. * @param baseMatrix defines the base matrix
  15676. * @param index defines index of the bone in the hiearchy
  15677. */
  15678. constructor(
  15679. /**
  15680. * defines the bone name
  15681. */
  15682. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15683. /**
  15684. * Gets the current object class name.
  15685. * @return the class name
  15686. */
  15687. getClassName(): string;
  15688. /**
  15689. * Gets the parent skeleton
  15690. * @returns a skeleton
  15691. */
  15692. getSkeleton(): Skeleton;
  15693. /**
  15694. * Gets parent bone
  15695. * @returns a bone or null if the bone is the root of the bone hierarchy
  15696. */
  15697. getParent(): Nullable<Bone>;
  15698. /**
  15699. * Returns an array containing the root bones
  15700. * @returns an array containing the root bones
  15701. */
  15702. getChildren(): Array<Bone>;
  15703. /**
  15704. * Gets the node index in matrix array generated for rendering
  15705. * @returns the node index
  15706. */
  15707. getIndex(): number;
  15708. /**
  15709. * Sets the parent bone
  15710. * @param parent defines the parent (can be null if the bone is the root)
  15711. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15712. */
  15713. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15714. /**
  15715. * Gets the local matrix
  15716. * @returns a matrix
  15717. */
  15718. getLocalMatrix(): Matrix;
  15719. /**
  15720. * Gets the base matrix (initial matrix which remains unchanged)
  15721. * @returns a matrix
  15722. */
  15723. getBaseMatrix(): Matrix;
  15724. /**
  15725. * Gets the rest pose matrix
  15726. * @returns a matrix
  15727. */
  15728. getRestPose(): Matrix;
  15729. /**
  15730. * Sets the rest pose matrix
  15731. * @param matrix the local-space rest pose to set for this bone
  15732. */
  15733. setRestPose(matrix: Matrix): void;
  15734. /**
  15735. * Gets the bind pose matrix
  15736. * @returns the bind pose matrix
  15737. */
  15738. getBindPose(): Matrix;
  15739. /**
  15740. * Sets the bind pose matrix
  15741. * @param matrix the local-space bind pose to set for this bone
  15742. */
  15743. setBindPose(matrix: Matrix): void;
  15744. /**
  15745. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15746. */
  15747. getWorldMatrix(): Matrix;
  15748. /**
  15749. * Sets the local matrix to rest pose matrix
  15750. */
  15751. returnToRest(): void;
  15752. /**
  15753. * Gets the inverse of the absolute transform matrix.
  15754. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15755. * @returns a matrix
  15756. */
  15757. getInvertedAbsoluteTransform(): Matrix;
  15758. /**
  15759. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15760. * @returns a matrix
  15761. */
  15762. getAbsoluteTransform(): Matrix;
  15763. /**
  15764. * Links with the given transform node.
  15765. * The local matrix of this bone is copied from the transform node every frame.
  15766. * @param transformNode defines the transform node to link to
  15767. */
  15768. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15769. /**
  15770. * Gets the node used to drive the bone's transformation
  15771. * @returns a transform node or null
  15772. */
  15773. getTransformNode(): Nullable<TransformNode>;
  15774. /** Gets or sets current position (in local space) */
  15775. get position(): Vector3;
  15776. set position(newPosition: Vector3);
  15777. /** Gets or sets current rotation (in local space) */
  15778. get rotation(): Vector3;
  15779. set rotation(newRotation: Vector3);
  15780. /** Gets or sets current rotation quaternion (in local space) */
  15781. get rotationQuaternion(): Quaternion;
  15782. set rotationQuaternion(newRotation: Quaternion);
  15783. /** Gets or sets current scaling (in local space) */
  15784. get scaling(): Vector3;
  15785. set scaling(newScaling: Vector3);
  15786. /**
  15787. * Gets the animation properties override
  15788. */
  15789. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15790. private _decompose;
  15791. private _compose;
  15792. /**
  15793. * Update the base and local matrices
  15794. * @param matrix defines the new base or local matrix
  15795. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15796. * @param updateLocalMatrix defines if the local matrix should be updated
  15797. */
  15798. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15799. /** @hidden */
  15800. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15801. /**
  15802. * Flag the bone as dirty (Forcing it to update everything)
  15803. */
  15804. markAsDirty(): void;
  15805. /** @hidden */
  15806. _markAsDirtyAndCompose(): void;
  15807. private _markAsDirtyAndDecompose;
  15808. /**
  15809. * Translate the bone in local or world space
  15810. * @param vec The amount to translate the bone
  15811. * @param space The space that the translation is in
  15812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15813. */
  15814. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15815. /**
  15816. * Set the postion of the bone in local or world space
  15817. * @param position The position to set the bone
  15818. * @param space The space that the position is in
  15819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15820. */
  15821. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15822. /**
  15823. * Set the absolute position of the bone (world space)
  15824. * @param position The position to set the bone
  15825. * @param mesh The mesh that this bone is attached to
  15826. */
  15827. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15828. /**
  15829. * Scale the bone on the x, y and z axes (in local space)
  15830. * @param x The amount to scale the bone on the x axis
  15831. * @param y The amount to scale the bone on the y axis
  15832. * @param z The amount to scale the bone on the z axis
  15833. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15834. */
  15835. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15836. /**
  15837. * Set the bone scaling in local space
  15838. * @param scale defines the scaling vector
  15839. */
  15840. setScale(scale: Vector3): void;
  15841. /**
  15842. * Gets the current scaling in local space
  15843. * @returns the current scaling vector
  15844. */
  15845. getScale(): Vector3;
  15846. /**
  15847. * Gets the current scaling in local space and stores it in a target vector
  15848. * @param result defines the target vector
  15849. */
  15850. getScaleToRef(result: Vector3): void;
  15851. /**
  15852. * Set the yaw, pitch, and roll of the bone in local or world space
  15853. * @param yaw The rotation of the bone on the y axis
  15854. * @param pitch The rotation of the bone on the x axis
  15855. * @param roll The rotation of the bone on the z axis
  15856. * @param space The space that the axes of rotation are in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. */
  15859. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15860. /**
  15861. * Add a rotation to the bone on an axis in local or world space
  15862. * @param axis The axis to rotate the bone on
  15863. * @param amount The amount to rotate the bone
  15864. * @param space The space that the axis is in
  15865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15866. */
  15867. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15868. /**
  15869. * Set the rotation of the bone to a particular axis angle in local or world space
  15870. * @param axis The axis to rotate the bone on
  15871. * @param angle The angle that the bone should be rotated to
  15872. * @param space The space that the axis is in
  15873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15874. */
  15875. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15876. /**
  15877. * Set the euler rotation of the bone in local or world space
  15878. * @param rotation The euler rotation that the bone should be set to
  15879. * @param space The space that the rotation is in
  15880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15881. */
  15882. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15883. /**
  15884. * Set the quaternion rotation of the bone in local or world space
  15885. * @param quat The quaternion rotation that the bone should be set to
  15886. * @param space The space that the rotation is in
  15887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15888. */
  15889. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15890. /**
  15891. * Set the rotation matrix of the bone in local or world space
  15892. * @param rotMat The rotation matrix that the bone should be set to
  15893. * @param space The space that the rotation is in
  15894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15895. */
  15896. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15897. private _rotateWithMatrix;
  15898. private _getNegativeRotationToRef;
  15899. /**
  15900. * Get the position of the bone in local or world space
  15901. * @param space The space that the returned position is in
  15902. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15903. * @returns The position of the bone
  15904. */
  15905. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15906. /**
  15907. * Copy the position of the bone to a vector3 in local or world space
  15908. * @param space The space that the returned position is in
  15909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15910. * @param result The vector3 to copy the position to
  15911. */
  15912. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15913. /**
  15914. * Get the absolute position of the bone (world space)
  15915. * @param mesh The mesh that this bone is attached to
  15916. * @returns The absolute position of the bone
  15917. */
  15918. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15919. /**
  15920. * Copy the absolute position of the bone (world space) to the result param
  15921. * @param mesh The mesh that this bone is attached to
  15922. * @param result The vector3 to copy the absolute position to
  15923. */
  15924. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15925. /**
  15926. * Compute the absolute transforms of this bone and its children
  15927. */
  15928. computeAbsoluteTransforms(): void;
  15929. /**
  15930. * Get the world direction from an axis that is in the local space of the bone
  15931. * @param localAxis The local direction that is used to compute the world direction
  15932. * @param mesh The mesh that this bone is attached to
  15933. * @returns The world direction
  15934. */
  15935. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15936. /**
  15937. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15938. * @param localAxis The local direction that is used to compute the world direction
  15939. * @param mesh The mesh that this bone is attached to
  15940. * @param result The vector3 that the world direction will be copied to
  15941. */
  15942. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15943. /**
  15944. * Get the euler rotation of the bone in local or world space
  15945. * @param space The space that the rotation should be in
  15946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15947. * @returns The euler rotation
  15948. */
  15949. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15950. /**
  15951. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15952. * @param space The space that the rotation should be in
  15953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15954. * @param result The vector3 that the rotation should be copied to
  15955. */
  15956. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15957. /**
  15958. * Get the quaternion rotation of the bone in either local or world space
  15959. * @param space The space that the rotation should be in
  15960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15961. * @returns The quaternion rotation
  15962. */
  15963. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15964. /**
  15965. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15966. * @param space The space that the rotation should be in
  15967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15968. * @param result The quaternion that the rotation should be copied to
  15969. */
  15970. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15971. /**
  15972. * Get the rotation matrix of the bone in local or world space
  15973. * @param space The space that the rotation should be in
  15974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15975. * @returns The rotation matrix
  15976. */
  15977. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15978. /**
  15979. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15980. * @param space The space that the rotation should be in
  15981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15982. * @param result The quaternion that the rotation should be copied to
  15983. */
  15984. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15985. /**
  15986. * Get the world position of a point that is in the local space of the bone
  15987. * @param position The local position
  15988. * @param mesh The mesh that this bone is attached to
  15989. * @returns The world position
  15990. */
  15991. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15992. /**
  15993. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15994. * @param position The local position
  15995. * @param mesh The mesh that this bone is attached to
  15996. * @param result The vector3 that the world position should be copied to
  15997. */
  15998. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15999. /**
  16000. * Get the local position of a point that is in world space
  16001. * @param position The world position
  16002. * @param mesh The mesh that this bone is attached to
  16003. * @returns The local position
  16004. */
  16005. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16006. /**
  16007. * Get the local position of a point that is in world space and copy it to the result param
  16008. * @param position The world position
  16009. * @param mesh The mesh that this bone is attached to
  16010. * @param result The vector3 that the local position should be copied to
  16011. */
  16012. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16013. /**
  16014. * Set the current local matrix as the restPose for this bone.
  16015. */
  16016. setCurrentPoseAsRest(): void;
  16017. }
  16018. }
  16019. declare module "babylonjs/Animations/runtimeAnimation" {
  16020. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16021. import { Animatable } from "babylonjs/Animations/animatable";
  16022. import { Scene } from "babylonjs/scene";
  16023. /**
  16024. * Defines a runtime animation
  16025. */
  16026. export class RuntimeAnimation {
  16027. private _events;
  16028. /**
  16029. * The current frame of the runtime animation
  16030. */
  16031. private _currentFrame;
  16032. /**
  16033. * The animation used by the runtime animation
  16034. */
  16035. private _animation;
  16036. /**
  16037. * The target of the runtime animation
  16038. */
  16039. private _target;
  16040. /**
  16041. * The initiating animatable
  16042. */
  16043. private _host;
  16044. /**
  16045. * The original value of the runtime animation
  16046. */
  16047. private _originalValue;
  16048. /**
  16049. * The original blend value of the runtime animation
  16050. */
  16051. private _originalBlendValue;
  16052. /**
  16053. * The offsets cache of the runtime animation
  16054. */
  16055. private _offsetsCache;
  16056. /**
  16057. * The high limits cache of the runtime animation
  16058. */
  16059. private _highLimitsCache;
  16060. /**
  16061. * Specifies if the runtime animation has been stopped
  16062. */
  16063. private _stopped;
  16064. /**
  16065. * The blending factor of the runtime animation
  16066. */
  16067. private _blendingFactor;
  16068. /**
  16069. * The BabylonJS scene
  16070. */
  16071. private _scene;
  16072. /**
  16073. * The current value of the runtime animation
  16074. */
  16075. private _currentValue;
  16076. /** @hidden */
  16077. _animationState: _IAnimationState;
  16078. /**
  16079. * The active target of the runtime animation
  16080. */
  16081. private _activeTargets;
  16082. private _currentActiveTarget;
  16083. private _directTarget;
  16084. /**
  16085. * The target path of the runtime animation
  16086. */
  16087. private _targetPath;
  16088. /**
  16089. * The weight of the runtime animation
  16090. */
  16091. private _weight;
  16092. /**
  16093. * The ratio offset of the runtime animation
  16094. */
  16095. private _ratioOffset;
  16096. /**
  16097. * The previous delay of the runtime animation
  16098. */
  16099. private _previousDelay;
  16100. /**
  16101. * The previous ratio of the runtime animation
  16102. */
  16103. private _previousRatio;
  16104. private _enableBlending;
  16105. private _keys;
  16106. private _minFrame;
  16107. private _maxFrame;
  16108. private _minValue;
  16109. private _maxValue;
  16110. private _targetIsArray;
  16111. /**
  16112. * Gets the current frame of the runtime animation
  16113. */
  16114. get currentFrame(): number;
  16115. /**
  16116. * Gets the weight of the runtime animation
  16117. */
  16118. get weight(): number;
  16119. /**
  16120. * Gets the current value of the runtime animation
  16121. */
  16122. get currentValue(): any;
  16123. /**
  16124. * Gets the target path of the runtime animation
  16125. */
  16126. get targetPath(): string;
  16127. /**
  16128. * Gets the actual target of the runtime animation
  16129. */
  16130. get target(): any;
  16131. /**
  16132. * Gets the additive state of the runtime animation
  16133. */
  16134. get isAdditive(): boolean;
  16135. /** @hidden */
  16136. _onLoop: () => void;
  16137. /**
  16138. * Create a new RuntimeAnimation object
  16139. * @param target defines the target of the animation
  16140. * @param animation defines the source animation object
  16141. * @param scene defines the hosting scene
  16142. * @param host defines the initiating Animatable
  16143. */
  16144. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16145. private _preparePath;
  16146. /**
  16147. * Gets the animation from the runtime animation
  16148. */
  16149. get animation(): Animation;
  16150. /**
  16151. * Resets the runtime animation to the beginning
  16152. * @param restoreOriginal defines whether to restore the target property to the original value
  16153. */
  16154. reset(restoreOriginal?: boolean): void;
  16155. /**
  16156. * Specifies if the runtime animation is stopped
  16157. * @returns Boolean specifying if the runtime animation is stopped
  16158. */
  16159. isStopped(): boolean;
  16160. /**
  16161. * Disposes of the runtime animation
  16162. */
  16163. dispose(): void;
  16164. /**
  16165. * Apply the interpolated value to the target
  16166. * @param currentValue defines the value computed by the animation
  16167. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16168. */
  16169. setValue(currentValue: any, weight: number): void;
  16170. private _getOriginalValues;
  16171. private _setValue;
  16172. /**
  16173. * Gets the loop pmode of the runtime animation
  16174. * @returns Loop Mode
  16175. */
  16176. private _getCorrectLoopMode;
  16177. /**
  16178. * Move the current animation to a given frame
  16179. * @param frame defines the frame to move to
  16180. */
  16181. goToFrame(frame: number): void;
  16182. /**
  16183. * @hidden Internal use only
  16184. */
  16185. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16186. /**
  16187. * Execute the current animation
  16188. * @param delay defines the delay to add to the current frame
  16189. * @param from defines the lower bound of the animation range
  16190. * @param to defines the upper bound of the animation range
  16191. * @param loop defines if the current animation must loop
  16192. * @param speedRatio defines the current speed ratio
  16193. * @param weight defines the weight of the animation (default is -1 so no weight)
  16194. * @param onLoop optional callback called when animation loops
  16195. * @returns a boolean indicating if the animation is running
  16196. */
  16197. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16198. }
  16199. }
  16200. declare module "babylonjs/Animations/animatable" {
  16201. import { Animation } from "babylonjs/Animations/animation";
  16202. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16203. import { Nullable } from "babylonjs/types";
  16204. import { Observable } from "babylonjs/Misc/observable";
  16205. import { Scene } from "babylonjs/scene";
  16206. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16207. import { Node } from "babylonjs/node";
  16208. /**
  16209. * Class used to store an actual running animation
  16210. */
  16211. export class Animatable {
  16212. /** defines the target object */
  16213. target: any;
  16214. /** defines the starting frame number (default is 0) */
  16215. fromFrame: number;
  16216. /** defines the ending frame number (default is 100) */
  16217. toFrame: number;
  16218. /** defines if the animation must loop (default is false) */
  16219. loopAnimation: boolean;
  16220. /** defines a callback to call when animation ends if it is not looping */
  16221. onAnimationEnd?: (() => void) | null | undefined;
  16222. /** defines a callback to call when animation loops */
  16223. onAnimationLoop?: (() => void) | null | undefined;
  16224. /** defines whether the animation should be evaluated additively */
  16225. isAdditive: boolean;
  16226. private _localDelayOffset;
  16227. private _pausedDelay;
  16228. private _runtimeAnimations;
  16229. private _paused;
  16230. private _scene;
  16231. private _speedRatio;
  16232. private _weight;
  16233. private _syncRoot;
  16234. /**
  16235. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16236. * This will only apply for non looping animation (default is true)
  16237. */
  16238. disposeOnEnd: boolean;
  16239. /**
  16240. * Gets a boolean indicating if the animation has started
  16241. */
  16242. animationStarted: boolean;
  16243. /**
  16244. * Observer raised when the animation ends
  16245. */
  16246. onAnimationEndObservable: Observable<Animatable>;
  16247. /**
  16248. * Observer raised when the animation loops
  16249. */
  16250. onAnimationLoopObservable: Observable<Animatable>;
  16251. /**
  16252. * Gets the root Animatable used to synchronize and normalize animations
  16253. */
  16254. get syncRoot(): Nullable<Animatable>;
  16255. /**
  16256. * Gets the current frame of the first RuntimeAnimation
  16257. * Used to synchronize Animatables
  16258. */
  16259. get masterFrame(): number;
  16260. /**
  16261. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16262. */
  16263. get weight(): number;
  16264. set weight(value: number);
  16265. /**
  16266. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16267. */
  16268. get speedRatio(): number;
  16269. set speedRatio(value: number);
  16270. /**
  16271. * Creates a new Animatable
  16272. * @param scene defines the hosting scene
  16273. * @param target defines the target object
  16274. * @param fromFrame defines the starting frame number (default is 0)
  16275. * @param toFrame defines the ending frame number (default is 100)
  16276. * @param loopAnimation defines if the animation must loop (default is false)
  16277. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16278. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16279. * @param animations defines a group of animation to add to the new Animatable
  16280. * @param onAnimationLoop defines a callback to call when animation loops
  16281. * @param isAdditive defines whether the animation should be evaluated additively
  16282. */
  16283. constructor(scene: Scene,
  16284. /** defines the target object */
  16285. target: any,
  16286. /** defines the starting frame number (default is 0) */
  16287. fromFrame?: number,
  16288. /** defines the ending frame number (default is 100) */
  16289. toFrame?: number,
  16290. /** defines if the animation must loop (default is false) */
  16291. loopAnimation?: boolean, speedRatio?: number,
  16292. /** defines a callback to call when animation ends if it is not looping */
  16293. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16294. /** defines a callback to call when animation loops */
  16295. onAnimationLoop?: (() => void) | null | undefined,
  16296. /** defines whether the animation should be evaluated additively */
  16297. isAdditive?: boolean);
  16298. /**
  16299. * Synchronize and normalize current Animatable with a source Animatable
  16300. * This is useful when using animation weights and when animations are not of the same length
  16301. * @param root defines the root Animatable to synchronize with
  16302. * @returns the current Animatable
  16303. */
  16304. syncWith(root: Animatable): Animatable;
  16305. /**
  16306. * Gets the list of runtime animations
  16307. * @returns an array of RuntimeAnimation
  16308. */
  16309. getAnimations(): RuntimeAnimation[];
  16310. /**
  16311. * Adds more animations to the current animatable
  16312. * @param target defines the target of the animations
  16313. * @param animations defines the new animations to add
  16314. */
  16315. appendAnimations(target: any, animations: Animation[]): void;
  16316. /**
  16317. * Gets the source animation for a specific property
  16318. * @param property defines the propertyu to look for
  16319. * @returns null or the source animation for the given property
  16320. */
  16321. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16322. /**
  16323. * Gets the runtime animation for a specific property
  16324. * @param property defines the propertyu to look for
  16325. * @returns null or the runtime animation for the given property
  16326. */
  16327. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16328. /**
  16329. * Resets the animatable to its original state
  16330. */
  16331. reset(): void;
  16332. /**
  16333. * Allows the animatable to blend with current running animations
  16334. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16335. * @param blendingSpeed defines the blending speed to use
  16336. */
  16337. enableBlending(blendingSpeed: number): void;
  16338. /**
  16339. * Disable animation blending
  16340. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16341. */
  16342. disableBlending(): void;
  16343. /**
  16344. * Jump directly to a given frame
  16345. * @param frame defines the frame to jump to
  16346. */
  16347. goToFrame(frame: number): void;
  16348. /**
  16349. * Pause the animation
  16350. */
  16351. pause(): void;
  16352. /**
  16353. * Restart the animation
  16354. */
  16355. restart(): void;
  16356. private _raiseOnAnimationEnd;
  16357. /**
  16358. * Stop and delete the current animation
  16359. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16360. * @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)
  16361. */
  16362. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16363. /**
  16364. * Wait asynchronously for the animation to end
  16365. * @returns a promise which will be fullfilled when the animation ends
  16366. */
  16367. waitAsync(): Promise<Animatable>;
  16368. /** @hidden */
  16369. _animate(delay: number): boolean;
  16370. }
  16371. module "babylonjs/scene" {
  16372. interface Scene {
  16373. /** @hidden */
  16374. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16375. /** @hidden */
  16376. _processLateAnimationBindingsForMatrices(holder: {
  16377. totalWeight: number;
  16378. totalAdditiveWeight: number;
  16379. animations: RuntimeAnimation[];
  16380. additiveAnimations: RuntimeAnimation[];
  16381. originalValue: Matrix;
  16382. }): any;
  16383. /** @hidden */
  16384. _processLateAnimationBindingsForQuaternions(holder: {
  16385. totalWeight: number;
  16386. totalAdditiveWeight: number;
  16387. animations: RuntimeAnimation[];
  16388. additiveAnimations: RuntimeAnimation[];
  16389. originalValue: Quaternion;
  16390. }, refQuaternion: Quaternion): Quaternion;
  16391. /** @hidden */
  16392. _processLateAnimationBindings(): void;
  16393. /**
  16394. * Will start the animation sequence of a given target
  16395. * @param target defines the target
  16396. * @param from defines from which frame should animation start
  16397. * @param to defines until which frame should animation run.
  16398. * @param weight defines the weight to apply to the animation (1.0 by default)
  16399. * @param loop defines if the animation loops
  16400. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16401. * @param onAnimationEnd defines the function to be executed when the animation ends
  16402. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16403. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16404. * @param onAnimationLoop defines the callback to call when an animation loops
  16405. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16406. * @returns the animatable object created for this animation
  16407. */
  16408. 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;
  16409. /**
  16410. * Will start the animation sequence of a given target
  16411. * @param target defines the target
  16412. * @param from defines from which frame should animation start
  16413. * @param to defines until which frame should animation run.
  16414. * @param loop defines if the animation loops
  16415. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16416. * @param onAnimationEnd defines the function to be executed when the animation ends
  16417. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16418. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16419. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16420. * @param onAnimationLoop defines the callback to call when an animation loops
  16421. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16422. * @returns the animatable object created for this animation
  16423. */
  16424. 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;
  16425. /**
  16426. * Will start the animation sequence of a given target and its hierarchy
  16427. * @param target defines the target
  16428. * @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.
  16429. * @param from defines from which frame should animation start
  16430. * @param to defines until which frame should animation run.
  16431. * @param loop defines if the animation loops
  16432. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16433. * @param onAnimationEnd defines the function to be executed when the animation ends
  16434. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16435. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16436. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16437. * @param onAnimationLoop defines the callback to call when an animation loops
  16438. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16439. * @returns the list of created animatables
  16440. */
  16441. 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[];
  16442. /**
  16443. * Begin a new animation on a given node
  16444. * @param target defines the target where the animation will take place
  16445. * @param animations defines the list of animations to start
  16446. * @param from defines the initial value
  16447. * @param to defines the final value
  16448. * @param loop defines if you want animation to loop (off by default)
  16449. * @param speedRatio defines the speed ratio to apply to all animations
  16450. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16451. * @param onAnimationLoop defines the callback to call when an animation loops
  16452. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16453. * @returns the list of created animatables
  16454. */
  16455. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16456. /**
  16457. * Begin a new animation on a given node and its hierarchy
  16458. * @param target defines the root node where the animation will take place
  16459. * @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.
  16460. * @param animations defines the list of animations to start
  16461. * @param from defines the initial value
  16462. * @param to defines the final value
  16463. * @param loop defines if you want animation to loop (off by default)
  16464. * @param speedRatio defines the speed ratio to apply to all animations
  16465. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16466. * @param onAnimationLoop defines the callback to call when an animation loops
  16467. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16468. * @returns the list of animatables created for all nodes
  16469. */
  16470. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16471. /**
  16472. * Gets the animatable associated with a specific target
  16473. * @param target defines the target of the animatable
  16474. * @returns the required animatable if found
  16475. */
  16476. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16477. /**
  16478. * Gets all animatables associated with a given target
  16479. * @param target defines the target to look animatables for
  16480. * @returns an array of Animatables
  16481. */
  16482. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16483. /**
  16484. * Stops and removes all animations that have been applied to the scene
  16485. */
  16486. stopAllAnimations(): void;
  16487. /**
  16488. * Gets the current delta time used by animation engine
  16489. */
  16490. deltaTime: number;
  16491. }
  16492. }
  16493. module "babylonjs/Bones/bone" {
  16494. interface Bone {
  16495. /**
  16496. * Copy an animation range from another bone
  16497. * @param source defines the source bone
  16498. * @param rangeName defines the range name to copy
  16499. * @param frameOffset defines the frame offset
  16500. * @param rescaleAsRequired defines if rescaling must be applied if required
  16501. * @param skelDimensionsRatio defines the scaling ratio
  16502. * @returns true if operation was successful
  16503. */
  16504. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16505. }
  16506. }
  16507. }
  16508. declare module "babylonjs/Bones/skeleton" {
  16509. import { Bone } from "babylonjs/Bones/bone";
  16510. import { Observable } from "babylonjs/Misc/observable";
  16511. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16512. import { Scene } from "babylonjs/scene";
  16513. import { Nullable } from "babylonjs/types";
  16514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16515. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16516. import { Animatable } from "babylonjs/Animations/animatable";
  16517. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16518. import { Animation } from "babylonjs/Animations/animation";
  16519. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16520. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16521. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16522. /**
  16523. * Class used to handle skinning animations
  16524. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16525. */
  16526. export class Skeleton implements IAnimatable {
  16527. /** defines the skeleton name */
  16528. name: string;
  16529. /** defines the skeleton Id */
  16530. id: string;
  16531. /**
  16532. * Defines the list of child bones
  16533. */
  16534. bones: Bone[];
  16535. /**
  16536. * Defines an estimate of the dimension of the skeleton at rest
  16537. */
  16538. dimensionsAtRest: Vector3;
  16539. /**
  16540. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16541. */
  16542. needInitialSkinMatrix: boolean;
  16543. /**
  16544. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16545. */
  16546. overrideMesh: Nullable<AbstractMesh>;
  16547. /**
  16548. * Gets the list of animations attached to this skeleton
  16549. */
  16550. animations: Array<Animation>;
  16551. private _scene;
  16552. private _isDirty;
  16553. private _transformMatrices;
  16554. private _transformMatrixTexture;
  16555. private _meshesWithPoseMatrix;
  16556. private _animatables;
  16557. private _identity;
  16558. private _synchronizedWithMesh;
  16559. private _ranges;
  16560. private _lastAbsoluteTransformsUpdateId;
  16561. private _canUseTextureForBones;
  16562. private _uniqueId;
  16563. /** @hidden */
  16564. _numBonesWithLinkedTransformNode: number;
  16565. /** @hidden */
  16566. _hasWaitingData: Nullable<boolean>;
  16567. /** @hidden */
  16568. _waitingOverrideMeshId: Nullable<string>;
  16569. /**
  16570. * Specifies if the skeleton should be serialized
  16571. */
  16572. doNotSerialize: boolean;
  16573. private _useTextureToStoreBoneMatrices;
  16574. /**
  16575. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16576. * Please note that this option is not available if the hardware does not support it
  16577. */
  16578. get useTextureToStoreBoneMatrices(): boolean;
  16579. set useTextureToStoreBoneMatrices(value: boolean);
  16580. private _animationPropertiesOverride;
  16581. /**
  16582. * Gets or sets the animation properties override
  16583. */
  16584. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16585. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16586. /**
  16587. * List of inspectable custom properties (used by the Inspector)
  16588. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16589. */
  16590. inspectableCustomProperties: IInspectable[];
  16591. /**
  16592. * An observable triggered before computing the skeleton's matrices
  16593. */
  16594. onBeforeComputeObservable: Observable<Skeleton>;
  16595. /**
  16596. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16597. */
  16598. get isUsingTextureForMatrices(): boolean;
  16599. /**
  16600. * Gets the unique ID of this skeleton
  16601. */
  16602. get uniqueId(): number;
  16603. /**
  16604. * Creates a new skeleton
  16605. * @param name defines the skeleton name
  16606. * @param id defines the skeleton Id
  16607. * @param scene defines the hosting scene
  16608. */
  16609. constructor(
  16610. /** defines the skeleton name */
  16611. name: string,
  16612. /** defines the skeleton Id */
  16613. id: string, scene: Scene);
  16614. /**
  16615. * Gets the current object class name.
  16616. * @return the class name
  16617. */
  16618. getClassName(): string;
  16619. /**
  16620. * Returns an array containing the root bones
  16621. * @returns an array containing the root bones
  16622. */
  16623. getChildren(): Array<Bone>;
  16624. /**
  16625. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16626. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16627. * @returns a Float32Array containing matrices data
  16628. */
  16629. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16630. /**
  16631. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16632. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16633. * @returns a raw texture containing the data
  16634. */
  16635. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16636. /**
  16637. * Gets the current hosting scene
  16638. * @returns a scene object
  16639. */
  16640. getScene(): Scene;
  16641. /**
  16642. * Gets a string representing the current skeleton data
  16643. * @param fullDetails defines a boolean indicating if we want a verbose version
  16644. * @returns a string representing the current skeleton data
  16645. */
  16646. toString(fullDetails?: boolean): string;
  16647. /**
  16648. * Get bone's index searching by name
  16649. * @param name defines bone's name to search for
  16650. * @return the indice of the bone. Returns -1 if not found
  16651. */
  16652. getBoneIndexByName(name: string): number;
  16653. /**
  16654. * Creater a new animation range
  16655. * @param name defines the name of the range
  16656. * @param from defines the start key
  16657. * @param to defines the end key
  16658. */
  16659. createAnimationRange(name: string, from: number, to: number): void;
  16660. /**
  16661. * Delete a specific animation range
  16662. * @param name defines the name of the range
  16663. * @param deleteFrames defines if frames must be removed as well
  16664. */
  16665. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16666. /**
  16667. * Gets a specific animation range
  16668. * @param name defines the name of the range to look for
  16669. * @returns the requested animation range or null if not found
  16670. */
  16671. getAnimationRange(name: string): Nullable<AnimationRange>;
  16672. /**
  16673. * Gets the list of all animation ranges defined on this skeleton
  16674. * @returns an array
  16675. */
  16676. getAnimationRanges(): Nullable<AnimationRange>[];
  16677. /**
  16678. * Copy animation range from a source skeleton.
  16679. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16680. * @param source defines the source skeleton
  16681. * @param name defines the name of the range to copy
  16682. * @param rescaleAsRequired defines if rescaling must be applied if required
  16683. * @returns true if operation was successful
  16684. */
  16685. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16686. /**
  16687. * Forces the skeleton to go to rest pose
  16688. */
  16689. returnToRest(): void;
  16690. private _getHighestAnimationFrame;
  16691. /**
  16692. * Begin a specific animation range
  16693. * @param name defines the name of the range to start
  16694. * @param loop defines if looping must be turned on (false by default)
  16695. * @param speedRatio defines the speed ratio to apply (1 by default)
  16696. * @param onAnimationEnd defines a callback which will be called when animation will end
  16697. * @returns a new animatable
  16698. */
  16699. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16700. /**
  16701. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16702. * @param skeleton defines the Skeleton containing the animation range to convert
  16703. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16704. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16705. * @returns the original skeleton
  16706. */
  16707. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16708. /** @hidden */
  16709. _markAsDirty(): void;
  16710. /** @hidden */
  16711. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16712. /** @hidden */
  16713. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16714. private _computeTransformMatrices;
  16715. /**
  16716. * Build all resources required to render a skeleton
  16717. */
  16718. prepare(): void;
  16719. /**
  16720. * Gets the list of animatables currently running for this skeleton
  16721. * @returns an array of animatables
  16722. */
  16723. getAnimatables(): IAnimatable[];
  16724. /**
  16725. * Clone the current skeleton
  16726. * @param name defines the name of the new skeleton
  16727. * @param id defines the id of the new skeleton
  16728. * @returns the new skeleton
  16729. */
  16730. clone(name: string, id?: string): Skeleton;
  16731. /**
  16732. * Enable animation blending for this skeleton
  16733. * @param blendingSpeed defines the blending speed to apply
  16734. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16735. */
  16736. enableBlending(blendingSpeed?: number): void;
  16737. /**
  16738. * Releases all resources associated with the current skeleton
  16739. */
  16740. dispose(): void;
  16741. /**
  16742. * Serialize the skeleton in a JSON object
  16743. * @returns a JSON object
  16744. */
  16745. serialize(): any;
  16746. /**
  16747. * Creates a new skeleton from serialized data
  16748. * @param parsedSkeleton defines the serialized data
  16749. * @param scene defines the hosting scene
  16750. * @returns a new skeleton
  16751. */
  16752. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16753. /**
  16754. * Compute all node absolute transforms
  16755. * @param forceUpdate defines if computation must be done even if cache is up to date
  16756. */
  16757. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16758. /**
  16759. * Gets the root pose matrix
  16760. * @returns a matrix
  16761. */
  16762. getPoseMatrix(): Nullable<Matrix>;
  16763. /**
  16764. * Sorts bones per internal index
  16765. */
  16766. sortBones(): void;
  16767. private _sortBones;
  16768. /**
  16769. * Set the current local matrix as the restPose for all bones in the skeleton.
  16770. */
  16771. setCurrentPoseAsRest(): void;
  16772. }
  16773. }
  16774. declare module "babylonjs/Meshes/instancedMesh" {
  16775. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16776. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16777. import { Camera } from "babylonjs/Cameras/camera";
  16778. import { Node } from "babylonjs/node";
  16779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16780. import { Mesh } from "babylonjs/Meshes/mesh";
  16781. import { Material } from "babylonjs/Materials/material";
  16782. import { Skeleton } from "babylonjs/Bones/skeleton";
  16783. import { Light } from "babylonjs/Lights/light";
  16784. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16785. /**
  16786. * Creates an instance based on a source mesh.
  16787. */
  16788. export class InstancedMesh extends AbstractMesh {
  16789. private _sourceMesh;
  16790. private _currentLOD;
  16791. /** @hidden */
  16792. _indexInSourceMeshInstanceArray: number;
  16793. constructor(name: string, source: Mesh);
  16794. /**
  16795. * Returns the string "InstancedMesh".
  16796. */
  16797. getClassName(): string;
  16798. /** Gets the list of lights affecting that mesh */
  16799. get lightSources(): Light[];
  16800. _resyncLightSources(): void;
  16801. _resyncLightSource(light: Light): void;
  16802. _removeLightSource(light: Light, dispose: boolean): void;
  16803. /**
  16804. * If the source mesh receives shadows
  16805. */
  16806. get receiveShadows(): boolean;
  16807. /**
  16808. * The material of the source mesh
  16809. */
  16810. get material(): Nullable<Material>;
  16811. /**
  16812. * Visibility of the source mesh
  16813. */
  16814. get visibility(): number;
  16815. /**
  16816. * Skeleton of the source mesh
  16817. */
  16818. get skeleton(): Nullable<Skeleton>;
  16819. /**
  16820. * Rendering ground id of the source mesh
  16821. */
  16822. get renderingGroupId(): number;
  16823. set renderingGroupId(value: number);
  16824. /**
  16825. * Returns the total number of vertices (integer).
  16826. */
  16827. getTotalVertices(): number;
  16828. /**
  16829. * Returns a positive integer : the total number of indices in this mesh geometry.
  16830. * @returns the numner of indices or zero if the mesh has no geometry.
  16831. */
  16832. getTotalIndices(): number;
  16833. /**
  16834. * The source mesh of the instance
  16835. */
  16836. get sourceMesh(): Mesh;
  16837. /**
  16838. * Creates a new InstancedMesh object from the mesh model.
  16839. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16840. * @param name defines the name of the new instance
  16841. * @returns a new InstancedMesh
  16842. */
  16843. createInstance(name: string): InstancedMesh;
  16844. /**
  16845. * Is this node ready to be used/rendered
  16846. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16847. * @return {boolean} is it ready
  16848. */
  16849. isReady(completeCheck?: boolean): boolean;
  16850. /**
  16851. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16852. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16853. * @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.
  16854. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16855. */
  16856. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16857. /**
  16858. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16859. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16860. * The `data` are either a numeric array either a Float32Array.
  16861. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16862. * 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).
  16863. * Note that a new underlying VertexBuffer object is created each call.
  16864. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16865. *
  16866. * Possible `kind` values :
  16867. * - VertexBuffer.PositionKind
  16868. * - VertexBuffer.UVKind
  16869. * - VertexBuffer.UV2Kind
  16870. * - VertexBuffer.UV3Kind
  16871. * - VertexBuffer.UV4Kind
  16872. * - VertexBuffer.UV5Kind
  16873. * - VertexBuffer.UV6Kind
  16874. * - VertexBuffer.ColorKind
  16875. * - VertexBuffer.MatricesIndicesKind
  16876. * - VertexBuffer.MatricesIndicesExtraKind
  16877. * - VertexBuffer.MatricesWeightsKind
  16878. * - VertexBuffer.MatricesWeightsExtraKind
  16879. *
  16880. * Returns the Mesh.
  16881. */
  16882. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16883. /**
  16884. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16885. * If the mesh has no geometry, it is simply returned as it is.
  16886. * The `data` are either a numeric array either a Float32Array.
  16887. * No new underlying VertexBuffer object is created.
  16888. * 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.
  16889. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16890. *
  16891. * Possible `kind` values :
  16892. * - VertexBuffer.PositionKind
  16893. * - VertexBuffer.UVKind
  16894. * - VertexBuffer.UV2Kind
  16895. * - VertexBuffer.UV3Kind
  16896. * - VertexBuffer.UV4Kind
  16897. * - VertexBuffer.UV5Kind
  16898. * - VertexBuffer.UV6Kind
  16899. * - VertexBuffer.ColorKind
  16900. * - VertexBuffer.MatricesIndicesKind
  16901. * - VertexBuffer.MatricesIndicesExtraKind
  16902. * - VertexBuffer.MatricesWeightsKind
  16903. * - VertexBuffer.MatricesWeightsExtraKind
  16904. *
  16905. * Returns the Mesh.
  16906. */
  16907. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16908. /**
  16909. * Sets the mesh indices.
  16910. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16911. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16912. * This method creates a new index buffer each call.
  16913. * Returns the Mesh.
  16914. */
  16915. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16916. /**
  16917. * Boolean : True if the mesh owns the requested kind of data.
  16918. */
  16919. isVerticesDataPresent(kind: string): boolean;
  16920. /**
  16921. * Returns an array of indices (IndicesArray).
  16922. */
  16923. getIndices(): Nullable<IndicesArray>;
  16924. get _positions(): Nullable<Vector3[]>;
  16925. /**
  16926. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16927. * This means the mesh underlying bounding box and sphere are recomputed.
  16928. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16929. * @returns the current mesh
  16930. */
  16931. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16932. /** @hidden */
  16933. _preActivate(): InstancedMesh;
  16934. /** @hidden */
  16935. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16936. /** @hidden */
  16937. _postActivate(): void;
  16938. getWorldMatrix(): Matrix;
  16939. get isAnInstance(): boolean;
  16940. /**
  16941. * Returns the current associated LOD AbstractMesh.
  16942. */
  16943. getLOD(camera: Camera): AbstractMesh;
  16944. /** @hidden */
  16945. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16946. /** @hidden */
  16947. _syncSubMeshes(): InstancedMesh;
  16948. /** @hidden */
  16949. _generatePointsArray(): boolean;
  16950. /** @hidden */
  16951. _updateBoundingInfo(): AbstractMesh;
  16952. /**
  16953. * Creates a new InstancedMesh from the current mesh.
  16954. * - name (string) : the cloned mesh name
  16955. * - newParent (optional Node) : the optional Node to parent the clone to.
  16956. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16957. *
  16958. * Returns the clone.
  16959. */
  16960. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16961. /**
  16962. * Disposes the InstancedMesh.
  16963. * Returns nothing.
  16964. */
  16965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16966. }
  16967. module "babylonjs/Meshes/mesh" {
  16968. interface Mesh {
  16969. /**
  16970. * Register a custom buffer that will be instanced
  16971. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16972. * @param kind defines the buffer kind
  16973. * @param stride defines the stride in floats
  16974. */
  16975. registerInstancedBuffer(kind: string, stride: number): void;
  16976. /**
  16977. * true to use the edge renderer for all instances of this mesh
  16978. */
  16979. edgesShareWithInstances: boolean;
  16980. /** @hidden */
  16981. _userInstancedBuffersStorage: {
  16982. data: {
  16983. [key: string]: Float32Array;
  16984. };
  16985. sizes: {
  16986. [key: string]: number;
  16987. };
  16988. vertexBuffers: {
  16989. [key: string]: Nullable<VertexBuffer>;
  16990. };
  16991. strides: {
  16992. [key: string]: number;
  16993. };
  16994. };
  16995. }
  16996. }
  16997. module "babylonjs/Meshes/abstractMesh" {
  16998. interface AbstractMesh {
  16999. /**
  17000. * Object used to store instanced buffers defined by user
  17001. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17002. */
  17003. instancedBuffers: {
  17004. [key: string]: any;
  17005. };
  17006. }
  17007. }
  17008. }
  17009. declare module "babylonjs/Materials/shaderMaterial" {
  17010. import { Nullable } from "babylonjs/types";
  17011. import { Scene } from "babylonjs/scene";
  17012. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17014. import { Mesh } from "babylonjs/Meshes/mesh";
  17015. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17017. import { Effect } from "babylonjs/Materials/effect";
  17018. import { Material } from "babylonjs/Materials/material";
  17019. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17020. /**
  17021. * Defines the options associated with the creation of a shader material.
  17022. */
  17023. export interface IShaderMaterialOptions {
  17024. /**
  17025. * Does the material work in alpha blend mode
  17026. */
  17027. needAlphaBlending: boolean;
  17028. /**
  17029. * Does the material work in alpha test mode
  17030. */
  17031. needAlphaTesting: boolean;
  17032. /**
  17033. * The list of attribute names used in the shader
  17034. */
  17035. attributes: string[];
  17036. /**
  17037. * The list of unifrom names used in the shader
  17038. */
  17039. uniforms: string[];
  17040. /**
  17041. * The list of UBO names used in the shader
  17042. */
  17043. uniformBuffers: string[];
  17044. /**
  17045. * The list of sampler names used in the shader
  17046. */
  17047. samplers: string[];
  17048. /**
  17049. * The list of defines used in the shader
  17050. */
  17051. defines: string[];
  17052. }
  17053. /**
  17054. * 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.
  17055. *
  17056. * This returned material effects how the mesh will look based on the code in the shaders.
  17057. *
  17058. * @see https://doc.babylonjs.com/how_to/shader_material
  17059. */
  17060. export class ShaderMaterial extends Material {
  17061. private _shaderPath;
  17062. private _options;
  17063. private _textures;
  17064. private _textureArrays;
  17065. private _floats;
  17066. private _ints;
  17067. private _floatsArrays;
  17068. private _colors3;
  17069. private _colors3Arrays;
  17070. private _colors4;
  17071. private _colors4Arrays;
  17072. private _vectors2;
  17073. private _vectors3;
  17074. private _vectors4;
  17075. private _matrices;
  17076. private _matrixArrays;
  17077. private _matrices3x3;
  17078. private _matrices2x2;
  17079. private _vectors2Arrays;
  17080. private _vectors3Arrays;
  17081. private _vectors4Arrays;
  17082. private _cachedWorldViewMatrix;
  17083. private _cachedWorldViewProjectionMatrix;
  17084. private _renderId;
  17085. private _multiview;
  17086. private _cachedDefines;
  17087. /** Define the Url to load snippets */
  17088. static SnippetUrl: string;
  17089. /** Snippet ID if the material was created from the snippet server */
  17090. snippetId: string;
  17091. /**
  17092. * Instantiate a new shader material.
  17093. * 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.
  17094. * This returned material effects how the mesh will look based on the code in the shaders.
  17095. * @see https://doc.babylonjs.com/how_to/shader_material
  17096. * @param name Define the name of the material in the scene
  17097. * @param scene Define the scene the material belongs to
  17098. * @param shaderPath Defines the route to the shader code in one of three ways:
  17099. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17100. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17101. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17102. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17103. * @param options Define the options used to create the shader
  17104. */
  17105. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17106. /**
  17107. * Gets the shader path used to define the shader code
  17108. * It can be modified to trigger a new compilation
  17109. */
  17110. get shaderPath(): any;
  17111. /**
  17112. * Sets the shader path used to define the shader code
  17113. * It can be modified to trigger a new compilation
  17114. */
  17115. set shaderPath(shaderPath: any);
  17116. /**
  17117. * Gets the options used to compile the shader.
  17118. * They can be modified to trigger a new compilation
  17119. */
  17120. get options(): IShaderMaterialOptions;
  17121. /**
  17122. * Gets the current class name of the material e.g. "ShaderMaterial"
  17123. * Mainly use in serialization.
  17124. * @returns the class name
  17125. */
  17126. getClassName(): string;
  17127. /**
  17128. * Specifies if the material will require alpha blending
  17129. * @returns a boolean specifying if alpha blending is needed
  17130. */
  17131. needAlphaBlending(): boolean;
  17132. /**
  17133. * Specifies if this material should be rendered in alpha test mode
  17134. * @returns a boolean specifying if an alpha test is needed.
  17135. */
  17136. needAlphaTesting(): boolean;
  17137. private _checkUniform;
  17138. /**
  17139. * Set a texture in the shader.
  17140. * @param name Define the name of the uniform samplers as defined in the shader
  17141. * @param texture Define the texture to bind to this sampler
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17145. /**
  17146. * Set a texture array in the shader.
  17147. * @param name Define the name of the uniform sampler array as defined in the shader
  17148. * @param textures Define the list of textures to bind to this sampler
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17152. /**
  17153. * Set a float in the shader.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setFloat(name: string, value: number): ShaderMaterial;
  17159. /**
  17160. * Set a int in the shader.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setInt(name: string, value: number): ShaderMaterial;
  17166. /**
  17167. * Set an array of floats in the shader.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setFloats(name: string, value: number[]): ShaderMaterial;
  17173. /**
  17174. * Set a vec3 in the shader from a Color3.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setColor3(name: string, value: Color3): ShaderMaterial;
  17180. /**
  17181. * Set a vec3 array in the shader from a Color3 array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17187. /**
  17188. * Set a vec4 in the shader from a Color4.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setColor4(name: string, value: Color4): ShaderMaterial;
  17194. /**
  17195. * Set a vec4 array in the shader from a Color4 array.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 in the shader from a Vector2.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setVector2(name: string, value: Vector2): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 in the shader from a Vector3.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setVector3(name: string, value: Vector3): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 in the shader from a Vector4.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setVector4(name: string, value: Vector4): ShaderMaterial;
  17222. /**
  17223. * Set a mat4 in the shader from a Matrix.
  17224. * @param name Define the name of the uniform as defined in the shader
  17225. * @param value Define the value to give to the uniform
  17226. * @return the material itself allowing "fluent" like uniform updates
  17227. */
  17228. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17229. /**
  17230. * Set a float32Array in the shader from a matrix array.
  17231. * @param name Define the name of the uniform as defined in the shader
  17232. * @param value Define the value to give to the uniform
  17233. * @return the material itself allowing "fluent" like uniform updates
  17234. */
  17235. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17236. /**
  17237. * Set a mat3 in the shader from a Float32Array.
  17238. * @param name Define the name of the uniform as defined in the shader
  17239. * @param value Define the value to give to the uniform
  17240. * @return the material itself allowing "fluent" like uniform updates
  17241. */
  17242. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17243. /**
  17244. * Set a mat2 in the shader from a Float32Array.
  17245. * @param name Define the name of the uniform as defined in the shader
  17246. * @param value Define the value to give to the uniform
  17247. * @return the material itself allowing "fluent" like uniform updates
  17248. */
  17249. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17250. /**
  17251. * Set a vec2 array in the shader from a number array.
  17252. * @param name Define the name of the uniform as defined in the shader
  17253. * @param value Define the value to give to the uniform
  17254. * @return the material itself allowing "fluent" like uniform updates
  17255. */
  17256. setArray2(name: string, value: number[]): ShaderMaterial;
  17257. /**
  17258. * Set a vec3 array in the shader from a number array.
  17259. * @param name Define the name of the uniform as defined in the shader
  17260. * @param value Define the value to give to the uniform
  17261. * @return the material itself allowing "fluent" like uniform updates
  17262. */
  17263. setArray3(name: string, value: number[]): ShaderMaterial;
  17264. /**
  17265. * Set a vec4 array in the shader from a number array.
  17266. * @param name Define the name of the uniform as defined in the shader
  17267. * @param value Define the value to give to the uniform
  17268. * @return the material itself allowing "fluent" like uniform updates
  17269. */
  17270. setArray4(name: string, value: number[]): ShaderMaterial;
  17271. private _checkCache;
  17272. /**
  17273. * Specifies that the submesh is ready to be used
  17274. * @param mesh defines the mesh to check
  17275. * @param subMesh defines which submesh to check
  17276. * @param useInstances specifies that instances should be used
  17277. * @returns a boolean indicating that the submesh is ready or not
  17278. */
  17279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17280. /**
  17281. * Checks if the material is ready to render the requested mesh
  17282. * @param mesh Define the mesh to render
  17283. * @param useInstances Define whether or not the material is used with instances
  17284. * @returns true if ready, otherwise false
  17285. */
  17286. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17287. /**
  17288. * Binds the world matrix to the material
  17289. * @param world defines the world transformation matrix
  17290. * @param effectOverride - If provided, use this effect instead of internal effect
  17291. */
  17292. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17293. /**
  17294. * Binds the submesh to this material by preparing the effect and shader to draw
  17295. * @param world defines the world transformation matrix
  17296. * @param mesh defines the mesh containing the submesh
  17297. * @param subMesh defines the submesh to bind the material to
  17298. */
  17299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17300. /**
  17301. * Binds the material to the mesh
  17302. * @param world defines the world transformation matrix
  17303. * @param mesh defines the mesh to bind the material to
  17304. * @param effectOverride - If provided, use this effect instead of internal effect
  17305. */
  17306. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17307. protected _afterBind(mesh?: Mesh): void;
  17308. /**
  17309. * Gets the active textures from the material
  17310. * @returns an array of textures
  17311. */
  17312. getActiveTextures(): BaseTexture[];
  17313. /**
  17314. * Specifies if the material uses a texture
  17315. * @param texture defines the texture to check against the material
  17316. * @returns a boolean specifying if the material uses the texture
  17317. */
  17318. hasTexture(texture: BaseTexture): boolean;
  17319. /**
  17320. * Makes a duplicate of the material, and gives it a new name
  17321. * @param name defines the new name for the duplicated material
  17322. * @returns the cloned material
  17323. */
  17324. clone(name: string): ShaderMaterial;
  17325. /**
  17326. * Disposes the material
  17327. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17328. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17329. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17330. */
  17331. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17332. /**
  17333. * Serializes this material in a JSON representation
  17334. * @returns the serialized material object
  17335. */
  17336. serialize(): any;
  17337. /**
  17338. * Creates a shader material from parsed shader material data
  17339. * @param source defines the JSON represnetation of the material
  17340. * @param scene defines the hosting scene
  17341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17342. * @returns a new material
  17343. */
  17344. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17345. /**
  17346. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17347. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17348. * @param url defines the url to load from
  17349. * @param scene defines the hosting scene
  17350. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17351. * @returns a promise that will resolve to the new ShaderMaterial
  17352. */
  17353. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17354. /**
  17355. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17356. * @param snippetId defines the snippet to load
  17357. * @param scene defines the hosting scene
  17358. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17359. * @returns a promise that will resolve to the new ShaderMaterial
  17360. */
  17361. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17362. }
  17363. }
  17364. declare module "babylonjs/Shaders/color.fragment" {
  17365. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17366. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17367. /** @hidden */
  17368. export var colorPixelShader: {
  17369. name: string;
  17370. shader: string;
  17371. };
  17372. }
  17373. declare module "babylonjs/Shaders/color.vertex" {
  17374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17376. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17377. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17378. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17380. /** @hidden */
  17381. export var colorVertexShader: {
  17382. name: string;
  17383. shader: string;
  17384. };
  17385. }
  17386. declare module "babylonjs/Meshes/linesMesh" {
  17387. import { Nullable } from "babylonjs/types";
  17388. import { Scene } from "babylonjs/scene";
  17389. import { Color3 } from "babylonjs/Maths/math.color";
  17390. import { Node } from "babylonjs/node";
  17391. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17392. import { Mesh } from "babylonjs/Meshes/mesh";
  17393. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17394. import { Effect } from "babylonjs/Materials/effect";
  17395. import { Material } from "babylonjs/Materials/material";
  17396. import "babylonjs/Shaders/color.fragment";
  17397. import "babylonjs/Shaders/color.vertex";
  17398. /**
  17399. * Line mesh
  17400. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17401. */
  17402. export class LinesMesh extends Mesh {
  17403. /**
  17404. * If vertex color should be applied to the mesh
  17405. */
  17406. readonly useVertexColor?: boolean | undefined;
  17407. /**
  17408. * If vertex alpha should be applied to the mesh
  17409. */
  17410. readonly useVertexAlpha?: boolean | undefined;
  17411. /**
  17412. * Color of the line (Default: White)
  17413. */
  17414. color: Color3;
  17415. /**
  17416. * Alpha of the line (Default: 1)
  17417. */
  17418. alpha: number;
  17419. /**
  17420. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17421. * This margin is expressed in world space coordinates, so its value may vary.
  17422. * Default value is 0.1
  17423. */
  17424. intersectionThreshold: number;
  17425. private _colorShader;
  17426. private color4;
  17427. /**
  17428. * Creates a new LinesMesh
  17429. * @param name defines the name
  17430. * @param scene defines the hosting scene
  17431. * @param parent defines the parent mesh if any
  17432. * @param source defines the optional source LinesMesh used to clone data from
  17433. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17434. * When false, achieved by calling a clone(), also passing False.
  17435. * This will make creation of children, recursive.
  17436. * @param useVertexColor defines if this LinesMesh supports vertex color
  17437. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17438. */
  17439. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17440. /**
  17441. * If vertex color should be applied to the mesh
  17442. */
  17443. useVertexColor?: boolean | undefined,
  17444. /**
  17445. * If vertex alpha should be applied to the mesh
  17446. */
  17447. useVertexAlpha?: boolean | undefined);
  17448. private _addClipPlaneDefine;
  17449. private _removeClipPlaneDefine;
  17450. isReady(): boolean;
  17451. /**
  17452. * Returns the string "LineMesh"
  17453. */
  17454. getClassName(): string;
  17455. /**
  17456. * @hidden
  17457. */
  17458. get material(): Material;
  17459. /**
  17460. * @hidden
  17461. */
  17462. set material(value: Material);
  17463. /**
  17464. * @hidden
  17465. */
  17466. get checkCollisions(): boolean;
  17467. /** @hidden */
  17468. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17469. /** @hidden */
  17470. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17471. /**
  17472. * Disposes of the line mesh
  17473. * @param doNotRecurse If children should be disposed
  17474. */
  17475. dispose(doNotRecurse?: boolean): void;
  17476. /**
  17477. * Returns a new LineMesh object cloned from the current one.
  17478. */
  17479. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17480. /**
  17481. * Creates a new InstancedLinesMesh object from the mesh model.
  17482. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17483. * @param name defines the name of the new instance
  17484. * @returns a new InstancedLinesMesh
  17485. */
  17486. createInstance(name: string): InstancedLinesMesh;
  17487. }
  17488. /**
  17489. * Creates an instance based on a source LinesMesh
  17490. */
  17491. export class InstancedLinesMesh extends InstancedMesh {
  17492. /**
  17493. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17494. * This margin is expressed in world space coordinates, so its value may vary.
  17495. * Initilized with the intersectionThreshold value of the source LinesMesh
  17496. */
  17497. intersectionThreshold: number;
  17498. constructor(name: string, source: LinesMesh);
  17499. /**
  17500. * Returns the string "InstancedLinesMesh".
  17501. */
  17502. getClassName(): string;
  17503. }
  17504. }
  17505. declare module "babylonjs/Shaders/line.fragment" {
  17506. /** @hidden */
  17507. export var linePixelShader: {
  17508. name: string;
  17509. shader: string;
  17510. };
  17511. }
  17512. declare module "babylonjs/Shaders/line.vertex" {
  17513. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17515. /** @hidden */
  17516. export var lineVertexShader: {
  17517. name: string;
  17518. shader: string;
  17519. };
  17520. }
  17521. declare module "babylonjs/Rendering/edgesRenderer" {
  17522. import { Nullable } from "babylonjs/types";
  17523. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17525. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17526. import { IDisposable } from "babylonjs/scene";
  17527. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17528. import "babylonjs/Shaders/line.fragment";
  17529. import "babylonjs/Shaders/line.vertex";
  17530. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17531. import { SmartArray } from "babylonjs/Misc/smartArray";
  17532. module "babylonjs/scene" {
  17533. interface Scene {
  17534. /** @hidden */
  17535. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17536. }
  17537. }
  17538. module "babylonjs/Meshes/abstractMesh" {
  17539. interface AbstractMesh {
  17540. /**
  17541. * Gets the edgesRenderer associated with the mesh
  17542. */
  17543. edgesRenderer: Nullable<EdgesRenderer>;
  17544. }
  17545. }
  17546. module "babylonjs/Meshes/linesMesh" {
  17547. interface LinesMesh {
  17548. /**
  17549. * Enables the edge rendering mode on the mesh.
  17550. * This mode makes the mesh edges visible
  17551. * @param epsilon defines the maximal distance between two angles to detect a face
  17552. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17553. * @returns the currentAbstractMesh
  17554. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17555. */
  17556. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17557. }
  17558. }
  17559. module "babylonjs/Meshes/linesMesh" {
  17560. interface InstancedLinesMesh {
  17561. /**
  17562. * Enables the edge rendering mode on the mesh.
  17563. * This mode makes the mesh edges visible
  17564. * @param epsilon defines the maximal distance between two angles to detect a face
  17565. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17566. * @returns the current InstancedLinesMesh
  17567. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17568. */
  17569. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17570. }
  17571. }
  17572. /**
  17573. * Defines the minimum contract an Edges renderer should follow.
  17574. */
  17575. export interface IEdgesRenderer extends IDisposable {
  17576. /**
  17577. * Gets or sets a boolean indicating if the edgesRenderer is active
  17578. */
  17579. isEnabled: boolean;
  17580. /**
  17581. * Renders the edges of the attached mesh,
  17582. */
  17583. render(): void;
  17584. /**
  17585. * Checks wether or not the edges renderer is ready to render.
  17586. * @return true if ready, otherwise false.
  17587. */
  17588. isReady(): boolean;
  17589. /**
  17590. * List of instances to render in case the source mesh has instances
  17591. */
  17592. customInstances: SmartArray<Matrix>;
  17593. }
  17594. /**
  17595. * Defines the additional options of the edges renderer
  17596. */
  17597. export interface IEdgesRendererOptions {
  17598. /**
  17599. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17600. * If not defined, the default value is true
  17601. */
  17602. useAlternateEdgeFinder?: boolean;
  17603. /**
  17604. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17605. * If not defined, the default value is true.
  17606. * 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)
  17607. * This option is used only if useAlternateEdgeFinder = true
  17608. */
  17609. useFastVertexMerger?: boolean;
  17610. /**
  17611. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17612. * The default value is 1e-6
  17613. * This option is used only if useAlternateEdgeFinder = true
  17614. */
  17615. epsilonVertexMerge?: number;
  17616. /**
  17617. * 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
  17618. * 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.
  17619. * This option is used only if useAlternateEdgeFinder = true
  17620. */
  17621. applyTessellation?: boolean;
  17622. /**
  17623. * 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
  17624. * The default value is 1e-6
  17625. * This option is used only if useAlternateEdgeFinder = true
  17626. */
  17627. epsilonVertexAligned?: number;
  17628. }
  17629. /**
  17630. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17631. */
  17632. export class EdgesRenderer implements IEdgesRenderer {
  17633. /**
  17634. * Define the size of the edges with an orthographic camera
  17635. */
  17636. edgesWidthScalerForOrthographic: number;
  17637. /**
  17638. * Define the size of the edges with a perspective camera
  17639. */
  17640. edgesWidthScalerForPerspective: number;
  17641. protected _source: AbstractMesh;
  17642. protected _linesPositions: number[];
  17643. protected _linesNormals: number[];
  17644. protected _linesIndices: number[];
  17645. protected _epsilon: number;
  17646. protected _indicesCount: number;
  17647. protected _lineShader: ShaderMaterial;
  17648. protected _ib: DataBuffer;
  17649. protected _buffers: {
  17650. [key: string]: Nullable<VertexBuffer>;
  17651. };
  17652. protected _buffersForInstances: {
  17653. [key: string]: Nullable<VertexBuffer>;
  17654. };
  17655. protected _checkVerticesInsteadOfIndices: boolean;
  17656. protected _options: Nullable<IEdgesRendererOptions>;
  17657. private _meshRebuildObserver;
  17658. private _meshDisposeObserver;
  17659. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17660. isEnabled: boolean;
  17661. /**
  17662. * List of instances to render in case the source mesh has instances
  17663. */
  17664. customInstances: SmartArray<Matrix>;
  17665. private static GetShader;
  17666. /**
  17667. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17668. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17669. * @param source Mesh used to create edges
  17670. * @param epsilon sum of angles in adjacency to check for edge
  17671. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17672. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17673. * @param options The options to apply when generating the edges
  17674. */
  17675. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17676. protected _prepareRessources(): void;
  17677. /** @hidden */
  17678. _rebuild(): void;
  17679. /**
  17680. * Releases the required resources for the edges renderer
  17681. */
  17682. dispose(): void;
  17683. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17684. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17685. /**
  17686. * Checks if the pair of p0 and p1 is en edge
  17687. * @param faceIndex
  17688. * @param edge
  17689. * @param faceNormals
  17690. * @param p0
  17691. * @param p1
  17692. * @private
  17693. */
  17694. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17695. /**
  17696. * push line into the position, normal and index buffer
  17697. * @protected
  17698. */
  17699. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17700. /**
  17701. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17702. */
  17703. private _tessellateTriangle;
  17704. private _generateEdgesLinesAlternate;
  17705. /**
  17706. * Generates lines edges from adjacencjes
  17707. * @private
  17708. */
  17709. _generateEdgesLines(): void;
  17710. /**
  17711. * Checks wether or not the edges renderer is ready to render.
  17712. * @return true if ready, otherwise false.
  17713. */
  17714. isReady(): boolean;
  17715. /**
  17716. * Renders the edges of the attached mesh,
  17717. */
  17718. render(): void;
  17719. }
  17720. /**
  17721. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17722. */
  17723. export class LineEdgesRenderer extends EdgesRenderer {
  17724. /**
  17725. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17726. * @param source LineMesh used to generate edges
  17727. * @param epsilon not important (specified angle for edge detection)
  17728. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17729. */
  17730. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17731. /**
  17732. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17733. */
  17734. _generateEdgesLines(): void;
  17735. }
  17736. }
  17737. declare module "babylonjs/Rendering/renderingGroup" {
  17738. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17741. import { Nullable } from "babylonjs/types";
  17742. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17743. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17744. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17745. import { Material } from "babylonjs/Materials/material";
  17746. import { Scene } from "babylonjs/scene";
  17747. /**
  17748. * This represents the object necessary to create a rendering group.
  17749. * This is exclusively used and created by the rendering manager.
  17750. * To modify the behavior, you use the available helpers in your scene or meshes.
  17751. * @hidden
  17752. */
  17753. export class RenderingGroup {
  17754. index: number;
  17755. private static _zeroVector;
  17756. private _scene;
  17757. private _opaqueSubMeshes;
  17758. private _transparentSubMeshes;
  17759. private _alphaTestSubMeshes;
  17760. private _depthOnlySubMeshes;
  17761. private _particleSystems;
  17762. private _spriteManagers;
  17763. private _opaqueSortCompareFn;
  17764. private _alphaTestSortCompareFn;
  17765. private _transparentSortCompareFn;
  17766. private _renderOpaque;
  17767. private _renderAlphaTest;
  17768. private _renderTransparent;
  17769. /** @hidden */
  17770. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17771. onBeforeTransparentRendering: () => void;
  17772. /**
  17773. * Set the opaque sort comparison function.
  17774. * If null the sub meshes will be render in the order they were created
  17775. */
  17776. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17777. /**
  17778. * Set the alpha test sort comparison function.
  17779. * If null the sub meshes will be render in the order they were created
  17780. */
  17781. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17782. /**
  17783. * Set the transparent sort comparison function.
  17784. * If null the sub meshes will be render in the order they were created
  17785. */
  17786. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17787. /**
  17788. * Creates a new rendering group.
  17789. * @param index The rendering group index
  17790. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17791. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17792. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17793. */
  17794. 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>);
  17795. /**
  17796. * Render all the sub meshes contained in the group.
  17797. * @param customRenderFunction Used to override the default render behaviour of the group.
  17798. * @returns true if rendered some submeshes.
  17799. */
  17800. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17801. /**
  17802. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17803. * @param subMeshes The submeshes to render
  17804. */
  17805. private renderOpaqueSorted;
  17806. /**
  17807. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17808. * @param subMeshes The submeshes to render
  17809. */
  17810. private renderAlphaTestSorted;
  17811. /**
  17812. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17813. * @param subMeshes The submeshes to render
  17814. */
  17815. private renderTransparentSorted;
  17816. /**
  17817. * Renders the submeshes in a specified order.
  17818. * @param subMeshes The submeshes to sort before render
  17819. * @param sortCompareFn The comparison function use to sort
  17820. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17821. * @param transparent Specifies to activate blending if true
  17822. */
  17823. private static renderSorted;
  17824. /**
  17825. * Renders the submeshes in the order they were dispatched (no sort applied).
  17826. * @param subMeshes The submeshes to render
  17827. */
  17828. private static renderUnsorted;
  17829. /**
  17830. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17831. * are rendered back to front if in the same alpha index.
  17832. *
  17833. * @param a The first submesh
  17834. * @param b The second submesh
  17835. * @returns The result of the comparison
  17836. */
  17837. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17838. /**
  17839. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17840. * are rendered back to front.
  17841. *
  17842. * @param a The first submesh
  17843. * @param b The second submesh
  17844. * @returns The result of the comparison
  17845. */
  17846. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17847. /**
  17848. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17849. * are rendered front to back (prevent overdraw).
  17850. *
  17851. * @param a The first submesh
  17852. * @param b The second submesh
  17853. * @returns The result of the comparison
  17854. */
  17855. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17856. /**
  17857. * Resets the different lists of submeshes to prepare a new frame.
  17858. */
  17859. prepare(): void;
  17860. dispose(): void;
  17861. /**
  17862. * Inserts the submesh in its correct queue depending on its material.
  17863. * @param subMesh The submesh to dispatch
  17864. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17865. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17866. */
  17867. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17868. dispatchSprites(spriteManager: ISpriteManager): void;
  17869. dispatchParticles(particleSystem: IParticleSystem): void;
  17870. private _renderParticles;
  17871. private _renderSprites;
  17872. }
  17873. }
  17874. declare module "babylonjs/Rendering/renderingManager" {
  17875. import { Nullable } from "babylonjs/types";
  17876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17878. import { SmartArray } from "babylonjs/Misc/smartArray";
  17879. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17880. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17881. import { Material } from "babylonjs/Materials/material";
  17882. import { Scene } from "babylonjs/scene";
  17883. import { Camera } from "babylonjs/Cameras/camera";
  17884. /**
  17885. * Interface describing the different options available in the rendering manager
  17886. * regarding Auto Clear between groups.
  17887. */
  17888. export interface IRenderingManagerAutoClearSetup {
  17889. /**
  17890. * Defines whether or not autoclear is enable.
  17891. */
  17892. autoClear: boolean;
  17893. /**
  17894. * Defines whether or not to autoclear the depth buffer.
  17895. */
  17896. depth: boolean;
  17897. /**
  17898. * Defines whether or not to autoclear the stencil buffer.
  17899. */
  17900. stencil: boolean;
  17901. }
  17902. /**
  17903. * This class is used by the onRenderingGroupObservable
  17904. */
  17905. export class RenderingGroupInfo {
  17906. /**
  17907. * The Scene that being rendered
  17908. */
  17909. scene: Scene;
  17910. /**
  17911. * The camera currently used for the rendering pass
  17912. */
  17913. camera: Nullable<Camera>;
  17914. /**
  17915. * The ID of the renderingGroup being processed
  17916. */
  17917. renderingGroupId: number;
  17918. }
  17919. /**
  17920. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17921. * It is enable to manage the different groups as well as the different necessary sort functions.
  17922. * This should not be used directly aside of the few static configurations
  17923. */
  17924. export class RenderingManager {
  17925. /**
  17926. * The max id used for rendering groups (not included)
  17927. */
  17928. static MAX_RENDERINGGROUPS: number;
  17929. /**
  17930. * The min id used for rendering groups (included)
  17931. */
  17932. static MIN_RENDERINGGROUPS: number;
  17933. /**
  17934. * Used to globally prevent autoclearing scenes.
  17935. */
  17936. static AUTOCLEAR: boolean;
  17937. /**
  17938. * @hidden
  17939. */
  17940. _useSceneAutoClearSetup: boolean;
  17941. private _scene;
  17942. private _renderingGroups;
  17943. private _depthStencilBufferAlreadyCleaned;
  17944. private _autoClearDepthStencil;
  17945. private _customOpaqueSortCompareFn;
  17946. private _customAlphaTestSortCompareFn;
  17947. private _customTransparentSortCompareFn;
  17948. private _renderingGroupInfo;
  17949. /**
  17950. * Instantiates a new rendering group for a particular scene
  17951. * @param scene Defines the scene the groups belongs to
  17952. */
  17953. constructor(scene: Scene);
  17954. private _clearDepthStencilBuffer;
  17955. /**
  17956. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17957. * @hidden
  17958. */
  17959. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17960. /**
  17961. * Resets the different information of the group to prepare a new frame
  17962. * @hidden
  17963. */
  17964. reset(): void;
  17965. /**
  17966. * Dispose and release the group and its associated resources.
  17967. * @hidden
  17968. */
  17969. dispose(): void;
  17970. /**
  17971. * Clear the info related to rendering groups preventing retention points during dispose.
  17972. */
  17973. freeRenderingGroups(): void;
  17974. private _prepareRenderingGroup;
  17975. /**
  17976. * Add a sprite manager to the rendering manager in order to render it this frame.
  17977. * @param spriteManager Define the sprite manager to render
  17978. */
  17979. dispatchSprites(spriteManager: ISpriteManager): void;
  17980. /**
  17981. * Add a particle system to the rendering manager in order to render it this frame.
  17982. * @param particleSystem Define the particle system to render
  17983. */
  17984. dispatchParticles(particleSystem: IParticleSystem): void;
  17985. /**
  17986. * Add a submesh to the manager in order to render it this frame
  17987. * @param subMesh The submesh to dispatch
  17988. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17989. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17990. */
  17991. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17992. /**
  17993. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17994. * This allowed control for front to back rendering or reversly depending of the special needs.
  17995. *
  17996. * @param renderingGroupId The rendering group id corresponding to its index
  17997. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17998. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17999. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18000. */
  18001. 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;
  18002. /**
  18003. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18004. *
  18005. * @param renderingGroupId The rendering group id corresponding to its index
  18006. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18007. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18008. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18009. */
  18010. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18011. /**
  18012. * Gets the current auto clear configuration for one rendering group of the rendering
  18013. * manager.
  18014. * @param index the rendering group index to get the information for
  18015. * @returns The auto clear setup for the requested rendering group
  18016. */
  18017. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18018. }
  18019. }
  18020. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18021. import { SmartArray } from "babylonjs/Misc/smartArray";
  18022. import { Nullable } from "babylonjs/types";
  18023. import { Scene } from "babylonjs/scene";
  18024. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18027. import { Mesh } from "babylonjs/Meshes/mesh";
  18028. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18029. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18030. import { Effect } from "babylonjs/Materials/effect";
  18031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18033. import "babylonjs/Shaders/shadowMap.fragment";
  18034. import "babylonjs/Shaders/shadowMap.vertex";
  18035. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18036. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18037. import { Observable } from "babylonjs/Misc/observable";
  18038. /**
  18039. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18040. */
  18041. export interface ICustomShaderOptions {
  18042. /**
  18043. * Gets or sets the custom shader name to use
  18044. */
  18045. shaderName: string;
  18046. /**
  18047. * The list of attribute names used in the shader
  18048. */
  18049. attributes?: string[];
  18050. /**
  18051. * The list of unifrom names used in the shader
  18052. */
  18053. uniforms?: string[];
  18054. /**
  18055. * The list of sampler names used in the shader
  18056. */
  18057. samplers?: string[];
  18058. /**
  18059. * The list of defines used in the shader
  18060. */
  18061. defines?: string[];
  18062. }
  18063. /**
  18064. * Interface to implement to create a shadow generator compatible with BJS.
  18065. */
  18066. export interface IShadowGenerator {
  18067. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18068. id: string;
  18069. /**
  18070. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18071. * @returns The render target texture if present otherwise, null
  18072. */
  18073. getShadowMap(): Nullable<RenderTargetTexture>;
  18074. /**
  18075. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18076. * @param subMesh The submesh we want to render in the shadow map
  18077. * @param useInstances Defines wether will draw in the map using instances
  18078. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18079. * @returns true if ready otherwise, false
  18080. */
  18081. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18082. /**
  18083. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18084. * @param defines Defines of the material we want to update
  18085. * @param lightIndex Index of the light in the enabled light list of the material
  18086. */
  18087. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18088. /**
  18089. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18090. * defined in the generator but impacting the effect).
  18091. * It implies the unifroms available on the materials are the standard BJS ones.
  18092. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18093. * @param effect The effect we are binfing the information for
  18094. */
  18095. bindShadowLight(lightIndex: string, effect: Effect): void;
  18096. /**
  18097. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18098. * (eq to shadow prjection matrix * light transform matrix)
  18099. * @returns The transform matrix used to create the shadow map
  18100. */
  18101. getTransformMatrix(): Matrix;
  18102. /**
  18103. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18104. * Cube and 2D textures for instance.
  18105. */
  18106. recreateShadowMap(): void;
  18107. /**
  18108. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18109. * @param onCompiled Callback triggered at the and of the effects compilation
  18110. * @param options Sets of optional options forcing the compilation with different modes
  18111. */
  18112. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18113. useInstances: boolean;
  18114. }>): void;
  18115. /**
  18116. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18117. * @param options Sets of optional options forcing the compilation with different modes
  18118. * @returns A promise that resolves when the compilation completes
  18119. */
  18120. forceCompilationAsync(options?: Partial<{
  18121. useInstances: boolean;
  18122. }>): Promise<void>;
  18123. /**
  18124. * Serializes the shadow generator setup to a json object.
  18125. * @returns The serialized JSON object
  18126. */
  18127. serialize(): any;
  18128. /**
  18129. * Disposes the Shadow map and related Textures and effects.
  18130. */
  18131. dispose(): void;
  18132. }
  18133. /**
  18134. * Default implementation IShadowGenerator.
  18135. * This is the main object responsible of generating shadows in the framework.
  18136. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18137. */
  18138. export class ShadowGenerator implements IShadowGenerator {
  18139. /**
  18140. * Name of the shadow generator class
  18141. */
  18142. static CLASSNAME: string;
  18143. /**
  18144. * Shadow generator mode None: no filtering applied.
  18145. */
  18146. static readonly FILTER_NONE: number;
  18147. /**
  18148. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18149. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18150. */
  18151. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18152. /**
  18153. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18154. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18155. */
  18156. static readonly FILTER_POISSONSAMPLING: number;
  18157. /**
  18158. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18159. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18160. */
  18161. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18162. /**
  18163. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18164. * edge artifacts on steep falloff.
  18165. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18166. */
  18167. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18168. /**
  18169. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18170. * edge artifacts on steep falloff.
  18171. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18172. */
  18173. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18174. /**
  18175. * Shadow generator mode PCF: Percentage Closer Filtering
  18176. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18177. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18178. */
  18179. static readonly FILTER_PCF: number;
  18180. /**
  18181. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18182. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18183. * Contact Hardening
  18184. */
  18185. static readonly FILTER_PCSS: number;
  18186. /**
  18187. * Reserved for PCF and PCSS
  18188. * Highest Quality.
  18189. *
  18190. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18191. *
  18192. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18193. */
  18194. static readonly QUALITY_HIGH: number;
  18195. /**
  18196. * Reserved for PCF and PCSS
  18197. * Good tradeoff for quality/perf cross devices
  18198. *
  18199. * Execute PCF on a 3*3 kernel.
  18200. *
  18201. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18202. */
  18203. static readonly QUALITY_MEDIUM: number;
  18204. /**
  18205. * Reserved for PCF and PCSS
  18206. * The lowest quality but the fastest.
  18207. *
  18208. * Execute PCF on a 1*1 kernel.
  18209. *
  18210. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18211. */
  18212. static readonly QUALITY_LOW: number;
  18213. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18214. id: string;
  18215. /** Gets or sets the custom shader name to use */
  18216. customShaderOptions: ICustomShaderOptions;
  18217. /**
  18218. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18219. */
  18220. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18221. /**
  18222. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18223. */
  18224. onAfterShadowMapRenderObservable: Observable<Effect>;
  18225. /**
  18226. * Observable triggered before a mesh is rendered in the shadow map.
  18227. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18228. */
  18229. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18230. /**
  18231. * Observable triggered after a mesh is rendered in the shadow map.
  18232. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18233. */
  18234. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18235. protected _bias: number;
  18236. /**
  18237. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18238. */
  18239. get bias(): number;
  18240. /**
  18241. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18242. */
  18243. set bias(bias: number);
  18244. protected _normalBias: number;
  18245. /**
  18246. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18247. */
  18248. get normalBias(): number;
  18249. /**
  18250. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18251. */
  18252. set normalBias(normalBias: number);
  18253. protected _blurBoxOffset: number;
  18254. /**
  18255. * Gets the blur box offset: offset applied during the blur pass.
  18256. * Only useful if useKernelBlur = false
  18257. */
  18258. get blurBoxOffset(): number;
  18259. /**
  18260. * Sets the blur box offset: offset applied during the blur pass.
  18261. * Only useful if useKernelBlur = false
  18262. */
  18263. set blurBoxOffset(value: number);
  18264. protected _blurScale: number;
  18265. /**
  18266. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18267. * 2 means half of the size.
  18268. */
  18269. get blurScale(): number;
  18270. /**
  18271. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18272. * 2 means half of the size.
  18273. */
  18274. set blurScale(value: number);
  18275. protected _blurKernel: number;
  18276. /**
  18277. * Gets the blur kernel: kernel size of the blur pass.
  18278. * Only useful if useKernelBlur = true
  18279. */
  18280. get blurKernel(): number;
  18281. /**
  18282. * Sets the blur kernel: kernel size of the blur pass.
  18283. * Only useful if useKernelBlur = true
  18284. */
  18285. set blurKernel(value: number);
  18286. protected _useKernelBlur: boolean;
  18287. /**
  18288. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18289. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18290. */
  18291. get useKernelBlur(): boolean;
  18292. /**
  18293. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18294. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18295. */
  18296. set useKernelBlur(value: boolean);
  18297. protected _depthScale: number;
  18298. /**
  18299. * Gets the depth scale used in ESM mode.
  18300. */
  18301. get depthScale(): number;
  18302. /**
  18303. * Sets the depth scale used in ESM mode.
  18304. * This can override the scale stored on the light.
  18305. */
  18306. set depthScale(value: number);
  18307. protected _validateFilter(filter: number): number;
  18308. protected _filter: number;
  18309. /**
  18310. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18311. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18312. */
  18313. get filter(): number;
  18314. /**
  18315. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18316. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18317. */
  18318. set filter(value: number);
  18319. /**
  18320. * Gets if the current filter is set to Poisson Sampling.
  18321. */
  18322. get usePoissonSampling(): boolean;
  18323. /**
  18324. * Sets the current filter to Poisson Sampling.
  18325. */
  18326. set usePoissonSampling(value: boolean);
  18327. /**
  18328. * Gets if the current filter is set to ESM.
  18329. */
  18330. get useExponentialShadowMap(): boolean;
  18331. /**
  18332. * Sets the current filter is to ESM.
  18333. */
  18334. set useExponentialShadowMap(value: boolean);
  18335. /**
  18336. * Gets if the current filter is set to filtered ESM.
  18337. */
  18338. get useBlurExponentialShadowMap(): boolean;
  18339. /**
  18340. * Gets if the current filter is set to filtered ESM.
  18341. */
  18342. set useBlurExponentialShadowMap(value: boolean);
  18343. /**
  18344. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18345. * exponential to prevent steep falloff artifacts).
  18346. */
  18347. get useCloseExponentialShadowMap(): boolean;
  18348. /**
  18349. * Sets the current filter to "close ESM" (using the inverse of the
  18350. * exponential to prevent steep falloff artifacts).
  18351. */
  18352. set useCloseExponentialShadowMap(value: boolean);
  18353. /**
  18354. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18355. * exponential to prevent steep falloff artifacts).
  18356. */
  18357. get useBlurCloseExponentialShadowMap(): boolean;
  18358. /**
  18359. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18360. * exponential to prevent steep falloff artifacts).
  18361. */
  18362. set useBlurCloseExponentialShadowMap(value: boolean);
  18363. /**
  18364. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18365. */
  18366. get usePercentageCloserFiltering(): boolean;
  18367. /**
  18368. * Sets the current filter to "PCF" (percentage closer filtering).
  18369. */
  18370. set usePercentageCloserFiltering(value: boolean);
  18371. protected _filteringQuality: number;
  18372. /**
  18373. * Gets the PCF or PCSS Quality.
  18374. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18375. */
  18376. get filteringQuality(): number;
  18377. /**
  18378. * Sets the PCF or PCSS Quality.
  18379. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18380. */
  18381. set filteringQuality(filteringQuality: number);
  18382. /**
  18383. * Gets if the current filter is set to "PCSS" (contact hardening).
  18384. */
  18385. get useContactHardeningShadow(): boolean;
  18386. /**
  18387. * Sets the current filter to "PCSS" (contact hardening).
  18388. */
  18389. set useContactHardeningShadow(value: boolean);
  18390. protected _contactHardeningLightSizeUVRatio: number;
  18391. /**
  18392. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18393. * Using a ratio helps keeping shape stability independently of the map size.
  18394. *
  18395. * It does not account for the light projection as it was having too much
  18396. * instability during the light setup or during light position changes.
  18397. *
  18398. * Only valid if useContactHardeningShadow is true.
  18399. */
  18400. get contactHardeningLightSizeUVRatio(): number;
  18401. /**
  18402. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18403. * Using a ratio helps keeping shape stability independently of the map size.
  18404. *
  18405. * It does not account for the light projection as it was having too much
  18406. * instability during the light setup or during light position changes.
  18407. *
  18408. * Only valid if useContactHardeningShadow is true.
  18409. */
  18410. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18411. protected _darkness: number;
  18412. /** Gets or sets the actual darkness of a shadow */
  18413. get darkness(): number;
  18414. set darkness(value: number);
  18415. /**
  18416. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18417. * 0 means strongest and 1 would means no shadow.
  18418. * @returns the darkness.
  18419. */
  18420. getDarkness(): number;
  18421. /**
  18422. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18423. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18424. * @returns the shadow generator allowing fluent coding.
  18425. */
  18426. setDarkness(darkness: number): ShadowGenerator;
  18427. protected _transparencyShadow: boolean;
  18428. /** Gets or sets the ability to have transparent shadow */
  18429. get transparencyShadow(): boolean;
  18430. set transparencyShadow(value: boolean);
  18431. /**
  18432. * Sets the ability to have transparent shadow (boolean).
  18433. * @param transparent True if transparent else False
  18434. * @returns the shadow generator allowing fluent coding
  18435. */
  18436. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18437. /**
  18438. * Enables or disables shadows with varying strength based on the transparency
  18439. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18440. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18441. * mesh.visibility * alphaTexture.a
  18442. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18443. */
  18444. enableSoftTransparentShadow: boolean;
  18445. protected _shadowMap: Nullable<RenderTargetTexture>;
  18446. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18447. /**
  18448. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18449. * @returns The render target texture if present otherwise, null
  18450. */
  18451. getShadowMap(): Nullable<RenderTargetTexture>;
  18452. /**
  18453. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18454. * @returns The render target texture if the shadow map is present otherwise, null
  18455. */
  18456. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18457. /**
  18458. * Gets the class name of that object
  18459. * @returns "ShadowGenerator"
  18460. */
  18461. getClassName(): string;
  18462. /**
  18463. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18464. * @param mesh Mesh to add
  18465. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18466. * @returns the Shadow Generator itself
  18467. */
  18468. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18469. /**
  18470. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18471. * @param mesh Mesh to remove
  18472. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18473. * @returns the Shadow Generator itself
  18474. */
  18475. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18476. /**
  18477. * Controls the extent to which the shadows fade out at the edge of the frustum
  18478. */
  18479. frustumEdgeFalloff: number;
  18480. protected _light: IShadowLight;
  18481. /**
  18482. * Returns the associated light object.
  18483. * @returns the light generating the shadow
  18484. */
  18485. getLight(): IShadowLight;
  18486. /**
  18487. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18488. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18489. * It might on the other hand introduce peter panning.
  18490. */
  18491. forceBackFacesOnly: boolean;
  18492. protected _scene: Scene;
  18493. protected _lightDirection: Vector3;
  18494. protected _effect: Effect;
  18495. protected _viewMatrix: Matrix;
  18496. protected _projectionMatrix: Matrix;
  18497. protected _transformMatrix: Matrix;
  18498. protected _cachedPosition: Vector3;
  18499. protected _cachedDirection: Vector3;
  18500. protected _cachedDefines: string;
  18501. protected _currentRenderID: number;
  18502. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18503. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18504. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18505. protected _blurPostProcesses: PostProcess[];
  18506. protected _mapSize: number;
  18507. protected _currentFaceIndex: number;
  18508. protected _currentFaceIndexCache: number;
  18509. protected _textureType: number;
  18510. protected _defaultTextureMatrix: Matrix;
  18511. protected _storedUniqueId: Nullable<number>;
  18512. /** @hidden */
  18513. static _SceneComponentInitialization: (scene: Scene) => void;
  18514. /**
  18515. * Gets or sets the size of the texture what stores the shadows
  18516. */
  18517. get mapSize(): number;
  18518. set mapSize(size: number);
  18519. /**
  18520. * Creates a ShadowGenerator object.
  18521. * A ShadowGenerator is the required tool to use the shadows.
  18522. * Each light casting shadows needs to use its own ShadowGenerator.
  18523. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18524. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18525. * @param light The light object generating the shadows.
  18526. * @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.
  18527. */
  18528. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18529. protected _initializeGenerator(): void;
  18530. protected _createTargetRenderTexture(): void;
  18531. protected _initializeShadowMap(): void;
  18532. protected _initializeBlurRTTAndPostProcesses(): void;
  18533. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18534. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18535. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18536. protected _applyFilterValues(): void;
  18537. /**
  18538. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18539. * @param onCompiled Callback triggered at the and of the effects compilation
  18540. * @param options Sets of optional options forcing the compilation with different modes
  18541. */
  18542. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18543. useInstances: boolean;
  18544. }>): void;
  18545. /**
  18546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18547. * @param options Sets of optional options forcing the compilation with different modes
  18548. * @returns A promise that resolves when the compilation completes
  18549. */
  18550. forceCompilationAsync(options?: Partial<{
  18551. useInstances: boolean;
  18552. }>): Promise<void>;
  18553. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18554. private _prepareShadowDefines;
  18555. /**
  18556. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18557. * @param subMesh The submesh we want to render in the shadow map
  18558. * @param useInstances Defines wether will draw in the map using instances
  18559. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18560. * @returns true if ready otherwise, false
  18561. */
  18562. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18563. /**
  18564. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18565. * @param defines Defines of the material we want to update
  18566. * @param lightIndex Index of the light in the enabled light list of the material
  18567. */
  18568. prepareDefines(defines: any, lightIndex: number): void;
  18569. /**
  18570. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18571. * defined in the generator but impacting the effect).
  18572. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18573. * @param effect The effect we are binfing the information for
  18574. */
  18575. bindShadowLight(lightIndex: string, effect: Effect): void;
  18576. /**
  18577. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18578. * (eq to shadow prjection matrix * light transform matrix)
  18579. * @returns The transform matrix used to create the shadow map
  18580. */
  18581. getTransformMatrix(): Matrix;
  18582. /**
  18583. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18584. * Cube and 2D textures for instance.
  18585. */
  18586. recreateShadowMap(): void;
  18587. protected _disposeBlurPostProcesses(): void;
  18588. protected _disposeRTTandPostProcesses(): void;
  18589. /**
  18590. * Disposes the ShadowGenerator.
  18591. * Returns nothing.
  18592. */
  18593. dispose(): void;
  18594. /**
  18595. * Serializes the shadow generator setup to a json object.
  18596. * @returns The serialized JSON object
  18597. */
  18598. serialize(): any;
  18599. /**
  18600. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18601. * @param parsedShadowGenerator The JSON object to parse
  18602. * @param scene The scene to create the shadow map for
  18603. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18604. * @returns The parsed shadow generator
  18605. */
  18606. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18607. }
  18608. }
  18609. declare module "babylonjs/Lights/light" {
  18610. import { Nullable } from "babylonjs/types";
  18611. import { Scene } from "babylonjs/scene";
  18612. import { Vector3 } from "babylonjs/Maths/math.vector";
  18613. import { Color3 } from "babylonjs/Maths/math.color";
  18614. import { Node } from "babylonjs/node";
  18615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18616. import { Effect } from "babylonjs/Materials/effect";
  18617. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18618. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18619. /**
  18620. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18621. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18622. * 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.
  18623. */
  18624. export abstract class Light extends Node {
  18625. /**
  18626. * Falloff Default: light is falling off following the material specification:
  18627. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18628. */
  18629. static readonly FALLOFF_DEFAULT: number;
  18630. /**
  18631. * Falloff Physical: light is falling off following the inverse squared distance law.
  18632. */
  18633. static readonly FALLOFF_PHYSICAL: number;
  18634. /**
  18635. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18636. * to enhance interoperability with other engines.
  18637. */
  18638. static readonly FALLOFF_GLTF: number;
  18639. /**
  18640. * Falloff Standard: light is falling off like in the standard material
  18641. * to enhance interoperability with other materials.
  18642. */
  18643. static readonly FALLOFF_STANDARD: number;
  18644. /**
  18645. * If every light affecting the material is in this lightmapMode,
  18646. * material.lightmapTexture adds or multiplies
  18647. * (depends on material.useLightmapAsShadowmap)
  18648. * after every other light calculations.
  18649. */
  18650. static readonly LIGHTMAP_DEFAULT: number;
  18651. /**
  18652. * material.lightmapTexture as only diffuse lighting from this light
  18653. * adds only specular lighting from this light
  18654. * adds dynamic shadows
  18655. */
  18656. static readonly LIGHTMAP_SPECULAR: number;
  18657. /**
  18658. * material.lightmapTexture as only lighting
  18659. * no light calculation from this light
  18660. * only adds dynamic shadows from this light
  18661. */
  18662. static readonly LIGHTMAP_SHADOWSONLY: number;
  18663. /**
  18664. * Each light type uses the default quantity according to its type:
  18665. * point/spot lights use luminous intensity
  18666. * directional lights use illuminance
  18667. */
  18668. static readonly INTENSITYMODE_AUTOMATIC: number;
  18669. /**
  18670. * lumen (lm)
  18671. */
  18672. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18673. /**
  18674. * candela (lm/sr)
  18675. */
  18676. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18677. /**
  18678. * lux (lm/m^2)
  18679. */
  18680. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18681. /**
  18682. * nit (cd/m^2)
  18683. */
  18684. static readonly INTENSITYMODE_LUMINANCE: number;
  18685. /**
  18686. * Light type const id of the point light.
  18687. */
  18688. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18689. /**
  18690. * Light type const id of the directional light.
  18691. */
  18692. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18693. /**
  18694. * Light type const id of the spot light.
  18695. */
  18696. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18697. /**
  18698. * Light type const id of the hemispheric light.
  18699. */
  18700. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18701. /**
  18702. * Diffuse gives the basic color to an object.
  18703. */
  18704. diffuse: Color3;
  18705. /**
  18706. * Specular produces a highlight color on an object.
  18707. * Note: This is note affecting PBR materials.
  18708. */
  18709. specular: Color3;
  18710. /**
  18711. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18712. * falling off base on range or angle.
  18713. * This can be set to any values in Light.FALLOFF_x.
  18714. *
  18715. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18716. * other types of materials.
  18717. */
  18718. falloffType: number;
  18719. /**
  18720. * Strength of the light.
  18721. * Note: By default it is define in the framework own unit.
  18722. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18723. */
  18724. intensity: number;
  18725. private _range;
  18726. protected _inverseSquaredRange: number;
  18727. /**
  18728. * Defines how far from the source the light is impacting in scene units.
  18729. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18730. */
  18731. get range(): number;
  18732. /**
  18733. * Defines how far from the source the light is impacting in scene units.
  18734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18735. */
  18736. set range(value: number);
  18737. /**
  18738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18739. * of light.
  18740. */
  18741. private _photometricScale;
  18742. private _intensityMode;
  18743. /**
  18744. * Gets the photometric scale used to interpret the intensity.
  18745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18746. */
  18747. get intensityMode(): number;
  18748. /**
  18749. * Sets the photometric scale used to interpret the intensity.
  18750. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18751. */
  18752. set intensityMode(value: number);
  18753. private _radius;
  18754. /**
  18755. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18756. */
  18757. get radius(): number;
  18758. /**
  18759. * sets the light radius used by PBR Materials to simulate soft area lights.
  18760. */
  18761. set radius(value: number);
  18762. private _renderPriority;
  18763. /**
  18764. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18765. * exceeding the number allowed of the materials.
  18766. */
  18767. renderPriority: number;
  18768. private _shadowEnabled;
  18769. /**
  18770. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18771. * the current shadow generator.
  18772. */
  18773. get shadowEnabled(): boolean;
  18774. /**
  18775. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18776. * the current shadow generator.
  18777. */
  18778. set shadowEnabled(value: boolean);
  18779. private _includedOnlyMeshes;
  18780. /**
  18781. * Gets the only meshes impacted by this light.
  18782. */
  18783. get includedOnlyMeshes(): AbstractMesh[];
  18784. /**
  18785. * Sets the only meshes impacted by this light.
  18786. */
  18787. set includedOnlyMeshes(value: AbstractMesh[]);
  18788. private _excludedMeshes;
  18789. /**
  18790. * Gets the meshes not impacted by this light.
  18791. */
  18792. get excludedMeshes(): AbstractMesh[];
  18793. /**
  18794. * Sets the meshes not impacted by this light.
  18795. */
  18796. set excludedMeshes(value: AbstractMesh[]);
  18797. private _excludeWithLayerMask;
  18798. /**
  18799. * Gets the layer id use to find what meshes are not impacted by the light.
  18800. * Inactive if 0
  18801. */
  18802. get excludeWithLayerMask(): number;
  18803. /**
  18804. * Sets the layer id use to find what meshes are not impacted by the light.
  18805. * Inactive if 0
  18806. */
  18807. set excludeWithLayerMask(value: number);
  18808. private _includeOnlyWithLayerMask;
  18809. /**
  18810. * Gets the layer id use to find what meshes are impacted by the light.
  18811. * Inactive if 0
  18812. */
  18813. get includeOnlyWithLayerMask(): number;
  18814. /**
  18815. * Sets the layer id use to find what meshes are impacted by the light.
  18816. * Inactive if 0
  18817. */
  18818. set includeOnlyWithLayerMask(value: number);
  18819. private _lightmapMode;
  18820. /**
  18821. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18822. */
  18823. get lightmapMode(): number;
  18824. /**
  18825. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18826. */
  18827. set lightmapMode(value: number);
  18828. /**
  18829. * Shadow generator associted to the light.
  18830. * @hidden Internal use only.
  18831. */
  18832. _shadowGenerator: Nullable<IShadowGenerator>;
  18833. /**
  18834. * @hidden Internal use only.
  18835. */
  18836. _excludedMeshesIds: string[];
  18837. /**
  18838. * @hidden Internal use only.
  18839. */
  18840. _includedOnlyMeshesIds: string[];
  18841. /**
  18842. * The current light unifom buffer.
  18843. * @hidden Internal use only.
  18844. */
  18845. _uniformBuffer: UniformBuffer;
  18846. /** @hidden */
  18847. _renderId: number;
  18848. /**
  18849. * Creates a Light object in the scene.
  18850. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18851. * @param name The firendly name of the light
  18852. * @param scene The scene the light belongs too
  18853. */
  18854. constructor(name: string, scene: Scene);
  18855. protected abstract _buildUniformLayout(): void;
  18856. /**
  18857. * Sets the passed Effect "effect" with the Light information.
  18858. * @param effect The effect to update
  18859. * @param lightIndex The index of the light in the effect to update
  18860. * @returns The light
  18861. */
  18862. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18863. /**
  18864. * Sets the passed Effect "effect" with the Light textures.
  18865. * @param effect The effect to update
  18866. * @param lightIndex The index of the light in the effect to update
  18867. * @returns The light
  18868. */
  18869. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18870. /**
  18871. * Binds the lights information from the scene to the effect for the given mesh.
  18872. * @param lightIndex Light index
  18873. * @param scene The scene where the light belongs to
  18874. * @param effect The effect we are binding the data to
  18875. * @param useSpecular Defines if specular is supported
  18876. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18877. */
  18878. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18879. /**
  18880. * Sets the passed Effect "effect" with the Light information.
  18881. * @param effect The effect to update
  18882. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18883. * @returns The light
  18884. */
  18885. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18886. /**
  18887. * Returns the string "Light".
  18888. * @returns the class name
  18889. */
  18890. getClassName(): string;
  18891. /** @hidden */
  18892. readonly _isLight: boolean;
  18893. /**
  18894. * Converts the light information to a readable string for debug purpose.
  18895. * @param fullDetails Supports for multiple levels of logging within scene loading
  18896. * @returns the human readable light info
  18897. */
  18898. toString(fullDetails?: boolean): string;
  18899. /** @hidden */
  18900. protected _syncParentEnabledState(): void;
  18901. /**
  18902. * Set the enabled state of this node.
  18903. * @param value - the new enabled state
  18904. */
  18905. setEnabled(value: boolean): void;
  18906. /**
  18907. * Returns the Light associated shadow generator if any.
  18908. * @return the associated shadow generator.
  18909. */
  18910. getShadowGenerator(): Nullable<IShadowGenerator>;
  18911. /**
  18912. * Returns a Vector3, the absolute light position in the World.
  18913. * @returns the world space position of the light
  18914. */
  18915. getAbsolutePosition(): Vector3;
  18916. /**
  18917. * Specifies if the light will affect the passed mesh.
  18918. * @param mesh The mesh to test against the light
  18919. * @return true the mesh is affected otherwise, false.
  18920. */
  18921. canAffectMesh(mesh: AbstractMesh): boolean;
  18922. /**
  18923. * Sort function to order lights for rendering.
  18924. * @param a First Light object to compare to second.
  18925. * @param b Second Light object to compare first.
  18926. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18927. */
  18928. static CompareLightsPriority(a: Light, b: Light): number;
  18929. /**
  18930. * Releases resources associated with this node.
  18931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18933. */
  18934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18935. /**
  18936. * Returns the light type ID (integer).
  18937. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18938. */
  18939. getTypeID(): number;
  18940. /**
  18941. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18942. * @returns the scaled intensity in intensity mode unit
  18943. */
  18944. getScaledIntensity(): number;
  18945. /**
  18946. * Returns a new Light object, named "name", from the current one.
  18947. * @param name The name of the cloned light
  18948. * @param newParent The parent of this light, if it has one
  18949. * @returns the new created light
  18950. */
  18951. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18952. /**
  18953. * Serializes the current light into a Serialization object.
  18954. * @returns the serialized object.
  18955. */
  18956. serialize(): any;
  18957. /**
  18958. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18959. * This new light is named "name" and added to the passed scene.
  18960. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18961. * @param name The friendly name of the light
  18962. * @param scene The scene the new light will belong to
  18963. * @returns the constructor function
  18964. */
  18965. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18966. /**
  18967. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18968. * @param parsedLight The JSON representation of the light
  18969. * @param scene The scene to create the parsed light in
  18970. * @returns the created light after parsing
  18971. */
  18972. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18973. private _hookArrayForExcluded;
  18974. private _hookArrayForIncludedOnly;
  18975. private _resyncMeshes;
  18976. /**
  18977. * Forces the meshes to update their light related information in their rendering used effects
  18978. * @hidden Internal Use Only
  18979. */
  18980. _markMeshesAsLightDirty(): void;
  18981. /**
  18982. * Recomputes the cached photometric scale if needed.
  18983. */
  18984. private _computePhotometricScale;
  18985. /**
  18986. * Returns the Photometric Scale according to the light type and intensity mode.
  18987. */
  18988. private _getPhotometricScale;
  18989. /**
  18990. * Reorder the light in the scene according to their defined priority.
  18991. * @hidden Internal Use Only
  18992. */
  18993. _reorderLightsInScene(): void;
  18994. /**
  18995. * Prepares the list of defines specific to the light type.
  18996. * @param defines the list of defines
  18997. * @param lightIndex defines the index of the light for the effect
  18998. */
  18999. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19000. }
  19001. }
  19002. declare module "babylonjs/Materials/prePassConfiguration" {
  19003. import { Matrix } from "babylonjs/Maths/math.vector";
  19004. import { Mesh } from "babylonjs/Meshes/mesh";
  19005. import { Scene } from "babylonjs/scene";
  19006. import { Effect } from "babylonjs/Materials/effect";
  19007. /**
  19008. * Configuration needed for prepass-capable materials
  19009. */
  19010. export class PrePassConfiguration {
  19011. /**
  19012. * Previous world matrices of meshes carrying this material
  19013. * Used for computing velocity
  19014. */
  19015. previousWorldMatrices: {
  19016. [index: number]: Matrix;
  19017. };
  19018. /**
  19019. * Previous view project matrix
  19020. * Used for computing velocity
  19021. */
  19022. previousViewProjection: Matrix;
  19023. /**
  19024. * Previous bones of meshes carrying this material
  19025. * Used for computing velocity
  19026. */
  19027. previousBones: {
  19028. [index: number]: Float32Array;
  19029. };
  19030. /**
  19031. * Add the required uniforms to the current list.
  19032. * @param uniforms defines the current uniform list.
  19033. */
  19034. static AddUniforms(uniforms: string[]): void;
  19035. /**
  19036. * Add the required samplers to the current list.
  19037. * @param samplers defines the current sampler list.
  19038. */
  19039. static AddSamplers(samplers: string[]): void;
  19040. /**
  19041. * Binds the material data.
  19042. * @param effect defines the effect to update
  19043. * @param scene defines the scene the material belongs to.
  19044. * @param mesh The mesh
  19045. * @param world World matrix of this mesh
  19046. * @param isFrozen Is the material frozen
  19047. */
  19048. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19049. }
  19050. }
  19051. declare module "babylonjs/Cameras/targetCamera" {
  19052. import { Nullable } from "babylonjs/types";
  19053. import { Camera } from "babylonjs/Cameras/camera";
  19054. import { Scene } from "babylonjs/scene";
  19055. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19056. /**
  19057. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19058. * This is the base of the follow, arc rotate cameras and Free camera
  19059. * @see https://doc.babylonjs.com/features/cameras
  19060. */
  19061. export class TargetCamera extends Camera {
  19062. private static _RigCamTransformMatrix;
  19063. private static _TargetTransformMatrix;
  19064. private static _TargetFocalPoint;
  19065. private _tmpUpVector;
  19066. private _tmpTargetVector;
  19067. /**
  19068. * Define the current direction the camera is moving to
  19069. */
  19070. cameraDirection: Vector3;
  19071. /**
  19072. * Define the current rotation the camera is rotating to
  19073. */
  19074. cameraRotation: Vector2;
  19075. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19076. ignoreParentScaling: boolean;
  19077. /**
  19078. * When set, the up vector of the camera will be updated by the rotation of the camera
  19079. */
  19080. updateUpVectorFromRotation: boolean;
  19081. private _tmpQuaternion;
  19082. /**
  19083. * Define the current rotation of the camera
  19084. */
  19085. rotation: Vector3;
  19086. /**
  19087. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19088. */
  19089. rotationQuaternion: Quaternion;
  19090. /**
  19091. * Define the current speed of the camera
  19092. */
  19093. speed: number;
  19094. /**
  19095. * Add constraint to the camera to prevent it to move freely in all directions and
  19096. * around all axis.
  19097. */
  19098. noRotationConstraint: boolean;
  19099. /**
  19100. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19101. * panning
  19102. */
  19103. invertRotation: boolean;
  19104. /**
  19105. * Speed multiplier for inverse camera panning
  19106. */
  19107. inverseRotationSpeed: number;
  19108. /**
  19109. * Define the current target of the camera as an object or a position.
  19110. */
  19111. lockedTarget: any;
  19112. /** @hidden */
  19113. _currentTarget: Vector3;
  19114. /** @hidden */
  19115. _initialFocalDistance: number;
  19116. /** @hidden */
  19117. _viewMatrix: Matrix;
  19118. /** @hidden */
  19119. _camMatrix: Matrix;
  19120. /** @hidden */
  19121. _cameraTransformMatrix: Matrix;
  19122. /** @hidden */
  19123. _cameraRotationMatrix: Matrix;
  19124. /** @hidden */
  19125. _referencePoint: Vector3;
  19126. /** @hidden */
  19127. _transformedReferencePoint: Vector3;
  19128. /** @hidden */
  19129. _reset: () => void;
  19130. private _defaultUp;
  19131. /**
  19132. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19133. * This is the base of the follow, arc rotate cameras and Free camera
  19134. * @see https://doc.babylonjs.com/features/cameras
  19135. * @param name Defines the name of the camera in the scene
  19136. * @param position Defines the start position of the camera in the scene
  19137. * @param scene Defines the scene the camera belongs to
  19138. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19139. */
  19140. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19141. /**
  19142. * Gets the position in front of the camera at a given distance.
  19143. * @param distance The distance from the camera we want the position to be
  19144. * @returns the position
  19145. */
  19146. getFrontPosition(distance: number): Vector3;
  19147. /** @hidden */
  19148. _getLockedTargetPosition(): Nullable<Vector3>;
  19149. private _storedPosition;
  19150. private _storedRotation;
  19151. private _storedRotationQuaternion;
  19152. /**
  19153. * Store current camera state of the camera (fov, position, rotation, etc..)
  19154. * @returns the camera
  19155. */
  19156. storeState(): Camera;
  19157. /**
  19158. * Restored camera state. You must call storeState() first
  19159. * @returns whether it was successful or not
  19160. * @hidden
  19161. */
  19162. _restoreStateValues(): boolean;
  19163. /** @hidden */
  19164. _initCache(): void;
  19165. /** @hidden */
  19166. _updateCache(ignoreParentClass?: boolean): void;
  19167. /** @hidden */
  19168. _isSynchronizedViewMatrix(): boolean;
  19169. /** @hidden */
  19170. _computeLocalCameraSpeed(): number;
  19171. /**
  19172. * Defines the target the camera should look at.
  19173. * @param target Defines the new target as a Vector or a mesh
  19174. */
  19175. setTarget(target: Vector3): void;
  19176. /**
  19177. * Defines the target point of the camera.
  19178. * The camera looks towards it form the radius distance.
  19179. */
  19180. get target(): Vector3;
  19181. set target(value: Vector3);
  19182. /**
  19183. * Return the current target position of the camera. This value is expressed in local space.
  19184. * @returns the target position
  19185. */
  19186. getTarget(): Vector3;
  19187. /** @hidden */
  19188. _decideIfNeedsToMove(): boolean;
  19189. /** @hidden */
  19190. _updatePosition(): void;
  19191. /** @hidden */
  19192. _checkInputs(): void;
  19193. protected _updateCameraRotationMatrix(): void;
  19194. /**
  19195. * 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)
  19196. * @returns the current camera
  19197. */
  19198. private _rotateUpVectorWithCameraRotationMatrix;
  19199. private _cachedRotationZ;
  19200. private _cachedQuaternionRotationZ;
  19201. /** @hidden */
  19202. _getViewMatrix(): Matrix;
  19203. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19204. /**
  19205. * @hidden
  19206. */
  19207. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19208. /**
  19209. * @hidden
  19210. */
  19211. _updateRigCameras(): void;
  19212. private _getRigCamPositionAndTarget;
  19213. /**
  19214. * Gets the current object class name.
  19215. * @return the class name
  19216. */
  19217. getClassName(): string;
  19218. }
  19219. }
  19220. declare module "babylonjs/Events/keyboardEvents" {
  19221. /**
  19222. * Gather the list of keyboard event types as constants.
  19223. */
  19224. export class KeyboardEventTypes {
  19225. /**
  19226. * The keydown event is fired when a key becomes active (pressed).
  19227. */
  19228. static readonly KEYDOWN: number;
  19229. /**
  19230. * The keyup event is fired when a key has been released.
  19231. */
  19232. static readonly KEYUP: number;
  19233. }
  19234. /**
  19235. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19236. */
  19237. export class KeyboardInfo {
  19238. /**
  19239. * Defines the type of event (KeyboardEventTypes)
  19240. */
  19241. type: number;
  19242. /**
  19243. * Defines the related dom event
  19244. */
  19245. event: KeyboardEvent;
  19246. /**
  19247. * Instantiates a new keyboard info.
  19248. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19249. * @param type Defines the type of event (KeyboardEventTypes)
  19250. * @param event Defines the related dom event
  19251. */
  19252. constructor(
  19253. /**
  19254. * Defines the type of event (KeyboardEventTypes)
  19255. */
  19256. type: number,
  19257. /**
  19258. * Defines the related dom event
  19259. */
  19260. event: KeyboardEvent);
  19261. }
  19262. /**
  19263. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19264. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19265. */
  19266. export class KeyboardInfoPre extends KeyboardInfo {
  19267. /**
  19268. * Defines the type of event (KeyboardEventTypes)
  19269. */
  19270. type: number;
  19271. /**
  19272. * Defines the related dom event
  19273. */
  19274. event: KeyboardEvent;
  19275. /**
  19276. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19277. */
  19278. skipOnPointerObservable: boolean;
  19279. /**
  19280. * Instantiates a new keyboard pre info.
  19281. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19282. * @param type Defines the type of event (KeyboardEventTypes)
  19283. * @param event Defines the related dom event
  19284. */
  19285. constructor(
  19286. /**
  19287. * Defines the type of event (KeyboardEventTypes)
  19288. */
  19289. type: number,
  19290. /**
  19291. * Defines the related dom event
  19292. */
  19293. event: KeyboardEvent);
  19294. }
  19295. }
  19296. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19297. import { Nullable } from "babylonjs/types";
  19298. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19300. /**
  19301. * Manage the keyboard inputs to control the movement of a free camera.
  19302. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19303. */
  19304. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19305. /**
  19306. * Defines the camera the input is attached to.
  19307. */
  19308. camera: FreeCamera;
  19309. /**
  19310. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19311. */
  19312. keysUp: number[];
  19313. /**
  19314. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19315. */
  19316. keysUpward: number[];
  19317. /**
  19318. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19319. */
  19320. keysDown: number[];
  19321. /**
  19322. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19323. */
  19324. keysDownward: number[];
  19325. /**
  19326. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19327. */
  19328. keysLeft: number[];
  19329. /**
  19330. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19331. */
  19332. keysRight: number[];
  19333. private _keys;
  19334. private _onCanvasBlurObserver;
  19335. private _onKeyboardObserver;
  19336. private _engine;
  19337. private _scene;
  19338. /**
  19339. * Attach the input controls to a specific dom element to get the input from.
  19340. * @param element Defines the element the controls should be listened from
  19341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19342. */
  19343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19344. /**
  19345. * Detach the current controls from the specified dom element.
  19346. * @param element Defines the element to stop listening the inputs from
  19347. */
  19348. detachControl(element: Nullable<HTMLElement>): void;
  19349. /**
  19350. * Update the current camera state depending on the inputs that have been used this frame.
  19351. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19352. */
  19353. checkInputs(): void;
  19354. /**
  19355. * Gets the class name of the current intput.
  19356. * @returns the class name
  19357. */
  19358. getClassName(): string;
  19359. /** @hidden */
  19360. _onLostFocus(): void;
  19361. /**
  19362. * Get the friendly name associated with the input class.
  19363. * @returns the input friendly name
  19364. */
  19365. getSimpleName(): string;
  19366. }
  19367. }
  19368. declare module "babylonjs/Events/pointerEvents" {
  19369. import { Nullable } from "babylonjs/types";
  19370. import { Vector2 } from "babylonjs/Maths/math.vector";
  19371. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19372. import { Ray } from "babylonjs/Culling/ray";
  19373. /**
  19374. * Gather the list of pointer event types as constants.
  19375. */
  19376. export class PointerEventTypes {
  19377. /**
  19378. * 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.
  19379. */
  19380. static readonly POINTERDOWN: number;
  19381. /**
  19382. * The pointerup event is fired when a pointer is no longer active.
  19383. */
  19384. static readonly POINTERUP: number;
  19385. /**
  19386. * The pointermove event is fired when a pointer changes coordinates.
  19387. */
  19388. static readonly POINTERMOVE: number;
  19389. /**
  19390. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19391. */
  19392. static readonly POINTERWHEEL: number;
  19393. /**
  19394. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19395. */
  19396. static readonly POINTERPICK: number;
  19397. /**
  19398. * The pointertap event is fired when a the object has been touched and released without drag.
  19399. */
  19400. static readonly POINTERTAP: number;
  19401. /**
  19402. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19403. */
  19404. static readonly POINTERDOUBLETAP: number;
  19405. }
  19406. /**
  19407. * Base class of pointer info types.
  19408. */
  19409. export class PointerInfoBase {
  19410. /**
  19411. * Defines the type of event (PointerEventTypes)
  19412. */
  19413. type: number;
  19414. /**
  19415. * Defines the related dom event
  19416. */
  19417. event: PointerEvent | MouseWheelEvent;
  19418. /**
  19419. * Instantiates the base class of pointers info.
  19420. * @param type Defines the type of event (PointerEventTypes)
  19421. * @param event Defines the related dom event
  19422. */
  19423. constructor(
  19424. /**
  19425. * Defines the type of event (PointerEventTypes)
  19426. */
  19427. type: number,
  19428. /**
  19429. * Defines the related dom event
  19430. */
  19431. event: PointerEvent | MouseWheelEvent);
  19432. }
  19433. /**
  19434. * This class is used to store pointer related info for the onPrePointerObservable event.
  19435. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19436. */
  19437. export class PointerInfoPre extends PointerInfoBase {
  19438. /**
  19439. * Ray from a pointer if availible (eg. 6dof controller)
  19440. */
  19441. ray: Nullable<Ray>;
  19442. /**
  19443. * Defines the local position of the pointer on the canvas.
  19444. */
  19445. localPosition: Vector2;
  19446. /**
  19447. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19448. */
  19449. skipOnPointerObservable: boolean;
  19450. /**
  19451. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19452. * @param type Defines the type of event (PointerEventTypes)
  19453. * @param event Defines the related dom event
  19454. * @param localX Defines the local x coordinates of the pointer when the event occured
  19455. * @param localY Defines the local y coordinates of the pointer when the event occured
  19456. */
  19457. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19458. }
  19459. /**
  19460. * This type contains all the data related to a pointer event in Babylon.js.
  19461. * 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.
  19462. */
  19463. export class PointerInfo extends PointerInfoBase {
  19464. /**
  19465. * Defines the picking info associated to the info (if any)\
  19466. */
  19467. pickInfo: Nullable<PickingInfo>;
  19468. /**
  19469. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19470. * @param type Defines the type of event (PointerEventTypes)
  19471. * @param event Defines the related dom event
  19472. * @param pickInfo Defines the picking info associated to the info (if any)\
  19473. */
  19474. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19475. /**
  19476. * Defines the picking info associated to the info (if any)\
  19477. */
  19478. pickInfo: Nullable<PickingInfo>);
  19479. }
  19480. /**
  19481. * Data relating to a touch event on the screen.
  19482. */
  19483. export interface PointerTouch {
  19484. /**
  19485. * X coordinate of touch.
  19486. */
  19487. x: number;
  19488. /**
  19489. * Y coordinate of touch.
  19490. */
  19491. y: number;
  19492. /**
  19493. * Id of touch. Unique for each finger.
  19494. */
  19495. pointerId: number;
  19496. /**
  19497. * Event type passed from DOM.
  19498. */
  19499. type: any;
  19500. }
  19501. }
  19502. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19503. import { Observable } from "babylonjs/Misc/observable";
  19504. import { Nullable } from "babylonjs/types";
  19505. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19506. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19507. /**
  19508. * Manage the mouse inputs to control the movement of a free camera.
  19509. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19510. */
  19511. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19512. /**
  19513. * Define if touch is enabled in the mouse input
  19514. */
  19515. touchEnabled: boolean;
  19516. /**
  19517. * Defines the camera the input is attached to.
  19518. */
  19519. camera: FreeCamera;
  19520. /**
  19521. * Defines the buttons associated with the input to handle camera move.
  19522. */
  19523. buttons: number[];
  19524. /**
  19525. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19526. */
  19527. angularSensibility: number;
  19528. private _pointerInput;
  19529. private _onMouseMove;
  19530. private _observer;
  19531. private previousPosition;
  19532. /**
  19533. * Observable for when a pointer move event occurs containing the move offset
  19534. */
  19535. onPointerMovedObservable: Observable<{
  19536. offsetX: number;
  19537. offsetY: number;
  19538. }>;
  19539. /**
  19540. * @hidden
  19541. * If the camera should be rotated automatically based on pointer movement
  19542. */
  19543. _allowCameraRotation: boolean;
  19544. /**
  19545. * Manage the mouse inputs to control the movement of a free camera.
  19546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19547. * @param touchEnabled Defines if touch is enabled or not
  19548. */
  19549. constructor(
  19550. /**
  19551. * Define if touch is enabled in the mouse input
  19552. */
  19553. touchEnabled?: boolean);
  19554. /**
  19555. * Attach the input controls to a specific dom element to get the input from.
  19556. * @param element Defines the element the controls should be listened from
  19557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19558. */
  19559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19560. /**
  19561. * Called on JS contextmenu event.
  19562. * Override this method to provide functionality.
  19563. */
  19564. protected onContextMenu(evt: PointerEvent): void;
  19565. /**
  19566. * Detach the current controls from the specified dom element.
  19567. * @param element Defines the element to stop listening the inputs from
  19568. */
  19569. detachControl(element: Nullable<HTMLElement>): void;
  19570. /**
  19571. * Gets the class name of the current intput.
  19572. * @returns the class name
  19573. */
  19574. getClassName(): string;
  19575. /**
  19576. * Get the friendly name associated with the input class.
  19577. * @returns the input friendly name
  19578. */
  19579. getSimpleName(): string;
  19580. }
  19581. }
  19582. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19583. import { Nullable } from "babylonjs/types";
  19584. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19585. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19586. /**
  19587. * Manage the touch inputs to control the movement of a free camera.
  19588. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19589. */
  19590. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19591. /**
  19592. * Define if mouse events can be treated as touch events
  19593. */
  19594. allowMouse: boolean;
  19595. /**
  19596. * Defines the camera the input is attached to.
  19597. */
  19598. camera: FreeCamera;
  19599. /**
  19600. * Defines the touch sensibility for rotation.
  19601. * The higher the faster.
  19602. */
  19603. touchAngularSensibility: number;
  19604. /**
  19605. * Defines the touch sensibility for move.
  19606. * The higher the faster.
  19607. */
  19608. touchMoveSensibility: number;
  19609. private _offsetX;
  19610. private _offsetY;
  19611. private _pointerPressed;
  19612. private _pointerInput;
  19613. private _observer;
  19614. private _onLostFocus;
  19615. /**
  19616. * Manage the touch inputs to control the movement of a free camera.
  19617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19618. * @param allowMouse Defines if mouse events can be treated as touch events
  19619. */
  19620. constructor(
  19621. /**
  19622. * Define if mouse events can be treated as touch events
  19623. */
  19624. allowMouse?: boolean);
  19625. /**
  19626. * Attach the input controls to a specific dom element to get the input from.
  19627. * @param element Defines the element the controls should be listened from
  19628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19629. */
  19630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19631. /**
  19632. * Detach the current controls from the specified dom element.
  19633. * @param element Defines the element to stop listening the inputs from
  19634. */
  19635. detachControl(element: Nullable<HTMLElement>): void;
  19636. /**
  19637. * Update the current camera state depending on the inputs that have been used this frame.
  19638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19639. */
  19640. checkInputs(): void;
  19641. /**
  19642. * Gets the class name of the current intput.
  19643. * @returns the class name
  19644. */
  19645. getClassName(): string;
  19646. /**
  19647. * Get the friendly name associated with the input class.
  19648. * @returns the input friendly name
  19649. */
  19650. getSimpleName(): string;
  19651. }
  19652. }
  19653. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19654. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19655. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19656. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19657. import { Nullable } from "babylonjs/types";
  19658. /**
  19659. * Default Inputs manager for the FreeCamera.
  19660. * It groups all the default supported inputs for ease of use.
  19661. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19662. */
  19663. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19664. /**
  19665. * @hidden
  19666. */
  19667. _mouseInput: Nullable<FreeCameraMouseInput>;
  19668. /**
  19669. * Instantiates a new FreeCameraInputsManager.
  19670. * @param camera Defines the camera the inputs belong to
  19671. */
  19672. constructor(camera: FreeCamera);
  19673. /**
  19674. * Add keyboard input support to the input manager.
  19675. * @returns the current input manager
  19676. */
  19677. addKeyboard(): FreeCameraInputsManager;
  19678. /**
  19679. * Add mouse input support to the input manager.
  19680. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19681. * @returns the current input manager
  19682. */
  19683. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19684. /**
  19685. * Removes the mouse input support from the manager
  19686. * @returns the current input manager
  19687. */
  19688. removeMouse(): FreeCameraInputsManager;
  19689. /**
  19690. * Add touch input support to the input manager.
  19691. * @returns the current input manager
  19692. */
  19693. addTouch(): FreeCameraInputsManager;
  19694. /**
  19695. * Remove all attached input methods from a camera
  19696. */
  19697. clear(): void;
  19698. }
  19699. }
  19700. declare module "babylonjs/Cameras/freeCamera" {
  19701. import { Vector3 } from "babylonjs/Maths/math.vector";
  19702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19703. import { Scene } from "babylonjs/scene";
  19704. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19705. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19706. /**
  19707. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19708. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19709. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19710. */
  19711. export class FreeCamera extends TargetCamera {
  19712. /**
  19713. * Define the collision ellipsoid of the camera.
  19714. * This is helpful to simulate a camera body like the player body around the camera
  19715. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19716. */
  19717. ellipsoid: Vector3;
  19718. /**
  19719. * Define an offset for the position of the ellipsoid around the camera.
  19720. * This can be helpful to determine the center of the body near the gravity center of the body
  19721. * instead of its head.
  19722. */
  19723. ellipsoidOffset: Vector3;
  19724. /**
  19725. * Enable or disable collisions of the camera with the rest of the scene objects.
  19726. */
  19727. checkCollisions: boolean;
  19728. /**
  19729. * Enable or disable gravity on the camera.
  19730. */
  19731. applyGravity: boolean;
  19732. /**
  19733. * Define the input manager associated to the camera.
  19734. */
  19735. inputs: FreeCameraInputsManager;
  19736. /**
  19737. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19738. * Higher values reduce sensitivity.
  19739. */
  19740. get angularSensibility(): number;
  19741. /**
  19742. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19743. * Higher values reduce sensitivity.
  19744. */
  19745. set angularSensibility(value: number);
  19746. /**
  19747. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19748. */
  19749. get keysUp(): number[];
  19750. set keysUp(value: number[]);
  19751. /**
  19752. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19753. */
  19754. get keysUpward(): number[];
  19755. set keysUpward(value: number[]);
  19756. /**
  19757. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19758. */
  19759. get keysDown(): number[];
  19760. set keysDown(value: number[]);
  19761. /**
  19762. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19763. */
  19764. get keysDownward(): number[];
  19765. set keysDownward(value: number[]);
  19766. /**
  19767. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19768. */
  19769. get keysLeft(): number[];
  19770. set keysLeft(value: number[]);
  19771. /**
  19772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19773. */
  19774. get keysRight(): number[];
  19775. set keysRight(value: number[]);
  19776. /**
  19777. * Event raised when the camera collide with a mesh in the scene.
  19778. */
  19779. onCollide: (collidedMesh: AbstractMesh) => void;
  19780. private _collider;
  19781. private _needMoveForGravity;
  19782. private _oldPosition;
  19783. private _diffPosition;
  19784. private _newPosition;
  19785. /** @hidden */
  19786. _localDirection: Vector3;
  19787. /** @hidden */
  19788. _transformedDirection: Vector3;
  19789. /**
  19790. * Instantiates a Free Camera.
  19791. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19792. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19793. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19794. * @param name Define the name of the camera in the scene
  19795. * @param position Define the start position of the camera in the scene
  19796. * @param scene Define the scene the camera belongs to
  19797. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19798. */
  19799. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19800. /**
  19801. * Attached controls to the current camera.
  19802. * @param element Defines the element the controls should be listened from
  19803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19804. */
  19805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19806. /**
  19807. * Detach the current controls from the camera.
  19808. * The camera will stop reacting to inputs.
  19809. * @param element Defines the element to stop listening the inputs from
  19810. */
  19811. detachControl(element: HTMLElement): void;
  19812. private _collisionMask;
  19813. /**
  19814. * Define a collision mask to limit the list of object the camera can collide with
  19815. */
  19816. get collisionMask(): number;
  19817. set collisionMask(mask: number);
  19818. /** @hidden */
  19819. _collideWithWorld(displacement: Vector3): void;
  19820. private _onCollisionPositionChange;
  19821. /** @hidden */
  19822. _checkInputs(): void;
  19823. /** @hidden */
  19824. _decideIfNeedsToMove(): boolean;
  19825. /** @hidden */
  19826. _updatePosition(): void;
  19827. /**
  19828. * Destroy the camera and release the current resources hold by it.
  19829. */
  19830. dispose(): void;
  19831. /**
  19832. * Gets the current object class name.
  19833. * @return the class name
  19834. */
  19835. getClassName(): string;
  19836. }
  19837. }
  19838. declare module "babylonjs/Gamepads/gamepad" {
  19839. import { Observable } from "babylonjs/Misc/observable";
  19840. /**
  19841. * Represents a gamepad control stick position
  19842. */
  19843. export class StickValues {
  19844. /**
  19845. * The x component of the control stick
  19846. */
  19847. x: number;
  19848. /**
  19849. * The y component of the control stick
  19850. */
  19851. y: number;
  19852. /**
  19853. * Initializes the gamepad x and y control stick values
  19854. * @param x The x component of the gamepad control stick value
  19855. * @param y The y component of the gamepad control stick value
  19856. */
  19857. constructor(
  19858. /**
  19859. * The x component of the control stick
  19860. */
  19861. x: number,
  19862. /**
  19863. * The y component of the control stick
  19864. */
  19865. y: number);
  19866. }
  19867. /**
  19868. * An interface which manages callbacks for gamepad button changes
  19869. */
  19870. export interface GamepadButtonChanges {
  19871. /**
  19872. * Called when a gamepad has been changed
  19873. */
  19874. changed: boolean;
  19875. /**
  19876. * Called when a gamepad press event has been triggered
  19877. */
  19878. pressChanged: boolean;
  19879. /**
  19880. * Called when a touch event has been triggered
  19881. */
  19882. touchChanged: boolean;
  19883. /**
  19884. * Called when a value has changed
  19885. */
  19886. valueChanged: boolean;
  19887. }
  19888. /**
  19889. * Represents a gamepad
  19890. */
  19891. export class Gamepad {
  19892. /**
  19893. * The id of the gamepad
  19894. */
  19895. id: string;
  19896. /**
  19897. * The index of the gamepad
  19898. */
  19899. index: number;
  19900. /**
  19901. * The browser gamepad
  19902. */
  19903. browserGamepad: any;
  19904. /**
  19905. * Specifies what type of gamepad this represents
  19906. */
  19907. type: number;
  19908. private _leftStick;
  19909. private _rightStick;
  19910. /** @hidden */
  19911. _isConnected: boolean;
  19912. private _leftStickAxisX;
  19913. private _leftStickAxisY;
  19914. private _rightStickAxisX;
  19915. private _rightStickAxisY;
  19916. /**
  19917. * Triggered when the left control stick has been changed
  19918. */
  19919. private _onleftstickchanged;
  19920. /**
  19921. * Triggered when the right control stick has been changed
  19922. */
  19923. private _onrightstickchanged;
  19924. /**
  19925. * Represents a gamepad controller
  19926. */
  19927. static GAMEPAD: number;
  19928. /**
  19929. * Represents a generic controller
  19930. */
  19931. static GENERIC: number;
  19932. /**
  19933. * Represents an XBox controller
  19934. */
  19935. static XBOX: number;
  19936. /**
  19937. * Represents a pose-enabled controller
  19938. */
  19939. static POSE_ENABLED: number;
  19940. /**
  19941. * Represents an Dual Shock controller
  19942. */
  19943. static DUALSHOCK: number;
  19944. /**
  19945. * Specifies whether the left control stick should be Y-inverted
  19946. */
  19947. protected _invertLeftStickY: boolean;
  19948. /**
  19949. * Specifies if the gamepad has been connected
  19950. */
  19951. get isConnected(): boolean;
  19952. /**
  19953. * Initializes the gamepad
  19954. * @param id The id of the gamepad
  19955. * @param index The index of the gamepad
  19956. * @param browserGamepad The browser gamepad
  19957. * @param leftStickX The x component of the left joystick
  19958. * @param leftStickY The y component of the left joystick
  19959. * @param rightStickX The x component of the right joystick
  19960. * @param rightStickY The y component of the right joystick
  19961. */
  19962. constructor(
  19963. /**
  19964. * The id of the gamepad
  19965. */
  19966. id: string,
  19967. /**
  19968. * The index of the gamepad
  19969. */
  19970. index: number,
  19971. /**
  19972. * The browser gamepad
  19973. */
  19974. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19975. /**
  19976. * Callback triggered when the left joystick has changed
  19977. * @param callback
  19978. */
  19979. onleftstickchanged(callback: (values: StickValues) => void): void;
  19980. /**
  19981. * Callback triggered when the right joystick has changed
  19982. * @param callback
  19983. */
  19984. onrightstickchanged(callback: (values: StickValues) => void): void;
  19985. /**
  19986. * Gets the left joystick
  19987. */
  19988. get leftStick(): StickValues;
  19989. /**
  19990. * Sets the left joystick values
  19991. */
  19992. set leftStick(newValues: StickValues);
  19993. /**
  19994. * Gets the right joystick
  19995. */
  19996. get rightStick(): StickValues;
  19997. /**
  19998. * Sets the right joystick value
  19999. */
  20000. set rightStick(newValues: StickValues);
  20001. /**
  20002. * Updates the gamepad joystick positions
  20003. */
  20004. update(): void;
  20005. /**
  20006. * Disposes the gamepad
  20007. */
  20008. dispose(): void;
  20009. }
  20010. /**
  20011. * Represents a generic gamepad
  20012. */
  20013. export class GenericPad extends Gamepad {
  20014. private _buttons;
  20015. private _onbuttondown;
  20016. private _onbuttonup;
  20017. /**
  20018. * Observable triggered when a button has been pressed
  20019. */
  20020. onButtonDownObservable: Observable<number>;
  20021. /**
  20022. * Observable triggered when a button has been released
  20023. */
  20024. onButtonUpObservable: Observable<number>;
  20025. /**
  20026. * Callback triggered when a button has been pressed
  20027. * @param callback Called when a button has been pressed
  20028. */
  20029. onbuttondown(callback: (buttonPressed: number) => void): void;
  20030. /**
  20031. * Callback triggered when a button has been released
  20032. * @param callback Called when a button has been released
  20033. */
  20034. onbuttonup(callback: (buttonReleased: number) => void): void;
  20035. /**
  20036. * Initializes the generic gamepad
  20037. * @param id The id of the generic gamepad
  20038. * @param index The index of the generic gamepad
  20039. * @param browserGamepad The browser gamepad
  20040. */
  20041. constructor(id: string, index: number, browserGamepad: any);
  20042. private _setButtonValue;
  20043. /**
  20044. * Updates the generic gamepad
  20045. */
  20046. update(): void;
  20047. /**
  20048. * Disposes the generic gamepad
  20049. */
  20050. dispose(): void;
  20051. }
  20052. }
  20053. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20054. import { Observable } from "babylonjs/Misc/observable";
  20055. import { Nullable } from "babylonjs/types";
  20056. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20057. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20059. import { Ray } from "babylonjs/Culling/ray";
  20060. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20061. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20062. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20063. /**
  20064. * Defines the types of pose enabled controllers that are supported
  20065. */
  20066. export enum PoseEnabledControllerType {
  20067. /**
  20068. * HTC Vive
  20069. */
  20070. VIVE = 0,
  20071. /**
  20072. * Oculus Rift
  20073. */
  20074. OCULUS = 1,
  20075. /**
  20076. * Windows mixed reality
  20077. */
  20078. WINDOWS = 2,
  20079. /**
  20080. * Samsung gear VR
  20081. */
  20082. GEAR_VR = 3,
  20083. /**
  20084. * Google Daydream
  20085. */
  20086. DAYDREAM = 4,
  20087. /**
  20088. * Generic
  20089. */
  20090. GENERIC = 5
  20091. }
  20092. /**
  20093. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20094. */
  20095. export interface MutableGamepadButton {
  20096. /**
  20097. * Value of the button/trigger
  20098. */
  20099. value: number;
  20100. /**
  20101. * If the button/trigger is currently touched
  20102. */
  20103. touched: boolean;
  20104. /**
  20105. * If the button/trigger is currently pressed
  20106. */
  20107. pressed: boolean;
  20108. }
  20109. /**
  20110. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20111. * @hidden
  20112. */
  20113. export interface ExtendedGamepadButton extends GamepadButton {
  20114. /**
  20115. * If the button/trigger is currently pressed
  20116. */
  20117. readonly pressed: boolean;
  20118. /**
  20119. * If the button/trigger is currently touched
  20120. */
  20121. readonly touched: boolean;
  20122. /**
  20123. * Value of the button/trigger
  20124. */
  20125. readonly value: number;
  20126. }
  20127. /** @hidden */
  20128. export interface _GamePadFactory {
  20129. /**
  20130. * Returns whether or not the current gamepad can be created for this type of controller.
  20131. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20132. * @returns true if it can be created, otherwise false
  20133. */
  20134. canCreate(gamepadInfo: any): boolean;
  20135. /**
  20136. * Creates a new instance of the Gamepad.
  20137. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20138. * @returns the new gamepad instance
  20139. */
  20140. create(gamepadInfo: any): Gamepad;
  20141. }
  20142. /**
  20143. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20144. */
  20145. export class PoseEnabledControllerHelper {
  20146. /** @hidden */
  20147. static _ControllerFactories: _GamePadFactory[];
  20148. /** @hidden */
  20149. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20150. /**
  20151. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20152. * @param vrGamepad the gamepad to initialized
  20153. * @returns a vr controller of the type the gamepad identified as
  20154. */
  20155. static InitiateController(vrGamepad: any): Gamepad;
  20156. }
  20157. /**
  20158. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20159. */
  20160. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20161. /**
  20162. * If the controller is used in a webXR session
  20163. */
  20164. isXR: boolean;
  20165. private _deviceRoomPosition;
  20166. private _deviceRoomRotationQuaternion;
  20167. /**
  20168. * The device position in babylon space
  20169. */
  20170. devicePosition: Vector3;
  20171. /**
  20172. * The device rotation in babylon space
  20173. */
  20174. deviceRotationQuaternion: Quaternion;
  20175. /**
  20176. * The scale factor of the device in babylon space
  20177. */
  20178. deviceScaleFactor: number;
  20179. /**
  20180. * (Likely devicePosition should be used instead) The device position in its room space
  20181. */
  20182. position: Vector3;
  20183. /**
  20184. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20185. */
  20186. rotationQuaternion: Quaternion;
  20187. /**
  20188. * The type of controller (Eg. Windows mixed reality)
  20189. */
  20190. controllerType: PoseEnabledControllerType;
  20191. protected _calculatedPosition: Vector3;
  20192. private _calculatedRotation;
  20193. /**
  20194. * The raw pose from the device
  20195. */
  20196. rawPose: DevicePose;
  20197. private _trackPosition;
  20198. private _maxRotationDistFromHeadset;
  20199. private _draggedRoomRotation;
  20200. /**
  20201. * @hidden
  20202. */
  20203. _disableTrackPosition(fixedPosition: Vector3): void;
  20204. /**
  20205. * Internal, the mesh attached to the controller
  20206. * @hidden
  20207. */
  20208. _mesh: Nullable<AbstractMesh>;
  20209. private _poseControlledCamera;
  20210. private _leftHandSystemQuaternion;
  20211. /**
  20212. * Internal, matrix used to convert room space to babylon space
  20213. * @hidden
  20214. */
  20215. _deviceToWorld: Matrix;
  20216. /**
  20217. * Node to be used when casting a ray from the controller
  20218. * @hidden
  20219. */
  20220. _pointingPoseNode: Nullable<TransformNode>;
  20221. /**
  20222. * Name of the child mesh that can be used to cast a ray from the controller
  20223. */
  20224. static readonly POINTING_POSE: string;
  20225. /**
  20226. * Creates a new PoseEnabledController from a gamepad
  20227. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20228. */
  20229. constructor(browserGamepad: any);
  20230. private _workingMatrix;
  20231. /**
  20232. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20233. */
  20234. update(): void;
  20235. /**
  20236. * Updates only the pose device and mesh without doing any button event checking
  20237. */
  20238. protected _updatePoseAndMesh(): void;
  20239. /**
  20240. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20241. * @param poseData raw pose fromthe device
  20242. */
  20243. updateFromDevice(poseData: DevicePose): void;
  20244. /**
  20245. * @hidden
  20246. */
  20247. _meshAttachedObservable: Observable<AbstractMesh>;
  20248. /**
  20249. * Attaches a mesh to the controller
  20250. * @param mesh the mesh to be attached
  20251. */
  20252. attachToMesh(mesh: AbstractMesh): void;
  20253. /**
  20254. * Attaches the controllers mesh to a camera
  20255. * @param camera the camera the mesh should be attached to
  20256. */
  20257. attachToPoseControlledCamera(camera: TargetCamera): void;
  20258. /**
  20259. * Disposes of the controller
  20260. */
  20261. dispose(): void;
  20262. /**
  20263. * The mesh that is attached to the controller
  20264. */
  20265. get mesh(): Nullable<AbstractMesh>;
  20266. /**
  20267. * Gets the ray of the controller in the direction the controller is pointing
  20268. * @param length the length the resulting ray should be
  20269. * @returns a ray in the direction the controller is pointing
  20270. */
  20271. getForwardRay(length?: number): Ray;
  20272. }
  20273. }
  20274. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20275. import { Observable } from "babylonjs/Misc/observable";
  20276. import { Scene } from "babylonjs/scene";
  20277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20278. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20279. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20280. import { Nullable } from "babylonjs/types";
  20281. /**
  20282. * Defines the WebVRController object that represents controllers tracked in 3D space
  20283. */
  20284. export abstract class WebVRController extends PoseEnabledController {
  20285. /**
  20286. * Internal, the default controller model for the controller
  20287. */
  20288. protected _defaultModel: Nullable<AbstractMesh>;
  20289. /**
  20290. * Fired when the trigger state has changed
  20291. */
  20292. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20293. /**
  20294. * Fired when the main button state has changed
  20295. */
  20296. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20297. /**
  20298. * Fired when the secondary button state has changed
  20299. */
  20300. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20301. /**
  20302. * Fired when the pad state has changed
  20303. */
  20304. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20305. /**
  20306. * Fired when controllers stick values have changed
  20307. */
  20308. onPadValuesChangedObservable: Observable<StickValues>;
  20309. /**
  20310. * Array of button availible on the controller
  20311. */
  20312. protected _buttons: Array<MutableGamepadButton>;
  20313. private _onButtonStateChange;
  20314. /**
  20315. * Fired when a controller button's state has changed
  20316. * @param callback the callback containing the button that was modified
  20317. */
  20318. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20319. /**
  20320. * X and Y axis corresponding to the controllers joystick
  20321. */
  20322. pad: StickValues;
  20323. /**
  20324. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20325. */
  20326. hand: string;
  20327. /**
  20328. * The default controller model for the controller
  20329. */
  20330. get defaultModel(): Nullable<AbstractMesh>;
  20331. /**
  20332. * Creates a new WebVRController from a gamepad
  20333. * @param vrGamepad the gamepad that the WebVRController should be created from
  20334. */
  20335. constructor(vrGamepad: any);
  20336. /**
  20337. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20338. */
  20339. update(): void;
  20340. /**
  20341. * Function to be called when a button is modified
  20342. */
  20343. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20344. /**
  20345. * Loads a mesh and attaches it to the controller
  20346. * @param scene the scene the mesh should be added to
  20347. * @param meshLoaded callback for when the mesh has been loaded
  20348. */
  20349. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20350. private _setButtonValue;
  20351. private _changes;
  20352. private _checkChanges;
  20353. /**
  20354. * Disposes of th webVRCOntroller
  20355. */
  20356. dispose(): void;
  20357. }
  20358. }
  20359. declare module "babylonjs/Lights/hemisphericLight" {
  20360. import { Nullable } from "babylonjs/types";
  20361. import { Scene } from "babylonjs/scene";
  20362. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20363. import { Color3 } from "babylonjs/Maths/math.color";
  20364. import { Effect } from "babylonjs/Materials/effect";
  20365. import { Light } from "babylonjs/Lights/light";
  20366. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20367. /**
  20368. * The HemisphericLight simulates the ambient environment light,
  20369. * so the passed direction is the light reflection direction, not the incoming direction.
  20370. */
  20371. export class HemisphericLight extends Light {
  20372. /**
  20373. * The groundColor is the light in the opposite direction to the one specified during creation.
  20374. * 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.
  20375. */
  20376. groundColor: Color3;
  20377. /**
  20378. * The light reflection direction, not the incoming direction.
  20379. */
  20380. direction: Vector3;
  20381. /**
  20382. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20383. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20384. * The HemisphericLight can't cast shadows.
  20385. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20386. * @param name The friendly name of the light
  20387. * @param direction The direction of the light reflection
  20388. * @param scene The scene the light belongs to
  20389. */
  20390. constructor(name: string, direction: Vector3, scene: Scene);
  20391. protected _buildUniformLayout(): void;
  20392. /**
  20393. * Returns the string "HemisphericLight".
  20394. * @return The class name
  20395. */
  20396. getClassName(): string;
  20397. /**
  20398. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20399. * Returns the updated direction.
  20400. * @param target The target the direction should point to
  20401. * @return The computed direction
  20402. */
  20403. setDirectionToTarget(target: Vector3): Vector3;
  20404. /**
  20405. * Returns the shadow generator associated to the light.
  20406. * @returns Always null for hemispheric lights because it does not support shadows.
  20407. */
  20408. getShadowGenerator(): Nullable<IShadowGenerator>;
  20409. /**
  20410. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20411. * @param effect The effect to update
  20412. * @param lightIndex The index of the light in the effect to update
  20413. * @returns The hemispheric light
  20414. */
  20415. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20416. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20417. /**
  20418. * Computes the world matrix of the node
  20419. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20420. * @param useWasUpdatedFlag defines a reserved property
  20421. * @returns the world matrix
  20422. */
  20423. computeWorldMatrix(): Matrix;
  20424. /**
  20425. * Returns the integer 3.
  20426. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20427. */
  20428. getTypeID(): number;
  20429. /**
  20430. * Prepares the list of defines specific to the light type.
  20431. * @param defines the list of defines
  20432. * @param lightIndex defines the index of the light for the effect
  20433. */
  20434. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20435. }
  20436. }
  20437. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20438. /** @hidden */
  20439. export var vrMultiviewToSingleviewPixelShader: {
  20440. name: string;
  20441. shader: string;
  20442. };
  20443. }
  20444. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20446. import { Scene } from "babylonjs/scene";
  20447. /**
  20448. * Renders to multiple views with a single draw call
  20449. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20450. */
  20451. export class MultiviewRenderTarget extends RenderTargetTexture {
  20452. /**
  20453. * Creates a multiview render target
  20454. * @param scene scene used with the render target
  20455. * @param size the size of the render target (used for each view)
  20456. */
  20457. constructor(scene: Scene, size?: number | {
  20458. width: number;
  20459. height: number;
  20460. } | {
  20461. ratio: number;
  20462. });
  20463. /**
  20464. * @hidden
  20465. * @param faceIndex the face index, if its a cube texture
  20466. */
  20467. _bindFrameBuffer(faceIndex?: number): void;
  20468. /**
  20469. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20470. * @returns the view count
  20471. */
  20472. getViewCount(): number;
  20473. }
  20474. }
  20475. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20476. import { Camera } from "babylonjs/Cameras/camera";
  20477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20478. import { Nullable } from "babylonjs/types";
  20479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20480. import { Matrix } from "babylonjs/Maths/math.vector";
  20481. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20482. module "babylonjs/Engines/engine" {
  20483. interface Engine {
  20484. /**
  20485. * Creates a new multiview render target
  20486. * @param width defines the width of the texture
  20487. * @param height defines the height of the texture
  20488. * @returns the created multiview texture
  20489. */
  20490. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20491. /**
  20492. * Binds a multiview framebuffer to be drawn to
  20493. * @param multiviewTexture texture to bind
  20494. */
  20495. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20496. }
  20497. }
  20498. module "babylonjs/Cameras/camera" {
  20499. interface Camera {
  20500. /**
  20501. * @hidden
  20502. * 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)
  20503. */
  20504. _useMultiviewToSingleView: boolean;
  20505. /**
  20506. * @hidden
  20507. * 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)
  20508. */
  20509. _multiviewTexture: Nullable<RenderTargetTexture>;
  20510. /**
  20511. * @hidden
  20512. * ensures the multiview texture of the camera exists and has the specified width/height
  20513. * @param width height to set on the multiview texture
  20514. * @param height width to set on the multiview texture
  20515. */
  20516. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20517. }
  20518. }
  20519. module "babylonjs/scene" {
  20520. interface Scene {
  20521. /** @hidden */
  20522. _transformMatrixR: Matrix;
  20523. /** @hidden */
  20524. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20525. /** @hidden */
  20526. _createMultiviewUbo(): void;
  20527. /** @hidden */
  20528. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20529. /** @hidden */
  20530. _renderMultiviewToSingleView(camera: Camera): void;
  20531. }
  20532. }
  20533. }
  20534. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20535. import { Camera } from "babylonjs/Cameras/camera";
  20536. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20537. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20538. import "babylonjs/Engines/Extensions/engine.multiview";
  20539. /**
  20540. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20541. * This will not be used for webXR as it supports displaying texture arrays directly
  20542. */
  20543. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20544. /**
  20545. * Gets a string identifying the name of the class
  20546. * @returns "VRMultiviewToSingleviewPostProcess" string
  20547. */
  20548. getClassName(): string;
  20549. /**
  20550. * Initializes a VRMultiviewToSingleview
  20551. * @param name name of the post process
  20552. * @param camera camera to be applied to
  20553. * @param scaleFactor scaling factor to the size of the output texture
  20554. */
  20555. constructor(name: string, camera: Camera, scaleFactor: number);
  20556. }
  20557. }
  20558. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20559. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20560. import { Nullable } from "babylonjs/types";
  20561. import { Size } from "babylonjs/Maths/math.size";
  20562. import { Observable } from "babylonjs/Misc/observable";
  20563. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20564. /**
  20565. * Interface used to define additional presentation attributes
  20566. */
  20567. export interface IVRPresentationAttributes {
  20568. /**
  20569. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20570. */
  20571. highRefreshRate: boolean;
  20572. /**
  20573. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20574. */
  20575. foveationLevel: number;
  20576. }
  20577. module "babylonjs/Engines/engine" {
  20578. interface Engine {
  20579. /** @hidden */
  20580. _vrDisplay: any;
  20581. /** @hidden */
  20582. _vrSupported: boolean;
  20583. /** @hidden */
  20584. _oldSize: Size;
  20585. /** @hidden */
  20586. _oldHardwareScaleFactor: number;
  20587. /** @hidden */
  20588. _vrExclusivePointerMode: boolean;
  20589. /** @hidden */
  20590. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20591. /** @hidden */
  20592. _onVRDisplayPointerRestricted: () => void;
  20593. /** @hidden */
  20594. _onVRDisplayPointerUnrestricted: () => void;
  20595. /** @hidden */
  20596. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20597. /** @hidden */
  20598. _onVrDisplayDisconnect: Nullable<() => void>;
  20599. /** @hidden */
  20600. _onVrDisplayPresentChange: Nullable<() => void>;
  20601. /**
  20602. * Observable signaled when VR display mode changes
  20603. */
  20604. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20605. /**
  20606. * Observable signaled when VR request present is complete
  20607. */
  20608. onVRRequestPresentComplete: Observable<boolean>;
  20609. /**
  20610. * Observable signaled when VR request present starts
  20611. */
  20612. onVRRequestPresentStart: Observable<Engine>;
  20613. /**
  20614. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20615. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20616. */
  20617. isInVRExclusivePointerMode: boolean;
  20618. /**
  20619. * Gets a boolean indicating if a webVR device was detected
  20620. * @returns true if a webVR device was detected
  20621. */
  20622. isVRDevicePresent(): boolean;
  20623. /**
  20624. * Gets the current webVR device
  20625. * @returns the current webVR device (or null)
  20626. */
  20627. getVRDevice(): any;
  20628. /**
  20629. * Initializes a webVR display and starts listening to display change events
  20630. * The onVRDisplayChangedObservable will be notified upon these changes
  20631. * @returns A promise containing a VRDisplay and if vr is supported
  20632. */
  20633. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20634. /** @hidden */
  20635. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20636. /**
  20637. * Gets or sets the presentation attributes used to configure VR rendering
  20638. */
  20639. vrPresentationAttributes?: IVRPresentationAttributes;
  20640. /**
  20641. * Call this function to switch to webVR mode
  20642. * Will do nothing if webVR is not supported or if there is no webVR device
  20643. * @param options the webvr options provided to the camera. mainly used for multiview
  20644. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20645. */
  20646. enableVR(options: WebVROptions): void;
  20647. /** @hidden */
  20648. _onVRFullScreenTriggered(): void;
  20649. }
  20650. }
  20651. }
  20652. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20653. import { Nullable } from "babylonjs/types";
  20654. import { Observable } from "babylonjs/Misc/observable";
  20655. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20656. import { Scene } from "babylonjs/scene";
  20657. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20658. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20659. import { Node } from "babylonjs/node";
  20660. import { Ray } from "babylonjs/Culling/ray";
  20661. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20662. import "babylonjs/Engines/Extensions/engine.webVR";
  20663. /**
  20664. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20665. * IMPORTANT!! The data is right-hand data.
  20666. * @export
  20667. * @interface DevicePose
  20668. */
  20669. export interface DevicePose {
  20670. /**
  20671. * The position of the device, values in array are [x,y,z].
  20672. */
  20673. readonly position: Nullable<Float32Array>;
  20674. /**
  20675. * The linearVelocity of the device, values in array are [x,y,z].
  20676. */
  20677. readonly linearVelocity: Nullable<Float32Array>;
  20678. /**
  20679. * The linearAcceleration of the device, values in array are [x,y,z].
  20680. */
  20681. readonly linearAcceleration: Nullable<Float32Array>;
  20682. /**
  20683. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20684. */
  20685. readonly orientation: Nullable<Float32Array>;
  20686. /**
  20687. * The angularVelocity of the device, values in array are [x,y,z].
  20688. */
  20689. readonly angularVelocity: Nullable<Float32Array>;
  20690. /**
  20691. * The angularAcceleration of the device, values in array are [x,y,z].
  20692. */
  20693. readonly angularAcceleration: Nullable<Float32Array>;
  20694. }
  20695. /**
  20696. * Interface representing a pose controlled object in Babylon.
  20697. * A pose controlled object has both regular pose values as well as pose values
  20698. * from an external device such as a VR head mounted display
  20699. */
  20700. export interface PoseControlled {
  20701. /**
  20702. * The position of the object in babylon space.
  20703. */
  20704. position: Vector3;
  20705. /**
  20706. * The rotation quaternion of the object in babylon space.
  20707. */
  20708. rotationQuaternion: Quaternion;
  20709. /**
  20710. * The position of the device in babylon space.
  20711. */
  20712. devicePosition?: Vector3;
  20713. /**
  20714. * The rotation quaternion of the device in babylon space.
  20715. */
  20716. deviceRotationQuaternion: Quaternion;
  20717. /**
  20718. * The raw pose coming from the device.
  20719. */
  20720. rawPose: Nullable<DevicePose>;
  20721. /**
  20722. * The scale of the device to be used when translating from device space to babylon space.
  20723. */
  20724. deviceScaleFactor: number;
  20725. /**
  20726. * Updates the poseControlled values based on the input device pose.
  20727. * @param poseData the pose data to update the object with
  20728. */
  20729. updateFromDevice(poseData: DevicePose): void;
  20730. }
  20731. /**
  20732. * Set of options to customize the webVRCamera
  20733. */
  20734. export interface WebVROptions {
  20735. /**
  20736. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20737. */
  20738. trackPosition?: boolean;
  20739. /**
  20740. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20741. */
  20742. positionScale?: number;
  20743. /**
  20744. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20745. */
  20746. displayName?: string;
  20747. /**
  20748. * Should the native controller meshes be initialized. (default: true)
  20749. */
  20750. controllerMeshes?: boolean;
  20751. /**
  20752. * Creating a default HemiLight only on controllers. (default: true)
  20753. */
  20754. defaultLightingOnControllers?: boolean;
  20755. /**
  20756. * If you don't want to use the default VR button of the helper. (default: false)
  20757. */
  20758. useCustomVRButton?: boolean;
  20759. /**
  20760. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20761. */
  20762. customVRButton?: HTMLButtonElement;
  20763. /**
  20764. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20765. */
  20766. rayLength?: number;
  20767. /**
  20768. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20769. */
  20770. defaultHeight?: number;
  20771. /**
  20772. * If multiview should be used if availible (default: false)
  20773. */
  20774. useMultiview?: boolean;
  20775. }
  20776. /**
  20777. * This represents a WebVR camera.
  20778. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20779. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20780. */
  20781. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20782. private webVROptions;
  20783. /**
  20784. * @hidden
  20785. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20786. */
  20787. _vrDevice: any;
  20788. /**
  20789. * The rawPose of the vrDevice.
  20790. */
  20791. rawPose: Nullable<DevicePose>;
  20792. private _onVREnabled;
  20793. private _specsVersion;
  20794. private _attached;
  20795. private _frameData;
  20796. protected _descendants: Array<Node>;
  20797. private _deviceRoomPosition;
  20798. /** @hidden */
  20799. _deviceRoomRotationQuaternion: Quaternion;
  20800. private _standingMatrix;
  20801. /**
  20802. * Represents device position in babylon space.
  20803. */
  20804. devicePosition: Vector3;
  20805. /**
  20806. * Represents device rotation in babylon space.
  20807. */
  20808. deviceRotationQuaternion: Quaternion;
  20809. /**
  20810. * The scale of the device to be used when translating from device space to babylon space.
  20811. */
  20812. deviceScaleFactor: number;
  20813. private _deviceToWorld;
  20814. private _worldToDevice;
  20815. /**
  20816. * References to the webVR controllers for the vrDevice.
  20817. */
  20818. controllers: Array<WebVRController>;
  20819. /**
  20820. * Emits an event when a controller is attached.
  20821. */
  20822. onControllersAttachedObservable: Observable<WebVRController[]>;
  20823. /**
  20824. * Emits an event when a controller's mesh has been loaded;
  20825. */
  20826. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20827. /**
  20828. * Emits an event when the HMD's pose has been updated.
  20829. */
  20830. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20831. private _poseSet;
  20832. /**
  20833. * If the rig cameras be used as parent instead of this camera.
  20834. */
  20835. rigParenting: boolean;
  20836. private _lightOnControllers;
  20837. private _defaultHeight?;
  20838. /**
  20839. * Instantiates a WebVRFreeCamera.
  20840. * @param name The name of the WebVRFreeCamera
  20841. * @param position The starting anchor position for the camera
  20842. * @param scene The scene the camera belongs to
  20843. * @param webVROptions a set of customizable options for the webVRCamera
  20844. */
  20845. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20846. /**
  20847. * Gets the device distance from the ground in meters.
  20848. * @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.
  20849. */
  20850. deviceDistanceToRoomGround(): number;
  20851. /**
  20852. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20853. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20854. */
  20855. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20856. /**
  20857. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20858. * @returns A promise with a boolean set to if the standing matrix is supported.
  20859. */
  20860. useStandingMatrixAsync(): Promise<boolean>;
  20861. /**
  20862. * Disposes the camera
  20863. */
  20864. dispose(): void;
  20865. /**
  20866. * Gets a vrController by name.
  20867. * @param name The name of the controller to retreive
  20868. * @returns the controller matching the name specified or null if not found
  20869. */
  20870. getControllerByName(name: string): Nullable<WebVRController>;
  20871. private _leftController;
  20872. /**
  20873. * The controller corresponding to the users left hand.
  20874. */
  20875. get leftController(): Nullable<WebVRController>;
  20876. private _rightController;
  20877. /**
  20878. * The controller corresponding to the users right hand.
  20879. */
  20880. get rightController(): Nullable<WebVRController>;
  20881. /**
  20882. * Casts a ray forward from the vrCamera's gaze.
  20883. * @param length Length of the ray (default: 100)
  20884. * @returns the ray corresponding to the gaze
  20885. */
  20886. getForwardRay(length?: number): Ray;
  20887. /**
  20888. * @hidden
  20889. * Updates the camera based on device's frame data
  20890. */
  20891. _checkInputs(): void;
  20892. /**
  20893. * Updates the poseControlled values based on the input device pose.
  20894. * @param poseData Pose coming from the device
  20895. */
  20896. updateFromDevice(poseData: DevicePose): void;
  20897. private _htmlElementAttached;
  20898. private _detachIfAttached;
  20899. /**
  20900. * WebVR's attach control will start broadcasting frames to the device.
  20901. * Note that in certain browsers (chrome for example) this function must be called
  20902. * within a user-interaction callback. Example:
  20903. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20904. *
  20905. * @param element html element to attach the vrDevice to
  20906. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20907. */
  20908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20909. /**
  20910. * Detaches the camera from the html element and disables VR
  20911. *
  20912. * @param element html element to detach from
  20913. */
  20914. detachControl(element: HTMLElement): void;
  20915. /**
  20916. * @returns the name of this class
  20917. */
  20918. getClassName(): string;
  20919. /**
  20920. * Calls resetPose on the vrDisplay
  20921. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20922. */
  20923. resetToCurrentRotation(): void;
  20924. /**
  20925. * @hidden
  20926. * Updates the rig cameras (left and right eye)
  20927. */
  20928. _updateRigCameras(): void;
  20929. private _workingVector;
  20930. private _oneVector;
  20931. private _workingMatrix;
  20932. private updateCacheCalled;
  20933. private _correctPositionIfNotTrackPosition;
  20934. /**
  20935. * @hidden
  20936. * Updates the cached values of the camera
  20937. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20938. */
  20939. _updateCache(ignoreParentClass?: boolean): void;
  20940. /**
  20941. * @hidden
  20942. * Get current device position in babylon world
  20943. */
  20944. _computeDevicePosition(): void;
  20945. /**
  20946. * Updates the current device position and rotation in the babylon world
  20947. */
  20948. update(): void;
  20949. /**
  20950. * @hidden
  20951. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20952. * @returns an identity matrix
  20953. */
  20954. _getViewMatrix(): Matrix;
  20955. private _tmpMatrix;
  20956. /**
  20957. * This function is called by the two RIG cameras.
  20958. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20959. * @hidden
  20960. */
  20961. _getWebVRViewMatrix(): Matrix;
  20962. /** @hidden */
  20963. _getWebVRProjectionMatrix(): Matrix;
  20964. private _onGamepadConnectedObserver;
  20965. private _onGamepadDisconnectedObserver;
  20966. private _updateCacheWhenTrackingDisabledObserver;
  20967. /**
  20968. * Initializes the controllers and their meshes
  20969. */
  20970. initControllers(): void;
  20971. }
  20972. }
  20973. declare module "babylonjs/Materials/materialHelper" {
  20974. import { Nullable } from "babylonjs/types";
  20975. import { Scene } from "babylonjs/scene";
  20976. import { Engine } from "babylonjs/Engines/engine";
  20977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20978. import { Light } from "babylonjs/Lights/light";
  20979. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20980. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20981. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20983. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20984. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20985. /**
  20986. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20987. *
  20988. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20989. *
  20990. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20991. */
  20992. export class MaterialHelper {
  20993. /**
  20994. * Bind the current view position to an effect.
  20995. * @param effect The effect to be bound
  20996. * @param scene The scene the eyes position is used from
  20997. * @param variableName name of the shader variable that will hold the eye position
  20998. */
  20999. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  21000. /**
  21001. * Helps preparing the defines values about the UVs in used in the effect.
  21002. * UVs are shared as much as we can accross channels in the shaders.
  21003. * @param texture The texture we are preparing the UVs for
  21004. * @param defines The defines to update
  21005. * @param key The channel key "diffuse", "specular"... used in the shader
  21006. */
  21007. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21008. /**
  21009. * Binds a texture matrix value to its corrsponding uniform
  21010. * @param texture The texture to bind the matrix for
  21011. * @param uniformBuffer The uniform buffer receivin the data
  21012. * @param key The channel key "diffuse", "specular"... used in the shader
  21013. */
  21014. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21015. /**
  21016. * Gets the current status of the fog (should it be enabled?)
  21017. * @param mesh defines the mesh to evaluate for fog support
  21018. * @param scene defines the hosting scene
  21019. * @returns true if fog must be enabled
  21020. */
  21021. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21022. /**
  21023. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21024. * @param mesh defines the current mesh
  21025. * @param scene defines the current scene
  21026. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21027. * @param pointsCloud defines if point cloud rendering has to be turned on
  21028. * @param fogEnabled defines if fog has to be turned on
  21029. * @param alphaTest defines if alpha testing has to be turned on
  21030. * @param defines defines the current list of defines
  21031. */
  21032. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21033. /**
  21034. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21035. * @param scene defines the current scene
  21036. * @param engine defines the current engine
  21037. * @param defines specifies the list of active defines
  21038. * @param useInstances defines if instances have to be turned on
  21039. * @param useClipPlane defines if clip plane have to be turned on
  21040. * @param useInstances defines if instances have to be turned on
  21041. * @param useThinInstances defines if thin instances have to be turned on
  21042. */
  21043. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21044. /**
  21045. * Prepares the defines for bones
  21046. * @param mesh The mesh containing the geometry data we will draw
  21047. * @param defines The defines to update
  21048. */
  21049. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21050. /**
  21051. * Prepares the defines for morph targets
  21052. * @param mesh The mesh containing the geometry data we will draw
  21053. * @param defines The defines to update
  21054. */
  21055. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21056. /**
  21057. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21058. * @param mesh The mesh containing the geometry data we will draw
  21059. * @param defines The defines to update
  21060. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21061. * @param useBones Precise whether bones should be used or not (override mesh info)
  21062. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21063. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21064. * @returns false if defines are considered not dirty and have not been checked
  21065. */
  21066. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21067. /**
  21068. * Prepares the defines related to multiview
  21069. * @param scene The scene we are intending to draw
  21070. * @param defines The defines to update
  21071. */
  21072. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21073. /**
  21074. * Prepares the defines related to the prepass
  21075. * @param scene The scene we are intending to draw
  21076. * @param defines The defines to update
  21077. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21078. */
  21079. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21080. /**
  21081. * Prepares the defines related to the light information passed in parameter
  21082. * @param scene The scene we are intending to draw
  21083. * @param mesh The mesh the effect is compiling for
  21084. * @param light The light the effect is compiling for
  21085. * @param lightIndex The index of the light
  21086. * @param defines The defines to update
  21087. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21088. * @param state Defines the current state regarding what is needed (normals, etc...)
  21089. */
  21090. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21091. needNormals: boolean;
  21092. needRebuild: boolean;
  21093. shadowEnabled: boolean;
  21094. specularEnabled: boolean;
  21095. lightmapMode: boolean;
  21096. }): void;
  21097. /**
  21098. * Prepares the defines related to the light information passed in parameter
  21099. * @param scene The scene we are intending to draw
  21100. * @param mesh The mesh the effect is compiling for
  21101. * @param defines The defines to update
  21102. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21103. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21104. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21105. * @returns true if normals will be required for the rest of the effect
  21106. */
  21107. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21108. /**
  21109. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21110. * @param lightIndex defines the light index
  21111. * @param uniformsList The uniform list
  21112. * @param samplersList The sampler list
  21113. * @param projectedLightTexture defines if projected texture must be used
  21114. * @param uniformBuffersList defines an optional list of uniform buffers
  21115. */
  21116. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21117. /**
  21118. * Prepares the uniforms and samplers list to be used in the effect
  21119. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21120. * @param samplersList The sampler list
  21121. * @param defines The defines helping in the list generation
  21122. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21123. */
  21124. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21125. /**
  21126. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21127. * @param defines The defines to update while falling back
  21128. * @param fallbacks The authorized effect fallbacks
  21129. * @param maxSimultaneousLights The maximum number of lights allowed
  21130. * @param rank the current rank of the Effect
  21131. * @returns The newly affected rank
  21132. */
  21133. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21134. private static _TmpMorphInfluencers;
  21135. /**
  21136. * Prepares the list of attributes required for morph targets according to the effect defines.
  21137. * @param attribs The current list of supported attribs
  21138. * @param mesh The mesh to prepare the morph targets attributes for
  21139. * @param influencers The number of influencers
  21140. */
  21141. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21142. /**
  21143. * Prepares the list of attributes required for morph targets according to the effect defines.
  21144. * @param attribs The current list of supported attribs
  21145. * @param mesh The mesh to prepare the morph targets attributes for
  21146. * @param defines The current Defines of the effect
  21147. */
  21148. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21149. /**
  21150. * Prepares the list of attributes required for bones according to the effect defines.
  21151. * @param attribs The current list of supported attribs
  21152. * @param mesh The mesh to prepare the bones attributes for
  21153. * @param defines The current Defines of the effect
  21154. * @param fallbacks The current efffect fallback strategy
  21155. */
  21156. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21157. /**
  21158. * Check and prepare the list of attributes required for instances according to the effect defines.
  21159. * @param attribs The current list of supported attribs
  21160. * @param defines The current MaterialDefines of the effect
  21161. */
  21162. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21163. /**
  21164. * Add the list of attributes required for instances to the attribs array.
  21165. * @param attribs The current list of supported attribs
  21166. */
  21167. static PushAttributesForInstances(attribs: string[]): void;
  21168. /**
  21169. * Binds the light information to the effect.
  21170. * @param light The light containing the generator
  21171. * @param effect The effect we are binding the data to
  21172. * @param lightIndex The light index in the effect used to render
  21173. */
  21174. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21175. /**
  21176. * Binds the lights information from the scene to the effect for the given mesh.
  21177. * @param light Light to bind
  21178. * @param lightIndex Light index
  21179. * @param scene The scene where the light belongs to
  21180. * @param effect The effect we are binding the data to
  21181. * @param useSpecular Defines if specular is supported
  21182. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21183. */
  21184. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21185. /**
  21186. * Binds the lights information from the scene to the effect for the given mesh.
  21187. * @param scene The scene the lights belongs to
  21188. * @param mesh The mesh we are binding the information to render
  21189. * @param effect The effect we are binding the data to
  21190. * @param defines The generated defines for the effect
  21191. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21192. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21193. */
  21194. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21195. private static _tempFogColor;
  21196. /**
  21197. * Binds the fog information from the scene to the effect for the given mesh.
  21198. * @param scene The scene the lights belongs to
  21199. * @param mesh The mesh we are binding the information to render
  21200. * @param effect The effect we are binding the data to
  21201. * @param linearSpace Defines if the fog effect is applied in linear space
  21202. */
  21203. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21204. /**
  21205. * Binds the bones information from the mesh to the effect.
  21206. * @param mesh The mesh we are binding the information to render
  21207. * @param effect The effect we are binding the data to
  21208. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21209. */
  21210. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21211. private static _CopyBonesTransformationMatrices;
  21212. /**
  21213. * Binds the morph targets information from the mesh to the effect.
  21214. * @param abstractMesh The mesh we are binding the information to render
  21215. * @param effect The effect we are binding the data to
  21216. */
  21217. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21218. /**
  21219. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21220. * @param defines The generated defines used in the effect
  21221. * @param effect The effect we are binding the data to
  21222. * @param scene The scene we are willing to render with logarithmic scale for
  21223. */
  21224. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21225. /**
  21226. * Binds the clip plane information from the scene to the effect.
  21227. * @param scene The scene the clip plane information are extracted from
  21228. * @param effect The effect we are binding the data to
  21229. */
  21230. static BindClipPlane(effect: Effect, scene: Scene): void;
  21231. }
  21232. }
  21233. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21235. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21236. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21237. import { Nullable } from "babylonjs/types";
  21238. import { Effect } from "babylonjs/Materials/effect";
  21239. import { Matrix } from "babylonjs/Maths/math.vector";
  21240. import { Scene } from "babylonjs/scene";
  21241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21243. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21244. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21245. import { Observable } from "babylonjs/Misc/observable";
  21246. /**
  21247. * Block used to expose an input value
  21248. */
  21249. export class InputBlock extends NodeMaterialBlock {
  21250. private _mode;
  21251. private _associatedVariableName;
  21252. private _storedValue;
  21253. private _valueCallback;
  21254. private _type;
  21255. private _animationType;
  21256. /** Gets or set a value used to limit the range of float values */
  21257. min: number;
  21258. /** Gets or set a value used to limit the range of float values */
  21259. max: number;
  21260. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21261. isBoolean: boolean;
  21262. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21263. matrixMode: number;
  21264. /** @hidden */
  21265. _systemValue: Nullable<NodeMaterialSystemValues>;
  21266. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21267. isConstant: boolean;
  21268. /** Gets or sets the group to use to display this block in the Inspector */
  21269. groupInInspector: string;
  21270. /** Gets an observable raised when the value is changed */
  21271. onValueChangedObservable: Observable<InputBlock>;
  21272. /**
  21273. * Gets or sets the connection point type (default is float)
  21274. */
  21275. get type(): NodeMaterialBlockConnectionPointTypes;
  21276. /**
  21277. * Creates a new InputBlock
  21278. * @param name defines the block name
  21279. * @param target defines the target of that block (Vertex by default)
  21280. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21281. */
  21282. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21283. /**
  21284. * Validates if a name is a reserve word.
  21285. * @param newName the new name to be given to the node.
  21286. * @returns false if the name is a reserve word, else true.
  21287. */
  21288. validateBlockName(newName: string): boolean;
  21289. /**
  21290. * Gets the output component
  21291. */
  21292. get output(): NodeMaterialConnectionPoint;
  21293. /**
  21294. * Set the source of this connection point to a vertex attribute
  21295. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21296. * @returns the current connection point
  21297. */
  21298. setAsAttribute(attributeName?: string): InputBlock;
  21299. /**
  21300. * Set the source of this connection point to a system value
  21301. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21302. * @returns the current connection point
  21303. */
  21304. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21305. /**
  21306. * Gets or sets the value of that point.
  21307. * Please note that this value will be ignored if valueCallback is defined
  21308. */
  21309. get value(): any;
  21310. set value(value: any);
  21311. /**
  21312. * Gets or sets a callback used to get the value of that point.
  21313. * Please note that setting this value will force the connection point to ignore the value property
  21314. */
  21315. get valueCallback(): () => any;
  21316. set valueCallback(value: () => any);
  21317. /**
  21318. * Gets or sets the associated variable name in the shader
  21319. */
  21320. get associatedVariableName(): string;
  21321. set associatedVariableName(value: string);
  21322. /** Gets or sets the type of animation applied to the input */
  21323. get animationType(): AnimatedInputBlockTypes;
  21324. set animationType(value: AnimatedInputBlockTypes);
  21325. /**
  21326. * Gets a boolean indicating that this connection point not defined yet
  21327. */
  21328. get isUndefined(): boolean;
  21329. /**
  21330. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21331. * In this case the connection point name must be the name of the uniform to use.
  21332. * Can only be set on inputs
  21333. */
  21334. get isUniform(): boolean;
  21335. set isUniform(value: boolean);
  21336. /**
  21337. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21338. * In this case the connection point name must be the name of the attribute to use
  21339. * Can only be set on inputs
  21340. */
  21341. get isAttribute(): boolean;
  21342. set isAttribute(value: boolean);
  21343. /**
  21344. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21345. * Can only be set on exit points
  21346. */
  21347. get isVarying(): boolean;
  21348. set isVarying(value: boolean);
  21349. /**
  21350. * Gets a boolean indicating that the current connection point is a system value
  21351. */
  21352. get isSystemValue(): boolean;
  21353. /**
  21354. * Gets or sets the current well known value or null if not defined as a system value
  21355. */
  21356. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21357. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21358. /**
  21359. * Gets the current class name
  21360. * @returns the class name
  21361. */
  21362. getClassName(): string;
  21363. /**
  21364. * Animate the input if animationType !== None
  21365. * @param scene defines the rendering scene
  21366. */
  21367. animate(scene: Scene): void;
  21368. private _emitDefine;
  21369. initialize(state: NodeMaterialBuildState): void;
  21370. /**
  21371. * Set the input block to its default value (based on its type)
  21372. */
  21373. setDefaultValue(): void;
  21374. private _emitConstant;
  21375. /** @hidden */
  21376. get _noContextSwitch(): boolean;
  21377. private _emit;
  21378. /** @hidden */
  21379. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21380. /** @hidden */
  21381. _transmit(effect: Effect, scene: Scene): void;
  21382. protected _buildBlock(state: NodeMaterialBuildState): void;
  21383. protected _dumpPropertiesCode(): string;
  21384. dispose(): void;
  21385. serialize(): any;
  21386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21387. }
  21388. }
  21389. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21390. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21391. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21392. import { Nullable } from "babylonjs/types";
  21393. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21394. import { Observable } from "babylonjs/Misc/observable";
  21395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21396. /**
  21397. * Enum used to define the compatibility state between two connection points
  21398. */
  21399. export enum NodeMaterialConnectionPointCompatibilityStates {
  21400. /** Points are compatibles */
  21401. Compatible = 0,
  21402. /** Points are incompatible because of their types */
  21403. TypeIncompatible = 1,
  21404. /** Points are incompatible because of their targets (vertex vs fragment) */
  21405. TargetIncompatible = 2
  21406. }
  21407. /**
  21408. * Defines the direction of a connection point
  21409. */
  21410. export enum NodeMaterialConnectionPointDirection {
  21411. /** Input */
  21412. Input = 0,
  21413. /** Output */
  21414. Output = 1
  21415. }
  21416. /**
  21417. * Defines a connection point for a block
  21418. */
  21419. export class NodeMaterialConnectionPoint {
  21420. /** @hidden */
  21421. _ownerBlock: NodeMaterialBlock;
  21422. /** @hidden */
  21423. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21424. private _endpoints;
  21425. private _associatedVariableName;
  21426. private _direction;
  21427. /** @hidden */
  21428. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21429. /** @hidden */
  21430. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21431. private _type;
  21432. /** @hidden */
  21433. _enforceAssociatedVariableName: boolean;
  21434. /** Gets the direction of the point */
  21435. get direction(): NodeMaterialConnectionPointDirection;
  21436. /** Indicates that this connection point needs dual validation before being connected to another point */
  21437. needDualDirectionValidation: boolean;
  21438. /**
  21439. * Gets or sets the additional types supported by this connection point
  21440. */
  21441. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21442. /**
  21443. * Gets or sets the additional types excluded by this connection point
  21444. */
  21445. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21446. /**
  21447. * Observable triggered when this point is connected
  21448. */
  21449. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21450. /**
  21451. * Gets or sets the associated variable name in the shader
  21452. */
  21453. get associatedVariableName(): string;
  21454. set associatedVariableName(value: string);
  21455. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21456. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21457. /**
  21458. * Gets or sets the connection point type (default is float)
  21459. */
  21460. get type(): NodeMaterialBlockConnectionPointTypes;
  21461. set type(value: NodeMaterialBlockConnectionPointTypes);
  21462. /**
  21463. * Gets or sets the connection point name
  21464. */
  21465. name: string;
  21466. /**
  21467. * Gets or sets the connection point name
  21468. */
  21469. displayName: string;
  21470. /**
  21471. * Gets or sets a boolean indicating that this connection point can be omitted
  21472. */
  21473. isOptional: boolean;
  21474. /**
  21475. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21476. */
  21477. isExposedOnFrame: boolean;
  21478. /**
  21479. * Gets or sets number indicating the position that the port is exposed to on a frame
  21480. */
  21481. exposedPortPosition: number;
  21482. /**
  21483. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21484. */
  21485. define: string;
  21486. /** @hidden */
  21487. _prioritizeVertex: boolean;
  21488. private _target;
  21489. /** Gets or sets the target of that connection point */
  21490. get target(): NodeMaterialBlockTargets;
  21491. set target(value: NodeMaterialBlockTargets);
  21492. /**
  21493. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21494. */
  21495. get isConnected(): boolean;
  21496. /**
  21497. * Gets a boolean indicating that the current point is connected to an input block
  21498. */
  21499. get isConnectedToInputBlock(): boolean;
  21500. /**
  21501. * Gets a the connected input block (if any)
  21502. */
  21503. get connectInputBlock(): Nullable<InputBlock>;
  21504. /** Get the other side of the connection (if any) */
  21505. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21506. /** Get the block that owns this connection point */
  21507. get ownerBlock(): NodeMaterialBlock;
  21508. /** Get the block connected on the other side of this connection (if any) */
  21509. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21510. /** Get the block connected on the endpoints of this connection (if any) */
  21511. get connectedBlocks(): Array<NodeMaterialBlock>;
  21512. /** Gets the list of connected endpoints */
  21513. get endpoints(): NodeMaterialConnectionPoint[];
  21514. /** Gets a boolean indicating if that output point is connected to at least one input */
  21515. get hasEndpoints(): boolean;
  21516. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21517. get isConnectedInVertexShader(): boolean;
  21518. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21519. get isConnectedInFragmentShader(): boolean;
  21520. /**
  21521. * Creates a block suitable to be used as an input for this input point.
  21522. * If null is returned, a block based on the point type will be created.
  21523. * @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
  21524. */
  21525. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21526. /**
  21527. * Creates a new connection point
  21528. * @param name defines the connection point name
  21529. * @param ownerBlock defines the block hosting this connection point
  21530. * @param direction defines the direction of the connection point
  21531. */
  21532. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21533. /**
  21534. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21535. * @returns the class name
  21536. */
  21537. getClassName(): string;
  21538. /**
  21539. * Gets a boolean indicating if the current point can be connected to another point
  21540. * @param connectionPoint defines the other connection point
  21541. * @returns a boolean
  21542. */
  21543. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21544. /**
  21545. * Gets a number indicating if the current point can be connected to another point
  21546. * @param connectionPoint defines the other connection point
  21547. * @returns a number defining the compatibility state
  21548. */
  21549. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21550. /**
  21551. * Connect this point to another connection point
  21552. * @param connectionPoint defines the other connection point
  21553. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21554. * @returns the current connection point
  21555. */
  21556. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21557. /**
  21558. * Disconnect this point from one of his endpoint
  21559. * @param endpoint defines the other connection point
  21560. * @returns the current connection point
  21561. */
  21562. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Serializes this point in a JSON representation
  21565. * @param isInput defines if the connection point is an input (default is true)
  21566. * @returns the serialized point object
  21567. */
  21568. serialize(isInput?: boolean): any;
  21569. /**
  21570. * Release resources
  21571. */
  21572. dispose(): void;
  21573. }
  21574. }
  21575. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21576. /**
  21577. * Enum used to define the material modes
  21578. */
  21579. export enum NodeMaterialModes {
  21580. /** Regular material */
  21581. Material = 0,
  21582. /** For post process */
  21583. PostProcess = 1,
  21584. /** For particle system */
  21585. Particle = 2,
  21586. /** For procedural texture */
  21587. ProceduralTexture = 3
  21588. }
  21589. }
  21590. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21593. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21596. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21597. import { Effect } from "babylonjs/Materials/effect";
  21598. import { Mesh } from "babylonjs/Meshes/mesh";
  21599. import { Nullable } from "babylonjs/types";
  21600. import { Texture } from "babylonjs/Materials/Textures/texture";
  21601. import { Scene } from "babylonjs/scene";
  21602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21603. /**
  21604. * Block used to read a texture from a sampler
  21605. */
  21606. export class TextureBlock extends NodeMaterialBlock {
  21607. private _defineName;
  21608. private _linearDefineName;
  21609. private _gammaDefineName;
  21610. private _tempTextureRead;
  21611. private _samplerName;
  21612. private _transformedUVName;
  21613. private _textureTransformName;
  21614. private _textureInfoName;
  21615. private _mainUVName;
  21616. private _mainUVDefineName;
  21617. private _fragmentOnly;
  21618. /**
  21619. * Gets or sets the texture associated with the node
  21620. */
  21621. texture: Nullable<Texture>;
  21622. /**
  21623. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21624. */
  21625. convertToGammaSpace: boolean;
  21626. /**
  21627. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21628. */
  21629. convertToLinearSpace: boolean;
  21630. /**
  21631. * Create a new TextureBlock
  21632. * @param name defines the block name
  21633. */
  21634. constructor(name: string, fragmentOnly?: boolean);
  21635. /**
  21636. * Gets the current class name
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Gets the uv input component
  21642. */
  21643. get uv(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the rgba output component
  21646. */
  21647. get rgba(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the rgb output component
  21650. */
  21651. get rgb(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the r output component
  21654. */
  21655. get r(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the g output component
  21658. */
  21659. get g(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the b output component
  21662. */
  21663. get b(): NodeMaterialConnectionPoint;
  21664. /**
  21665. * Gets the a output component
  21666. */
  21667. get a(): NodeMaterialConnectionPoint;
  21668. get target(): NodeMaterialBlockTargets;
  21669. autoConfigure(material: NodeMaterial): void;
  21670. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21672. isReady(): boolean;
  21673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21674. private get _isMixed();
  21675. private _injectVertexCode;
  21676. private _writeTextureRead;
  21677. private _writeOutput;
  21678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21679. protected _dumpPropertiesCode(): string;
  21680. serialize(): any;
  21681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21682. }
  21683. }
  21684. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21685. /** @hidden */
  21686. export var reflectionFunction: {
  21687. name: string;
  21688. shader: string;
  21689. };
  21690. }
  21691. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21697. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21698. import { Effect } from "babylonjs/Materials/effect";
  21699. import { Mesh } from "babylonjs/Meshes/mesh";
  21700. import { Nullable } from "babylonjs/types";
  21701. import { Scene } from "babylonjs/scene";
  21702. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21703. /**
  21704. * Base block used to read a reflection texture from a sampler
  21705. */
  21706. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21707. /** @hidden */
  21708. _define3DName: string;
  21709. /** @hidden */
  21710. _defineCubicName: string;
  21711. /** @hidden */
  21712. _defineExplicitName: string;
  21713. /** @hidden */
  21714. _defineProjectionName: string;
  21715. /** @hidden */
  21716. _defineLocalCubicName: string;
  21717. /** @hidden */
  21718. _defineSphericalName: string;
  21719. /** @hidden */
  21720. _definePlanarName: string;
  21721. /** @hidden */
  21722. _defineEquirectangularName: string;
  21723. /** @hidden */
  21724. _defineMirroredEquirectangularFixedName: string;
  21725. /** @hidden */
  21726. _defineEquirectangularFixedName: string;
  21727. /** @hidden */
  21728. _defineSkyboxName: string;
  21729. /** @hidden */
  21730. _defineOppositeZ: string;
  21731. /** @hidden */
  21732. _cubeSamplerName: string;
  21733. /** @hidden */
  21734. _2DSamplerName: string;
  21735. protected _positionUVWName: string;
  21736. protected _directionWName: string;
  21737. protected _reflectionVectorName: string;
  21738. /** @hidden */
  21739. _reflectionCoordsName: string;
  21740. /** @hidden */
  21741. _reflectionMatrixName: string;
  21742. protected _reflectionColorName: string;
  21743. /**
  21744. * Gets or sets the texture associated with the node
  21745. */
  21746. texture: Nullable<BaseTexture>;
  21747. /**
  21748. * Create a new ReflectionTextureBaseBlock
  21749. * @param name defines the block name
  21750. */
  21751. constructor(name: string);
  21752. /**
  21753. * Gets the current class name
  21754. * @returns the class name
  21755. */
  21756. getClassName(): string;
  21757. /**
  21758. * Gets the world position input component
  21759. */
  21760. abstract get position(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the world position input component
  21763. */
  21764. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the world normal input component
  21767. */
  21768. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the world input component
  21771. */
  21772. abstract get world(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the camera (or eye) position component
  21775. */
  21776. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the view input component
  21779. */
  21780. abstract get view(): NodeMaterialConnectionPoint;
  21781. protected _getTexture(): Nullable<BaseTexture>;
  21782. autoConfigure(material: NodeMaterial): void;
  21783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21784. isReady(): boolean;
  21785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21786. /**
  21787. * Gets the code to inject in the vertex shader
  21788. * @param state current state of the node material building
  21789. * @returns the shader code
  21790. */
  21791. handleVertexSide(state: NodeMaterialBuildState): string;
  21792. /**
  21793. * Handles the inits for the fragment code path
  21794. * @param state node material build state
  21795. */
  21796. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21797. /**
  21798. * Generates the reflection coords code for the fragment code path
  21799. * @param worldNormalVarName name of the world normal variable
  21800. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21801. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21802. * @returns the shader code
  21803. */
  21804. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21805. /**
  21806. * Generates the reflection color code for the fragment code path
  21807. * @param lodVarName name of the lod variable
  21808. * @param swizzleLookupTexture swizzle to use for the final color variable
  21809. * @returns the shader code
  21810. */
  21811. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21812. /**
  21813. * Generates the code corresponding to the connected output points
  21814. * @param state node material build state
  21815. * @param varName name of the variable to output
  21816. * @returns the shader code
  21817. */
  21818. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21819. protected _buildBlock(state: NodeMaterialBuildState): this;
  21820. protected _dumpPropertiesCode(): string;
  21821. serialize(): any;
  21822. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21823. }
  21824. }
  21825. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21827. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21828. import { Nullable } from "babylonjs/types";
  21829. /**
  21830. * Defines a connection point to be used for points with a custom object type
  21831. */
  21832. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21833. private _blockType;
  21834. private _blockName;
  21835. private _nameForCheking?;
  21836. /**
  21837. * Creates a new connection point
  21838. * @param name defines the connection point name
  21839. * @param ownerBlock defines the block hosting this connection point
  21840. * @param direction defines the direction of the connection point
  21841. */
  21842. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21843. /**
  21844. * Gets a number indicating if the current point can be connected to another point
  21845. * @param connectionPoint defines the other connection point
  21846. * @returns a number defining the compatibility state
  21847. */
  21848. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21849. /**
  21850. * Creates a block suitable to be used as an input for this input point.
  21851. * If null is returned, a block based on the point type will be created.
  21852. * @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
  21853. */
  21854. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21855. }
  21856. }
  21857. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21858. /**
  21859. * Enum defining the type of properties that can be edited in the property pages in the NME
  21860. */
  21861. export enum PropertyTypeForEdition {
  21862. /** property is a boolean */
  21863. Boolean = 0,
  21864. /** property is a float */
  21865. Float = 1,
  21866. /** property is a Vector2 */
  21867. Vector2 = 2,
  21868. /** property is a list of values */
  21869. List = 3
  21870. }
  21871. /**
  21872. * Interface that defines an option in a variable of type list
  21873. */
  21874. export interface IEditablePropertyListOption {
  21875. /** label of the option */
  21876. "label": string;
  21877. /** value of the option */
  21878. "value": number;
  21879. }
  21880. /**
  21881. * Interface that defines the options available for an editable property
  21882. */
  21883. export interface IEditablePropertyOption {
  21884. /** min value */
  21885. "min"?: number;
  21886. /** max value */
  21887. "max"?: number;
  21888. /** notifiers: indicates which actions to take when the property is changed */
  21889. "notifiers"?: {
  21890. /** the material should be rebuilt */
  21891. "rebuild"?: boolean;
  21892. /** the preview should be updated */
  21893. "update"?: boolean;
  21894. };
  21895. /** list of the options for a variable of type list */
  21896. "options"?: IEditablePropertyListOption[];
  21897. }
  21898. /**
  21899. * Interface that describes an editable property
  21900. */
  21901. export interface IPropertyDescriptionForEdition {
  21902. /** name of the property */
  21903. "propertyName": string;
  21904. /** display name of the property */
  21905. "displayName": string;
  21906. /** type of the property */
  21907. "type": PropertyTypeForEdition;
  21908. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21909. "groupName": string;
  21910. /** options for the property */
  21911. "options": IEditablePropertyOption;
  21912. }
  21913. /**
  21914. * Decorator that flags a property in a node material block as being editable
  21915. */
  21916. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21917. }
  21918. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21921. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21923. import { Nullable } from "babylonjs/types";
  21924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21925. import { Mesh } from "babylonjs/Meshes/mesh";
  21926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21927. import { Effect } from "babylonjs/Materials/effect";
  21928. import { Scene } from "babylonjs/scene";
  21929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21930. /**
  21931. * Block used to implement the refraction part of the sub surface module of the PBR material
  21932. */
  21933. export class RefractionBlock extends NodeMaterialBlock {
  21934. /** @hidden */
  21935. _define3DName: string;
  21936. /** @hidden */
  21937. _refractionMatrixName: string;
  21938. /** @hidden */
  21939. _defineLODRefractionAlpha: string;
  21940. /** @hidden */
  21941. _defineLinearSpecularRefraction: string;
  21942. /** @hidden */
  21943. _defineOppositeZ: string;
  21944. /** @hidden */
  21945. _cubeSamplerName: string;
  21946. /** @hidden */
  21947. _2DSamplerName: string;
  21948. /** @hidden */
  21949. _vRefractionMicrosurfaceInfosName: string;
  21950. /** @hidden */
  21951. _vRefractionInfosName: string;
  21952. private _scene;
  21953. /**
  21954. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21955. * Materials half opaque for instance using refraction could benefit from this control.
  21956. */
  21957. linkRefractionWithTransparency: boolean;
  21958. /**
  21959. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21960. */
  21961. invertRefractionY: boolean;
  21962. /**
  21963. * Gets or sets the texture associated with the node
  21964. */
  21965. texture: Nullable<BaseTexture>;
  21966. /**
  21967. * Create a new RefractionBlock
  21968. * @param name defines the block name
  21969. */
  21970. constructor(name: string);
  21971. /**
  21972. * Gets the current class name
  21973. * @returns the class name
  21974. */
  21975. getClassName(): string;
  21976. /**
  21977. * Gets the intensity input component
  21978. */
  21979. get intensity(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Gets the index of refraction input component
  21982. */
  21983. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21984. /**
  21985. * Gets the tint at distance input component
  21986. */
  21987. get tintAtDistance(): NodeMaterialConnectionPoint;
  21988. /**
  21989. * Gets the view input component
  21990. */
  21991. get view(): NodeMaterialConnectionPoint;
  21992. /**
  21993. * Gets the refraction object output component
  21994. */
  21995. get refraction(): NodeMaterialConnectionPoint;
  21996. /**
  21997. * Returns true if the block has a texture
  21998. */
  21999. get hasTexture(): boolean;
  22000. protected _getTexture(): Nullable<BaseTexture>;
  22001. autoConfigure(material: NodeMaterial): void;
  22002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22003. isReady(): boolean;
  22004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22005. /**
  22006. * Gets the main code of the block (fragment side)
  22007. * @param state current state of the node material building
  22008. * @returns the shader code
  22009. */
  22010. getCode(state: NodeMaterialBuildState): string;
  22011. protected _buildBlock(state: NodeMaterialBuildState): this;
  22012. protected _dumpPropertiesCode(): string;
  22013. serialize(): any;
  22014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22015. }
  22016. }
  22017. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22020. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22023. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22025. import { Nullable } from "babylonjs/types";
  22026. import { Scene } from "babylonjs/scene";
  22027. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22028. /**
  22029. * Base block used as input for post process
  22030. */
  22031. export class CurrentScreenBlock extends NodeMaterialBlock {
  22032. private _samplerName;
  22033. private _linearDefineName;
  22034. private _gammaDefineName;
  22035. private _mainUVName;
  22036. private _tempTextureRead;
  22037. /**
  22038. * Gets or sets the texture associated with the node
  22039. */
  22040. texture: Nullable<BaseTexture>;
  22041. /**
  22042. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22043. */
  22044. convertToGammaSpace: boolean;
  22045. /**
  22046. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22047. */
  22048. convertToLinearSpace: boolean;
  22049. /**
  22050. * Create a new CurrentScreenBlock
  22051. * @param name defines the block name
  22052. */
  22053. constructor(name: string);
  22054. /**
  22055. * Gets the current class name
  22056. * @returns the class name
  22057. */
  22058. getClassName(): string;
  22059. /**
  22060. * Gets the uv input component
  22061. */
  22062. get uv(): NodeMaterialConnectionPoint;
  22063. /**
  22064. * Gets the rgba output component
  22065. */
  22066. get rgba(): NodeMaterialConnectionPoint;
  22067. /**
  22068. * Gets the rgb output component
  22069. */
  22070. get rgb(): NodeMaterialConnectionPoint;
  22071. /**
  22072. * Gets the r output component
  22073. */
  22074. get r(): NodeMaterialConnectionPoint;
  22075. /**
  22076. * Gets the g output component
  22077. */
  22078. get g(): NodeMaterialConnectionPoint;
  22079. /**
  22080. * Gets the b output component
  22081. */
  22082. get b(): NodeMaterialConnectionPoint;
  22083. /**
  22084. * Gets the a output component
  22085. */
  22086. get a(): NodeMaterialConnectionPoint;
  22087. /**
  22088. * Initialize the block and prepare the context for build
  22089. * @param state defines the state that will be used for the build
  22090. */
  22091. initialize(state: NodeMaterialBuildState): void;
  22092. get target(): NodeMaterialBlockTargets;
  22093. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22094. isReady(): boolean;
  22095. private _injectVertexCode;
  22096. private _writeTextureRead;
  22097. private _writeOutput;
  22098. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22099. serialize(): any;
  22100. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22101. }
  22102. }
  22103. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22108. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22109. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22110. import { Nullable } from "babylonjs/types";
  22111. import { Scene } from "babylonjs/scene";
  22112. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22113. /**
  22114. * Base block used for the particle texture
  22115. */
  22116. export class ParticleTextureBlock extends NodeMaterialBlock {
  22117. private _samplerName;
  22118. private _linearDefineName;
  22119. private _gammaDefineName;
  22120. private _tempTextureRead;
  22121. /**
  22122. * Gets or sets the texture associated with the node
  22123. */
  22124. texture: Nullable<BaseTexture>;
  22125. /**
  22126. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22127. */
  22128. convertToGammaSpace: boolean;
  22129. /**
  22130. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22131. */
  22132. convertToLinearSpace: boolean;
  22133. /**
  22134. * Create a new ParticleTextureBlock
  22135. * @param name defines the block name
  22136. */
  22137. constructor(name: string);
  22138. /**
  22139. * Gets the current class name
  22140. * @returns the class name
  22141. */
  22142. getClassName(): string;
  22143. /**
  22144. * Gets the uv input component
  22145. */
  22146. get uv(): NodeMaterialConnectionPoint;
  22147. /**
  22148. * Gets the rgba output component
  22149. */
  22150. get rgba(): NodeMaterialConnectionPoint;
  22151. /**
  22152. * Gets the rgb output component
  22153. */
  22154. get rgb(): NodeMaterialConnectionPoint;
  22155. /**
  22156. * Gets the r output component
  22157. */
  22158. get r(): NodeMaterialConnectionPoint;
  22159. /**
  22160. * Gets the g output component
  22161. */
  22162. get g(): NodeMaterialConnectionPoint;
  22163. /**
  22164. * Gets the b output component
  22165. */
  22166. get b(): NodeMaterialConnectionPoint;
  22167. /**
  22168. * Gets the a output component
  22169. */
  22170. get a(): NodeMaterialConnectionPoint;
  22171. /**
  22172. * Initialize the block and prepare the context for build
  22173. * @param state defines the state that will be used for the build
  22174. */
  22175. initialize(state: NodeMaterialBuildState): void;
  22176. autoConfigure(material: NodeMaterial): void;
  22177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22178. isReady(): boolean;
  22179. private _writeOutput;
  22180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22181. serialize(): any;
  22182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22183. }
  22184. }
  22185. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22188. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22189. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22190. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22191. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22192. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22193. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22194. import { Scene } from "babylonjs/scene";
  22195. /**
  22196. * Class used to store shared data between 2 NodeMaterialBuildState
  22197. */
  22198. export class NodeMaterialBuildStateSharedData {
  22199. /**
  22200. * Gets the list of emitted varyings
  22201. */
  22202. temps: string[];
  22203. /**
  22204. * Gets the list of emitted varyings
  22205. */
  22206. varyings: string[];
  22207. /**
  22208. * Gets the varying declaration string
  22209. */
  22210. varyingDeclaration: string;
  22211. /**
  22212. * Input blocks
  22213. */
  22214. inputBlocks: InputBlock[];
  22215. /**
  22216. * Input blocks
  22217. */
  22218. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22219. /**
  22220. * Bindable blocks (Blocks that need to set data to the effect)
  22221. */
  22222. bindableBlocks: NodeMaterialBlock[];
  22223. /**
  22224. * List of blocks that can provide a compilation fallback
  22225. */
  22226. blocksWithFallbacks: NodeMaterialBlock[];
  22227. /**
  22228. * List of blocks that can provide a define update
  22229. */
  22230. blocksWithDefines: NodeMaterialBlock[];
  22231. /**
  22232. * List of blocks that can provide a repeatable content
  22233. */
  22234. repeatableContentBlocks: NodeMaterialBlock[];
  22235. /**
  22236. * List of blocks that can provide a dynamic list of uniforms
  22237. */
  22238. dynamicUniformBlocks: NodeMaterialBlock[];
  22239. /**
  22240. * List of blocks that can block the isReady function for the material
  22241. */
  22242. blockingBlocks: NodeMaterialBlock[];
  22243. /**
  22244. * Gets the list of animated inputs
  22245. */
  22246. animatedInputs: InputBlock[];
  22247. /**
  22248. * Build Id used to avoid multiple recompilations
  22249. */
  22250. buildId: number;
  22251. /** List of emitted variables */
  22252. variableNames: {
  22253. [key: string]: number;
  22254. };
  22255. /** List of emitted defines */
  22256. defineNames: {
  22257. [key: string]: number;
  22258. };
  22259. /** Should emit comments? */
  22260. emitComments: boolean;
  22261. /** Emit build activity */
  22262. verbose: boolean;
  22263. /** Gets or sets the hosting scene */
  22264. scene: Scene;
  22265. /**
  22266. * Gets the compilation hints emitted at compilation time
  22267. */
  22268. hints: {
  22269. needWorldViewMatrix: boolean;
  22270. needWorldViewProjectionMatrix: boolean;
  22271. needAlphaBlending: boolean;
  22272. needAlphaTesting: boolean;
  22273. };
  22274. /**
  22275. * List of compilation checks
  22276. */
  22277. checks: {
  22278. emitVertex: boolean;
  22279. emitFragment: boolean;
  22280. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22281. };
  22282. /**
  22283. * Is vertex program allowed to be empty?
  22284. */
  22285. allowEmptyVertexProgram: boolean;
  22286. /** Creates a new shared data */
  22287. constructor();
  22288. /**
  22289. * Emits console errors and exceptions if there is a failing check
  22290. */
  22291. emitErrors(): void;
  22292. }
  22293. }
  22294. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22295. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22296. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22297. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22298. /**
  22299. * Class used to store node based material build state
  22300. */
  22301. export class NodeMaterialBuildState {
  22302. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22303. supportUniformBuffers: boolean;
  22304. /**
  22305. * Gets the list of emitted attributes
  22306. */
  22307. attributes: string[];
  22308. /**
  22309. * Gets the list of emitted uniforms
  22310. */
  22311. uniforms: string[];
  22312. /**
  22313. * Gets the list of emitted constants
  22314. */
  22315. constants: string[];
  22316. /**
  22317. * Gets the list of emitted samplers
  22318. */
  22319. samplers: string[];
  22320. /**
  22321. * Gets the list of emitted functions
  22322. */
  22323. functions: {
  22324. [key: string]: string;
  22325. };
  22326. /**
  22327. * Gets the list of emitted extensions
  22328. */
  22329. extensions: {
  22330. [key: string]: string;
  22331. };
  22332. /**
  22333. * Gets the target of the compilation state
  22334. */
  22335. target: NodeMaterialBlockTargets;
  22336. /**
  22337. * Gets the list of emitted counters
  22338. */
  22339. counters: {
  22340. [key: string]: number;
  22341. };
  22342. /**
  22343. * Shared data between multiple NodeMaterialBuildState instances
  22344. */
  22345. sharedData: NodeMaterialBuildStateSharedData;
  22346. /** @hidden */
  22347. _vertexState: NodeMaterialBuildState;
  22348. /** @hidden */
  22349. _attributeDeclaration: string;
  22350. /** @hidden */
  22351. _uniformDeclaration: string;
  22352. /** @hidden */
  22353. _constantDeclaration: string;
  22354. /** @hidden */
  22355. _samplerDeclaration: string;
  22356. /** @hidden */
  22357. _varyingTransfer: string;
  22358. /** @hidden */
  22359. _injectAtEnd: string;
  22360. private _repeatableContentAnchorIndex;
  22361. /** @hidden */
  22362. _builtCompilationString: string;
  22363. /**
  22364. * Gets the emitted compilation strings
  22365. */
  22366. compilationString: string;
  22367. /**
  22368. * Finalize the compilation strings
  22369. * @param state defines the current compilation state
  22370. */
  22371. finalize(state: NodeMaterialBuildState): void;
  22372. /** @hidden */
  22373. get _repeatableContentAnchor(): string;
  22374. /** @hidden */
  22375. _getFreeVariableName(prefix: string): string;
  22376. /** @hidden */
  22377. _getFreeDefineName(prefix: string): string;
  22378. /** @hidden */
  22379. _excludeVariableName(name: string): void;
  22380. /** @hidden */
  22381. _emit2DSampler(name: string): void;
  22382. /** @hidden */
  22383. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22384. /** @hidden */
  22385. _emitExtension(name: string, extension: string, define?: string): void;
  22386. /** @hidden */
  22387. _emitFunction(name: string, code: string, comments: string): void;
  22388. /** @hidden */
  22389. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22390. replaceStrings?: {
  22391. search: RegExp;
  22392. replace: string;
  22393. }[];
  22394. repeatKey?: string;
  22395. }): string;
  22396. /** @hidden */
  22397. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22398. repeatKey?: string;
  22399. removeAttributes?: boolean;
  22400. removeUniforms?: boolean;
  22401. removeVaryings?: boolean;
  22402. removeIfDef?: boolean;
  22403. replaceStrings?: {
  22404. search: RegExp;
  22405. replace: string;
  22406. }[];
  22407. }, storeKey?: string): void;
  22408. /** @hidden */
  22409. _registerTempVariable(name: string): boolean;
  22410. /** @hidden */
  22411. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22412. /** @hidden */
  22413. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22414. /** @hidden */
  22415. _emitFloat(value: number): string;
  22416. }
  22417. }
  22418. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22419. /**
  22420. * Helper class used to generate session unique ID
  22421. */
  22422. export class UniqueIdGenerator {
  22423. private static _UniqueIdCounter;
  22424. /**
  22425. * Gets an unique (relatively to the current scene) Id
  22426. */
  22427. static get UniqueId(): number;
  22428. }
  22429. }
  22430. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22431. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22433. import { Nullable } from "babylonjs/types";
  22434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22435. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22436. import { Effect } from "babylonjs/Materials/effect";
  22437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22438. import { Mesh } from "babylonjs/Meshes/mesh";
  22439. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22440. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22441. import { Scene } from "babylonjs/scene";
  22442. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22443. /**
  22444. * Defines a block that can be used inside a node based material
  22445. */
  22446. export class NodeMaterialBlock {
  22447. private _buildId;
  22448. private _buildTarget;
  22449. private _target;
  22450. private _isFinalMerger;
  22451. private _isInput;
  22452. private _name;
  22453. protected _isUnique: boolean;
  22454. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22455. inputsAreExclusive: boolean;
  22456. /** @hidden */
  22457. _codeVariableName: string;
  22458. /** @hidden */
  22459. _inputs: NodeMaterialConnectionPoint[];
  22460. /** @hidden */
  22461. _outputs: NodeMaterialConnectionPoint[];
  22462. /** @hidden */
  22463. _preparationId: number;
  22464. /**
  22465. * Gets the name of the block
  22466. */
  22467. get name(): string;
  22468. /**
  22469. * Sets the name of the block. Will check if the name is valid.
  22470. */
  22471. set name(newName: string);
  22472. /**
  22473. * Gets or sets the unique id of the node
  22474. */
  22475. uniqueId: number;
  22476. /**
  22477. * Gets or sets the comments associated with this block
  22478. */
  22479. comments: string;
  22480. /**
  22481. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22482. */
  22483. get isUnique(): boolean;
  22484. /**
  22485. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22486. */
  22487. get isFinalMerger(): boolean;
  22488. /**
  22489. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22490. */
  22491. get isInput(): boolean;
  22492. /**
  22493. * Gets or sets the build Id
  22494. */
  22495. get buildId(): number;
  22496. set buildId(value: number);
  22497. /**
  22498. * Gets or sets the target of the block
  22499. */
  22500. get target(): NodeMaterialBlockTargets;
  22501. set target(value: NodeMaterialBlockTargets);
  22502. /**
  22503. * Gets the list of input points
  22504. */
  22505. get inputs(): NodeMaterialConnectionPoint[];
  22506. /** Gets the list of output points */
  22507. get outputs(): NodeMaterialConnectionPoint[];
  22508. /**
  22509. * Find an input by its name
  22510. * @param name defines the name of the input to look for
  22511. * @returns the input or null if not found
  22512. */
  22513. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22514. /**
  22515. * Find an output by its name
  22516. * @param name defines the name of the outputto look for
  22517. * @returns the output or null if not found
  22518. */
  22519. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22520. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22521. visibleInInspector: boolean;
  22522. /**
  22523. * Creates a new NodeMaterialBlock
  22524. * @param name defines the block name
  22525. * @param target defines the target of that block (Vertex by default)
  22526. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22527. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22528. */
  22529. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22530. /**
  22531. * Initialize the block and prepare the context for build
  22532. * @param state defines the state that will be used for the build
  22533. */
  22534. initialize(state: NodeMaterialBuildState): void;
  22535. /**
  22536. * Bind data to effect. Will only be called for blocks with isBindable === true
  22537. * @param effect defines the effect to bind data to
  22538. * @param nodeMaterial defines the hosting NodeMaterial
  22539. * @param mesh defines the mesh that will be rendered
  22540. * @param subMesh defines the submesh that will be rendered
  22541. */
  22542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22543. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22544. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22545. protected _writeFloat(value: number): string;
  22546. /**
  22547. * Gets the current class name e.g. "NodeMaterialBlock"
  22548. * @returns the class name
  22549. */
  22550. getClassName(): string;
  22551. /**
  22552. * Register a new input. Must be called inside a block constructor
  22553. * @param name defines the connection point name
  22554. * @param type defines the connection point type
  22555. * @param isOptional defines a boolean indicating that this input can be omitted
  22556. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22557. * @param point an already created connection point. If not provided, create a new one
  22558. * @returns the current block
  22559. */
  22560. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22561. /**
  22562. * Register a new output. Must be called inside a block constructor
  22563. * @param name defines the connection point name
  22564. * @param type defines the connection point type
  22565. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22566. * @param point an already created connection point. If not provided, create a new one
  22567. * @returns the current block
  22568. */
  22569. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22570. /**
  22571. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22572. * @param forOutput defines an optional connection point to check compatibility with
  22573. * @returns the first available input or null
  22574. */
  22575. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22576. /**
  22577. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22578. * @param forBlock defines an optional block to check compatibility with
  22579. * @returns the first available input or null
  22580. */
  22581. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22582. /**
  22583. * Gets the sibling of the given output
  22584. * @param current defines the current output
  22585. * @returns the next output in the list or null
  22586. */
  22587. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22588. /**
  22589. * Connect current block with another block
  22590. * @param other defines the block to connect with
  22591. * @param options define the various options to help pick the right connections
  22592. * @returns the current block
  22593. */
  22594. connectTo(other: NodeMaterialBlock, options?: {
  22595. input?: string;
  22596. output?: string;
  22597. outputSwizzle?: string;
  22598. }): this | undefined;
  22599. protected _buildBlock(state: NodeMaterialBuildState): void;
  22600. /**
  22601. * Add uniforms, samplers and uniform buffers at compilation time
  22602. * @param state defines the state to update
  22603. * @param nodeMaterial defines the node material requesting the update
  22604. * @param defines defines the material defines to update
  22605. * @param uniformBuffers defines the list of uniform buffer names
  22606. */
  22607. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22608. /**
  22609. * Add potential fallbacks if shader compilation fails
  22610. * @param mesh defines the mesh to be rendered
  22611. * @param fallbacks defines the current prioritized list of fallbacks
  22612. */
  22613. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22614. /**
  22615. * Initialize defines for shader compilation
  22616. * @param mesh defines the mesh to be rendered
  22617. * @param nodeMaterial defines the node material requesting the update
  22618. * @param defines defines the material defines to update
  22619. * @param useInstances specifies that instances should be used
  22620. */
  22621. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22622. /**
  22623. * Update defines for shader compilation
  22624. * @param mesh defines the mesh to be rendered
  22625. * @param nodeMaterial defines the node material requesting the update
  22626. * @param defines defines the material defines to update
  22627. * @param useInstances specifies that instances should be used
  22628. * @param subMesh defines which submesh to render
  22629. */
  22630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22631. /**
  22632. * Lets the block try to connect some inputs automatically
  22633. * @param material defines the hosting NodeMaterial
  22634. */
  22635. autoConfigure(material: NodeMaterial): void;
  22636. /**
  22637. * Function called when a block is declared as repeatable content generator
  22638. * @param vertexShaderState defines the current compilation state for the vertex shader
  22639. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22640. * @param mesh defines the mesh to be rendered
  22641. * @param defines defines the material defines to update
  22642. */
  22643. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22644. /**
  22645. * Checks if the block is ready
  22646. * @param mesh defines the mesh to be rendered
  22647. * @param nodeMaterial defines the node material requesting the update
  22648. * @param defines defines the material defines to update
  22649. * @param useInstances specifies that instances should be used
  22650. * @returns true if the block is ready
  22651. */
  22652. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22653. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22654. private _processBuild;
  22655. /**
  22656. * Validates the new name for the block node.
  22657. * @param newName the new name to be given to the node.
  22658. * @returns false if the name is a reserve word, else true.
  22659. */
  22660. validateBlockName(newName: string): boolean;
  22661. /**
  22662. * Compile the current node and generate the shader code
  22663. * @param state defines the current compilation state (uniforms, samplers, current string)
  22664. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22665. * @returns true if already built
  22666. */
  22667. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22668. protected _inputRename(name: string): string;
  22669. protected _outputRename(name: string): string;
  22670. protected _dumpPropertiesCode(): string;
  22671. /** @hidden */
  22672. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22673. /** @hidden */
  22674. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22675. /**
  22676. * Clone the current block to a new identical block
  22677. * @param scene defines the hosting scene
  22678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22679. * @returns a copy of the current block
  22680. */
  22681. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22682. /**
  22683. * Serializes this block in a JSON representation
  22684. * @returns the serialized block object
  22685. */
  22686. serialize(): any;
  22687. /** @hidden */
  22688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22689. private _deserializePortDisplayNamesAndExposedOnFrame;
  22690. /**
  22691. * Release resources
  22692. */
  22693. dispose(): void;
  22694. }
  22695. }
  22696. declare module "babylonjs/Materials/pushMaterial" {
  22697. import { Nullable } from "babylonjs/types";
  22698. import { Scene } from "babylonjs/scene";
  22699. import { Matrix } from "babylonjs/Maths/math.vector";
  22700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22701. import { Mesh } from "babylonjs/Meshes/mesh";
  22702. import { Material } from "babylonjs/Materials/material";
  22703. import { Effect } from "babylonjs/Materials/effect";
  22704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22705. /**
  22706. * Base class of materials working in push mode in babylon JS
  22707. * @hidden
  22708. */
  22709. export class PushMaterial extends Material {
  22710. protected _activeEffect: Effect;
  22711. protected _normalMatrix: Matrix;
  22712. constructor(name: string, scene: Scene);
  22713. getEffect(): Effect;
  22714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22715. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22716. /**
  22717. * Binds the given world matrix to the active effect
  22718. *
  22719. * @param world the matrix to bind
  22720. */
  22721. bindOnlyWorldMatrix(world: Matrix): void;
  22722. /**
  22723. * Binds the given normal matrix to the active effect
  22724. *
  22725. * @param normalMatrix the matrix to bind
  22726. */
  22727. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22728. bind(world: Matrix, mesh?: Mesh): void;
  22729. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22730. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22731. }
  22732. }
  22733. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22735. /**
  22736. * Root class for all node material optimizers
  22737. */
  22738. export class NodeMaterialOptimizer {
  22739. /**
  22740. * Function used to optimize a NodeMaterial graph
  22741. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22742. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22743. */
  22744. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22745. }
  22746. }
  22747. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22751. import { Scene } from "babylonjs/scene";
  22752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22753. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22754. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22755. /**
  22756. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22757. */
  22758. export class TransformBlock extends NodeMaterialBlock {
  22759. /**
  22760. * Defines the value to use to complement W value to transform it to a Vector4
  22761. */
  22762. complementW: number;
  22763. /**
  22764. * Defines the value to use to complement z value to transform it to a Vector4
  22765. */
  22766. complementZ: number;
  22767. /**
  22768. * Creates a new TransformBlock
  22769. * @param name defines the block name
  22770. */
  22771. constructor(name: string);
  22772. /**
  22773. * Gets the current class name
  22774. * @returns the class name
  22775. */
  22776. getClassName(): string;
  22777. /**
  22778. * Gets the vector input
  22779. */
  22780. get vector(): NodeMaterialConnectionPoint;
  22781. /**
  22782. * Gets the output component
  22783. */
  22784. get output(): NodeMaterialConnectionPoint;
  22785. /**
  22786. * Gets the xyz output component
  22787. */
  22788. get xyz(): NodeMaterialConnectionPoint;
  22789. /**
  22790. * Gets the matrix transform input
  22791. */
  22792. get transform(): NodeMaterialConnectionPoint;
  22793. protected _buildBlock(state: NodeMaterialBuildState): this;
  22794. /**
  22795. * Update defines for shader compilation
  22796. * @param mesh defines the mesh to be rendered
  22797. * @param nodeMaterial defines the node material requesting the update
  22798. * @param defines defines the material defines to update
  22799. * @param useInstances specifies that instances should be used
  22800. * @param subMesh defines which submesh to render
  22801. */
  22802. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22803. serialize(): any;
  22804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22805. protected _dumpPropertiesCode(): string;
  22806. }
  22807. }
  22808. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22812. /**
  22813. * Block used to output the vertex position
  22814. */
  22815. export class VertexOutputBlock extends NodeMaterialBlock {
  22816. /**
  22817. * Creates a new VertexOutputBlock
  22818. * @param name defines the block name
  22819. */
  22820. constructor(name: string);
  22821. /**
  22822. * Gets the current class name
  22823. * @returns the class name
  22824. */
  22825. getClassName(): string;
  22826. /**
  22827. * Gets the vector input component
  22828. */
  22829. get vector(): NodeMaterialConnectionPoint;
  22830. protected _buildBlock(state: NodeMaterialBuildState): this;
  22831. }
  22832. }
  22833. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22837. /**
  22838. * Block used to output the final color
  22839. */
  22840. export class FragmentOutputBlock extends NodeMaterialBlock {
  22841. /**
  22842. * Create a new FragmentOutputBlock
  22843. * @param name defines the block name
  22844. */
  22845. constructor(name: string);
  22846. /**
  22847. * Gets the current class name
  22848. * @returns the class name
  22849. */
  22850. getClassName(): string;
  22851. /**
  22852. * Gets the rgba input component
  22853. */
  22854. get rgba(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the rgb input component
  22857. */
  22858. get rgb(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the a input component
  22861. */
  22862. get a(): NodeMaterialConnectionPoint;
  22863. protected _buildBlock(state: NodeMaterialBuildState): this;
  22864. }
  22865. }
  22866. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22870. /**
  22871. * Block used for the particle ramp gradient section
  22872. */
  22873. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22874. /**
  22875. * Create a new ParticleRampGradientBlock
  22876. * @param name defines the block name
  22877. */
  22878. constructor(name: string);
  22879. /**
  22880. * Gets the current class name
  22881. * @returns the class name
  22882. */
  22883. getClassName(): string;
  22884. /**
  22885. * Gets the color input component
  22886. */
  22887. get color(): NodeMaterialConnectionPoint;
  22888. /**
  22889. * Gets the rampColor output component
  22890. */
  22891. get rampColor(): NodeMaterialConnectionPoint;
  22892. /**
  22893. * Initialize the block and prepare the context for build
  22894. * @param state defines the state that will be used for the build
  22895. */
  22896. initialize(state: NodeMaterialBuildState): void;
  22897. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22898. }
  22899. }
  22900. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22904. /**
  22905. * Block used for the particle blend multiply section
  22906. */
  22907. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22908. /**
  22909. * Create a new ParticleBlendMultiplyBlock
  22910. * @param name defines the block name
  22911. */
  22912. constructor(name: string);
  22913. /**
  22914. * Gets the current class name
  22915. * @returns the class name
  22916. */
  22917. getClassName(): string;
  22918. /**
  22919. * Gets the color input component
  22920. */
  22921. get color(): NodeMaterialConnectionPoint;
  22922. /**
  22923. * Gets the alphaTexture input component
  22924. */
  22925. get alphaTexture(): NodeMaterialConnectionPoint;
  22926. /**
  22927. * Gets the alphaColor input component
  22928. */
  22929. get alphaColor(): NodeMaterialConnectionPoint;
  22930. /**
  22931. * Gets the blendColor output component
  22932. */
  22933. get blendColor(): NodeMaterialConnectionPoint;
  22934. /**
  22935. * Initialize the block and prepare the context for build
  22936. * @param state defines the state that will be used for the build
  22937. */
  22938. initialize(state: NodeMaterialBuildState): void;
  22939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22940. }
  22941. }
  22942. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22946. /**
  22947. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22948. */
  22949. export class VectorMergerBlock extends NodeMaterialBlock {
  22950. /**
  22951. * Create a new VectorMergerBlock
  22952. * @param name defines the block name
  22953. */
  22954. constructor(name: string);
  22955. /**
  22956. * Gets the current class name
  22957. * @returns the class name
  22958. */
  22959. getClassName(): string;
  22960. /**
  22961. * Gets the xyz component (input)
  22962. */
  22963. get xyzIn(): NodeMaterialConnectionPoint;
  22964. /**
  22965. * Gets the xy component (input)
  22966. */
  22967. get xyIn(): NodeMaterialConnectionPoint;
  22968. /**
  22969. * Gets the x component (input)
  22970. */
  22971. get x(): NodeMaterialConnectionPoint;
  22972. /**
  22973. * Gets the y component (input)
  22974. */
  22975. get y(): NodeMaterialConnectionPoint;
  22976. /**
  22977. * Gets the z component (input)
  22978. */
  22979. get z(): NodeMaterialConnectionPoint;
  22980. /**
  22981. * Gets the w component (input)
  22982. */
  22983. get w(): NodeMaterialConnectionPoint;
  22984. /**
  22985. * Gets the xyzw component (output)
  22986. */
  22987. get xyzw(): NodeMaterialConnectionPoint;
  22988. /**
  22989. * Gets the xyz component (output)
  22990. */
  22991. get xyzOut(): NodeMaterialConnectionPoint;
  22992. /**
  22993. * Gets the xy component (output)
  22994. */
  22995. get xyOut(): NodeMaterialConnectionPoint;
  22996. /**
  22997. * Gets the xy component (output)
  22998. * @deprecated Please use xyOut instead.
  22999. */
  23000. get xy(): NodeMaterialConnectionPoint;
  23001. /**
  23002. * Gets the xyz component (output)
  23003. * @deprecated Please use xyzOut instead.
  23004. */
  23005. get xyz(): NodeMaterialConnectionPoint;
  23006. protected _buildBlock(state: NodeMaterialBuildState): this;
  23007. }
  23008. }
  23009. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23013. import { Vector2 } from "babylonjs/Maths/math.vector";
  23014. import { Scene } from "babylonjs/scene";
  23015. /**
  23016. * Block used to remap a float from a range to a new one
  23017. */
  23018. export class RemapBlock extends NodeMaterialBlock {
  23019. /**
  23020. * Gets or sets the source range
  23021. */
  23022. sourceRange: Vector2;
  23023. /**
  23024. * Gets or sets the target range
  23025. */
  23026. targetRange: Vector2;
  23027. /**
  23028. * Creates a new RemapBlock
  23029. * @param name defines the block name
  23030. */
  23031. constructor(name: string);
  23032. /**
  23033. * Gets the current class name
  23034. * @returns the class name
  23035. */
  23036. getClassName(): string;
  23037. /**
  23038. * Gets the input component
  23039. */
  23040. get input(): NodeMaterialConnectionPoint;
  23041. /**
  23042. * Gets the source min input component
  23043. */
  23044. get sourceMin(): NodeMaterialConnectionPoint;
  23045. /**
  23046. * Gets the source max input component
  23047. */
  23048. get sourceMax(): NodeMaterialConnectionPoint;
  23049. /**
  23050. * Gets the target min input component
  23051. */
  23052. get targetMin(): NodeMaterialConnectionPoint;
  23053. /**
  23054. * Gets the target max input component
  23055. */
  23056. get targetMax(): NodeMaterialConnectionPoint;
  23057. /**
  23058. * Gets the output component
  23059. */
  23060. get output(): NodeMaterialConnectionPoint;
  23061. protected _buildBlock(state: NodeMaterialBuildState): this;
  23062. protected _dumpPropertiesCode(): string;
  23063. serialize(): any;
  23064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23065. }
  23066. }
  23067. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23071. /**
  23072. * Block used to multiply 2 values
  23073. */
  23074. export class MultiplyBlock extends NodeMaterialBlock {
  23075. /**
  23076. * Creates a new MultiplyBlock
  23077. * @param name defines the block name
  23078. */
  23079. constructor(name: string);
  23080. /**
  23081. * Gets the current class name
  23082. * @returns the class name
  23083. */
  23084. getClassName(): string;
  23085. /**
  23086. * Gets the left operand input component
  23087. */
  23088. get left(): NodeMaterialConnectionPoint;
  23089. /**
  23090. * Gets the right operand input component
  23091. */
  23092. get right(): NodeMaterialConnectionPoint;
  23093. /**
  23094. * Gets the output component
  23095. */
  23096. get output(): NodeMaterialConnectionPoint;
  23097. protected _buildBlock(state: NodeMaterialBuildState): this;
  23098. }
  23099. }
  23100. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23104. /**
  23105. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23106. */
  23107. export class ColorSplitterBlock extends NodeMaterialBlock {
  23108. /**
  23109. * Create a new ColorSplitterBlock
  23110. * @param name defines the block name
  23111. */
  23112. constructor(name: string);
  23113. /**
  23114. * Gets the current class name
  23115. * @returns the class name
  23116. */
  23117. getClassName(): string;
  23118. /**
  23119. * Gets the rgba component (input)
  23120. */
  23121. get rgba(): NodeMaterialConnectionPoint;
  23122. /**
  23123. * Gets the rgb component (input)
  23124. */
  23125. get rgbIn(): NodeMaterialConnectionPoint;
  23126. /**
  23127. * Gets the rgb component (output)
  23128. */
  23129. get rgbOut(): NodeMaterialConnectionPoint;
  23130. /**
  23131. * Gets the r component (output)
  23132. */
  23133. get r(): NodeMaterialConnectionPoint;
  23134. /**
  23135. * Gets the g component (output)
  23136. */
  23137. get g(): NodeMaterialConnectionPoint;
  23138. /**
  23139. * Gets the b component (output)
  23140. */
  23141. get b(): NodeMaterialConnectionPoint;
  23142. /**
  23143. * Gets the a component (output)
  23144. */
  23145. get a(): NodeMaterialConnectionPoint;
  23146. protected _inputRename(name: string): string;
  23147. protected _outputRename(name: string): string;
  23148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23149. }
  23150. }
  23151. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23155. import { Scene } from "babylonjs/scene";
  23156. /**
  23157. * Operations supported by the Trigonometry block
  23158. */
  23159. export enum TrigonometryBlockOperations {
  23160. /** Cos */
  23161. Cos = 0,
  23162. /** Sin */
  23163. Sin = 1,
  23164. /** Abs */
  23165. Abs = 2,
  23166. /** Exp */
  23167. Exp = 3,
  23168. /** Exp2 */
  23169. Exp2 = 4,
  23170. /** Round */
  23171. Round = 5,
  23172. /** Floor */
  23173. Floor = 6,
  23174. /** Ceiling */
  23175. Ceiling = 7,
  23176. /** Square root */
  23177. Sqrt = 8,
  23178. /** Log */
  23179. Log = 9,
  23180. /** Tangent */
  23181. Tan = 10,
  23182. /** Arc tangent */
  23183. ArcTan = 11,
  23184. /** Arc cosinus */
  23185. ArcCos = 12,
  23186. /** Arc sinus */
  23187. ArcSin = 13,
  23188. /** Fraction */
  23189. Fract = 14,
  23190. /** Sign */
  23191. Sign = 15,
  23192. /** To radians (from degrees) */
  23193. Radians = 16,
  23194. /** To degrees (from radians) */
  23195. Degrees = 17
  23196. }
  23197. /**
  23198. * Block used to apply trigonometry operation to floats
  23199. */
  23200. export class TrigonometryBlock extends NodeMaterialBlock {
  23201. /**
  23202. * Gets or sets the operation applied by the block
  23203. */
  23204. operation: TrigonometryBlockOperations;
  23205. /**
  23206. * Creates a new TrigonometryBlock
  23207. * @param name defines the block name
  23208. */
  23209. constructor(name: string);
  23210. /**
  23211. * Gets the current class name
  23212. * @returns the class name
  23213. */
  23214. getClassName(): string;
  23215. /**
  23216. * Gets the input component
  23217. */
  23218. get input(): NodeMaterialConnectionPoint;
  23219. /**
  23220. * Gets the output component
  23221. */
  23222. get output(): NodeMaterialConnectionPoint;
  23223. protected _buildBlock(state: NodeMaterialBuildState): this;
  23224. serialize(): any;
  23225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23226. protected _dumpPropertiesCode(): string;
  23227. }
  23228. }
  23229. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23231. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23232. import { Scene } from "babylonjs/scene";
  23233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23234. import { Matrix } from "babylonjs/Maths/math.vector";
  23235. import { Mesh } from "babylonjs/Meshes/mesh";
  23236. import { Engine } from "babylonjs/Engines/engine";
  23237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23238. import { Observable } from "babylonjs/Misc/observable";
  23239. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23240. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23241. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23242. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23243. import { Nullable } from "babylonjs/types";
  23244. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23245. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23246. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23247. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23248. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23249. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23250. import { Effect } from "babylonjs/Materials/effect";
  23251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23252. import { Camera } from "babylonjs/Cameras/camera";
  23253. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23254. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23255. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23256. /**
  23257. * Interface used to configure the node material editor
  23258. */
  23259. export interface INodeMaterialEditorOptions {
  23260. /** Define the URl to load node editor script */
  23261. editorURL?: string;
  23262. }
  23263. /** @hidden */
  23264. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23265. NORMAL: boolean;
  23266. TANGENT: boolean;
  23267. UV1: boolean;
  23268. /** BONES */
  23269. NUM_BONE_INFLUENCERS: number;
  23270. BonesPerMesh: number;
  23271. BONETEXTURE: boolean;
  23272. /** MORPH TARGETS */
  23273. MORPHTARGETS: boolean;
  23274. MORPHTARGETS_NORMAL: boolean;
  23275. MORPHTARGETS_TANGENT: boolean;
  23276. MORPHTARGETS_UV: boolean;
  23277. NUM_MORPH_INFLUENCERS: number;
  23278. /** IMAGE PROCESSING */
  23279. IMAGEPROCESSING: boolean;
  23280. VIGNETTE: boolean;
  23281. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23282. VIGNETTEBLENDMODEOPAQUE: boolean;
  23283. TONEMAPPING: boolean;
  23284. TONEMAPPING_ACES: boolean;
  23285. CONTRAST: boolean;
  23286. EXPOSURE: boolean;
  23287. COLORCURVES: boolean;
  23288. COLORGRADING: boolean;
  23289. COLORGRADING3D: boolean;
  23290. SAMPLER3DGREENDEPTH: boolean;
  23291. SAMPLER3DBGRMAP: boolean;
  23292. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23293. /** MISC. */
  23294. BUMPDIRECTUV: number;
  23295. constructor();
  23296. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23297. }
  23298. /**
  23299. * Class used to configure NodeMaterial
  23300. */
  23301. export interface INodeMaterialOptions {
  23302. /**
  23303. * Defines if blocks should emit comments
  23304. */
  23305. emitComments: boolean;
  23306. }
  23307. /**
  23308. * Class used to create a node based material built by assembling shader blocks
  23309. */
  23310. export class NodeMaterial extends PushMaterial {
  23311. private static _BuildIdGenerator;
  23312. private _options;
  23313. private _vertexCompilationState;
  23314. private _fragmentCompilationState;
  23315. private _sharedData;
  23316. private _buildId;
  23317. private _buildWasSuccessful;
  23318. private _cachedWorldViewMatrix;
  23319. private _cachedWorldViewProjectionMatrix;
  23320. private _optimizers;
  23321. private _animationFrame;
  23322. /** Define the Url to load node editor script */
  23323. static EditorURL: string;
  23324. /** Define the Url to load snippets */
  23325. static SnippetUrl: string;
  23326. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23327. static IgnoreTexturesAtLoadTime: boolean;
  23328. private BJSNODEMATERIALEDITOR;
  23329. /** Get the inspector from bundle or global */
  23330. private _getGlobalNodeMaterialEditor;
  23331. /**
  23332. * Snippet ID if the material was created from the snippet server
  23333. */
  23334. snippetId: string;
  23335. /**
  23336. * Gets or sets data used by visual editor
  23337. * @see https://nme.babylonjs.com
  23338. */
  23339. editorData: any;
  23340. /**
  23341. * 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)
  23342. */
  23343. ignoreAlpha: boolean;
  23344. /**
  23345. * Defines the maximum number of lights that can be used in the material
  23346. */
  23347. maxSimultaneousLights: number;
  23348. /**
  23349. * Observable raised when the material is built
  23350. */
  23351. onBuildObservable: Observable<NodeMaterial>;
  23352. /**
  23353. * Gets or sets the root nodes of the material vertex shader
  23354. */
  23355. _vertexOutputNodes: NodeMaterialBlock[];
  23356. /**
  23357. * Gets or sets the root nodes of the material fragment (pixel) shader
  23358. */
  23359. _fragmentOutputNodes: NodeMaterialBlock[];
  23360. /** Gets or sets options to control the node material overall behavior */
  23361. get options(): INodeMaterialOptions;
  23362. set options(options: INodeMaterialOptions);
  23363. /**
  23364. * Default configuration related to image processing available in the standard Material.
  23365. */
  23366. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23367. /**
  23368. * Gets the image processing configuration used either in this material.
  23369. */
  23370. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23371. /**
  23372. * Sets the Default image processing configuration used either in the this material.
  23373. *
  23374. * If sets to null, the scene one is in use.
  23375. */
  23376. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23377. /**
  23378. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23379. */
  23380. attachedBlocks: NodeMaterialBlock[];
  23381. /**
  23382. * Specifies the mode of the node material
  23383. * @hidden
  23384. */
  23385. _mode: NodeMaterialModes;
  23386. /**
  23387. * Gets the mode property
  23388. */
  23389. get mode(): NodeMaterialModes;
  23390. /**
  23391. * Create a new node based material
  23392. * @param name defines the material name
  23393. * @param scene defines the hosting scene
  23394. * @param options defines creation option
  23395. */
  23396. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23397. /**
  23398. * Gets the current class name of the material e.g. "NodeMaterial"
  23399. * @returns the class name
  23400. */
  23401. getClassName(): string;
  23402. /**
  23403. * Keep track of the image processing observer to allow dispose and replace.
  23404. */
  23405. private _imageProcessingObserver;
  23406. /**
  23407. * Attaches a new image processing configuration to the Standard Material.
  23408. * @param configuration
  23409. */
  23410. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23411. /**
  23412. * Get a block by its name
  23413. * @param name defines the name of the block to retrieve
  23414. * @returns the required block or null if not found
  23415. */
  23416. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23417. /**
  23418. * Get a block by its name
  23419. * @param predicate defines the predicate used to find the good candidate
  23420. * @returns the required block or null if not found
  23421. */
  23422. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23423. /**
  23424. * Get an input block by its name
  23425. * @param predicate defines the predicate used to find the good candidate
  23426. * @returns the required input block or null if not found
  23427. */
  23428. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23429. /**
  23430. * Gets the list of input blocks attached to this material
  23431. * @returns an array of InputBlocks
  23432. */
  23433. getInputBlocks(): InputBlock[];
  23434. /**
  23435. * Adds a new optimizer to the list of optimizers
  23436. * @param optimizer defines the optimizers to add
  23437. * @returns the current material
  23438. */
  23439. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23440. /**
  23441. * Remove an optimizer from the list of optimizers
  23442. * @param optimizer defines the optimizers to remove
  23443. * @returns the current material
  23444. */
  23445. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23446. /**
  23447. * Add a new block to the list of output nodes
  23448. * @param node defines the node to add
  23449. * @returns the current material
  23450. */
  23451. addOutputNode(node: NodeMaterialBlock): this;
  23452. /**
  23453. * Remove a block from the list of root nodes
  23454. * @param node defines the node to remove
  23455. * @returns the current material
  23456. */
  23457. removeOutputNode(node: NodeMaterialBlock): this;
  23458. private _addVertexOutputNode;
  23459. private _removeVertexOutputNode;
  23460. private _addFragmentOutputNode;
  23461. private _removeFragmentOutputNode;
  23462. /**
  23463. * Specifies if the material will require alpha blending
  23464. * @returns a boolean specifying if alpha blending is needed
  23465. */
  23466. needAlphaBlending(): boolean;
  23467. /**
  23468. * Specifies if this material should be rendered in alpha test mode
  23469. * @returns a boolean specifying if an alpha test is needed.
  23470. */
  23471. needAlphaTesting(): boolean;
  23472. private _initializeBlock;
  23473. private _resetDualBlocks;
  23474. /**
  23475. * Remove a block from the current node material
  23476. * @param block defines the block to remove
  23477. */
  23478. removeBlock(block: NodeMaterialBlock): void;
  23479. /**
  23480. * Build the material and generates the inner effect
  23481. * @param verbose defines if the build should log activity
  23482. */
  23483. build(verbose?: boolean): void;
  23484. /**
  23485. * Runs an otpimization phase to try to improve the shader code
  23486. */
  23487. optimize(): void;
  23488. private _prepareDefinesForAttributes;
  23489. /**
  23490. * Create a post process from the material
  23491. * @param camera The camera to apply the render pass to.
  23492. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23494. * @param engine The engine which the post process will be applied. (default: current engine)
  23495. * @param reusable If the post process can be reused on the same frame. (default: false)
  23496. * @param textureType Type of textures used when performing the post process. (default: 0)
  23497. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23498. * @returns the post process created
  23499. */
  23500. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23501. /**
  23502. * Create the post process effect from the material
  23503. * @param postProcess The post process to create the effect for
  23504. */
  23505. createEffectForPostProcess(postProcess: PostProcess): void;
  23506. private _createEffectForPostProcess;
  23507. /**
  23508. * Create a new procedural texture based on this node material
  23509. * @param size defines the size of the texture
  23510. * @param scene defines the hosting scene
  23511. * @returns the new procedural texture attached to this node material
  23512. */
  23513. createProceduralTexture(size: number | {
  23514. width: number;
  23515. height: number;
  23516. layers?: number;
  23517. }, scene: Scene): Nullable<ProceduralTexture>;
  23518. private _createEffectForParticles;
  23519. private _checkInternals;
  23520. /**
  23521. * Create the effect to be used as the custom effect for a particle system
  23522. * @param particleSystem Particle system to create the effect for
  23523. * @param onCompiled defines a function to call when the effect creation is successful
  23524. * @param onError defines a function to call when the effect creation has failed
  23525. */
  23526. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23527. private _processDefines;
  23528. /**
  23529. * Get if the submesh is ready to be used and all its information available.
  23530. * Child classes can use it to update shaders
  23531. * @param mesh defines the mesh to check
  23532. * @param subMesh defines which submesh to check
  23533. * @param useInstances specifies that instances should be used
  23534. * @returns a boolean indicating that the submesh is ready or not
  23535. */
  23536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23537. /**
  23538. * Get a string representing the shaders built by the current node graph
  23539. */
  23540. get compiledShaders(): string;
  23541. /**
  23542. * Binds the world matrix to the material
  23543. * @param world defines the world transformation matrix
  23544. */
  23545. bindOnlyWorldMatrix(world: Matrix): void;
  23546. /**
  23547. * Binds the submesh to this material by preparing the effect and shader to draw
  23548. * @param world defines the world transformation matrix
  23549. * @param mesh defines the mesh containing the submesh
  23550. * @param subMesh defines the submesh to bind the material to
  23551. */
  23552. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23553. /**
  23554. * Gets the active textures from the material
  23555. * @returns an array of textures
  23556. */
  23557. getActiveTextures(): BaseTexture[];
  23558. /**
  23559. * Gets the list of texture blocks
  23560. * @returns an array of texture blocks
  23561. */
  23562. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23563. /**
  23564. * Specifies if the material uses a texture
  23565. * @param texture defines the texture to check against the material
  23566. * @returns a boolean specifying if the material uses the texture
  23567. */
  23568. hasTexture(texture: BaseTexture): boolean;
  23569. /**
  23570. * Disposes the material
  23571. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23572. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23573. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23574. */
  23575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23576. /** Creates the node editor window. */
  23577. private _createNodeEditor;
  23578. /**
  23579. * Launch the node material editor
  23580. * @param config Define the configuration of the editor
  23581. * @return a promise fulfilled when the node editor is visible
  23582. */
  23583. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23584. /**
  23585. * Clear the current material
  23586. */
  23587. clear(): void;
  23588. /**
  23589. * Clear the current material and set it to a default state
  23590. */
  23591. setToDefault(): void;
  23592. /**
  23593. * Clear the current material and set it to a default state for post process
  23594. */
  23595. setToDefaultPostProcess(): void;
  23596. /**
  23597. * Clear the current material and set it to a default state for procedural texture
  23598. */
  23599. setToDefaultProceduralTexture(): void;
  23600. /**
  23601. * Clear the current material and set it to a default state for particle
  23602. */
  23603. setToDefaultParticle(): void;
  23604. /**
  23605. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23606. * @param url defines the url to load from
  23607. * @returns a promise that will fullfil when the material is fully loaded
  23608. */
  23609. loadAsync(url: string): Promise<void>;
  23610. private _gatherBlocks;
  23611. /**
  23612. * Generate a string containing the code declaration required to create an equivalent of this material
  23613. * @returns a string
  23614. */
  23615. generateCode(): string;
  23616. /**
  23617. * Serializes this material in a JSON representation
  23618. * @returns the serialized material object
  23619. */
  23620. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23621. private _restoreConnections;
  23622. /**
  23623. * Clear the current graph and load a new one from a serialization object
  23624. * @param source defines the JSON representation of the material
  23625. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23626. * @param merge defines whether or not the source must be merged or replace the current content
  23627. */
  23628. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23629. /**
  23630. * Makes a duplicate of the current material.
  23631. * @param name - name to use for the new material.
  23632. */
  23633. clone(name: string): NodeMaterial;
  23634. /**
  23635. * Creates a node material from parsed material data
  23636. * @param source defines the JSON representation of the material
  23637. * @param scene defines the hosting scene
  23638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23639. * @returns a new node material
  23640. */
  23641. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23642. /**
  23643. * Creates a node material from a snippet saved in a remote file
  23644. * @param name defines the name of the material to create
  23645. * @param url defines the url to load from
  23646. * @param scene defines the hosting scene
  23647. * @returns a promise that will resolve to the new node material
  23648. */
  23649. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23650. /**
  23651. * Creates a node material from a snippet saved by the node material editor
  23652. * @param snippetId defines the snippet to load
  23653. * @param scene defines the hosting scene
  23654. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23655. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23656. * @returns a promise that will resolve to the new node material
  23657. */
  23658. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23659. /**
  23660. * Creates a new node material set to default basic configuration
  23661. * @param name defines the name of the material
  23662. * @param scene defines the hosting scene
  23663. * @returns a new NodeMaterial
  23664. */
  23665. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23666. }
  23667. }
  23668. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23670. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23671. import { Nullable } from "babylonjs/types";
  23672. module "babylonjs/Engines/thinEngine" {
  23673. interface ThinEngine {
  23674. /**
  23675. * Unbind a list of render target textures from the webGL context
  23676. * This is used only when drawBuffer extension or webGL2 are active
  23677. * @param textures defines the render target textures to unbind
  23678. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23679. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23680. */
  23681. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23682. /**
  23683. * Create a multi render target texture
  23684. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23685. * @param size defines the size of the texture
  23686. * @param options defines the creation options
  23687. * @returns the cube texture as an InternalTexture
  23688. */
  23689. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23690. /**
  23691. * Update the sample count for a given multiple render target texture
  23692. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23693. * @param textures defines the textures to update
  23694. * @param samples defines the sample count to set
  23695. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23696. */
  23697. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23698. /**
  23699. * Select a subsets of attachments to draw to.
  23700. * @param attachments gl attachments
  23701. */
  23702. bindAttachments(attachments: number[]): void;
  23703. /**
  23704. * Creates a layout object to draw/clear on specific textures in a MRT
  23705. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23706. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23707. */
  23708. buildTextureLayout(textureStatus: boolean[]): number[];
  23709. /**
  23710. * Restores the webgl state to only draw on the main color attachment
  23711. */
  23712. restoreSingleAttachment(): void;
  23713. }
  23714. }
  23715. }
  23716. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23717. import { Scene } from "babylonjs/scene";
  23718. import { Engine } from "babylonjs/Engines/engine";
  23719. import { Texture } from "babylonjs/Materials/Textures/texture";
  23720. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23721. import "babylonjs/Engines/Extensions/engine.multiRender";
  23722. /**
  23723. * Creation options of the multi render target texture.
  23724. */
  23725. export interface IMultiRenderTargetOptions {
  23726. /**
  23727. * Define if the texture needs to create mip maps after render.
  23728. */
  23729. generateMipMaps?: boolean;
  23730. /**
  23731. * Define the types of all the draw buffers we want to create
  23732. */
  23733. types?: number[];
  23734. /**
  23735. * Define the sampling modes of all the draw buffers we want to create
  23736. */
  23737. samplingModes?: number[];
  23738. /**
  23739. * Define if a depth buffer is required
  23740. */
  23741. generateDepthBuffer?: boolean;
  23742. /**
  23743. * Define if a stencil buffer is required
  23744. */
  23745. generateStencilBuffer?: boolean;
  23746. /**
  23747. * Define if a depth texture is required instead of a depth buffer
  23748. */
  23749. generateDepthTexture?: boolean;
  23750. /**
  23751. * Define the number of desired draw buffers
  23752. */
  23753. textureCount?: number;
  23754. /**
  23755. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23756. */
  23757. doNotChangeAspectRatio?: boolean;
  23758. /**
  23759. * Define the default type of the buffers we are creating
  23760. */
  23761. defaultType?: number;
  23762. }
  23763. /**
  23764. * A multi render target, like a render target provides the ability to render to a texture.
  23765. * Unlike the render target, it can render to several draw buffers in one draw.
  23766. * This is specially interesting in deferred rendering or for any effects requiring more than
  23767. * just one color from a single pass.
  23768. */
  23769. export class MultiRenderTarget extends RenderTargetTexture {
  23770. private _internalTextures;
  23771. private _textures;
  23772. private _multiRenderTargetOptions;
  23773. private _count;
  23774. /**
  23775. * Get if draw buffers are currently supported by the used hardware and browser.
  23776. */
  23777. get isSupported(): boolean;
  23778. /**
  23779. * Get the list of textures generated by the multi render target.
  23780. */
  23781. get textures(): Texture[];
  23782. /**
  23783. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23784. */
  23785. get count(): number;
  23786. /**
  23787. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23788. */
  23789. get depthTexture(): Texture;
  23790. /**
  23791. * Set the wrapping mode on U of all the textures we are rendering to.
  23792. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23793. */
  23794. set wrapU(wrap: number);
  23795. /**
  23796. * Set the wrapping mode on V of all the textures we are rendering to.
  23797. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23798. */
  23799. set wrapV(wrap: number);
  23800. /**
  23801. * Instantiate a new multi render target texture.
  23802. * A multi render target, like a render target provides the ability to render to a texture.
  23803. * Unlike the render target, it can render to several draw buffers in one draw.
  23804. * This is specially interesting in deferred rendering or for any effects requiring more than
  23805. * just one color from a single pass.
  23806. * @param name Define the name of the texture
  23807. * @param size Define the size of the buffers to render to
  23808. * @param count Define the number of target we are rendering into
  23809. * @param scene Define the scene the texture belongs to
  23810. * @param options Define the options used to create the multi render target
  23811. */
  23812. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23813. private _initTypes;
  23814. /** @hidden */
  23815. _rebuild(forceFullRebuild?: boolean): void;
  23816. private _createInternalTextures;
  23817. private _createTextures;
  23818. /**
  23819. * Replaces a texture within the MRT.
  23820. * @param texture The new texture to insert in the MRT
  23821. * @param index The index of the texture to replace
  23822. */
  23823. replaceTexture(texture: Texture, index: number): void;
  23824. /**
  23825. * Define the number of samples used if MSAA is enabled.
  23826. */
  23827. get samples(): number;
  23828. set samples(value: number);
  23829. /**
  23830. * Resize all the textures in the multi render target.
  23831. * Be careful as it will recreate all the data in the new texture.
  23832. * @param size Define the new size
  23833. */
  23834. resize(size: any): void;
  23835. /**
  23836. * Changes the number of render targets in this MRT
  23837. * Be careful as it will recreate all the data in the new texture.
  23838. * @param count new texture count
  23839. * @param options Specifies texture types and sampling modes for new textures
  23840. */
  23841. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23842. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23843. /**
  23844. * Dispose the render targets and their associated resources
  23845. */
  23846. dispose(): void;
  23847. /**
  23848. * Release all the underlying texture used as draw buffers.
  23849. */
  23850. releaseInternalTextures(): void;
  23851. }
  23852. }
  23853. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23854. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23856. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23857. /** @hidden */
  23858. export var imageProcessingPixelShader: {
  23859. name: string;
  23860. shader: string;
  23861. };
  23862. }
  23863. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23864. import { Nullable } from "babylonjs/types";
  23865. import { Color4 } from "babylonjs/Maths/math.color";
  23866. import { Camera } from "babylonjs/Cameras/camera";
  23867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23868. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23869. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23870. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23871. import { Engine } from "babylonjs/Engines/engine";
  23872. import "babylonjs/Shaders/imageProcessing.fragment";
  23873. import "babylonjs/Shaders/postprocess.vertex";
  23874. /**
  23875. * ImageProcessingPostProcess
  23876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23877. */
  23878. export class ImageProcessingPostProcess extends PostProcess {
  23879. /**
  23880. * Default configuration related to image processing available in the PBR Material.
  23881. */
  23882. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23883. /**
  23884. * Gets the image processing configuration used either in this material.
  23885. */
  23886. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23887. /**
  23888. * Sets the Default image processing configuration used either in the this material.
  23889. *
  23890. * If sets to null, the scene one is in use.
  23891. */
  23892. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23893. /**
  23894. * Keep track of the image processing observer to allow dispose and replace.
  23895. */
  23896. private _imageProcessingObserver;
  23897. /**
  23898. * Attaches a new image processing configuration to the PBR Material.
  23899. * @param configuration
  23900. */
  23901. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23902. /**
  23903. * If the post process is supported.
  23904. */
  23905. get isSupported(): boolean;
  23906. /**
  23907. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23908. */
  23909. get colorCurves(): Nullable<ColorCurves>;
  23910. /**
  23911. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23912. */
  23913. set colorCurves(value: Nullable<ColorCurves>);
  23914. /**
  23915. * Gets wether the color curves effect is enabled.
  23916. */
  23917. get colorCurvesEnabled(): boolean;
  23918. /**
  23919. * Sets wether the color curves effect is enabled.
  23920. */
  23921. set colorCurvesEnabled(value: boolean);
  23922. /**
  23923. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23924. */
  23925. get colorGradingTexture(): Nullable<BaseTexture>;
  23926. /**
  23927. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23928. */
  23929. set colorGradingTexture(value: Nullable<BaseTexture>);
  23930. /**
  23931. * Gets wether the color grading effect is enabled.
  23932. */
  23933. get colorGradingEnabled(): boolean;
  23934. /**
  23935. * Gets wether the color grading effect is enabled.
  23936. */
  23937. set colorGradingEnabled(value: boolean);
  23938. /**
  23939. * Gets exposure used in the effect.
  23940. */
  23941. get exposure(): number;
  23942. /**
  23943. * Sets exposure used in the effect.
  23944. */
  23945. set exposure(value: number);
  23946. /**
  23947. * Gets wether tonemapping is enabled or not.
  23948. */
  23949. get toneMappingEnabled(): boolean;
  23950. /**
  23951. * Sets wether tonemapping is enabled or not
  23952. */
  23953. set toneMappingEnabled(value: boolean);
  23954. /**
  23955. * Gets the type of tone mapping effect.
  23956. */
  23957. get toneMappingType(): number;
  23958. /**
  23959. * Sets the type of tone mapping effect.
  23960. */
  23961. set toneMappingType(value: number);
  23962. /**
  23963. * Gets contrast used in the effect.
  23964. */
  23965. get contrast(): number;
  23966. /**
  23967. * Sets contrast used in the effect.
  23968. */
  23969. set contrast(value: number);
  23970. /**
  23971. * Gets Vignette stretch size.
  23972. */
  23973. get vignetteStretch(): number;
  23974. /**
  23975. * Sets Vignette stretch size.
  23976. */
  23977. set vignetteStretch(value: number);
  23978. /**
  23979. * Gets Vignette centre X Offset.
  23980. */
  23981. get vignetteCentreX(): number;
  23982. /**
  23983. * Sets Vignette centre X Offset.
  23984. */
  23985. set vignetteCentreX(value: number);
  23986. /**
  23987. * Gets Vignette centre Y Offset.
  23988. */
  23989. get vignetteCentreY(): number;
  23990. /**
  23991. * Sets Vignette centre Y Offset.
  23992. */
  23993. set vignetteCentreY(value: number);
  23994. /**
  23995. * Gets Vignette weight or intensity of the vignette effect.
  23996. */
  23997. get vignetteWeight(): number;
  23998. /**
  23999. * Sets Vignette weight or intensity of the vignette effect.
  24000. */
  24001. set vignetteWeight(value: number);
  24002. /**
  24003. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24004. * if vignetteEnabled is set to true.
  24005. */
  24006. get vignetteColor(): Color4;
  24007. /**
  24008. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24009. * if vignetteEnabled is set to true.
  24010. */
  24011. set vignetteColor(value: Color4);
  24012. /**
  24013. * Gets Camera field of view used by the Vignette effect.
  24014. */
  24015. get vignetteCameraFov(): number;
  24016. /**
  24017. * Sets Camera field of view used by the Vignette effect.
  24018. */
  24019. set vignetteCameraFov(value: number);
  24020. /**
  24021. * Gets the vignette blend mode allowing different kind of effect.
  24022. */
  24023. get vignetteBlendMode(): number;
  24024. /**
  24025. * Sets the vignette blend mode allowing different kind of effect.
  24026. */
  24027. set vignetteBlendMode(value: number);
  24028. /**
  24029. * Gets wether the vignette effect is enabled.
  24030. */
  24031. get vignetteEnabled(): boolean;
  24032. /**
  24033. * Sets wether the vignette effect is enabled.
  24034. */
  24035. set vignetteEnabled(value: boolean);
  24036. private _fromLinearSpace;
  24037. /**
  24038. * Gets wether the input of the processing is in Gamma or Linear Space.
  24039. */
  24040. get fromLinearSpace(): boolean;
  24041. /**
  24042. * Sets wether the input of the processing is in Gamma or Linear Space.
  24043. */
  24044. set fromLinearSpace(value: boolean);
  24045. /**
  24046. * Defines cache preventing GC.
  24047. */
  24048. private _defines;
  24049. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24050. /**
  24051. * "ImageProcessingPostProcess"
  24052. * @returns "ImageProcessingPostProcess"
  24053. */
  24054. getClassName(): string;
  24055. /**
  24056. * @hidden
  24057. */
  24058. _updateParameters(): void;
  24059. dispose(camera?: Camera): void;
  24060. }
  24061. }
  24062. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24064. /**
  24065. * Interface for defining prepass effects in the prepass post-process pipeline
  24066. */
  24067. export interface PrePassEffectConfiguration {
  24068. /**
  24069. * Name of the effect
  24070. */
  24071. name: string;
  24072. /**
  24073. * Post process to attach for this effect
  24074. */
  24075. postProcess?: PostProcess;
  24076. /**
  24077. * Textures required in the MRT
  24078. */
  24079. texturesRequired: number[];
  24080. /**
  24081. * Is the effect enabled
  24082. */
  24083. enabled: boolean;
  24084. /**
  24085. * Disposes the effect configuration
  24086. */
  24087. dispose?: () => void;
  24088. /**
  24089. * Creates the associated post process
  24090. */
  24091. createPostProcess?: () => PostProcess;
  24092. }
  24093. }
  24094. declare module "babylonjs/Materials/fresnelParameters" {
  24095. import { DeepImmutable } from "babylonjs/types";
  24096. import { Color3 } from "babylonjs/Maths/math.color";
  24097. /**
  24098. * Options to be used when creating a FresnelParameters.
  24099. */
  24100. export type IFresnelParametersCreationOptions = {
  24101. /**
  24102. * Define the color used on edges (grazing angle)
  24103. */
  24104. leftColor?: Color3;
  24105. /**
  24106. * Define the color used on center
  24107. */
  24108. rightColor?: Color3;
  24109. /**
  24110. * Define bias applied to computed fresnel term
  24111. */
  24112. bias?: number;
  24113. /**
  24114. * Defined the power exponent applied to fresnel term
  24115. */
  24116. power?: number;
  24117. /**
  24118. * Define if the fresnel effect is enable or not.
  24119. */
  24120. isEnabled?: boolean;
  24121. };
  24122. /**
  24123. * Serialized format for FresnelParameters.
  24124. */
  24125. export type IFresnelParametersSerialized = {
  24126. /**
  24127. * Define the color used on edges (grazing angle) [as an array]
  24128. */
  24129. leftColor: number[];
  24130. /**
  24131. * Define the color used on center [as an array]
  24132. */
  24133. rightColor: number[];
  24134. /**
  24135. * Define bias applied to computed fresnel term
  24136. */
  24137. bias: number;
  24138. /**
  24139. * Defined the power exponent applied to fresnel term
  24140. */
  24141. power?: number;
  24142. /**
  24143. * Define if the fresnel effect is enable or not.
  24144. */
  24145. isEnabled: boolean;
  24146. };
  24147. /**
  24148. * This represents all the required information to add a fresnel effect on a material:
  24149. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24150. */
  24151. export class FresnelParameters {
  24152. private _isEnabled;
  24153. /**
  24154. * Define if the fresnel effect is enable or not.
  24155. */
  24156. get isEnabled(): boolean;
  24157. set isEnabled(value: boolean);
  24158. /**
  24159. * Define the color used on edges (grazing angle)
  24160. */
  24161. leftColor: Color3;
  24162. /**
  24163. * Define the color used on center
  24164. */
  24165. rightColor: Color3;
  24166. /**
  24167. * Define bias applied to computed fresnel term
  24168. */
  24169. bias: number;
  24170. /**
  24171. * Defined the power exponent applied to fresnel term
  24172. */
  24173. power: number;
  24174. /**
  24175. * Creates a new FresnelParameters object.
  24176. *
  24177. * @param options provide your own settings to optionally to override defaults
  24178. */
  24179. constructor(options?: IFresnelParametersCreationOptions);
  24180. /**
  24181. * Clones the current fresnel and its valuues
  24182. * @returns a clone fresnel configuration
  24183. */
  24184. clone(): FresnelParameters;
  24185. /**
  24186. * Determines equality between FresnelParameters objects
  24187. * @param otherFresnelParameters defines the second operand
  24188. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24189. */
  24190. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24191. /**
  24192. * Serializes the current fresnel parameters to a JSON representation.
  24193. * @return the JSON serialization
  24194. */
  24195. serialize(): IFresnelParametersSerialized;
  24196. /**
  24197. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24198. * @param parsedFresnelParameters Define the JSON representation
  24199. * @returns the parsed parameters
  24200. */
  24201. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24202. }
  24203. }
  24204. declare module "babylonjs/Materials/materialFlags" {
  24205. /**
  24206. * This groups all the flags used to control the materials channel.
  24207. */
  24208. export class MaterialFlags {
  24209. private static _DiffuseTextureEnabled;
  24210. /**
  24211. * Are diffuse textures enabled in the application.
  24212. */
  24213. static get DiffuseTextureEnabled(): boolean;
  24214. static set DiffuseTextureEnabled(value: boolean);
  24215. private static _DetailTextureEnabled;
  24216. /**
  24217. * Are detail textures enabled in the application.
  24218. */
  24219. static get DetailTextureEnabled(): boolean;
  24220. static set DetailTextureEnabled(value: boolean);
  24221. private static _AmbientTextureEnabled;
  24222. /**
  24223. * Are ambient textures enabled in the application.
  24224. */
  24225. static get AmbientTextureEnabled(): boolean;
  24226. static set AmbientTextureEnabled(value: boolean);
  24227. private static _OpacityTextureEnabled;
  24228. /**
  24229. * Are opacity textures enabled in the application.
  24230. */
  24231. static get OpacityTextureEnabled(): boolean;
  24232. static set OpacityTextureEnabled(value: boolean);
  24233. private static _ReflectionTextureEnabled;
  24234. /**
  24235. * Are reflection textures enabled in the application.
  24236. */
  24237. static get ReflectionTextureEnabled(): boolean;
  24238. static set ReflectionTextureEnabled(value: boolean);
  24239. private static _EmissiveTextureEnabled;
  24240. /**
  24241. * Are emissive textures enabled in the application.
  24242. */
  24243. static get EmissiveTextureEnabled(): boolean;
  24244. static set EmissiveTextureEnabled(value: boolean);
  24245. private static _SpecularTextureEnabled;
  24246. /**
  24247. * Are specular textures enabled in the application.
  24248. */
  24249. static get SpecularTextureEnabled(): boolean;
  24250. static set SpecularTextureEnabled(value: boolean);
  24251. private static _BumpTextureEnabled;
  24252. /**
  24253. * Are bump textures enabled in the application.
  24254. */
  24255. static get BumpTextureEnabled(): boolean;
  24256. static set BumpTextureEnabled(value: boolean);
  24257. private static _LightmapTextureEnabled;
  24258. /**
  24259. * Are lightmap textures enabled in the application.
  24260. */
  24261. static get LightmapTextureEnabled(): boolean;
  24262. static set LightmapTextureEnabled(value: boolean);
  24263. private static _RefractionTextureEnabled;
  24264. /**
  24265. * Are refraction textures enabled in the application.
  24266. */
  24267. static get RefractionTextureEnabled(): boolean;
  24268. static set RefractionTextureEnabled(value: boolean);
  24269. private static _ColorGradingTextureEnabled;
  24270. /**
  24271. * Are color grading textures enabled in the application.
  24272. */
  24273. static get ColorGradingTextureEnabled(): boolean;
  24274. static set ColorGradingTextureEnabled(value: boolean);
  24275. private static _FresnelEnabled;
  24276. /**
  24277. * Are fresnels enabled in the application.
  24278. */
  24279. static get FresnelEnabled(): boolean;
  24280. static set FresnelEnabled(value: boolean);
  24281. private static _ClearCoatTextureEnabled;
  24282. /**
  24283. * Are clear coat textures enabled in the application.
  24284. */
  24285. static get ClearCoatTextureEnabled(): boolean;
  24286. static set ClearCoatTextureEnabled(value: boolean);
  24287. private static _ClearCoatBumpTextureEnabled;
  24288. /**
  24289. * Are clear coat bump textures enabled in the application.
  24290. */
  24291. static get ClearCoatBumpTextureEnabled(): boolean;
  24292. static set ClearCoatBumpTextureEnabled(value: boolean);
  24293. private static _ClearCoatTintTextureEnabled;
  24294. /**
  24295. * Are clear coat tint textures enabled in the application.
  24296. */
  24297. static get ClearCoatTintTextureEnabled(): boolean;
  24298. static set ClearCoatTintTextureEnabled(value: boolean);
  24299. private static _SheenTextureEnabled;
  24300. /**
  24301. * Are sheen textures enabled in the application.
  24302. */
  24303. static get SheenTextureEnabled(): boolean;
  24304. static set SheenTextureEnabled(value: boolean);
  24305. private static _AnisotropicTextureEnabled;
  24306. /**
  24307. * Are anisotropic textures enabled in the application.
  24308. */
  24309. static get AnisotropicTextureEnabled(): boolean;
  24310. static set AnisotropicTextureEnabled(value: boolean);
  24311. private static _ThicknessTextureEnabled;
  24312. /**
  24313. * Are thickness textures enabled in the application.
  24314. */
  24315. static get ThicknessTextureEnabled(): boolean;
  24316. static set ThicknessTextureEnabled(value: boolean);
  24317. }
  24318. }
  24319. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24320. /** @hidden */
  24321. export var defaultFragmentDeclaration: {
  24322. name: string;
  24323. shader: string;
  24324. };
  24325. }
  24326. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24327. /** @hidden */
  24328. export var defaultUboDeclaration: {
  24329. name: string;
  24330. shader: string;
  24331. };
  24332. }
  24333. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24334. /** @hidden */
  24335. export var prePassDeclaration: {
  24336. name: string;
  24337. shader: string;
  24338. };
  24339. }
  24340. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24341. /** @hidden */
  24342. export var lightFragmentDeclaration: {
  24343. name: string;
  24344. shader: string;
  24345. };
  24346. }
  24347. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24348. /** @hidden */
  24349. export var lightUboDeclaration: {
  24350. name: string;
  24351. shader: string;
  24352. };
  24353. }
  24354. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24355. /** @hidden */
  24356. export var lightsFragmentFunctions: {
  24357. name: string;
  24358. shader: string;
  24359. };
  24360. }
  24361. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24362. /** @hidden */
  24363. export var shadowsFragmentFunctions: {
  24364. name: string;
  24365. shader: string;
  24366. };
  24367. }
  24368. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24369. /** @hidden */
  24370. export var fresnelFunction: {
  24371. name: string;
  24372. shader: string;
  24373. };
  24374. }
  24375. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24376. /** @hidden */
  24377. export var bumpFragmentMainFunctions: {
  24378. name: string;
  24379. shader: string;
  24380. };
  24381. }
  24382. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24383. /** @hidden */
  24384. export var bumpFragmentFunctions: {
  24385. name: string;
  24386. shader: string;
  24387. };
  24388. }
  24389. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24390. /** @hidden */
  24391. export var logDepthDeclaration: {
  24392. name: string;
  24393. shader: string;
  24394. };
  24395. }
  24396. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24397. /** @hidden */
  24398. export var bumpFragment: {
  24399. name: string;
  24400. shader: string;
  24401. };
  24402. }
  24403. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24404. /** @hidden */
  24405. export var depthPrePass: {
  24406. name: string;
  24407. shader: string;
  24408. };
  24409. }
  24410. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24411. /** @hidden */
  24412. export var lightFragment: {
  24413. name: string;
  24414. shader: string;
  24415. };
  24416. }
  24417. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24418. /** @hidden */
  24419. export var logDepthFragment: {
  24420. name: string;
  24421. shader: string;
  24422. };
  24423. }
  24424. declare module "babylonjs/Shaders/default.fragment" {
  24425. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24426. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24427. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24428. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24429. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24430. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24431. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24432. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24433. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24434. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24435. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24436. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24437. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24438. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24439. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24440. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24441. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24442. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24443. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24444. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24445. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24446. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24447. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24448. /** @hidden */
  24449. export var defaultPixelShader: {
  24450. name: string;
  24451. shader: string;
  24452. };
  24453. }
  24454. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24455. /** @hidden */
  24456. export var defaultVertexDeclaration: {
  24457. name: string;
  24458. shader: string;
  24459. };
  24460. }
  24461. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24462. /** @hidden */
  24463. export var prePassVertexDeclaration: {
  24464. name: string;
  24465. shader: string;
  24466. };
  24467. }
  24468. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24469. /** @hidden */
  24470. export var bumpVertexDeclaration: {
  24471. name: string;
  24472. shader: string;
  24473. };
  24474. }
  24475. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24476. /** @hidden */
  24477. export var prePassVertex: {
  24478. name: string;
  24479. shader: string;
  24480. };
  24481. }
  24482. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24483. /** @hidden */
  24484. export var bumpVertex: {
  24485. name: string;
  24486. shader: string;
  24487. };
  24488. }
  24489. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24490. /** @hidden */
  24491. export var fogVertex: {
  24492. name: string;
  24493. shader: string;
  24494. };
  24495. }
  24496. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24497. /** @hidden */
  24498. export var shadowsVertex: {
  24499. name: string;
  24500. shader: string;
  24501. };
  24502. }
  24503. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24504. /** @hidden */
  24505. export var pointCloudVertex: {
  24506. name: string;
  24507. shader: string;
  24508. };
  24509. }
  24510. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24511. /** @hidden */
  24512. export var logDepthVertex: {
  24513. name: string;
  24514. shader: string;
  24515. };
  24516. }
  24517. declare module "babylonjs/Shaders/default.vertex" {
  24518. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24519. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24520. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24521. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24522. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24523. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24524. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24526. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24527. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24528. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24529. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24530. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24531. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24533. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24534. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24535. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24536. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24537. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24538. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24539. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24540. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24541. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24542. /** @hidden */
  24543. export var defaultVertexShader: {
  24544. name: string;
  24545. shader: string;
  24546. };
  24547. }
  24548. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24549. import { Nullable } from "babylonjs/types";
  24550. import { Scene } from "babylonjs/scene";
  24551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24552. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24553. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24554. /**
  24555. * @hidden
  24556. */
  24557. export interface IMaterialDetailMapDefines {
  24558. DETAIL: boolean;
  24559. DETAILDIRECTUV: number;
  24560. DETAIL_NORMALBLENDMETHOD: number;
  24561. /** @hidden */
  24562. _areTexturesDirty: boolean;
  24563. }
  24564. /**
  24565. * Define the code related to the detail map parameters of a material
  24566. *
  24567. * Inspired from:
  24568. * 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
  24569. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24570. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24571. */
  24572. export class DetailMapConfiguration {
  24573. private _texture;
  24574. /**
  24575. * The detail texture of the material.
  24576. */
  24577. texture: Nullable<BaseTexture>;
  24578. /**
  24579. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24580. * Bigger values mean stronger blending
  24581. */
  24582. diffuseBlendLevel: number;
  24583. /**
  24584. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24585. * Bigger values mean stronger blending. Only used with PBR materials
  24586. */
  24587. roughnessBlendLevel: number;
  24588. /**
  24589. * Defines how strong the bump effect from the detail map is
  24590. * Bigger values mean stronger effect
  24591. */
  24592. bumpLevel: number;
  24593. private _normalBlendMethod;
  24594. /**
  24595. * The method used to blend the bump and detail normals together
  24596. */
  24597. normalBlendMethod: number;
  24598. private _isEnabled;
  24599. /**
  24600. * Enable or disable the detail map on this material
  24601. */
  24602. isEnabled: boolean;
  24603. /** @hidden */
  24604. private _internalMarkAllSubMeshesAsTexturesDirty;
  24605. /** @hidden */
  24606. _markAllSubMeshesAsTexturesDirty(): void;
  24607. /**
  24608. * Instantiate a new detail map
  24609. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24610. */
  24611. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24612. /**
  24613. * Gets whether the submesh is ready to be used or not.
  24614. * @param defines the list of "defines" to update.
  24615. * @param scene defines the scene the material belongs to.
  24616. * @returns - boolean indicating that the submesh is ready or not.
  24617. */
  24618. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24619. /**
  24620. * Update the defines for detail map usage
  24621. * @param defines the list of "defines" to update.
  24622. * @param scene defines the scene the material belongs to.
  24623. */
  24624. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24625. /**
  24626. * Binds the material data.
  24627. * @param uniformBuffer defines the Uniform buffer to fill in.
  24628. * @param scene defines the scene the material belongs to.
  24629. * @param isFrozen defines whether the material is frozen or not.
  24630. */
  24631. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24632. /**
  24633. * Checks to see if a texture is used in the material.
  24634. * @param texture - Base texture to use.
  24635. * @returns - Boolean specifying if a texture is used in the material.
  24636. */
  24637. hasTexture(texture: BaseTexture): boolean;
  24638. /**
  24639. * Returns an array of the actively used textures.
  24640. * @param activeTextures Array of BaseTextures
  24641. */
  24642. getActiveTextures(activeTextures: BaseTexture[]): void;
  24643. /**
  24644. * Returns the animatable textures.
  24645. * @param animatables Array of animatable textures.
  24646. */
  24647. getAnimatables(animatables: IAnimatable[]): void;
  24648. /**
  24649. * Disposes the resources of the material.
  24650. * @param forceDisposeTextures - Forces the disposal of all textures.
  24651. */
  24652. dispose(forceDisposeTextures?: boolean): void;
  24653. /**
  24654. * Get the current class name useful for serialization or dynamic coding.
  24655. * @returns "DetailMap"
  24656. */
  24657. getClassName(): string;
  24658. /**
  24659. * Add the required uniforms to the current list.
  24660. * @param uniforms defines the current uniform list.
  24661. */
  24662. static AddUniforms(uniforms: string[]): void;
  24663. /**
  24664. * Add the required samplers to the current list.
  24665. * @param samplers defines the current sampler list.
  24666. */
  24667. static AddSamplers(samplers: string[]): void;
  24668. /**
  24669. * Add the required uniforms to the current buffer.
  24670. * @param uniformBuffer defines the current uniform buffer.
  24671. */
  24672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24673. /**
  24674. * Makes a duplicate of the current instance into another one.
  24675. * @param detailMap define the instance where to copy the info
  24676. */
  24677. copyTo(detailMap: DetailMapConfiguration): void;
  24678. /**
  24679. * Serializes this detail map instance
  24680. * @returns - An object with the serialized instance.
  24681. */
  24682. serialize(): any;
  24683. /**
  24684. * Parses a detail map setting from a serialized object.
  24685. * @param source - Serialized object.
  24686. * @param scene Defines the scene we are parsing for
  24687. * @param rootUrl Defines the rootUrl to load from
  24688. */
  24689. parse(source: any, scene: Scene, rootUrl: string): void;
  24690. }
  24691. }
  24692. declare module "babylonjs/Materials/standardMaterial" {
  24693. import { SmartArray } from "babylonjs/Misc/smartArray";
  24694. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24695. import { Nullable } from "babylonjs/types";
  24696. import { Scene } from "babylonjs/scene";
  24697. import { Matrix } from "babylonjs/Maths/math.vector";
  24698. import { Color3 } from "babylonjs/Maths/math.color";
  24699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24701. import { Mesh } from "babylonjs/Meshes/mesh";
  24702. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24703. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24704. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24705. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24706. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24707. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24710. import "babylonjs/Shaders/default.fragment";
  24711. import "babylonjs/Shaders/default.vertex";
  24712. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24713. /** @hidden */
  24714. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24715. MAINUV1: boolean;
  24716. MAINUV2: boolean;
  24717. DIFFUSE: boolean;
  24718. DIFFUSEDIRECTUV: number;
  24719. DETAIL: boolean;
  24720. DETAILDIRECTUV: number;
  24721. DETAIL_NORMALBLENDMETHOD: number;
  24722. AMBIENT: boolean;
  24723. AMBIENTDIRECTUV: number;
  24724. OPACITY: boolean;
  24725. OPACITYDIRECTUV: number;
  24726. OPACITYRGB: boolean;
  24727. REFLECTION: boolean;
  24728. EMISSIVE: boolean;
  24729. EMISSIVEDIRECTUV: number;
  24730. SPECULAR: boolean;
  24731. SPECULARDIRECTUV: number;
  24732. BUMP: boolean;
  24733. BUMPDIRECTUV: number;
  24734. PARALLAX: boolean;
  24735. PARALLAXOCCLUSION: boolean;
  24736. SPECULAROVERALPHA: boolean;
  24737. CLIPPLANE: boolean;
  24738. CLIPPLANE2: boolean;
  24739. CLIPPLANE3: boolean;
  24740. CLIPPLANE4: boolean;
  24741. CLIPPLANE5: boolean;
  24742. CLIPPLANE6: boolean;
  24743. ALPHATEST: boolean;
  24744. DEPTHPREPASS: boolean;
  24745. ALPHAFROMDIFFUSE: boolean;
  24746. POINTSIZE: boolean;
  24747. FOG: boolean;
  24748. SPECULARTERM: boolean;
  24749. DIFFUSEFRESNEL: boolean;
  24750. OPACITYFRESNEL: boolean;
  24751. REFLECTIONFRESNEL: boolean;
  24752. REFRACTIONFRESNEL: boolean;
  24753. EMISSIVEFRESNEL: boolean;
  24754. FRESNEL: boolean;
  24755. NORMAL: boolean;
  24756. UV1: boolean;
  24757. UV2: boolean;
  24758. VERTEXCOLOR: boolean;
  24759. VERTEXALPHA: boolean;
  24760. NUM_BONE_INFLUENCERS: number;
  24761. BonesPerMesh: number;
  24762. BONETEXTURE: boolean;
  24763. BONES_VELOCITY_ENABLED: boolean;
  24764. INSTANCES: boolean;
  24765. THIN_INSTANCES: boolean;
  24766. GLOSSINESS: boolean;
  24767. ROUGHNESS: boolean;
  24768. EMISSIVEASILLUMINATION: boolean;
  24769. LINKEMISSIVEWITHDIFFUSE: boolean;
  24770. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24771. LIGHTMAP: boolean;
  24772. LIGHTMAPDIRECTUV: number;
  24773. OBJECTSPACE_NORMALMAP: boolean;
  24774. USELIGHTMAPASSHADOWMAP: boolean;
  24775. REFLECTIONMAP_3D: boolean;
  24776. REFLECTIONMAP_SPHERICAL: boolean;
  24777. REFLECTIONMAP_PLANAR: boolean;
  24778. REFLECTIONMAP_CUBIC: boolean;
  24779. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24780. REFLECTIONMAP_PROJECTION: boolean;
  24781. REFLECTIONMAP_SKYBOX: boolean;
  24782. REFLECTIONMAP_EXPLICIT: boolean;
  24783. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24784. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24785. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24786. INVERTCUBICMAP: boolean;
  24787. LOGARITHMICDEPTH: boolean;
  24788. REFRACTION: boolean;
  24789. REFRACTIONMAP_3D: boolean;
  24790. REFLECTIONOVERALPHA: boolean;
  24791. TWOSIDEDLIGHTING: boolean;
  24792. SHADOWFLOAT: boolean;
  24793. MORPHTARGETS: boolean;
  24794. MORPHTARGETS_NORMAL: boolean;
  24795. MORPHTARGETS_TANGENT: boolean;
  24796. MORPHTARGETS_UV: boolean;
  24797. NUM_MORPH_INFLUENCERS: number;
  24798. NONUNIFORMSCALING: boolean;
  24799. PREMULTIPLYALPHA: boolean;
  24800. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24801. ALPHABLEND: boolean;
  24802. PREPASS: boolean;
  24803. PREPASS_IRRADIANCE: boolean;
  24804. PREPASS_IRRADIANCE_INDEX: number;
  24805. PREPASS_ALBEDO: boolean;
  24806. PREPASS_ALBEDO_INDEX: number;
  24807. PREPASS_DEPTHNORMAL: boolean;
  24808. PREPASS_DEPTHNORMAL_INDEX: number;
  24809. PREPASS_POSITION: boolean;
  24810. PREPASS_POSITION_INDEX: number;
  24811. PREPASS_VELOCITY: boolean;
  24812. PREPASS_VELOCITY_INDEX: number;
  24813. PREPASS_REFLECTIVITY: boolean;
  24814. PREPASS_REFLECTIVITY_INDEX: number;
  24815. SCENE_MRT_COUNT: number;
  24816. RGBDLIGHTMAP: boolean;
  24817. RGBDREFLECTION: boolean;
  24818. RGBDREFRACTION: boolean;
  24819. IMAGEPROCESSING: boolean;
  24820. VIGNETTE: boolean;
  24821. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24822. VIGNETTEBLENDMODEOPAQUE: boolean;
  24823. TONEMAPPING: boolean;
  24824. TONEMAPPING_ACES: boolean;
  24825. CONTRAST: boolean;
  24826. COLORCURVES: boolean;
  24827. COLORGRADING: boolean;
  24828. COLORGRADING3D: boolean;
  24829. SAMPLER3DGREENDEPTH: boolean;
  24830. SAMPLER3DBGRMAP: boolean;
  24831. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24832. MULTIVIEW: boolean;
  24833. /**
  24834. * If the reflection texture on this material is in linear color space
  24835. * @hidden
  24836. */
  24837. IS_REFLECTION_LINEAR: boolean;
  24838. /**
  24839. * If the refraction texture on this material is in linear color space
  24840. * @hidden
  24841. */
  24842. IS_REFRACTION_LINEAR: boolean;
  24843. EXPOSURE: boolean;
  24844. constructor();
  24845. setReflectionMode(modeToEnable: string): void;
  24846. }
  24847. /**
  24848. * This is the default material used in Babylon. It is the best trade off between quality
  24849. * and performances.
  24850. * @see https://doc.babylonjs.com/babylon101/materials
  24851. */
  24852. export class StandardMaterial extends PushMaterial {
  24853. private _diffuseTexture;
  24854. /**
  24855. * The basic texture of the material as viewed under a light.
  24856. */
  24857. diffuseTexture: Nullable<BaseTexture>;
  24858. private _ambientTexture;
  24859. /**
  24860. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24861. */
  24862. ambientTexture: Nullable<BaseTexture>;
  24863. private _opacityTexture;
  24864. /**
  24865. * Define the transparency of the material from a texture.
  24866. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24867. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24868. */
  24869. opacityTexture: Nullable<BaseTexture>;
  24870. private _reflectionTexture;
  24871. /**
  24872. * Define the texture used to display the reflection.
  24873. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24874. */
  24875. reflectionTexture: Nullable<BaseTexture>;
  24876. private _emissiveTexture;
  24877. /**
  24878. * Define texture of the material as if self lit.
  24879. * This will be mixed in the final result even in the absence of light.
  24880. */
  24881. emissiveTexture: Nullable<BaseTexture>;
  24882. private _specularTexture;
  24883. /**
  24884. * Define how the color and intensity of the highlight given by the light in the material.
  24885. */
  24886. specularTexture: Nullable<BaseTexture>;
  24887. private _bumpTexture;
  24888. /**
  24889. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24890. * 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.
  24891. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24892. */
  24893. bumpTexture: Nullable<BaseTexture>;
  24894. private _lightmapTexture;
  24895. /**
  24896. * Complex lighting can be computationally expensive to compute at runtime.
  24897. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24898. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24899. */
  24900. lightmapTexture: Nullable<BaseTexture>;
  24901. private _refractionTexture;
  24902. /**
  24903. * Define the texture used to display the refraction.
  24904. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24905. */
  24906. refractionTexture: Nullable<BaseTexture>;
  24907. /**
  24908. * The color of the material lit by the environmental background lighting.
  24909. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24910. */
  24911. ambientColor: Color3;
  24912. /**
  24913. * The basic color of the material as viewed under a light.
  24914. */
  24915. diffuseColor: Color3;
  24916. /**
  24917. * Define how the color and intensity of the highlight given by the light in the material.
  24918. */
  24919. specularColor: Color3;
  24920. /**
  24921. * Define the color of the material as if self lit.
  24922. * This will be mixed in the final result even in the absence of light.
  24923. */
  24924. emissiveColor: Color3;
  24925. /**
  24926. * Defines how sharp are the highlights in the material.
  24927. * The bigger the value the sharper giving a more glossy feeling to the result.
  24928. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24929. */
  24930. specularPower: number;
  24931. private _useAlphaFromDiffuseTexture;
  24932. /**
  24933. * Does the transparency come from the diffuse texture alpha channel.
  24934. */
  24935. useAlphaFromDiffuseTexture: boolean;
  24936. private _useEmissiveAsIllumination;
  24937. /**
  24938. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24939. */
  24940. useEmissiveAsIllumination: boolean;
  24941. private _linkEmissiveWithDiffuse;
  24942. /**
  24943. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24944. * the emissive level when the final color is close to one.
  24945. */
  24946. linkEmissiveWithDiffuse: boolean;
  24947. private _useSpecularOverAlpha;
  24948. /**
  24949. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24950. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24951. */
  24952. useSpecularOverAlpha: boolean;
  24953. private _useReflectionOverAlpha;
  24954. /**
  24955. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24956. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24957. */
  24958. useReflectionOverAlpha: boolean;
  24959. private _disableLighting;
  24960. /**
  24961. * Does lights from the scene impacts this material.
  24962. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24963. */
  24964. disableLighting: boolean;
  24965. private _useObjectSpaceNormalMap;
  24966. /**
  24967. * Allows using an object space normal map (instead of tangent space).
  24968. */
  24969. useObjectSpaceNormalMap: boolean;
  24970. private _useParallax;
  24971. /**
  24972. * Is parallax enabled or not.
  24973. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24974. */
  24975. useParallax: boolean;
  24976. private _useParallaxOcclusion;
  24977. /**
  24978. * Is parallax occlusion enabled or not.
  24979. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24980. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24981. */
  24982. useParallaxOcclusion: boolean;
  24983. /**
  24984. * 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.
  24985. */
  24986. parallaxScaleBias: number;
  24987. private _roughness;
  24988. /**
  24989. * Helps to define how blurry the reflections should appears in the material.
  24990. */
  24991. roughness: number;
  24992. /**
  24993. * In case of refraction, define the value of the index of refraction.
  24994. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24995. */
  24996. indexOfRefraction: number;
  24997. /**
  24998. * Invert the refraction texture alongside the y axis.
  24999. * It can be useful with procedural textures or probe for instance.
  25000. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25001. */
  25002. invertRefractionY: boolean;
  25003. /**
  25004. * Defines the alpha limits in alpha test mode.
  25005. */
  25006. alphaCutOff: number;
  25007. private _useLightmapAsShadowmap;
  25008. /**
  25009. * In case of light mapping, define whether the map contains light or shadow informations.
  25010. */
  25011. useLightmapAsShadowmap: boolean;
  25012. private _diffuseFresnelParameters;
  25013. /**
  25014. * Define the diffuse fresnel parameters of the material.
  25015. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25016. */
  25017. diffuseFresnelParameters: FresnelParameters;
  25018. private _opacityFresnelParameters;
  25019. /**
  25020. * Define the opacity fresnel parameters of the material.
  25021. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25022. */
  25023. opacityFresnelParameters: FresnelParameters;
  25024. private _reflectionFresnelParameters;
  25025. /**
  25026. * Define the reflection fresnel parameters of the material.
  25027. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25028. */
  25029. reflectionFresnelParameters: FresnelParameters;
  25030. private _refractionFresnelParameters;
  25031. /**
  25032. * Define the refraction fresnel parameters of the material.
  25033. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25034. */
  25035. refractionFresnelParameters: FresnelParameters;
  25036. private _emissiveFresnelParameters;
  25037. /**
  25038. * Define the emissive fresnel parameters of the material.
  25039. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25040. */
  25041. emissiveFresnelParameters: FresnelParameters;
  25042. private _useReflectionFresnelFromSpecular;
  25043. /**
  25044. * If true automatically deducts the fresnels values from the material specularity.
  25045. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25046. */
  25047. useReflectionFresnelFromSpecular: boolean;
  25048. private _useGlossinessFromSpecularMapAlpha;
  25049. /**
  25050. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25051. */
  25052. useGlossinessFromSpecularMapAlpha: boolean;
  25053. private _maxSimultaneousLights;
  25054. /**
  25055. * Defines the maximum number of lights that can be used in the material
  25056. */
  25057. maxSimultaneousLights: number;
  25058. private _invertNormalMapX;
  25059. /**
  25060. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25061. */
  25062. invertNormalMapX: boolean;
  25063. private _invertNormalMapY;
  25064. /**
  25065. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25066. */
  25067. invertNormalMapY: boolean;
  25068. private _twoSidedLighting;
  25069. /**
  25070. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25071. */
  25072. twoSidedLighting: boolean;
  25073. /**
  25074. * Default configuration related to image processing available in the standard Material.
  25075. */
  25076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25077. /**
  25078. * Gets the image processing configuration used either in this material.
  25079. */
  25080. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25081. /**
  25082. * Sets the Default image processing configuration used either in the this material.
  25083. *
  25084. * If sets to null, the scene one is in use.
  25085. */
  25086. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25087. /**
  25088. * Keep track of the image processing observer to allow dispose and replace.
  25089. */
  25090. private _imageProcessingObserver;
  25091. /**
  25092. * Attaches a new image processing configuration to the Standard Material.
  25093. * @param configuration
  25094. */
  25095. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25096. /**
  25097. * Defines additionnal PrePass parameters for the material.
  25098. */
  25099. readonly prePassConfiguration: PrePassConfiguration;
  25100. /**
  25101. * Gets wether the color curves effect is enabled.
  25102. */
  25103. get cameraColorCurvesEnabled(): boolean;
  25104. /**
  25105. * Sets wether the color curves effect is enabled.
  25106. */
  25107. set cameraColorCurvesEnabled(value: boolean);
  25108. /**
  25109. * Gets wether the color grading effect is enabled.
  25110. */
  25111. get cameraColorGradingEnabled(): boolean;
  25112. /**
  25113. * Gets wether the color grading effect is enabled.
  25114. */
  25115. set cameraColorGradingEnabled(value: boolean);
  25116. /**
  25117. * Gets wether tonemapping is enabled or not.
  25118. */
  25119. get cameraToneMappingEnabled(): boolean;
  25120. /**
  25121. * Sets wether tonemapping is enabled or not
  25122. */
  25123. set cameraToneMappingEnabled(value: boolean);
  25124. /**
  25125. * The camera exposure used on this material.
  25126. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25127. * This corresponds to a photographic exposure.
  25128. */
  25129. get cameraExposure(): number;
  25130. /**
  25131. * The camera exposure used on this material.
  25132. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25133. * This corresponds to a photographic exposure.
  25134. */
  25135. set cameraExposure(value: number);
  25136. /**
  25137. * Gets The camera contrast used on this material.
  25138. */
  25139. get cameraContrast(): number;
  25140. /**
  25141. * Sets The camera contrast used on this material.
  25142. */
  25143. set cameraContrast(value: number);
  25144. /**
  25145. * Gets the Color Grading 2D Lookup Texture.
  25146. */
  25147. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25148. /**
  25149. * Sets the Color Grading 2D Lookup Texture.
  25150. */
  25151. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25152. /**
  25153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25155. * 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;
  25156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25157. */
  25158. get cameraColorCurves(): Nullable<ColorCurves>;
  25159. /**
  25160. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25161. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25162. * 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;
  25163. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25164. */
  25165. set cameraColorCurves(value: Nullable<ColorCurves>);
  25166. /**
  25167. * Can this material render to several textures at once
  25168. */
  25169. get canRenderToMRT(): boolean;
  25170. /**
  25171. * Defines the detail map parameters for the material.
  25172. */
  25173. readonly detailMap: DetailMapConfiguration;
  25174. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25175. protected _worldViewProjectionMatrix: Matrix;
  25176. protected _globalAmbientColor: Color3;
  25177. protected _useLogarithmicDepth: boolean;
  25178. protected _rebuildInParallel: boolean;
  25179. /**
  25180. * Instantiates a new standard material.
  25181. * This is the default material used in Babylon. It is the best trade off between quality
  25182. * and performances.
  25183. * @see https://doc.babylonjs.com/babylon101/materials
  25184. * @param name Define the name of the material in the scene
  25185. * @param scene Define the scene the material belong to
  25186. */
  25187. constructor(name: string, scene: Scene);
  25188. /**
  25189. * Gets a boolean indicating that current material needs to register RTT
  25190. */
  25191. get hasRenderTargetTextures(): boolean;
  25192. /**
  25193. * Gets the current class name of the material e.g. "StandardMaterial"
  25194. * Mainly use in serialization.
  25195. * @returns the class name
  25196. */
  25197. getClassName(): string;
  25198. /**
  25199. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25200. * You can try switching to logarithmic depth.
  25201. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25202. */
  25203. get useLogarithmicDepth(): boolean;
  25204. set useLogarithmicDepth(value: boolean);
  25205. /**
  25206. * Specifies if the material will require alpha blending
  25207. * @returns a boolean specifying if alpha blending is needed
  25208. */
  25209. needAlphaBlending(): boolean;
  25210. /**
  25211. * Specifies if this material should be rendered in alpha test mode
  25212. * @returns a boolean specifying if an alpha test is needed.
  25213. */
  25214. needAlphaTesting(): boolean;
  25215. /**
  25216. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25217. */
  25218. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25219. /**
  25220. * Specifies whether or not there is a usable alpha channel for transparency.
  25221. */
  25222. protected _hasAlphaChannel(): boolean;
  25223. /**
  25224. * Get the texture used for alpha test purpose.
  25225. * @returns the diffuse texture in case of the standard material.
  25226. */
  25227. getAlphaTestTexture(): Nullable<BaseTexture>;
  25228. /**
  25229. * Get if the submesh is ready to be used and all its information available.
  25230. * Child classes can use it to update shaders
  25231. * @param mesh defines the mesh to check
  25232. * @param subMesh defines which submesh to check
  25233. * @param useInstances specifies that instances should be used
  25234. * @returns a boolean indicating that the submesh is ready or not
  25235. */
  25236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25237. /**
  25238. * Builds the material UBO layouts.
  25239. * Used internally during the effect preparation.
  25240. */
  25241. buildUniformLayout(): void;
  25242. /**
  25243. * Unbinds the material from the mesh
  25244. */
  25245. unbind(): void;
  25246. /**
  25247. * Binds the submesh to this material by preparing the effect and shader to draw
  25248. * @param world defines the world transformation matrix
  25249. * @param mesh defines the mesh containing the submesh
  25250. * @param subMesh defines the submesh to bind the material to
  25251. */
  25252. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25253. /**
  25254. * Get the list of animatables in the material.
  25255. * @returns the list of animatables object used in the material
  25256. */
  25257. getAnimatables(): IAnimatable[];
  25258. /**
  25259. * Gets the active textures from the material
  25260. * @returns an array of textures
  25261. */
  25262. getActiveTextures(): BaseTexture[];
  25263. /**
  25264. * Specifies if the material uses a texture
  25265. * @param texture defines the texture to check against the material
  25266. * @returns a boolean specifying if the material uses the texture
  25267. */
  25268. hasTexture(texture: BaseTexture): boolean;
  25269. /**
  25270. * Disposes the material
  25271. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25272. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25273. */
  25274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25275. /**
  25276. * Makes a duplicate of the material, and gives it a new name
  25277. * @param name defines the new name for the duplicated material
  25278. * @returns the cloned material
  25279. */
  25280. clone(name: string): StandardMaterial;
  25281. /**
  25282. * Serializes this material in a JSON representation
  25283. * @returns the serialized material object
  25284. */
  25285. serialize(): any;
  25286. /**
  25287. * Creates a standard material from parsed material data
  25288. * @param source defines the JSON representation of the material
  25289. * @param scene defines the hosting scene
  25290. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25291. * @returns a new standard material
  25292. */
  25293. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25294. /**
  25295. * Are diffuse textures enabled in the application.
  25296. */
  25297. static get DiffuseTextureEnabled(): boolean;
  25298. static set DiffuseTextureEnabled(value: boolean);
  25299. /**
  25300. * Are detail textures enabled in the application.
  25301. */
  25302. static get DetailTextureEnabled(): boolean;
  25303. static set DetailTextureEnabled(value: boolean);
  25304. /**
  25305. * Are ambient textures enabled in the application.
  25306. */
  25307. static get AmbientTextureEnabled(): boolean;
  25308. static set AmbientTextureEnabled(value: boolean);
  25309. /**
  25310. * Are opacity textures enabled in the application.
  25311. */
  25312. static get OpacityTextureEnabled(): boolean;
  25313. static set OpacityTextureEnabled(value: boolean);
  25314. /**
  25315. * Are reflection textures enabled in the application.
  25316. */
  25317. static get ReflectionTextureEnabled(): boolean;
  25318. static set ReflectionTextureEnabled(value: boolean);
  25319. /**
  25320. * Are emissive textures enabled in the application.
  25321. */
  25322. static get EmissiveTextureEnabled(): boolean;
  25323. static set EmissiveTextureEnabled(value: boolean);
  25324. /**
  25325. * Are specular textures enabled in the application.
  25326. */
  25327. static get SpecularTextureEnabled(): boolean;
  25328. static set SpecularTextureEnabled(value: boolean);
  25329. /**
  25330. * Are bump textures enabled in the application.
  25331. */
  25332. static get BumpTextureEnabled(): boolean;
  25333. static set BumpTextureEnabled(value: boolean);
  25334. /**
  25335. * Are lightmap textures enabled in the application.
  25336. */
  25337. static get LightmapTextureEnabled(): boolean;
  25338. static set LightmapTextureEnabled(value: boolean);
  25339. /**
  25340. * Are refraction textures enabled in the application.
  25341. */
  25342. static get RefractionTextureEnabled(): boolean;
  25343. static set RefractionTextureEnabled(value: boolean);
  25344. /**
  25345. * Are color grading textures enabled in the application.
  25346. */
  25347. static get ColorGradingTextureEnabled(): boolean;
  25348. static set ColorGradingTextureEnabled(value: boolean);
  25349. /**
  25350. * Are fresnels enabled in the application.
  25351. */
  25352. static get FresnelEnabled(): boolean;
  25353. static set FresnelEnabled(value: boolean);
  25354. }
  25355. }
  25356. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25357. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25358. /** @hidden */
  25359. export var rgbdDecodePixelShader: {
  25360. name: string;
  25361. shader: string;
  25362. };
  25363. }
  25364. declare module "babylonjs/Misc/rgbdTextureTools" {
  25365. import "babylonjs/Shaders/rgbdDecode.fragment";
  25366. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25367. import { Texture } from "babylonjs/Materials/Textures/texture";
  25368. /**
  25369. * Class used to host RGBD texture specific utilities
  25370. */
  25371. export class RGBDTextureTools {
  25372. /**
  25373. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25374. * @param texture the texture to expand.
  25375. */
  25376. static ExpandRGBDTexture(texture: Texture): void;
  25377. }
  25378. }
  25379. declare module "babylonjs/Misc/brdfTextureTools" {
  25380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25381. import { Scene } from "babylonjs/scene";
  25382. /**
  25383. * Class used to host texture specific utilities
  25384. */
  25385. export class BRDFTextureTools {
  25386. /**
  25387. * Prevents texture cache collision
  25388. */
  25389. private static _instanceNumber;
  25390. /**
  25391. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25392. * @param scene defines the hosting scene
  25393. * @returns the environment BRDF texture
  25394. */
  25395. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25396. private static _environmentBRDFBase64Texture;
  25397. }
  25398. }
  25399. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25400. import { Nullable } from "babylonjs/types";
  25401. import { Color3 } from "babylonjs/Maths/math.color";
  25402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25404. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25405. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25406. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25407. import { Engine } from "babylonjs/Engines/engine";
  25408. import { Scene } from "babylonjs/scene";
  25409. /**
  25410. * @hidden
  25411. */
  25412. export interface IMaterialClearCoatDefines {
  25413. CLEARCOAT: boolean;
  25414. CLEARCOAT_DEFAULTIOR: boolean;
  25415. CLEARCOAT_TEXTURE: boolean;
  25416. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25417. CLEARCOAT_TEXTUREDIRECTUV: number;
  25418. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25419. CLEARCOAT_BUMP: boolean;
  25420. CLEARCOAT_BUMPDIRECTUV: number;
  25421. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25422. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25423. CLEARCOAT_REMAP_F0: boolean;
  25424. CLEARCOAT_TINT: boolean;
  25425. CLEARCOAT_TINT_TEXTURE: boolean;
  25426. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25427. /** @hidden */
  25428. _areTexturesDirty: boolean;
  25429. }
  25430. /**
  25431. * Define the code related to the clear coat parameters of the pbr material.
  25432. */
  25433. export class PBRClearCoatConfiguration {
  25434. /**
  25435. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25436. * The default fits with a polyurethane material.
  25437. */
  25438. private static readonly _DefaultIndexOfRefraction;
  25439. private _isEnabled;
  25440. /**
  25441. * Defines if the clear coat is enabled in the material.
  25442. */
  25443. isEnabled: boolean;
  25444. /**
  25445. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25446. */
  25447. intensity: number;
  25448. /**
  25449. * Defines the clear coat layer roughness.
  25450. */
  25451. roughness: number;
  25452. private _indexOfRefraction;
  25453. /**
  25454. * Defines the index of refraction of the clear coat.
  25455. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25456. * The default fits with a polyurethane material.
  25457. * Changing the default value is more performance intensive.
  25458. */
  25459. indexOfRefraction: number;
  25460. private _texture;
  25461. /**
  25462. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25463. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25464. * if textureRoughness is not empty, else no texture roughness is used
  25465. */
  25466. texture: Nullable<BaseTexture>;
  25467. private _useRoughnessFromMainTexture;
  25468. /**
  25469. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25470. * If false, the green channel from textureRoughness is used for roughness
  25471. */
  25472. useRoughnessFromMainTexture: boolean;
  25473. private _textureRoughness;
  25474. /**
  25475. * Stores the clear coat roughness in a texture (green channel)
  25476. * Not used if useRoughnessFromMainTexture is true
  25477. */
  25478. textureRoughness: Nullable<BaseTexture>;
  25479. private _remapF0OnInterfaceChange;
  25480. /**
  25481. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25482. */
  25483. remapF0OnInterfaceChange: boolean;
  25484. private _bumpTexture;
  25485. /**
  25486. * Define the clear coat specific bump texture.
  25487. */
  25488. bumpTexture: Nullable<BaseTexture>;
  25489. private _isTintEnabled;
  25490. /**
  25491. * Defines if the clear coat tint is enabled in the material.
  25492. */
  25493. isTintEnabled: boolean;
  25494. /**
  25495. * Defines the clear coat tint of the material.
  25496. * This is only use if tint is enabled
  25497. */
  25498. tintColor: Color3;
  25499. /**
  25500. * Defines the distance at which the tint color should be found in the
  25501. * clear coat media.
  25502. * This is only use if tint is enabled
  25503. */
  25504. tintColorAtDistance: number;
  25505. /**
  25506. * Defines the clear coat layer thickness.
  25507. * This is only use if tint is enabled
  25508. */
  25509. tintThickness: number;
  25510. private _tintTexture;
  25511. /**
  25512. * Stores the clear tint values in a texture.
  25513. * rgb is tint
  25514. * a is a thickness factor
  25515. */
  25516. tintTexture: Nullable<BaseTexture>;
  25517. /** @hidden */
  25518. private _internalMarkAllSubMeshesAsTexturesDirty;
  25519. /** @hidden */
  25520. _markAllSubMeshesAsTexturesDirty(): void;
  25521. /**
  25522. * Instantiate a new istance of clear coat configuration.
  25523. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25524. */
  25525. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25526. /**
  25527. * Gets wehter the submesh is ready to be used or not.
  25528. * @param defines the list of "defines" to update.
  25529. * @param scene defines the scene the material belongs to.
  25530. * @param engine defines the engine the material belongs to.
  25531. * @param disableBumpMap defines wether the material disables bump or not.
  25532. * @returns - boolean indicating that the submesh is ready or not.
  25533. */
  25534. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25535. /**
  25536. * Checks to see if a texture is used in the material.
  25537. * @param defines the list of "defines" to update.
  25538. * @param scene defines the scene to the material belongs to.
  25539. */
  25540. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25541. /**
  25542. * Binds the material data.
  25543. * @param uniformBuffer defines the Uniform buffer to fill in.
  25544. * @param scene defines the scene the material belongs to.
  25545. * @param engine defines the engine the material belongs to.
  25546. * @param disableBumpMap defines wether the material disables bump or not.
  25547. * @param isFrozen defines wether the material is frozen or not.
  25548. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25549. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25550. * @param subMesh the submesh to bind data for
  25551. */
  25552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25553. /**
  25554. * Checks to see if a texture is used in the material.
  25555. * @param texture - Base texture to use.
  25556. * @returns - Boolean specifying if a texture is used in the material.
  25557. */
  25558. hasTexture(texture: BaseTexture): boolean;
  25559. /**
  25560. * Returns an array of the actively used textures.
  25561. * @param activeTextures Array of BaseTextures
  25562. */
  25563. getActiveTextures(activeTextures: BaseTexture[]): void;
  25564. /**
  25565. * Returns the animatable textures.
  25566. * @param animatables Array of animatable textures.
  25567. */
  25568. getAnimatables(animatables: IAnimatable[]): void;
  25569. /**
  25570. * Disposes the resources of the material.
  25571. * @param forceDisposeTextures - Forces the disposal of all textures.
  25572. */
  25573. dispose(forceDisposeTextures?: boolean): void;
  25574. /**
  25575. * Get the current class name of the texture useful for serialization or dynamic coding.
  25576. * @returns "PBRClearCoatConfiguration"
  25577. */
  25578. getClassName(): string;
  25579. /**
  25580. * Add fallbacks to the effect fallbacks list.
  25581. * @param defines defines the Base texture to use.
  25582. * @param fallbacks defines the current fallback list.
  25583. * @param currentRank defines the current fallback rank.
  25584. * @returns the new fallback rank.
  25585. */
  25586. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25587. /**
  25588. * Add the required uniforms to the current list.
  25589. * @param uniforms defines the current uniform list.
  25590. */
  25591. static AddUniforms(uniforms: string[]): void;
  25592. /**
  25593. * Add the required samplers to the current list.
  25594. * @param samplers defines the current sampler list.
  25595. */
  25596. static AddSamplers(samplers: string[]): void;
  25597. /**
  25598. * Add the required uniforms to the current buffer.
  25599. * @param uniformBuffer defines the current uniform buffer.
  25600. */
  25601. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25602. /**
  25603. * Makes a duplicate of the current configuration into another one.
  25604. * @param clearCoatConfiguration define the config where to copy the info
  25605. */
  25606. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25607. /**
  25608. * Serializes this clear coat configuration.
  25609. * @returns - An object with the serialized config.
  25610. */
  25611. serialize(): any;
  25612. /**
  25613. * Parses a anisotropy Configuration from a serialized object.
  25614. * @param source - Serialized object.
  25615. * @param scene Defines the scene we are parsing for
  25616. * @param rootUrl Defines the rootUrl to load from
  25617. */
  25618. parse(source: any, scene: Scene, rootUrl: string): void;
  25619. }
  25620. }
  25621. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25622. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25624. import { Vector2 } from "babylonjs/Maths/math.vector";
  25625. import { Scene } from "babylonjs/scene";
  25626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25627. import { Nullable } from "babylonjs/types";
  25628. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25629. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25630. /**
  25631. * @hidden
  25632. */
  25633. export interface IMaterialAnisotropicDefines {
  25634. ANISOTROPIC: boolean;
  25635. ANISOTROPIC_TEXTURE: boolean;
  25636. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25637. MAINUV1: boolean;
  25638. _areTexturesDirty: boolean;
  25639. _needUVs: boolean;
  25640. }
  25641. /**
  25642. * Define the code related to the anisotropic parameters of the pbr material.
  25643. */
  25644. export class PBRAnisotropicConfiguration {
  25645. private _isEnabled;
  25646. /**
  25647. * Defines if the anisotropy is enabled in the material.
  25648. */
  25649. isEnabled: boolean;
  25650. /**
  25651. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25652. */
  25653. intensity: number;
  25654. /**
  25655. * Defines if the effect is along the tangents, bitangents or in between.
  25656. * By default, the effect is "strectching" the highlights along the tangents.
  25657. */
  25658. direction: Vector2;
  25659. private _texture;
  25660. /**
  25661. * Stores the anisotropy values in a texture.
  25662. * rg is direction (like normal from -1 to 1)
  25663. * b is a intensity
  25664. */
  25665. texture: Nullable<BaseTexture>;
  25666. /** @hidden */
  25667. private _internalMarkAllSubMeshesAsTexturesDirty;
  25668. /** @hidden */
  25669. _markAllSubMeshesAsTexturesDirty(): void;
  25670. /**
  25671. * Instantiate a new istance of anisotropy configuration.
  25672. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25673. */
  25674. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25675. /**
  25676. * Specifies that the submesh is ready to be used.
  25677. * @param defines the list of "defines" to update.
  25678. * @param scene defines the scene the material belongs to.
  25679. * @returns - boolean indicating that the submesh is ready or not.
  25680. */
  25681. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25682. /**
  25683. * Checks to see if a texture is used in the material.
  25684. * @param defines the list of "defines" to update.
  25685. * @param mesh the mesh we are preparing the defines for.
  25686. * @param scene defines the scene the material belongs to.
  25687. */
  25688. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25689. /**
  25690. * Binds the material data.
  25691. * @param uniformBuffer defines the Uniform buffer to fill in.
  25692. * @param scene defines the scene the material belongs to.
  25693. * @param isFrozen defines wether the material is frozen or not.
  25694. */
  25695. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25696. /**
  25697. * Checks to see if a texture is used in the material.
  25698. * @param texture - Base texture to use.
  25699. * @returns - Boolean specifying if a texture is used in the material.
  25700. */
  25701. hasTexture(texture: BaseTexture): boolean;
  25702. /**
  25703. * Returns an array of the actively used textures.
  25704. * @param activeTextures Array of BaseTextures
  25705. */
  25706. getActiveTextures(activeTextures: BaseTexture[]): void;
  25707. /**
  25708. * Returns the animatable textures.
  25709. * @param animatables Array of animatable textures.
  25710. */
  25711. getAnimatables(animatables: IAnimatable[]): void;
  25712. /**
  25713. * Disposes the resources of the material.
  25714. * @param forceDisposeTextures - Forces the disposal of all textures.
  25715. */
  25716. dispose(forceDisposeTextures?: boolean): void;
  25717. /**
  25718. * Get the current class name of the texture useful for serialization or dynamic coding.
  25719. * @returns "PBRAnisotropicConfiguration"
  25720. */
  25721. getClassName(): string;
  25722. /**
  25723. * Add fallbacks to the effect fallbacks list.
  25724. * @param defines defines the Base texture to use.
  25725. * @param fallbacks defines the current fallback list.
  25726. * @param currentRank defines the current fallback rank.
  25727. * @returns the new fallback rank.
  25728. */
  25729. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25730. /**
  25731. * Add the required uniforms to the current list.
  25732. * @param uniforms defines the current uniform list.
  25733. */
  25734. static AddUniforms(uniforms: string[]): void;
  25735. /**
  25736. * Add the required uniforms to the current buffer.
  25737. * @param uniformBuffer defines the current uniform buffer.
  25738. */
  25739. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25740. /**
  25741. * Add the required samplers to the current list.
  25742. * @param samplers defines the current sampler list.
  25743. */
  25744. static AddSamplers(samplers: string[]): void;
  25745. /**
  25746. * Makes a duplicate of the current configuration into another one.
  25747. * @param anisotropicConfiguration define the config where to copy the info
  25748. */
  25749. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25750. /**
  25751. * Serializes this anisotropy configuration.
  25752. * @returns - An object with the serialized config.
  25753. */
  25754. serialize(): any;
  25755. /**
  25756. * Parses a anisotropy Configuration from a serialized object.
  25757. * @param source - Serialized object.
  25758. * @param scene Defines the scene we are parsing for
  25759. * @param rootUrl Defines the rootUrl to load from
  25760. */
  25761. parse(source: any, scene: Scene, rootUrl: string): void;
  25762. }
  25763. }
  25764. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25765. import { Scene } from "babylonjs/scene";
  25766. /**
  25767. * @hidden
  25768. */
  25769. export interface IMaterialBRDFDefines {
  25770. BRDF_V_HEIGHT_CORRELATED: boolean;
  25771. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25772. SPHERICAL_HARMONICS: boolean;
  25773. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25774. /** @hidden */
  25775. _areMiscDirty: boolean;
  25776. }
  25777. /**
  25778. * Define the code related to the BRDF parameters of the pbr material.
  25779. */
  25780. export class PBRBRDFConfiguration {
  25781. /**
  25782. * Default value used for the energy conservation.
  25783. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25784. */
  25785. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25786. /**
  25787. * Default value used for the Smith Visibility Height Correlated mode.
  25788. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25789. */
  25790. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25791. /**
  25792. * Default value used for the IBL diffuse part.
  25793. * This can help switching back to the polynomials mode globally which is a tiny bit
  25794. * less GPU intensive at the drawback of a lower quality.
  25795. */
  25796. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25797. /**
  25798. * Default value used for activating energy conservation for the specular workflow.
  25799. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25800. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25801. */
  25802. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25803. private _useEnergyConservation;
  25804. /**
  25805. * Defines if the material uses energy conservation.
  25806. */
  25807. useEnergyConservation: boolean;
  25808. private _useSmithVisibilityHeightCorrelated;
  25809. /**
  25810. * LEGACY Mode set to false
  25811. * Defines if the material uses height smith correlated visibility term.
  25812. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25813. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25814. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25815. * Not relying on height correlated will also disable energy conservation.
  25816. */
  25817. useSmithVisibilityHeightCorrelated: boolean;
  25818. private _useSphericalHarmonics;
  25819. /**
  25820. * LEGACY Mode set to false
  25821. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25822. * diffuse part of the IBL.
  25823. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25824. * to the ground truth.
  25825. */
  25826. useSphericalHarmonics: boolean;
  25827. private _useSpecularGlossinessInputEnergyConservation;
  25828. /**
  25829. * Defines if the material uses energy conservation, when the specular workflow is active.
  25830. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25831. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25832. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25833. */
  25834. useSpecularGlossinessInputEnergyConservation: boolean;
  25835. /** @hidden */
  25836. private _internalMarkAllSubMeshesAsMiscDirty;
  25837. /** @hidden */
  25838. _markAllSubMeshesAsMiscDirty(): void;
  25839. /**
  25840. * Instantiate a new istance of clear coat configuration.
  25841. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25842. */
  25843. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25844. /**
  25845. * Checks to see if a texture is used in the material.
  25846. * @param defines the list of "defines" to update.
  25847. */
  25848. prepareDefines(defines: IMaterialBRDFDefines): void;
  25849. /**
  25850. * Get the current class name of the texture useful for serialization or dynamic coding.
  25851. * @returns "PBRClearCoatConfiguration"
  25852. */
  25853. getClassName(): string;
  25854. /**
  25855. * Makes a duplicate of the current configuration into another one.
  25856. * @param brdfConfiguration define the config where to copy the info
  25857. */
  25858. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25859. /**
  25860. * Serializes this BRDF configuration.
  25861. * @returns - An object with the serialized config.
  25862. */
  25863. serialize(): any;
  25864. /**
  25865. * Parses a anisotropy Configuration from a serialized object.
  25866. * @param source - Serialized object.
  25867. * @param scene Defines the scene we are parsing for
  25868. * @param rootUrl Defines the rootUrl to load from
  25869. */
  25870. parse(source: any, scene: Scene, rootUrl: string): void;
  25871. }
  25872. }
  25873. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25874. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25875. import { Color3 } from "babylonjs/Maths/math.color";
  25876. import { Scene } from "babylonjs/scene";
  25877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25878. import { Nullable } from "babylonjs/types";
  25879. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25880. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25881. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25882. /**
  25883. * @hidden
  25884. */
  25885. export interface IMaterialSheenDefines {
  25886. SHEEN: boolean;
  25887. SHEEN_TEXTURE: boolean;
  25888. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25889. SHEEN_TEXTUREDIRECTUV: number;
  25890. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25891. SHEEN_LINKWITHALBEDO: boolean;
  25892. SHEEN_ROUGHNESS: boolean;
  25893. SHEEN_ALBEDOSCALING: boolean;
  25894. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25895. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25896. /** @hidden */
  25897. _areTexturesDirty: boolean;
  25898. }
  25899. /**
  25900. * Define the code related to the Sheen parameters of the pbr material.
  25901. */
  25902. export class PBRSheenConfiguration {
  25903. private _isEnabled;
  25904. /**
  25905. * Defines if the material uses sheen.
  25906. */
  25907. isEnabled: boolean;
  25908. private _linkSheenWithAlbedo;
  25909. /**
  25910. * Defines if the sheen is linked to the sheen color.
  25911. */
  25912. linkSheenWithAlbedo: boolean;
  25913. /**
  25914. * Defines the sheen intensity.
  25915. */
  25916. intensity: number;
  25917. /**
  25918. * Defines the sheen color.
  25919. */
  25920. color: Color3;
  25921. private _texture;
  25922. /**
  25923. * Stores the sheen tint values in a texture.
  25924. * rgb is tint
  25925. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25926. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25927. */
  25928. texture: Nullable<BaseTexture>;
  25929. private _useRoughnessFromMainTexture;
  25930. /**
  25931. * Indicates that the alpha channel of the texture property will be used for roughness.
  25932. * Has no effect if the roughness (and texture!) property is not defined
  25933. */
  25934. useRoughnessFromMainTexture: boolean;
  25935. private _roughness;
  25936. /**
  25937. * Defines the sheen roughness.
  25938. * It is not taken into account if linkSheenWithAlbedo is true.
  25939. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25940. */
  25941. roughness: Nullable<number>;
  25942. private _textureRoughness;
  25943. /**
  25944. * Stores the sheen roughness in a texture.
  25945. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25946. */
  25947. textureRoughness: Nullable<BaseTexture>;
  25948. private _albedoScaling;
  25949. /**
  25950. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25951. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25952. * making it easier to setup and tweak the effect
  25953. */
  25954. albedoScaling: boolean;
  25955. /** @hidden */
  25956. private _internalMarkAllSubMeshesAsTexturesDirty;
  25957. /** @hidden */
  25958. _markAllSubMeshesAsTexturesDirty(): void;
  25959. /**
  25960. * Instantiate a new istance of clear coat configuration.
  25961. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25962. */
  25963. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25964. /**
  25965. * Specifies that the submesh is ready to be used.
  25966. * @param defines the list of "defines" to update.
  25967. * @param scene defines the scene the material belongs to.
  25968. * @returns - boolean indicating that the submesh is ready or not.
  25969. */
  25970. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25971. /**
  25972. * Checks to see if a texture is used in the material.
  25973. * @param defines the list of "defines" to update.
  25974. * @param scene defines the scene the material belongs to.
  25975. */
  25976. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25977. /**
  25978. * Binds the material data.
  25979. * @param uniformBuffer defines the Uniform buffer to fill in.
  25980. * @param scene defines the scene the material belongs to.
  25981. * @param isFrozen defines wether the material is frozen or not.
  25982. * @param subMesh the submesh to bind data for
  25983. */
  25984. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25985. /**
  25986. * Checks to see if a texture is used in the material.
  25987. * @param texture - Base texture to use.
  25988. * @returns - Boolean specifying if a texture is used in the material.
  25989. */
  25990. hasTexture(texture: BaseTexture): boolean;
  25991. /**
  25992. * Returns an array of the actively used textures.
  25993. * @param activeTextures Array of BaseTextures
  25994. */
  25995. getActiveTextures(activeTextures: BaseTexture[]): void;
  25996. /**
  25997. * Returns the animatable textures.
  25998. * @param animatables Array of animatable textures.
  25999. */
  26000. getAnimatables(animatables: IAnimatable[]): void;
  26001. /**
  26002. * Disposes the resources of the material.
  26003. * @param forceDisposeTextures - Forces the disposal of all textures.
  26004. */
  26005. dispose(forceDisposeTextures?: boolean): void;
  26006. /**
  26007. * Get the current class name of the texture useful for serialization or dynamic coding.
  26008. * @returns "PBRSheenConfiguration"
  26009. */
  26010. getClassName(): string;
  26011. /**
  26012. * Add fallbacks to the effect fallbacks list.
  26013. * @param defines defines the Base texture to use.
  26014. * @param fallbacks defines the current fallback list.
  26015. * @param currentRank defines the current fallback rank.
  26016. * @returns the new fallback rank.
  26017. */
  26018. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26019. /**
  26020. * Add the required uniforms to the current list.
  26021. * @param uniforms defines the current uniform list.
  26022. */
  26023. static AddUniforms(uniforms: string[]): void;
  26024. /**
  26025. * Add the required uniforms to the current buffer.
  26026. * @param uniformBuffer defines the current uniform buffer.
  26027. */
  26028. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26029. /**
  26030. * Add the required samplers to the current list.
  26031. * @param samplers defines the current sampler list.
  26032. */
  26033. static AddSamplers(samplers: string[]): void;
  26034. /**
  26035. * Makes a duplicate of the current configuration into another one.
  26036. * @param sheenConfiguration define the config where to copy the info
  26037. */
  26038. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26039. /**
  26040. * Serializes this BRDF configuration.
  26041. * @returns - An object with the serialized config.
  26042. */
  26043. serialize(): any;
  26044. /**
  26045. * Parses a anisotropy Configuration from a serialized object.
  26046. * @param source - Serialized object.
  26047. * @param scene Defines the scene we are parsing for
  26048. * @param rootUrl Defines the rootUrl to load from
  26049. */
  26050. parse(source: any, scene: Scene, rootUrl: string): void;
  26051. }
  26052. }
  26053. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26054. import { Nullable } from "babylonjs/types";
  26055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26056. import { Color3 } from "babylonjs/Maths/math.color";
  26057. import { SmartArray } from "babylonjs/Misc/smartArray";
  26058. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26060. import { Effect } from "babylonjs/Materials/effect";
  26061. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26062. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26063. import { Engine } from "babylonjs/Engines/engine";
  26064. import { Scene } from "babylonjs/scene";
  26065. /**
  26066. * @hidden
  26067. */
  26068. export interface IMaterialSubSurfaceDefines {
  26069. SUBSURFACE: boolean;
  26070. SS_REFRACTION: boolean;
  26071. SS_TRANSLUCENCY: boolean;
  26072. SS_SCATTERING: boolean;
  26073. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26074. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26075. SS_REFRACTIONMAP_3D: boolean;
  26076. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26077. SS_LODINREFRACTIONALPHA: boolean;
  26078. SS_GAMMAREFRACTION: boolean;
  26079. SS_RGBDREFRACTION: boolean;
  26080. SS_LINEARSPECULARREFRACTION: boolean;
  26081. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26082. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26083. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26084. /** @hidden */
  26085. _areTexturesDirty: boolean;
  26086. }
  26087. /**
  26088. * Define the code related to the sub surface parameters of the pbr material.
  26089. */
  26090. export class PBRSubSurfaceConfiguration {
  26091. private _isRefractionEnabled;
  26092. /**
  26093. * Defines if the refraction is enabled in the material.
  26094. */
  26095. isRefractionEnabled: boolean;
  26096. private _isTranslucencyEnabled;
  26097. /**
  26098. * Defines if the translucency is enabled in the material.
  26099. */
  26100. isTranslucencyEnabled: boolean;
  26101. private _isScatteringEnabled;
  26102. /**
  26103. * Defines if the sub surface scattering is enabled in the material.
  26104. */
  26105. isScatteringEnabled: boolean;
  26106. private _scatteringDiffusionProfileIndex;
  26107. /**
  26108. * Diffusion profile for subsurface scattering.
  26109. * Useful for better scattering in the skins or foliages.
  26110. */
  26111. get scatteringDiffusionProfile(): Nullable<Color3>;
  26112. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26113. /**
  26114. * Defines the refraction intensity of the material.
  26115. * The refraction when enabled replaces the Diffuse part of the material.
  26116. * The intensity helps transitionning between diffuse and refraction.
  26117. */
  26118. refractionIntensity: number;
  26119. /**
  26120. * Defines the translucency intensity of the material.
  26121. * When translucency has been enabled, this defines how much of the "translucency"
  26122. * is addded to the diffuse part of the material.
  26123. */
  26124. translucencyIntensity: number;
  26125. /**
  26126. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26127. */
  26128. useAlbedoToTintRefraction: boolean;
  26129. private _thicknessTexture;
  26130. /**
  26131. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26132. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26133. * 0 would mean minimumThickness
  26134. * 1 would mean maximumThickness
  26135. * The other channels might be use as a mask to vary the different effects intensity.
  26136. */
  26137. thicknessTexture: Nullable<BaseTexture>;
  26138. private _refractionTexture;
  26139. /**
  26140. * Defines the texture to use for refraction.
  26141. */
  26142. refractionTexture: Nullable<BaseTexture>;
  26143. private _indexOfRefraction;
  26144. /**
  26145. * Index of refraction of the material base layer.
  26146. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26147. *
  26148. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26149. *
  26150. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26151. */
  26152. indexOfRefraction: number;
  26153. private _volumeIndexOfRefraction;
  26154. /**
  26155. * Index of refraction of the material's volume.
  26156. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26157. *
  26158. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26159. * the volume will use the same IOR as the surface.
  26160. */
  26161. get volumeIndexOfRefraction(): number;
  26162. set volumeIndexOfRefraction(value: number);
  26163. private _invertRefractionY;
  26164. /**
  26165. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26166. */
  26167. invertRefractionY: boolean;
  26168. private _linkRefractionWithTransparency;
  26169. /**
  26170. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26171. * Materials half opaque for instance using refraction could benefit from this control.
  26172. */
  26173. linkRefractionWithTransparency: boolean;
  26174. /**
  26175. * Defines the minimum thickness stored in the thickness map.
  26176. * If no thickness map is defined, this value will be used to simulate thickness.
  26177. */
  26178. minimumThickness: number;
  26179. /**
  26180. * Defines the maximum thickness stored in the thickness map.
  26181. */
  26182. maximumThickness: number;
  26183. /**
  26184. * Defines the volume tint of the material.
  26185. * This is used for both translucency and scattering.
  26186. */
  26187. tintColor: Color3;
  26188. /**
  26189. * Defines the distance at which the tint color should be found in the media.
  26190. * This is used for refraction only.
  26191. */
  26192. tintColorAtDistance: number;
  26193. /**
  26194. * Defines how far each channel transmit through the media.
  26195. * It is defined as a color to simplify it selection.
  26196. */
  26197. diffusionDistance: Color3;
  26198. private _useMaskFromThicknessTexture;
  26199. /**
  26200. * Stores the intensity of the different subsurface effects in the thickness texture.
  26201. * * the green channel is the translucency intensity.
  26202. * * the blue channel is the scattering intensity.
  26203. * * the alpha channel is the refraction intensity.
  26204. */
  26205. useMaskFromThicknessTexture: boolean;
  26206. private _scene;
  26207. /** @hidden */
  26208. private _internalMarkAllSubMeshesAsTexturesDirty;
  26209. private _internalMarkScenePrePassDirty;
  26210. /** @hidden */
  26211. _markAllSubMeshesAsTexturesDirty(): void;
  26212. /** @hidden */
  26213. _markScenePrePassDirty(): void;
  26214. /**
  26215. * Instantiate a new istance of sub surface configuration.
  26216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26217. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26218. * @param scene The scene
  26219. */
  26220. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26221. /**
  26222. * Gets wehter the submesh is ready to be used or not.
  26223. * @param defines the list of "defines" to update.
  26224. * @param scene defines the scene the material belongs to.
  26225. * @returns - boolean indicating that the submesh is ready or not.
  26226. */
  26227. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26228. /**
  26229. * Checks to see if a texture is used in the material.
  26230. * @param defines the list of "defines" to update.
  26231. * @param scene defines the scene to the material belongs to.
  26232. */
  26233. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26234. /**
  26235. * Binds the material data.
  26236. * @param uniformBuffer defines the Uniform buffer to fill in.
  26237. * @param scene defines the scene the material belongs to.
  26238. * @param engine defines the engine the material belongs to.
  26239. * @param isFrozen defines whether the material is frozen or not.
  26240. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26241. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26242. */
  26243. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26244. /**
  26245. * Unbinds the material from the mesh.
  26246. * @param activeEffect defines the effect that should be unbound from.
  26247. * @returns true if unbound, otherwise false
  26248. */
  26249. unbind(activeEffect: Effect): boolean;
  26250. /**
  26251. * Returns the texture used for refraction or null if none is used.
  26252. * @param scene defines the scene the material belongs to.
  26253. * @returns - Refraction texture if present. If no refraction texture and refraction
  26254. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26255. */
  26256. private _getRefractionTexture;
  26257. /**
  26258. * Returns true if alpha blending should be disabled.
  26259. */
  26260. get disableAlphaBlending(): boolean;
  26261. /**
  26262. * Fills the list of render target textures.
  26263. * @param renderTargets the list of render targets to update
  26264. */
  26265. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26266. /**
  26267. * Checks to see if a texture is used in the material.
  26268. * @param texture - Base texture to use.
  26269. * @returns - Boolean specifying if a texture is used in the material.
  26270. */
  26271. hasTexture(texture: BaseTexture): boolean;
  26272. /**
  26273. * Gets a boolean indicating that current material needs to register RTT
  26274. * @returns true if this uses a render target otherwise false.
  26275. */
  26276. hasRenderTargetTextures(): boolean;
  26277. /**
  26278. * Returns an array of the actively used textures.
  26279. * @param activeTextures Array of BaseTextures
  26280. */
  26281. getActiveTextures(activeTextures: BaseTexture[]): void;
  26282. /**
  26283. * Returns the animatable textures.
  26284. * @param animatables Array of animatable textures.
  26285. */
  26286. getAnimatables(animatables: IAnimatable[]): void;
  26287. /**
  26288. * Disposes the resources of the material.
  26289. * @param forceDisposeTextures - Forces the disposal of all textures.
  26290. */
  26291. dispose(forceDisposeTextures?: boolean): void;
  26292. /**
  26293. * Get the current class name of the texture useful for serialization or dynamic coding.
  26294. * @returns "PBRSubSurfaceConfiguration"
  26295. */
  26296. getClassName(): string;
  26297. /**
  26298. * Add fallbacks to the effect fallbacks list.
  26299. * @param defines defines the Base texture to use.
  26300. * @param fallbacks defines the current fallback list.
  26301. * @param currentRank defines the current fallback rank.
  26302. * @returns the new fallback rank.
  26303. */
  26304. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26305. /**
  26306. * Add the required uniforms to the current list.
  26307. * @param uniforms defines the current uniform list.
  26308. */
  26309. static AddUniforms(uniforms: string[]): void;
  26310. /**
  26311. * Add the required samplers to the current list.
  26312. * @param samplers defines the current sampler list.
  26313. */
  26314. static AddSamplers(samplers: string[]): void;
  26315. /**
  26316. * Add the required uniforms to the current buffer.
  26317. * @param uniformBuffer defines the current uniform buffer.
  26318. */
  26319. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26320. /**
  26321. * Makes a duplicate of the current configuration into another one.
  26322. * @param configuration define the config where to copy the info
  26323. */
  26324. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26325. /**
  26326. * Serializes this Sub Surface configuration.
  26327. * @returns - An object with the serialized config.
  26328. */
  26329. serialize(): any;
  26330. /**
  26331. * Parses a anisotropy Configuration from a serialized object.
  26332. * @param source - Serialized object.
  26333. * @param scene Defines the scene we are parsing for
  26334. * @param rootUrl Defines the rootUrl to load from
  26335. */
  26336. parse(source: any, scene: Scene, rootUrl: string): void;
  26337. }
  26338. }
  26339. declare module "babylonjs/Maths/sphericalPolynomial" {
  26340. import { Vector3 } from "babylonjs/Maths/math.vector";
  26341. import { Color3 } from "babylonjs/Maths/math.color";
  26342. /**
  26343. * Class representing spherical harmonics coefficients to the 3rd degree
  26344. */
  26345. export class SphericalHarmonics {
  26346. /**
  26347. * Defines whether or not the harmonics have been prescaled for rendering.
  26348. */
  26349. preScaled: boolean;
  26350. /**
  26351. * The l0,0 coefficients of the spherical harmonics
  26352. */
  26353. l00: Vector3;
  26354. /**
  26355. * The l1,-1 coefficients of the spherical harmonics
  26356. */
  26357. l1_1: Vector3;
  26358. /**
  26359. * The l1,0 coefficients of the spherical harmonics
  26360. */
  26361. l10: Vector3;
  26362. /**
  26363. * The l1,1 coefficients of the spherical harmonics
  26364. */
  26365. l11: Vector3;
  26366. /**
  26367. * The l2,-2 coefficients of the spherical harmonics
  26368. */
  26369. l2_2: Vector3;
  26370. /**
  26371. * The l2,-1 coefficients of the spherical harmonics
  26372. */
  26373. l2_1: Vector3;
  26374. /**
  26375. * The l2,0 coefficients of the spherical harmonics
  26376. */
  26377. l20: Vector3;
  26378. /**
  26379. * The l2,1 coefficients of the spherical harmonics
  26380. */
  26381. l21: Vector3;
  26382. /**
  26383. * The l2,2 coefficients of the spherical harmonics
  26384. */
  26385. l22: Vector3;
  26386. /**
  26387. * Adds a light to the spherical harmonics
  26388. * @param direction the direction of the light
  26389. * @param color the color of the light
  26390. * @param deltaSolidAngle the delta solid angle of the light
  26391. */
  26392. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26393. /**
  26394. * Scales the spherical harmonics by the given amount
  26395. * @param scale the amount to scale
  26396. */
  26397. scaleInPlace(scale: number): void;
  26398. /**
  26399. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26400. *
  26401. * ```
  26402. * E_lm = A_l * L_lm
  26403. * ```
  26404. *
  26405. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26406. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26407. * the scaling factors are given in equation 9.
  26408. */
  26409. convertIncidentRadianceToIrradiance(): void;
  26410. /**
  26411. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26412. *
  26413. * ```
  26414. * L = (1/pi) * E * rho
  26415. * ```
  26416. *
  26417. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26418. */
  26419. convertIrradianceToLambertianRadiance(): void;
  26420. /**
  26421. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26422. * required operations at run time.
  26423. *
  26424. * This is simply done by scaling back the SH with Ylm constants parameter.
  26425. * The trigonometric part being applied by the shader at run time.
  26426. */
  26427. preScaleForRendering(): void;
  26428. /**
  26429. * Constructs a spherical harmonics from an array.
  26430. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26431. * @returns the spherical harmonics
  26432. */
  26433. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26434. /**
  26435. * Gets the spherical harmonics from polynomial
  26436. * @param polynomial the spherical polynomial
  26437. * @returns the spherical harmonics
  26438. */
  26439. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26440. }
  26441. /**
  26442. * Class representing spherical polynomial coefficients to the 3rd degree
  26443. */
  26444. export class SphericalPolynomial {
  26445. private _harmonics;
  26446. /**
  26447. * The spherical harmonics used to create the polynomials.
  26448. */
  26449. get preScaledHarmonics(): SphericalHarmonics;
  26450. /**
  26451. * The x coefficients of the spherical polynomial
  26452. */
  26453. x: Vector3;
  26454. /**
  26455. * The y coefficients of the spherical polynomial
  26456. */
  26457. y: Vector3;
  26458. /**
  26459. * The z coefficients of the spherical polynomial
  26460. */
  26461. z: Vector3;
  26462. /**
  26463. * The xx coefficients of the spherical polynomial
  26464. */
  26465. xx: Vector3;
  26466. /**
  26467. * The yy coefficients of the spherical polynomial
  26468. */
  26469. yy: Vector3;
  26470. /**
  26471. * The zz coefficients of the spherical polynomial
  26472. */
  26473. zz: Vector3;
  26474. /**
  26475. * The xy coefficients of the spherical polynomial
  26476. */
  26477. xy: Vector3;
  26478. /**
  26479. * The yz coefficients of the spherical polynomial
  26480. */
  26481. yz: Vector3;
  26482. /**
  26483. * The zx coefficients of the spherical polynomial
  26484. */
  26485. zx: Vector3;
  26486. /**
  26487. * Adds an ambient color to the spherical polynomial
  26488. * @param color the color to add
  26489. */
  26490. addAmbient(color: Color3): void;
  26491. /**
  26492. * Scales the spherical polynomial by the given amount
  26493. * @param scale the amount to scale
  26494. */
  26495. scaleInPlace(scale: number): void;
  26496. /**
  26497. * Gets the spherical polynomial from harmonics
  26498. * @param harmonics the spherical harmonics
  26499. * @returns the spherical polynomial
  26500. */
  26501. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26502. /**
  26503. * Constructs a spherical polynomial from an array.
  26504. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26505. * @returns the spherical polynomial
  26506. */
  26507. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26508. }
  26509. }
  26510. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26511. import { Nullable } from "babylonjs/types";
  26512. /**
  26513. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26514. */
  26515. export interface CubeMapInfo {
  26516. /**
  26517. * The pixel array for the front face.
  26518. * This is stored in format, left to right, up to down format.
  26519. */
  26520. front: Nullable<ArrayBufferView>;
  26521. /**
  26522. * The pixel array for the back face.
  26523. * This is stored in format, left to right, up to down format.
  26524. */
  26525. back: Nullable<ArrayBufferView>;
  26526. /**
  26527. * The pixel array for the left face.
  26528. * This is stored in format, left to right, up to down format.
  26529. */
  26530. left: Nullable<ArrayBufferView>;
  26531. /**
  26532. * The pixel array for the right face.
  26533. * This is stored in format, left to right, up to down format.
  26534. */
  26535. right: Nullable<ArrayBufferView>;
  26536. /**
  26537. * The pixel array for the up face.
  26538. * This is stored in format, left to right, up to down format.
  26539. */
  26540. up: Nullable<ArrayBufferView>;
  26541. /**
  26542. * The pixel array for the down face.
  26543. * This is stored in format, left to right, up to down format.
  26544. */
  26545. down: Nullable<ArrayBufferView>;
  26546. /**
  26547. * The size of the cubemap stored.
  26548. *
  26549. * Each faces will be size * size pixels.
  26550. */
  26551. size: number;
  26552. /**
  26553. * The format of the texture.
  26554. *
  26555. * RGBA, RGB.
  26556. */
  26557. format: number;
  26558. /**
  26559. * The type of the texture data.
  26560. *
  26561. * UNSIGNED_INT, FLOAT.
  26562. */
  26563. type: number;
  26564. /**
  26565. * Specifies whether the texture is in gamma space.
  26566. */
  26567. gammaSpace: boolean;
  26568. }
  26569. /**
  26570. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26571. */
  26572. export class PanoramaToCubeMapTools {
  26573. private static FACE_LEFT;
  26574. private static FACE_RIGHT;
  26575. private static FACE_FRONT;
  26576. private static FACE_BACK;
  26577. private static FACE_DOWN;
  26578. private static FACE_UP;
  26579. /**
  26580. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26581. *
  26582. * @param float32Array The source data.
  26583. * @param inputWidth The width of the input panorama.
  26584. * @param inputHeight The height of the input panorama.
  26585. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26586. * @return The cubemap data
  26587. */
  26588. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26589. private static CreateCubemapTexture;
  26590. private static CalcProjectionSpherical;
  26591. }
  26592. }
  26593. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26594. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26596. import { Nullable } from "babylonjs/types";
  26597. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26598. /**
  26599. * Helper class dealing with the extraction of spherical polynomial dataArray
  26600. * from a cube map.
  26601. */
  26602. export class CubeMapToSphericalPolynomialTools {
  26603. private static FileFaces;
  26604. /**
  26605. * Converts a texture to the according Spherical Polynomial data.
  26606. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26607. *
  26608. * @param texture The texture to extract the information from.
  26609. * @return The Spherical Polynomial data.
  26610. */
  26611. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26612. /**
  26613. * Converts a cubemap to the according Spherical Polynomial data.
  26614. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26615. *
  26616. * @param cubeInfo The Cube map to extract the information from.
  26617. * @return The Spherical Polynomial data.
  26618. */
  26619. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26620. }
  26621. }
  26622. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26623. import { Nullable } from "babylonjs/types";
  26624. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26625. module "babylonjs/Materials/Textures/baseTexture" {
  26626. interface BaseTexture {
  26627. /**
  26628. * Get the polynomial representation of the texture data.
  26629. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26630. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26631. */
  26632. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26633. }
  26634. }
  26635. }
  26636. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26637. /** @hidden */
  26638. export var pbrFragmentDeclaration: {
  26639. name: string;
  26640. shader: string;
  26641. };
  26642. }
  26643. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26644. /** @hidden */
  26645. export var pbrUboDeclaration: {
  26646. name: string;
  26647. shader: string;
  26648. };
  26649. }
  26650. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26651. /** @hidden */
  26652. export var pbrFragmentExtraDeclaration: {
  26653. name: string;
  26654. shader: string;
  26655. };
  26656. }
  26657. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26658. /** @hidden */
  26659. export var pbrFragmentSamplersDeclaration: {
  26660. name: string;
  26661. shader: string;
  26662. };
  26663. }
  26664. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26665. /** @hidden */
  26666. export var subSurfaceScatteringFunctions: {
  26667. name: string;
  26668. shader: string;
  26669. };
  26670. }
  26671. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26672. /** @hidden */
  26673. export var importanceSampling: {
  26674. name: string;
  26675. shader: string;
  26676. };
  26677. }
  26678. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26679. /** @hidden */
  26680. export var pbrHelperFunctions: {
  26681. name: string;
  26682. shader: string;
  26683. };
  26684. }
  26685. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26686. /** @hidden */
  26687. export var harmonicsFunctions: {
  26688. name: string;
  26689. shader: string;
  26690. };
  26691. }
  26692. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26693. /** @hidden */
  26694. export var pbrDirectLightingSetupFunctions: {
  26695. name: string;
  26696. shader: string;
  26697. };
  26698. }
  26699. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26700. /** @hidden */
  26701. export var pbrDirectLightingFalloffFunctions: {
  26702. name: string;
  26703. shader: string;
  26704. };
  26705. }
  26706. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26707. /** @hidden */
  26708. export var pbrBRDFFunctions: {
  26709. name: string;
  26710. shader: string;
  26711. };
  26712. }
  26713. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26714. /** @hidden */
  26715. export var hdrFilteringFunctions: {
  26716. name: string;
  26717. shader: string;
  26718. };
  26719. }
  26720. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26721. /** @hidden */
  26722. export var pbrDirectLightingFunctions: {
  26723. name: string;
  26724. shader: string;
  26725. };
  26726. }
  26727. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26728. /** @hidden */
  26729. export var pbrIBLFunctions: {
  26730. name: string;
  26731. shader: string;
  26732. };
  26733. }
  26734. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26735. /** @hidden */
  26736. export var pbrBlockAlbedoOpacity: {
  26737. name: string;
  26738. shader: string;
  26739. };
  26740. }
  26741. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26742. /** @hidden */
  26743. export var pbrBlockReflectivity: {
  26744. name: string;
  26745. shader: string;
  26746. };
  26747. }
  26748. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26749. /** @hidden */
  26750. export var pbrBlockAmbientOcclusion: {
  26751. name: string;
  26752. shader: string;
  26753. };
  26754. }
  26755. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26756. /** @hidden */
  26757. export var pbrBlockAlphaFresnel: {
  26758. name: string;
  26759. shader: string;
  26760. };
  26761. }
  26762. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26763. /** @hidden */
  26764. export var pbrBlockAnisotropic: {
  26765. name: string;
  26766. shader: string;
  26767. };
  26768. }
  26769. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26770. /** @hidden */
  26771. export var pbrBlockReflection: {
  26772. name: string;
  26773. shader: string;
  26774. };
  26775. }
  26776. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26777. /** @hidden */
  26778. export var pbrBlockSheen: {
  26779. name: string;
  26780. shader: string;
  26781. };
  26782. }
  26783. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26784. /** @hidden */
  26785. export var pbrBlockClearcoat: {
  26786. name: string;
  26787. shader: string;
  26788. };
  26789. }
  26790. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26791. /** @hidden */
  26792. export var pbrBlockSubSurface: {
  26793. name: string;
  26794. shader: string;
  26795. };
  26796. }
  26797. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26798. /** @hidden */
  26799. export var pbrBlockNormalGeometric: {
  26800. name: string;
  26801. shader: string;
  26802. };
  26803. }
  26804. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26805. /** @hidden */
  26806. export var pbrBlockNormalFinal: {
  26807. name: string;
  26808. shader: string;
  26809. };
  26810. }
  26811. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26812. /** @hidden */
  26813. export var pbrBlockLightmapInit: {
  26814. name: string;
  26815. shader: string;
  26816. };
  26817. }
  26818. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26819. /** @hidden */
  26820. export var pbrBlockGeometryInfo: {
  26821. name: string;
  26822. shader: string;
  26823. };
  26824. }
  26825. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26826. /** @hidden */
  26827. export var pbrBlockReflectance0: {
  26828. name: string;
  26829. shader: string;
  26830. };
  26831. }
  26832. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26833. /** @hidden */
  26834. export var pbrBlockReflectance: {
  26835. name: string;
  26836. shader: string;
  26837. };
  26838. }
  26839. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26840. /** @hidden */
  26841. export var pbrBlockDirectLighting: {
  26842. name: string;
  26843. shader: string;
  26844. };
  26845. }
  26846. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26847. /** @hidden */
  26848. export var pbrBlockFinalLitComponents: {
  26849. name: string;
  26850. shader: string;
  26851. };
  26852. }
  26853. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26854. /** @hidden */
  26855. export var pbrBlockFinalUnlitComponents: {
  26856. name: string;
  26857. shader: string;
  26858. };
  26859. }
  26860. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26861. /** @hidden */
  26862. export var pbrBlockFinalColorComposition: {
  26863. name: string;
  26864. shader: string;
  26865. };
  26866. }
  26867. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26868. /** @hidden */
  26869. export var pbrBlockImageProcessing: {
  26870. name: string;
  26871. shader: string;
  26872. };
  26873. }
  26874. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26875. /** @hidden */
  26876. export var pbrDebug: {
  26877. name: string;
  26878. shader: string;
  26879. };
  26880. }
  26881. declare module "babylonjs/Shaders/pbr.fragment" {
  26882. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26883. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26884. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26885. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26886. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26887. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26888. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26889. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26890. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26891. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26892. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26893. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26894. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26895. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26896. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26897. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26898. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26899. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26900. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26901. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26902. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26903. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26904. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26905. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26906. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26907. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26908. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26909. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26910. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26911. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26912. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26913. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26914. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26915. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26916. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26917. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26918. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26919. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26920. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26921. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26922. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26923. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26924. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26925. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26926. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26927. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26928. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26929. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26930. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26931. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26932. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26933. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26934. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26935. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26936. /** @hidden */
  26937. export var pbrPixelShader: {
  26938. name: string;
  26939. shader: string;
  26940. };
  26941. }
  26942. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26943. /** @hidden */
  26944. export var pbrVertexDeclaration: {
  26945. name: string;
  26946. shader: string;
  26947. };
  26948. }
  26949. declare module "babylonjs/Shaders/pbr.vertex" {
  26950. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26951. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26952. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26953. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26954. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26955. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26956. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26957. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26958. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26959. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26960. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26961. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26962. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26964. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26965. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26966. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26967. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26968. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26969. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26970. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26971. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26972. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26973. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26974. /** @hidden */
  26975. export var pbrVertexShader: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26981. import { Nullable } from "babylonjs/types";
  26982. import { Scene } from "babylonjs/scene";
  26983. import { Matrix } from "babylonjs/Maths/math.vector";
  26984. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26986. import { Mesh } from "babylonjs/Meshes/mesh";
  26987. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26988. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26989. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26990. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26991. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26992. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26993. import { Color3 } from "babylonjs/Maths/math.color";
  26994. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26995. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26996. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26997. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26999. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27000. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  27001. import "babylonjs/Shaders/pbr.fragment";
  27002. import "babylonjs/Shaders/pbr.vertex";
  27003. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  27004. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27005. /**
  27006. * Manages the defines for the PBR Material.
  27007. * @hidden
  27008. */
  27009. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27010. PBR: boolean;
  27011. NUM_SAMPLES: string;
  27012. REALTIME_FILTERING: boolean;
  27013. MAINUV1: boolean;
  27014. MAINUV2: boolean;
  27015. UV1: boolean;
  27016. UV2: boolean;
  27017. ALBEDO: boolean;
  27018. GAMMAALBEDO: boolean;
  27019. ALBEDODIRECTUV: number;
  27020. VERTEXCOLOR: boolean;
  27021. DETAIL: boolean;
  27022. DETAILDIRECTUV: number;
  27023. DETAIL_NORMALBLENDMETHOD: number;
  27024. AMBIENT: boolean;
  27025. AMBIENTDIRECTUV: number;
  27026. AMBIENTINGRAYSCALE: boolean;
  27027. OPACITY: boolean;
  27028. VERTEXALPHA: boolean;
  27029. OPACITYDIRECTUV: number;
  27030. OPACITYRGB: boolean;
  27031. ALPHATEST: boolean;
  27032. DEPTHPREPASS: boolean;
  27033. ALPHABLEND: boolean;
  27034. ALPHAFROMALBEDO: boolean;
  27035. ALPHATESTVALUE: string;
  27036. SPECULAROVERALPHA: boolean;
  27037. RADIANCEOVERALPHA: boolean;
  27038. ALPHAFRESNEL: boolean;
  27039. LINEARALPHAFRESNEL: boolean;
  27040. PREMULTIPLYALPHA: boolean;
  27041. EMISSIVE: boolean;
  27042. EMISSIVEDIRECTUV: number;
  27043. REFLECTIVITY: boolean;
  27044. REFLECTIVITYDIRECTUV: number;
  27045. SPECULARTERM: boolean;
  27046. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27047. MICROSURFACEAUTOMATIC: boolean;
  27048. LODBASEDMICROSFURACE: boolean;
  27049. MICROSURFACEMAP: boolean;
  27050. MICROSURFACEMAPDIRECTUV: number;
  27051. METALLICWORKFLOW: boolean;
  27052. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27053. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27054. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27055. AOSTOREINMETALMAPRED: boolean;
  27056. METALLIC_REFLECTANCE: boolean;
  27057. METALLIC_REFLECTANCEDIRECTUV: number;
  27058. ENVIRONMENTBRDF: boolean;
  27059. ENVIRONMENTBRDF_RGBD: boolean;
  27060. NORMAL: boolean;
  27061. TANGENT: boolean;
  27062. BUMP: boolean;
  27063. BUMPDIRECTUV: number;
  27064. OBJECTSPACE_NORMALMAP: boolean;
  27065. PARALLAX: boolean;
  27066. PARALLAXOCCLUSION: boolean;
  27067. NORMALXYSCALE: boolean;
  27068. LIGHTMAP: boolean;
  27069. LIGHTMAPDIRECTUV: number;
  27070. USELIGHTMAPASSHADOWMAP: boolean;
  27071. GAMMALIGHTMAP: boolean;
  27072. RGBDLIGHTMAP: boolean;
  27073. REFLECTION: boolean;
  27074. REFLECTIONMAP_3D: boolean;
  27075. REFLECTIONMAP_SPHERICAL: boolean;
  27076. REFLECTIONMAP_PLANAR: boolean;
  27077. REFLECTIONMAP_CUBIC: boolean;
  27078. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27079. REFLECTIONMAP_PROJECTION: boolean;
  27080. REFLECTIONMAP_SKYBOX: boolean;
  27081. REFLECTIONMAP_EXPLICIT: boolean;
  27082. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27083. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27084. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27085. INVERTCUBICMAP: boolean;
  27086. USESPHERICALFROMREFLECTIONMAP: boolean;
  27087. USEIRRADIANCEMAP: boolean;
  27088. SPHERICAL_HARMONICS: boolean;
  27089. USESPHERICALINVERTEX: boolean;
  27090. REFLECTIONMAP_OPPOSITEZ: boolean;
  27091. LODINREFLECTIONALPHA: boolean;
  27092. GAMMAREFLECTION: boolean;
  27093. RGBDREFLECTION: boolean;
  27094. LINEARSPECULARREFLECTION: boolean;
  27095. RADIANCEOCCLUSION: boolean;
  27096. HORIZONOCCLUSION: boolean;
  27097. INSTANCES: boolean;
  27098. THIN_INSTANCES: boolean;
  27099. PREPASS: boolean;
  27100. PREPASS_IRRADIANCE: boolean;
  27101. PREPASS_IRRADIANCE_INDEX: number;
  27102. PREPASS_ALBEDO: boolean;
  27103. PREPASS_ALBEDO_INDEX: number;
  27104. PREPASS_DEPTHNORMAL: boolean;
  27105. PREPASS_DEPTHNORMAL_INDEX: number;
  27106. PREPASS_POSITION: boolean;
  27107. PREPASS_POSITION_INDEX: number;
  27108. PREPASS_VELOCITY: boolean;
  27109. PREPASS_VELOCITY_INDEX: number;
  27110. PREPASS_REFLECTIVITY: boolean;
  27111. PREPASS_REFLECTIVITY_INDEX: number;
  27112. SCENE_MRT_COUNT: number;
  27113. NUM_BONE_INFLUENCERS: number;
  27114. BonesPerMesh: number;
  27115. BONETEXTURE: boolean;
  27116. BONES_VELOCITY_ENABLED: boolean;
  27117. NONUNIFORMSCALING: boolean;
  27118. MORPHTARGETS: boolean;
  27119. MORPHTARGETS_NORMAL: boolean;
  27120. MORPHTARGETS_TANGENT: boolean;
  27121. MORPHTARGETS_UV: boolean;
  27122. NUM_MORPH_INFLUENCERS: number;
  27123. IMAGEPROCESSING: boolean;
  27124. VIGNETTE: boolean;
  27125. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27126. VIGNETTEBLENDMODEOPAQUE: boolean;
  27127. TONEMAPPING: boolean;
  27128. TONEMAPPING_ACES: boolean;
  27129. CONTRAST: boolean;
  27130. COLORCURVES: boolean;
  27131. COLORGRADING: boolean;
  27132. COLORGRADING3D: boolean;
  27133. SAMPLER3DGREENDEPTH: boolean;
  27134. SAMPLER3DBGRMAP: boolean;
  27135. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27136. EXPOSURE: boolean;
  27137. MULTIVIEW: boolean;
  27138. USEPHYSICALLIGHTFALLOFF: boolean;
  27139. USEGLTFLIGHTFALLOFF: boolean;
  27140. TWOSIDEDLIGHTING: boolean;
  27141. SHADOWFLOAT: boolean;
  27142. CLIPPLANE: boolean;
  27143. CLIPPLANE2: boolean;
  27144. CLIPPLANE3: boolean;
  27145. CLIPPLANE4: boolean;
  27146. CLIPPLANE5: boolean;
  27147. CLIPPLANE6: boolean;
  27148. POINTSIZE: boolean;
  27149. FOG: boolean;
  27150. LOGARITHMICDEPTH: boolean;
  27151. FORCENORMALFORWARD: boolean;
  27152. SPECULARAA: boolean;
  27153. CLEARCOAT: boolean;
  27154. CLEARCOAT_DEFAULTIOR: boolean;
  27155. CLEARCOAT_TEXTURE: boolean;
  27156. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27157. CLEARCOAT_TEXTUREDIRECTUV: number;
  27158. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27159. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27160. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27161. CLEARCOAT_BUMP: boolean;
  27162. CLEARCOAT_BUMPDIRECTUV: number;
  27163. CLEARCOAT_REMAP_F0: boolean;
  27164. CLEARCOAT_TINT: boolean;
  27165. CLEARCOAT_TINT_TEXTURE: boolean;
  27166. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27167. ANISOTROPIC: boolean;
  27168. ANISOTROPIC_TEXTURE: boolean;
  27169. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27170. BRDF_V_HEIGHT_CORRELATED: boolean;
  27171. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27172. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27173. SHEEN: boolean;
  27174. SHEEN_TEXTURE: boolean;
  27175. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27176. SHEEN_TEXTUREDIRECTUV: number;
  27177. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27178. SHEEN_LINKWITHALBEDO: boolean;
  27179. SHEEN_ROUGHNESS: boolean;
  27180. SHEEN_ALBEDOSCALING: boolean;
  27181. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27182. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27183. SUBSURFACE: boolean;
  27184. SS_REFRACTION: boolean;
  27185. SS_TRANSLUCENCY: boolean;
  27186. SS_SCATTERING: boolean;
  27187. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27188. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27189. SS_REFRACTIONMAP_3D: boolean;
  27190. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27191. SS_LODINREFRACTIONALPHA: boolean;
  27192. SS_GAMMAREFRACTION: boolean;
  27193. SS_RGBDREFRACTION: boolean;
  27194. SS_LINEARSPECULARREFRACTION: boolean;
  27195. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27196. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27197. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27198. UNLIT: boolean;
  27199. DEBUGMODE: number;
  27200. /**
  27201. * Initializes the PBR Material defines.
  27202. */
  27203. constructor();
  27204. /**
  27205. * Resets the PBR Material defines.
  27206. */
  27207. reset(): void;
  27208. }
  27209. /**
  27210. * The Physically based material base class of BJS.
  27211. *
  27212. * This offers the main features of a standard PBR material.
  27213. * For more information, please refer to the documentation :
  27214. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27215. */
  27216. export abstract class PBRBaseMaterial extends PushMaterial {
  27217. /**
  27218. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27219. */
  27220. static readonly PBRMATERIAL_OPAQUE: number;
  27221. /**
  27222. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27223. */
  27224. static readonly PBRMATERIAL_ALPHATEST: number;
  27225. /**
  27226. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27227. */
  27228. static readonly PBRMATERIAL_ALPHABLEND: number;
  27229. /**
  27230. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27231. * They are also discarded below the alpha cutoff threshold to improve performances.
  27232. */
  27233. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27234. /**
  27235. * Defines the default value of how much AO map is occluding the analytical lights
  27236. * (point spot...).
  27237. */
  27238. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27239. /**
  27240. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27241. */
  27242. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27243. /**
  27244. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27245. * to enhance interoperability with other engines.
  27246. */
  27247. static readonly LIGHTFALLOFF_GLTF: number;
  27248. /**
  27249. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27250. * to enhance interoperability with other materials.
  27251. */
  27252. static readonly LIGHTFALLOFF_STANDARD: number;
  27253. /**
  27254. * Intensity of the direct lights e.g. the four lights available in your scene.
  27255. * This impacts both the direct diffuse and specular highlights.
  27256. */
  27257. protected _directIntensity: number;
  27258. /**
  27259. * Intensity of the emissive part of the material.
  27260. * This helps controlling the emissive effect without modifying the emissive color.
  27261. */
  27262. protected _emissiveIntensity: number;
  27263. /**
  27264. * Intensity of the environment e.g. how much the environment will light the object
  27265. * either through harmonics for rough material or through the refelction for shiny ones.
  27266. */
  27267. protected _environmentIntensity: number;
  27268. /**
  27269. * This is a special control allowing the reduction of the specular highlights coming from the
  27270. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27271. */
  27272. protected _specularIntensity: number;
  27273. /**
  27274. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27275. */
  27276. private _lightingInfos;
  27277. /**
  27278. * Debug Control allowing disabling the bump map on this material.
  27279. */
  27280. protected _disableBumpMap: boolean;
  27281. /**
  27282. * AKA Diffuse Texture in standard nomenclature.
  27283. */
  27284. protected _albedoTexture: Nullable<BaseTexture>;
  27285. /**
  27286. * AKA Occlusion Texture in other nomenclature.
  27287. */
  27288. protected _ambientTexture: Nullable<BaseTexture>;
  27289. /**
  27290. * AKA Occlusion Texture Intensity in other nomenclature.
  27291. */
  27292. protected _ambientTextureStrength: number;
  27293. /**
  27294. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27295. * 1 means it completely occludes it
  27296. * 0 mean it has no impact
  27297. */
  27298. protected _ambientTextureImpactOnAnalyticalLights: number;
  27299. /**
  27300. * Stores the alpha values in a texture.
  27301. */
  27302. protected _opacityTexture: Nullable<BaseTexture>;
  27303. /**
  27304. * Stores the reflection values in a texture.
  27305. */
  27306. protected _reflectionTexture: Nullable<BaseTexture>;
  27307. /**
  27308. * Stores the emissive values in a texture.
  27309. */
  27310. protected _emissiveTexture: Nullable<BaseTexture>;
  27311. /**
  27312. * AKA Specular texture in other nomenclature.
  27313. */
  27314. protected _reflectivityTexture: Nullable<BaseTexture>;
  27315. /**
  27316. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27317. */
  27318. protected _metallicTexture: Nullable<BaseTexture>;
  27319. /**
  27320. * Specifies the metallic scalar of the metallic/roughness workflow.
  27321. * Can also be used to scale the metalness values of the metallic texture.
  27322. */
  27323. protected _metallic: Nullable<number>;
  27324. /**
  27325. * Specifies the roughness scalar of the metallic/roughness workflow.
  27326. * Can also be used to scale the roughness values of the metallic texture.
  27327. */
  27328. protected _roughness: Nullable<number>;
  27329. /**
  27330. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27331. * By default the indexOfrefraction is used to compute F0;
  27332. *
  27333. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27334. *
  27335. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27336. * F90 = metallicReflectanceColor;
  27337. */
  27338. protected _metallicF0Factor: number;
  27339. /**
  27340. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27341. * By default the F90 is always 1;
  27342. *
  27343. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27344. *
  27345. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27346. * F90 = metallicReflectanceColor;
  27347. */
  27348. protected _metallicReflectanceColor: Color3;
  27349. /**
  27350. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27351. * This is multiply against the scalar values defined in the material.
  27352. */
  27353. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27354. /**
  27355. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27356. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27357. */
  27358. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27359. /**
  27360. * Stores surface normal data used to displace a mesh in a texture.
  27361. */
  27362. protected _bumpTexture: Nullable<BaseTexture>;
  27363. /**
  27364. * Stores the pre-calculated light information of a mesh in a texture.
  27365. */
  27366. protected _lightmapTexture: Nullable<BaseTexture>;
  27367. /**
  27368. * The color of a material in ambient lighting.
  27369. */
  27370. protected _ambientColor: Color3;
  27371. /**
  27372. * AKA Diffuse Color in other nomenclature.
  27373. */
  27374. protected _albedoColor: Color3;
  27375. /**
  27376. * AKA Specular Color in other nomenclature.
  27377. */
  27378. protected _reflectivityColor: Color3;
  27379. /**
  27380. * The color applied when light is reflected from a material.
  27381. */
  27382. protected _reflectionColor: Color3;
  27383. /**
  27384. * The color applied when light is emitted from a material.
  27385. */
  27386. protected _emissiveColor: Color3;
  27387. /**
  27388. * AKA Glossiness in other nomenclature.
  27389. */
  27390. protected _microSurface: number;
  27391. /**
  27392. * Specifies that the material will use the light map as a show map.
  27393. */
  27394. protected _useLightmapAsShadowmap: boolean;
  27395. /**
  27396. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27397. * makes the reflect vector face the model (under horizon).
  27398. */
  27399. protected _useHorizonOcclusion: boolean;
  27400. /**
  27401. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27402. * too much the area relying on ambient texture to define their ambient occlusion.
  27403. */
  27404. protected _useRadianceOcclusion: boolean;
  27405. /**
  27406. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27407. */
  27408. protected _useAlphaFromAlbedoTexture: boolean;
  27409. /**
  27410. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27411. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27412. */
  27413. protected _useSpecularOverAlpha: boolean;
  27414. /**
  27415. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27416. */
  27417. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27418. /**
  27419. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27420. */
  27421. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27422. /**
  27423. * Specifies if the metallic texture contains the roughness information in its green channel.
  27424. */
  27425. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27426. /**
  27427. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27428. */
  27429. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27430. /**
  27431. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27432. */
  27433. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27434. /**
  27435. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27436. */
  27437. protected _useAmbientInGrayScale: boolean;
  27438. /**
  27439. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27440. * The material will try to infer what glossiness each pixel should be.
  27441. */
  27442. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27443. /**
  27444. * Defines the falloff type used in this material.
  27445. * It by default is Physical.
  27446. */
  27447. protected _lightFalloff: number;
  27448. /**
  27449. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27450. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27451. */
  27452. protected _useRadianceOverAlpha: boolean;
  27453. /**
  27454. * Allows using an object space normal map (instead of tangent space).
  27455. */
  27456. protected _useObjectSpaceNormalMap: boolean;
  27457. /**
  27458. * Allows using the bump map in parallax mode.
  27459. */
  27460. protected _useParallax: boolean;
  27461. /**
  27462. * Allows using the bump map in parallax occlusion mode.
  27463. */
  27464. protected _useParallaxOcclusion: boolean;
  27465. /**
  27466. * Controls the scale bias of the parallax mode.
  27467. */
  27468. protected _parallaxScaleBias: number;
  27469. /**
  27470. * If sets to true, disables all the lights affecting the material.
  27471. */
  27472. protected _disableLighting: boolean;
  27473. /**
  27474. * Number of Simultaneous lights allowed on the material.
  27475. */
  27476. protected _maxSimultaneousLights: number;
  27477. /**
  27478. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27479. */
  27480. protected _invertNormalMapX: boolean;
  27481. /**
  27482. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27483. */
  27484. protected _invertNormalMapY: boolean;
  27485. /**
  27486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27487. */
  27488. protected _twoSidedLighting: boolean;
  27489. /**
  27490. * Defines the alpha limits in alpha test mode.
  27491. */
  27492. protected _alphaCutOff: number;
  27493. /**
  27494. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27495. */
  27496. protected _forceAlphaTest: boolean;
  27497. /**
  27498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27499. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27500. */
  27501. protected _useAlphaFresnel: boolean;
  27502. /**
  27503. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27504. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27505. */
  27506. protected _useLinearAlphaFresnel: boolean;
  27507. /**
  27508. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27509. * from cos thetav and roughness:
  27510. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27511. */
  27512. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27513. /**
  27514. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27515. */
  27516. protected _forceIrradianceInFragment: boolean;
  27517. private _realTimeFiltering;
  27518. /**
  27519. * Enables realtime filtering on the texture.
  27520. */
  27521. get realTimeFiltering(): boolean;
  27522. set realTimeFiltering(b: boolean);
  27523. private _realTimeFilteringQuality;
  27524. /**
  27525. * Quality switch for realtime filtering
  27526. */
  27527. get realTimeFilteringQuality(): number;
  27528. set realTimeFilteringQuality(n: number);
  27529. /**
  27530. * Can this material render to several textures at once
  27531. */
  27532. get canRenderToMRT(): boolean;
  27533. /**
  27534. * Force normal to face away from face.
  27535. */
  27536. protected _forceNormalForward: boolean;
  27537. /**
  27538. * Enables specular anti aliasing in the PBR shader.
  27539. * It will both interacts on the Geometry for analytical and IBL lighting.
  27540. * It also prefilter the roughness map based on the bump values.
  27541. */
  27542. protected _enableSpecularAntiAliasing: boolean;
  27543. /**
  27544. * Default configuration related to image processing available in the PBR Material.
  27545. */
  27546. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27547. /**
  27548. * Keep track of the image processing observer to allow dispose and replace.
  27549. */
  27550. private _imageProcessingObserver;
  27551. /**
  27552. * Attaches a new image processing configuration to the PBR Material.
  27553. * @param configuration
  27554. */
  27555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27556. /**
  27557. * Stores the available render targets.
  27558. */
  27559. private _renderTargets;
  27560. /**
  27561. * Sets the global ambient color for the material used in lighting calculations.
  27562. */
  27563. private _globalAmbientColor;
  27564. /**
  27565. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27566. */
  27567. private _useLogarithmicDepth;
  27568. /**
  27569. * If set to true, no lighting calculations will be applied.
  27570. */
  27571. private _unlit;
  27572. private _debugMode;
  27573. /**
  27574. * @hidden
  27575. * This is reserved for the inspector.
  27576. * Defines the material debug mode.
  27577. * It helps seeing only some components of the material while troubleshooting.
  27578. */
  27579. debugMode: number;
  27580. /**
  27581. * @hidden
  27582. * This is reserved for the inspector.
  27583. * Specify from where on screen the debug mode should start.
  27584. * The value goes from -1 (full screen) to 1 (not visible)
  27585. * It helps with side by side comparison against the final render
  27586. * This defaults to -1
  27587. */
  27588. private debugLimit;
  27589. /**
  27590. * @hidden
  27591. * This is reserved for the inspector.
  27592. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27593. * You can use the factor to better multiply the final value.
  27594. */
  27595. private debugFactor;
  27596. /**
  27597. * Defines the clear coat layer parameters for the material.
  27598. */
  27599. readonly clearCoat: PBRClearCoatConfiguration;
  27600. /**
  27601. * Defines the anisotropic parameters for the material.
  27602. */
  27603. readonly anisotropy: PBRAnisotropicConfiguration;
  27604. /**
  27605. * Defines the BRDF parameters for the material.
  27606. */
  27607. readonly brdf: PBRBRDFConfiguration;
  27608. /**
  27609. * Defines the Sheen parameters for the material.
  27610. */
  27611. readonly sheen: PBRSheenConfiguration;
  27612. /**
  27613. * Defines the SubSurface parameters for the material.
  27614. */
  27615. readonly subSurface: PBRSubSurfaceConfiguration;
  27616. /**
  27617. * Defines additionnal PrePass parameters for the material.
  27618. */
  27619. readonly prePassConfiguration: PrePassConfiguration;
  27620. /**
  27621. * Defines the detail map parameters for the material.
  27622. */
  27623. readonly detailMap: DetailMapConfiguration;
  27624. protected _rebuildInParallel: boolean;
  27625. /**
  27626. * Instantiates a new PBRMaterial instance.
  27627. *
  27628. * @param name The material name
  27629. * @param scene The scene the material will be use in.
  27630. */
  27631. constructor(name: string, scene: Scene);
  27632. /**
  27633. * Gets a boolean indicating that current material needs to register RTT
  27634. */
  27635. get hasRenderTargetTextures(): boolean;
  27636. /**
  27637. * Gets the name of the material class.
  27638. */
  27639. getClassName(): string;
  27640. /**
  27641. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27642. */
  27643. get useLogarithmicDepth(): boolean;
  27644. /**
  27645. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27646. */
  27647. set useLogarithmicDepth(value: boolean);
  27648. /**
  27649. * Returns true if alpha blending should be disabled.
  27650. */
  27651. protected get _disableAlphaBlending(): boolean;
  27652. /**
  27653. * Specifies whether or not this material should be rendered in alpha blend mode.
  27654. */
  27655. needAlphaBlending(): boolean;
  27656. /**
  27657. * Specifies whether or not this material should be rendered in alpha test mode.
  27658. */
  27659. needAlphaTesting(): boolean;
  27660. /**
  27661. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27662. */
  27663. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27664. /**
  27665. * Specifies whether or not there is a usable alpha channel for transparency.
  27666. */
  27667. protected _hasAlphaChannel(): boolean;
  27668. /**
  27669. * Gets the texture used for the alpha test.
  27670. */
  27671. getAlphaTestTexture(): Nullable<BaseTexture>;
  27672. /**
  27673. * Specifies that the submesh is ready to be used.
  27674. * @param mesh - BJS mesh.
  27675. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27676. * @param useInstances - Specifies that instances should be used.
  27677. * @returns - boolean indicating that the submesh is ready or not.
  27678. */
  27679. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27680. /**
  27681. * Specifies if the material uses metallic roughness workflow.
  27682. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27683. */
  27684. isMetallicWorkflow(): boolean;
  27685. private _prepareEffect;
  27686. private _prepareDefines;
  27687. /**
  27688. * Force shader compilation
  27689. */
  27690. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27691. /**
  27692. * Initializes the uniform buffer layout for the shader.
  27693. */
  27694. buildUniformLayout(): void;
  27695. /**
  27696. * Unbinds the material from the mesh
  27697. */
  27698. unbind(): void;
  27699. /**
  27700. * Binds the submesh data.
  27701. * @param world - The world matrix.
  27702. * @param mesh - The BJS mesh.
  27703. * @param subMesh - A submesh of the BJS mesh.
  27704. */
  27705. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27706. /**
  27707. * Returns the animatable textures.
  27708. * @returns - Array of animatable textures.
  27709. */
  27710. getAnimatables(): IAnimatable[];
  27711. /**
  27712. * Returns the texture used for reflections.
  27713. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27714. */
  27715. private _getReflectionTexture;
  27716. /**
  27717. * Returns an array of the actively used textures.
  27718. * @returns - Array of BaseTextures
  27719. */
  27720. getActiveTextures(): BaseTexture[];
  27721. /**
  27722. * Checks to see if a texture is used in the material.
  27723. * @param texture - Base texture to use.
  27724. * @returns - Boolean specifying if a texture is used in the material.
  27725. */
  27726. hasTexture(texture: BaseTexture): boolean;
  27727. /**
  27728. * Sets the required values to the prepass renderer.
  27729. * @param prePassRenderer defines the prepass renderer to setup
  27730. */
  27731. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27732. /**
  27733. * Disposes the resources of the material.
  27734. * @param forceDisposeEffect - Forces the disposal of effects.
  27735. * @param forceDisposeTextures - Forces the disposal of all textures.
  27736. */
  27737. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27738. }
  27739. }
  27740. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27741. import { Nullable } from "babylonjs/types";
  27742. import { Scene } from "babylonjs/scene";
  27743. import { Color3 } from "babylonjs/Maths/math.color";
  27744. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27745. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27747. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27748. /**
  27749. * The Physically based material of BJS.
  27750. *
  27751. * This offers the main features of a standard PBR material.
  27752. * For more information, please refer to the documentation :
  27753. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27754. */
  27755. export class PBRMaterial extends PBRBaseMaterial {
  27756. /**
  27757. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27758. */
  27759. static readonly PBRMATERIAL_OPAQUE: number;
  27760. /**
  27761. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27762. */
  27763. static readonly PBRMATERIAL_ALPHATEST: number;
  27764. /**
  27765. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27766. */
  27767. static readonly PBRMATERIAL_ALPHABLEND: number;
  27768. /**
  27769. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27770. * They are also discarded below the alpha cutoff threshold to improve performances.
  27771. */
  27772. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27773. /**
  27774. * Defines the default value of how much AO map is occluding the analytical lights
  27775. * (point spot...).
  27776. */
  27777. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27778. /**
  27779. * Intensity of the direct lights e.g. the four lights available in your scene.
  27780. * This impacts both the direct diffuse and specular highlights.
  27781. */
  27782. directIntensity: number;
  27783. /**
  27784. * Intensity of the emissive part of the material.
  27785. * This helps controlling the emissive effect without modifying the emissive color.
  27786. */
  27787. emissiveIntensity: number;
  27788. /**
  27789. * Intensity of the environment e.g. how much the environment will light the object
  27790. * either through harmonics for rough material or through the refelction for shiny ones.
  27791. */
  27792. environmentIntensity: number;
  27793. /**
  27794. * This is a special control allowing the reduction of the specular highlights coming from the
  27795. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27796. */
  27797. specularIntensity: number;
  27798. /**
  27799. * Debug Control allowing disabling the bump map on this material.
  27800. */
  27801. disableBumpMap: boolean;
  27802. /**
  27803. * AKA Diffuse Texture in standard nomenclature.
  27804. */
  27805. albedoTexture: BaseTexture;
  27806. /**
  27807. * AKA Occlusion Texture in other nomenclature.
  27808. */
  27809. ambientTexture: BaseTexture;
  27810. /**
  27811. * AKA Occlusion Texture Intensity in other nomenclature.
  27812. */
  27813. ambientTextureStrength: number;
  27814. /**
  27815. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27816. * 1 means it completely occludes it
  27817. * 0 mean it has no impact
  27818. */
  27819. ambientTextureImpactOnAnalyticalLights: number;
  27820. /**
  27821. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27822. */
  27823. opacityTexture: BaseTexture;
  27824. /**
  27825. * Stores the reflection values in a texture.
  27826. */
  27827. reflectionTexture: Nullable<BaseTexture>;
  27828. /**
  27829. * Stores the emissive values in a texture.
  27830. */
  27831. emissiveTexture: BaseTexture;
  27832. /**
  27833. * AKA Specular texture in other nomenclature.
  27834. */
  27835. reflectivityTexture: BaseTexture;
  27836. /**
  27837. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27838. */
  27839. metallicTexture: BaseTexture;
  27840. /**
  27841. * Specifies the metallic scalar of the metallic/roughness workflow.
  27842. * Can also be used to scale the metalness values of the metallic texture.
  27843. */
  27844. metallic: Nullable<number>;
  27845. /**
  27846. * Specifies the roughness scalar of the metallic/roughness workflow.
  27847. * Can also be used to scale the roughness values of the metallic texture.
  27848. */
  27849. roughness: Nullable<number>;
  27850. /**
  27851. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27852. * By default the indexOfrefraction is used to compute F0;
  27853. *
  27854. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27855. *
  27856. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27857. * F90 = metallicReflectanceColor;
  27858. */
  27859. metallicF0Factor: number;
  27860. /**
  27861. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27862. * By default the F90 is always 1;
  27863. *
  27864. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27865. *
  27866. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27867. * F90 = metallicReflectanceColor;
  27868. */
  27869. metallicReflectanceColor: Color3;
  27870. /**
  27871. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27872. * This is multiply against the scalar values defined in the material.
  27873. */
  27874. metallicReflectanceTexture: Nullable<BaseTexture>;
  27875. /**
  27876. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27877. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27878. */
  27879. microSurfaceTexture: BaseTexture;
  27880. /**
  27881. * Stores surface normal data used to displace a mesh in a texture.
  27882. */
  27883. bumpTexture: BaseTexture;
  27884. /**
  27885. * Stores the pre-calculated light information of a mesh in a texture.
  27886. */
  27887. lightmapTexture: BaseTexture;
  27888. /**
  27889. * Stores the refracted light information in a texture.
  27890. */
  27891. get refractionTexture(): Nullable<BaseTexture>;
  27892. set refractionTexture(value: Nullable<BaseTexture>);
  27893. /**
  27894. * The color of a material in ambient lighting.
  27895. */
  27896. ambientColor: Color3;
  27897. /**
  27898. * AKA Diffuse Color in other nomenclature.
  27899. */
  27900. albedoColor: Color3;
  27901. /**
  27902. * AKA Specular Color in other nomenclature.
  27903. */
  27904. reflectivityColor: Color3;
  27905. /**
  27906. * The color reflected from the material.
  27907. */
  27908. reflectionColor: Color3;
  27909. /**
  27910. * The color emitted from the material.
  27911. */
  27912. emissiveColor: Color3;
  27913. /**
  27914. * AKA Glossiness in other nomenclature.
  27915. */
  27916. microSurface: number;
  27917. /**
  27918. * Index of refraction of the material base layer.
  27919. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27920. *
  27921. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27922. *
  27923. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27924. */
  27925. get indexOfRefraction(): number;
  27926. set indexOfRefraction(value: number);
  27927. /**
  27928. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27929. */
  27930. get invertRefractionY(): boolean;
  27931. set invertRefractionY(value: boolean);
  27932. /**
  27933. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27934. * Materials half opaque for instance using refraction could benefit from this control.
  27935. */
  27936. get linkRefractionWithTransparency(): boolean;
  27937. set linkRefractionWithTransparency(value: boolean);
  27938. /**
  27939. * If true, the light map contains occlusion information instead of lighting info.
  27940. */
  27941. useLightmapAsShadowmap: boolean;
  27942. /**
  27943. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27944. */
  27945. useAlphaFromAlbedoTexture: boolean;
  27946. /**
  27947. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27948. */
  27949. forceAlphaTest: boolean;
  27950. /**
  27951. * Defines the alpha limits in alpha test mode.
  27952. */
  27953. alphaCutOff: number;
  27954. /**
  27955. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27956. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27957. */
  27958. useSpecularOverAlpha: boolean;
  27959. /**
  27960. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27961. */
  27962. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27963. /**
  27964. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27965. */
  27966. useRoughnessFromMetallicTextureAlpha: boolean;
  27967. /**
  27968. * Specifies if the metallic texture contains the roughness information in its green channel.
  27969. */
  27970. useRoughnessFromMetallicTextureGreen: boolean;
  27971. /**
  27972. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27973. */
  27974. useMetallnessFromMetallicTextureBlue: boolean;
  27975. /**
  27976. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27977. */
  27978. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27979. /**
  27980. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27981. */
  27982. useAmbientInGrayScale: boolean;
  27983. /**
  27984. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27985. * The material will try to infer what glossiness each pixel should be.
  27986. */
  27987. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27988. /**
  27989. * BJS is using an harcoded light falloff based on a manually sets up range.
  27990. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27991. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27992. */
  27993. get usePhysicalLightFalloff(): boolean;
  27994. /**
  27995. * BJS is using an harcoded light falloff based on a manually sets up range.
  27996. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27997. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27998. */
  27999. set usePhysicalLightFalloff(value: boolean);
  28000. /**
  28001. * In order to support the falloff compatibility with gltf, a special mode has been added
  28002. * to reproduce the gltf light falloff.
  28003. */
  28004. get useGLTFLightFalloff(): boolean;
  28005. /**
  28006. * In order to support the falloff compatibility with gltf, a special mode has been added
  28007. * to reproduce the gltf light falloff.
  28008. */
  28009. set useGLTFLightFalloff(value: boolean);
  28010. /**
  28011. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28012. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28013. */
  28014. useRadianceOverAlpha: boolean;
  28015. /**
  28016. * Allows using an object space normal map (instead of tangent space).
  28017. */
  28018. useObjectSpaceNormalMap: boolean;
  28019. /**
  28020. * Allows using the bump map in parallax mode.
  28021. */
  28022. useParallax: boolean;
  28023. /**
  28024. * Allows using the bump map in parallax occlusion mode.
  28025. */
  28026. useParallaxOcclusion: boolean;
  28027. /**
  28028. * Controls the scale bias of the parallax mode.
  28029. */
  28030. parallaxScaleBias: number;
  28031. /**
  28032. * If sets to true, disables all the lights affecting the material.
  28033. */
  28034. disableLighting: boolean;
  28035. /**
  28036. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28037. */
  28038. forceIrradianceInFragment: boolean;
  28039. /**
  28040. * Number of Simultaneous lights allowed on the material.
  28041. */
  28042. maxSimultaneousLights: number;
  28043. /**
  28044. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28045. */
  28046. invertNormalMapX: boolean;
  28047. /**
  28048. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28049. */
  28050. invertNormalMapY: boolean;
  28051. /**
  28052. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28053. */
  28054. twoSidedLighting: boolean;
  28055. /**
  28056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28057. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28058. */
  28059. useAlphaFresnel: boolean;
  28060. /**
  28061. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28062. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28063. */
  28064. useLinearAlphaFresnel: boolean;
  28065. /**
  28066. * Let user defines the brdf lookup texture used for IBL.
  28067. * A default 8bit version is embedded but you could point at :
  28068. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28069. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28070. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28071. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28072. */
  28073. environmentBRDFTexture: Nullable<BaseTexture>;
  28074. /**
  28075. * Force normal to face away from face.
  28076. */
  28077. forceNormalForward: boolean;
  28078. /**
  28079. * Enables specular anti aliasing in the PBR shader.
  28080. * It will both interacts on the Geometry for analytical and IBL lighting.
  28081. * It also prefilter the roughness map based on the bump values.
  28082. */
  28083. enableSpecularAntiAliasing: boolean;
  28084. /**
  28085. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28086. * makes the reflect vector face the model (under horizon).
  28087. */
  28088. useHorizonOcclusion: boolean;
  28089. /**
  28090. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28091. * too much the area relying on ambient texture to define their ambient occlusion.
  28092. */
  28093. useRadianceOcclusion: boolean;
  28094. /**
  28095. * If set to true, no lighting calculations will be applied.
  28096. */
  28097. unlit: boolean;
  28098. /**
  28099. * Gets the image processing configuration used either in this material.
  28100. */
  28101. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28102. /**
  28103. * Sets the Default image processing configuration used either in the this material.
  28104. *
  28105. * If sets to null, the scene one is in use.
  28106. */
  28107. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28108. /**
  28109. * Gets wether the color curves effect is enabled.
  28110. */
  28111. get cameraColorCurvesEnabled(): boolean;
  28112. /**
  28113. * Sets wether the color curves effect is enabled.
  28114. */
  28115. set cameraColorCurvesEnabled(value: boolean);
  28116. /**
  28117. * Gets wether the color grading effect is enabled.
  28118. */
  28119. get cameraColorGradingEnabled(): boolean;
  28120. /**
  28121. * Gets wether the color grading effect is enabled.
  28122. */
  28123. set cameraColorGradingEnabled(value: boolean);
  28124. /**
  28125. * Gets wether tonemapping is enabled or not.
  28126. */
  28127. get cameraToneMappingEnabled(): boolean;
  28128. /**
  28129. * Sets wether tonemapping is enabled or not
  28130. */
  28131. set cameraToneMappingEnabled(value: boolean);
  28132. /**
  28133. * The camera exposure used on this material.
  28134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28135. * This corresponds to a photographic exposure.
  28136. */
  28137. get cameraExposure(): number;
  28138. /**
  28139. * The camera exposure used on this material.
  28140. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28141. * This corresponds to a photographic exposure.
  28142. */
  28143. set cameraExposure(value: number);
  28144. /**
  28145. * Gets The camera contrast used on this material.
  28146. */
  28147. get cameraContrast(): number;
  28148. /**
  28149. * Sets The camera contrast used on this material.
  28150. */
  28151. set cameraContrast(value: number);
  28152. /**
  28153. * Gets the Color Grading 2D Lookup Texture.
  28154. */
  28155. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28156. /**
  28157. * Sets the Color Grading 2D Lookup Texture.
  28158. */
  28159. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28160. /**
  28161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28163. * 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;
  28164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28165. */
  28166. get cameraColorCurves(): Nullable<ColorCurves>;
  28167. /**
  28168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28170. * 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;
  28171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28172. */
  28173. set cameraColorCurves(value: Nullable<ColorCurves>);
  28174. /**
  28175. * Instantiates a new PBRMaterial instance.
  28176. *
  28177. * @param name The material name
  28178. * @param scene The scene the material will be use in.
  28179. */
  28180. constructor(name: string, scene: Scene);
  28181. /**
  28182. * Returns the name of this material class.
  28183. */
  28184. getClassName(): string;
  28185. /**
  28186. * Makes a duplicate of the current material.
  28187. * @param name - name to use for the new material.
  28188. */
  28189. clone(name: string): PBRMaterial;
  28190. /**
  28191. * Serializes this PBR Material.
  28192. * @returns - An object with the serialized material.
  28193. */
  28194. serialize(): any;
  28195. /**
  28196. * Parses a PBR Material from a serialized object.
  28197. * @param source - Serialized object.
  28198. * @param scene - BJS scene instance.
  28199. * @param rootUrl - url for the scene object
  28200. * @returns - PBRMaterial
  28201. */
  28202. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28203. }
  28204. }
  28205. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28206. /** @hidden */
  28207. export var mrtFragmentDeclaration: {
  28208. name: string;
  28209. shader: string;
  28210. };
  28211. }
  28212. declare module "babylonjs/Shaders/geometry.fragment" {
  28213. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28214. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28215. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28216. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28217. /** @hidden */
  28218. export var geometryPixelShader: {
  28219. name: string;
  28220. shader: string;
  28221. };
  28222. }
  28223. declare module "babylonjs/Shaders/geometry.vertex" {
  28224. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28226. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28227. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28229. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28230. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28231. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28232. /** @hidden */
  28233. export var geometryVertexShader: {
  28234. name: string;
  28235. shader: string;
  28236. };
  28237. }
  28238. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28239. import { Matrix } from "babylonjs/Maths/math.vector";
  28240. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28242. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28243. import { Effect } from "babylonjs/Materials/effect";
  28244. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28245. import { Scene } from "babylonjs/scene";
  28246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28247. import { Nullable } from "babylonjs/types";
  28248. import "babylonjs/Shaders/geometry.fragment";
  28249. import "babylonjs/Shaders/geometry.vertex";
  28250. /** @hidden */
  28251. interface ISavedTransformationMatrix {
  28252. world: Matrix;
  28253. viewProjection: Matrix;
  28254. }
  28255. /**
  28256. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28257. */
  28258. export class GeometryBufferRenderer {
  28259. /**
  28260. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28261. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28262. */
  28263. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28264. /**
  28265. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28266. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28267. */
  28268. static readonly POSITION_TEXTURE_TYPE: number;
  28269. /**
  28270. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28271. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28272. */
  28273. static readonly VELOCITY_TEXTURE_TYPE: number;
  28274. /**
  28275. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28276. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28277. */
  28278. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28279. /**
  28280. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28281. * in order to compute objects velocities when enableVelocity is set to "true"
  28282. * @hidden
  28283. */
  28284. _previousTransformationMatrices: {
  28285. [index: number]: ISavedTransformationMatrix;
  28286. };
  28287. /**
  28288. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28289. * in order to compute objects velocities when enableVelocity is set to "true"
  28290. * @hidden
  28291. */
  28292. _previousBonesTransformationMatrices: {
  28293. [index: number]: Float32Array;
  28294. };
  28295. /**
  28296. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28297. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28298. */
  28299. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28300. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28301. renderTransparentMeshes: boolean;
  28302. private _scene;
  28303. private _resizeObserver;
  28304. private _multiRenderTarget;
  28305. private _ratio;
  28306. private _enablePosition;
  28307. private _enableVelocity;
  28308. private _enableReflectivity;
  28309. private _positionIndex;
  28310. private _velocityIndex;
  28311. private _reflectivityIndex;
  28312. private _depthNormalIndex;
  28313. private _linkedWithPrePass;
  28314. private _prePassRenderer;
  28315. private _attachments;
  28316. protected _effect: Effect;
  28317. protected _cachedDefines: string;
  28318. /**
  28319. * @hidden
  28320. * Sets up internal structures to share outputs with PrePassRenderer
  28321. * This method should only be called by the PrePassRenderer itself
  28322. */
  28323. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28324. /**
  28325. * @hidden
  28326. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28327. * This method should only be called by the PrePassRenderer itself
  28328. */
  28329. _unlinkPrePassRenderer(): void;
  28330. /**
  28331. * @hidden
  28332. * Resets the geometry buffer layout
  28333. */
  28334. _resetLayout(): void;
  28335. /**
  28336. * @hidden
  28337. * Replaces a texture in the geometry buffer renderer
  28338. * Useful when linking textures of the prepass renderer
  28339. */
  28340. _forceTextureType(geometryBufferType: number, index: number): void;
  28341. /**
  28342. * @hidden
  28343. * Sets texture attachments
  28344. * Useful when linking textures of the prepass renderer
  28345. */
  28346. _setAttachments(attachments: number[]): void;
  28347. /**
  28348. * @hidden
  28349. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28350. * Useful when linking textures of the prepass renderer
  28351. */
  28352. _linkInternalTexture(internalTexture: InternalTexture): void;
  28353. /**
  28354. * Gets the render list (meshes to be rendered) used in the G buffer.
  28355. */
  28356. get renderList(): Nullable<AbstractMesh[]>;
  28357. /**
  28358. * Set the render list (meshes to be rendered) used in the G buffer.
  28359. */
  28360. set renderList(meshes: Nullable<AbstractMesh[]>);
  28361. /**
  28362. * Gets wether or not G buffer are supported by the running hardware.
  28363. * This requires draw buffer supports
  28364. */
  28365. get isSupported(): boolean;
  28366. /**
  28367. * Returns the index of the given texture type in the G-Buffer textures array
  28368. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28369. * @returns the index of the given texture type in the G-Buffer textures array
  28370. */
  28371. getTextureIndex(textureType: number): number;
  28372. /**
  28373. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28374. */
  28375. get enablePosition(): boolean;
  28376. /**
  28377. * Sets whether or not objects positions are enabled for the G buffer.
  28378. */
  28379. set enablePosition(enable: boolean);
  28380. /**
  28381. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28382. */
  28383. get enableVelocity(): boolean;
  28384. /**
  28385. * Sets wether or not objects velocities are enabled for the G buffer.
  28386. */
  28387. set enableVelocity(enable: boolean);
  28388. /**
  28389. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28390. */
  28391. get enableReflectivity(): boolean;
  28392. /**
  28393. * Sets wether or not objects roughness are enabled for the G buffer.
  28394. */
  28395. set enableReflectivity(enable: boolean);
  28396. /**
  28397. * Gets the scene associated with the buffer.
  28398. */
  28399. get scene(): Scene;
  28400. /**
  28401. * Gets the ratio used by the buffer during its creation.
  28402. * How big is the buffer related to the main canvas.
  28403. */
  28404. get ratio(): number;
  28405. /** @hidden */
  28406. static _SceneComponentInitialization: (scene: Scene) => void;
  28407. /**
  28408. * Creates a new G Buffer for the scene
  28409. * @param scene The scene the buffer belongs to
  28410. * @param ratio How big is the buffer related to the main canvas.
  28411. */
  28412. constructor(scene: Scene, ratio?: number);
  28413. /**
  28414. * Checks wether everything is ready to render a submesh to the G buffer.
  28415. * @param subMesh the submesh to check readiness for
  28416. * @param useInstances is the mesh drawn using instance or not
  28417. * @returns true if ready otherwise false
  28418. */
  28419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28420. /**
  28421. * Gets the current underlying G Buffer.
  28422. * @returns the buffer
  28423. */
  28424. getGBuffer(): MultiRenderTarget;
  28425. /**
  28426. * Gets the number of samples used to render the buffer (anti aliasing).
  28427. */
  28428. get samples(): number;
  28429. /**
  28430. * Sets the number of samples used to render the buffer (anti aliasing).
  28431. */
  28432. set samples(value: number);
  28433. /**
  28434. * Disposes the renderer and frees up associated resources.
  28435. */
  28436. dispose(): void;
  28437. private _assignRenderTargetIndices;
  28438. protected _createRenderTargets(): void;
  28439. private _copyBonesTransformationMatrices;
  28440. }
  28441. }
  28442. declare module "babylonjs/Rendering/prePassRenderer" {
  28443. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28444. import { Scene } from "babylonjs/scene";
  28445. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28446. import { Effect } from "babylonjs/Materials/effect";
  28447. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28449. import { Material } from "babylonjs/Materials/material";
  28450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28451. /**
  28452. * Renders a pre pass of the scene
  28453. * This means every mesh in the scene will be rendered to a render target texture
  28454. * And then this texture will be composited to the rendering canvas with post processes
  28455. * It is necessary for effects like subsurface scattering or deferred shading
  28456. */
  28457. export class PrePassRenderer {
  28458. /** @hidden */
  28459. static _SceneComponentInitialization: (scene: Scene) => void;
  28460. private _textureFormats;
  28461. /**
  28462. * To save performance, we can excluded skinned meshes from the prepass
  28463. */
  28464. excludedSkinnedMesh: AbstractMesh[];
  28465. /**
  28466. * Force material to be excluded from the prepass
  28467. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28468. * and you don't want a material to show in the effect.
  28469. */
  28470. excludedMaterials: Material[];
  28471. private _textureIndices;
  28472. private _scene;
  28473. private _engine;
  28474. private _isDirty;
  28475. /**
  28476. * Number of textures in the multi render target texture where the scene is directly rendered
  28477. */
  28478. mrtCount: number;
  28479. /**
  28480. * The render target where the scene is directly rendered
  28481. */
  28482. prePassRT: MultiRenderTarget;
  28483. private _multiRenderAttachments;
  28484. private _defaultAttachments;
  28485. private _clearAttachments;
  28486. private _postProcesses;
  28487. private readonly _clearColor;
  28488. /**
  28489. * Image processing post process for composition
  28490. */
  28491. imageProcessingPostProcess: ImageProcessingPostProcess;
  28492. /**
  28493. * Configuration for prepass effects
  28494. */
  28495. private _effectConfigurations;
  28496. private _mrtFormats;
  28497. private _mrtLayout;
  28498. private _enabled;
  28499. /**
  28500. * Indicates if the prepass is enabled
  28501. */
  28502. get enabled(): boolean;
  28503. /**
  28504. * How many samples are used for MSAA of the scene render target
  28505. */
  28506. get samples(): number;
  28507. set samples(n: number);
  28508. private _geometryBuffer;
  28509. private _useGeometryBufferFallback;
  28510. /**
  28511. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28512. */
  28513. get useGeometryBufferFallback(): boolean;
  28514. set useGeometryBufferFallback(value: boolean);
  28515. /**
  28516. * Instanciates a prepass renderer
  28517. * @param scene The scene
  28518. */
  28519. constructor(scene: Scene);
  28520. private _initializeAttachments;
  28521. private _createCompositionEffect;
  28522. /**
  28523. * Indicates if rendering a prepass is supported
  28524. */
  28525. get isSupported(): boolean;
  28526. /**
  28527. * Sets the proper output textures to draw in the engine.
  28528. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28529. * @param subMesh Submesh on which the effect is applied
  28530. */
  28531. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28532. /**
  28533. * @hidden
  28534. */
  28535. _beforeCameraDraw(): void;
  28536. /**
  28537. * @hidden
  28538. */
  28539. _afterCameraDraw(): void;
  28540. private _checkRTSize;
  28541. private _bindFrameBuffer;
  28542. /**
  28543. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28544. */
  28545. clear(): void;
  28546. private _setState;
  28547. private _updateGeometryBufferLayout;
  28548. /**
  28549. * Adds an effect configuration to the prepass.
  28550. * If an effect has already been added, it won't add it twice and will return the configuration
  28551. * already present.
  28552. * @param cfg the effect configuration
  28553. * @return the effect configuration now used by the prepass
  28554. */
  28555. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28556. /**
  28557. * Returns the index of a texture in the multi render target texture array.
  28558. * @param type Texture type
  28559. * @return The index
  28560. */
  28561. getIndex(type: number): number;
  28562. private _enable;
  28563. private _disable;
  28564. private _resetLayout;
  28565. private _resetPostProcessChain;
  28566. private _bindPostProcessChain;
  28567. /**
  28568. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28569. */
  28570. markAsDirty(): void;
  28571. /**
  28572. * Enables a texture on the MultiRenderTarget for prepass
  28573. */
  28574. private _enableTextures;
  28575. private _update;
  28576. private _markAllMaterialsAsPrePassDirty;
  28577. /**
  28578. * Disposes the prepass renderer.
  28579. */
  28580. dispose(): void;
  28581. }
  28582. }
  28583. declare module "babylonjs/PostProcesses/postProcess" {
  28584. import { Nullable } from "babylonjs/types";
  28585. import { SmartArray } from "babylonjs/Misc/smartArray";
  28586. import { Observable } from "babylonjs/Misc/observable";
  28587. import { Vector2 } from "babylonjs/Maths/math.vector";
  28588. import { Camera } from "babylonjs/Cameras/camera";
  28589. import { Effect } from "babylonjs/Materials/effect";
  28590. import "babylonjs/Shaders/postprocess.vertex";
  28591. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28592. import { Engine } from "babylonjs/Engines/engine";
  28593. import { Color4 } from "babylonjs/Maths/math.color";
  28594. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28595. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28596. import { Scene } from "babylonjs/scene";
  28597. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28598. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28599. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28600. /**
  28601. * Size options for a post process
  28602. */
  28603. export type PostProcessOptions = {
  28604. width: number;
  28605. height: number;
  28606. };
  28607. /**
  28608. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28609. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28610. */
  28611. export class PostProcess {
  28612. /**
  28613. * Gets or sets the unique id of the post process
  28614. */
  28615. uniqueId: number;
  28616. /** Name of the PostProcess. */
  28617. name: string;
  28618. /**
  28619. * Width of the texture to apply the post process on
  28620. */
  28621. width: number;
  28622. /**
  28623. * Height of the texture to apply the post process on
  28624. */
  28625. height: number;
  28626. /**
  28627. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28628. */
  28629. nodeMaterialSource: Nullable<NodeMaterial>;
  28630. /**
  28631. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28632. * @hidden
  28633. */
  28634. _outputTexture: Nullable<InternalTexture>;
  28635. /**
  28636. * Sampling mode used by the shader
  28637. * See https://doc.babylonjs.com/classes/3.1/texture
  28638. */
  28639. renderTargetSamplingMode: number;
  28640. /**
  28641. * Clear color to use when screen clearing
  28642. */
  28643. clearColor: Color4;
  28644. /**
  28645. * If the buffer needs to be cleared before applying the post process. (default: true)
  28646. * Should be set to false if shader will overwrite all previous pixels.
  28647. */
  28648. autoClear: boolean;
  28649. /**
  28650. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28651. */
  28652. alphaMode: number;
  28653. /**
  28654. * Sets the setAlphaBlendConstants of the babylon engine
  28655. */
  28656. alphaConstants: Color4;
  28657. /**
  28658. * Animations to be used for the post processing
  28659. */
  28660. animations: import("babylonjs/Animations/animation").Animation[];
  28661. /**
  28662. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28663. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28664. */
  28665. enablePixelPerfectMode: boolean;
  28666. /**
  28667. * Force the postprocess to be applied without taking in account viewport
  28668. */
  28669. forceFullscreenViewport: boolean;
  28670. /**
  28671. * List of inspectable custom properties (used by the Inspector)
  28672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28673. */
  28674. inspectableCustomProperties: IInspectable[];
  28675. /**
  28676. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28677. *
  28678. * | Value | Type | Description |
  28679. * | ----- | ----------------------------------- | ----------- |
  28680. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28681. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28682. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28683. *
  28684. */
  28685. scaleMode: number;
  28686. /**
  28687. * Force textures to be a power of two (default: false)
  28688. */
  28689. alwaysForcePOT: boolean;
  28690. private _samples;
  28691. /**
  28692. * Number of sample textures (default: 1)
  28693. */
  28694. get samples(): number;
  28695. set samples(n: number);
  28696. /**
  28697. * Modify the scale of the post process to be the same as the viewport (default: false)
  28698. */
  28699. adaptScaleToCurrentViewport: boolean;
  28700. private _camera;
  28701. protected _scene: Scene;
  28702. private _engine;
  28703. private _options;
  28704. private _reusable;
  28705. private _textureType;
  28706. private _textureFormat;
  28707. /**
  28708. * Smart array of input and output textures for the post process.
  28709. * @hidden
  28710. */
  28711. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28712. /**
  28713. * The index in _textures that corresponds to the output texture.
  28714. * @hidden
  28715. */
  28716. _currentRenderTextureInd: number;
  28717. private _effect;
  28718. private _samplers;
  28719. private _fragmentUrl;
  28720. private _vertexUrl;
  28721. private _parameters;
  28722. private _scaleRatio;
  28723. protected _indexParameters: any;
  28724. private _shareOutputWithPostProcess;
  28725. private _texelSize;
  28726. private _forcedOutputTexture;
  28727. /**
  28728. * Prepass configuration in case this post process needs a texture from prepass
  28729. * @hidden
  28730. */
  28731. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28732. /**
  28733. * Returns the fragment url or shader name used in the post process.
  28734. * @returns the fragment url or name in the shader store.
  28735. */
  28736. getEffectName(): string;
  28737. /**
  28738. * An event triggered when the postprocess is activated.
  28739. */
  28740. onActivateObservable: Observable<Camera>;
  28741. private _onActivateObserver;
  28742. /**
  28743. * A function that is added to the onActivateObservable
  28744. */
  28745. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28746. /**
  28747. * An event triggered when the postprocess changes its size.
  28748. */
  28749. onSizeChangedObservable: Observable<PostProcess>;
  28750. private _onSizeChangedObserver;
  28751. /**
  28752. * A function that is added to the onSizeChangedObservable
  28753. */
  28754. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28755. /**
  28756. * An event triggered when the postprocess applies its effect.
  28757. */
  28758. onApplyObservable: Observable<Effect>;
  28759. private _onApplyObserver;
  28760. /**
  28761. * A function that is added to the onApplyObservable
  28762. */
  28763. set onApply(callback: (effect: Effect) => void);
  28764. /**
  28765. * An event triggered before rendering the postprocess
  28766. */
  28767. onBeforeRenderObservable: Observable<Effect>;
  28768. private _onBeforeRenderObserver;
  28769. /**
  28770. * A function that is added to the onBeforeRenderObservable
  28771. */
  28772. set onBeforeRender(callback: (effect: Effect) => void);
  28773. /**
  28774. * An event triggered after rendering the postprocess
  28775. */
  28776. onAfterRenderObservable: Observable<Effect>;
  28777. private _onAfterRenderObserver;
  28778. /**
  28779. * A function that is added to the onAfterRenderObservable
  28780. */
  28781. set onAfterRender(callback: (efect: Effect) => void);
  28782. /**
  28783. * 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
  28784. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28785. */
  28786. get inputTexture(): InternalTexture;
  28787. set inputTexture(value: InternalTexture);
  28788. /**
  28789. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28790. * the only way to unset it is to use this function to restore its internal state
  28791. */
  28792. restoreDefaultInputTexture(): void;
  28793. /**
  28794. * Gets the camera which post process is applied to.
  28795. * @returns The camera the post process is applied to.
  28796. */
  28797. getCamera(): Camera;
  28798. /**
  28799. * Gets the texel size of the postprocess.
  28800. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28801. */
  28802. get texelSize(): Vector2;
  28803. /**
  28804. * Creates a new instance PostProcess
  28805. * @param name The name of the PostProcess.
  28806. * @param fragmentUrl The url of the fragment shader to be used.
  28807. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28808. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28809. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28810. * @param camera The camera to apply the render pass to.
  28811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28812. * @param engine The engine which the post process will be applied. (default: current engine)
  28813. * @param reusable If the post process can be reused on the same frame. (default: false)
  28814. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28815. * @param textureType Type of textures used when performing the post process. (default: 0)
  28816. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28817. * @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
  28818. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28819. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28820. */
  28821. 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);
  28822. /**
  28823. * Gets a string identifying the name of the class
  28824. * @returns "PostProcess" string
  28825. */
  28826. getClassName(): string;
  28827. /**
  28828. * Gets the engine which this post process belongs to.
  28829. * @returns The engine the post process was enabled with.
  28830. */
  28831. getEngine(): Engine;
  28832. /**
  28833. * The effect that is created when initializing the post process.
  28834. * @returns The created effect corresponding the the postprocess.
  28835. */
  28836. getEffect(): Effect;
  28837. /**
  28838. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28839. * @param postProcess The post process to share the output with.
  28840. * @returns This post process.
  28841. */
  28842. shareOutputWith(postProcess: PostProcess): PostProcess;
  28843. /**
  28844. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28845. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28846. */
  28847. useOwnOutput(): void;
  28848. /**
  28849. * Updates the effect with the current post process compile time values and recompiles the shader.
  28850. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28851. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28852. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28853. * @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
  28854. * @param onCompiled Called when the shader has been compiled.
  28855. * @param onError Called if there is an error when compiling a shader.
  28856. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28857. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28858. */
  28859. 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;
  28860. /**
  28861. * The post process is reusable if it can be used multiple times within one frame.
  28862. * @returns If the post process is reusable
  28863. */
  28864. isReusable(): boolean;
  28865. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28866. markTextureDirty(): void;
  28867. /**
  28868. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28869. * 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.
  28870. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28871. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28872. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28873. * @returns The target texture that was bound to be written to.
  28874. */
  28875. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28876. /**
  28877. * If the post process is supported.
  28878. */
  28879. get isSupported(): boolean;
  28880. /**
  28881. * The aspect ratio of the output texture.
  28882. */
  28883. get aspectRatio(): number;
  28884. /**
  28885. * Get a value indicating if the post-process is ready to be used
  28886. * @returns true if the post-process is ready (shader is compiled)
  28887. */
  28888. isReady(): boolean;
  28889. /**
  28890. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28891. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28892. */
  28893. apply(): Nullable<Effect>;
  28894. private _disposeTextures;
  28895. /**
  28896. * Sets the required values to the prepass renderer.
  28897. * @param prePassRenderer defines the prepass renderer to setup.
  28898. * @returns true if the pre pass is needed.
  28899. */
  28900. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28901. /**
  28902. * Disposes the post process.
  28903. * @param camera The camera to dispose the post process on.
  28904. */
  28905. dispose(camera?: Camera): void;
  28906. /**
  28907. * Serializes the particle system to a JSON object
  28908. * @returns the JSON object
  28909. */
  28910. serialize(): any;
  28911. /**
  28912. * Creates a material from parsed material data
  28913. * @param parsedPostProcess defines parsed post process data
  28914. * @param scene defines the hosting scene
  28915. * @param rootUrl defines the root URL to use to load textures
  28916. * @returns a new post process
  28917. */
  28918. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28919. }
  28920. }
  28921. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28922. /** @hidden */
  28923. export var kernelBlurVaryingDeclaration: {
  28924. name: string;
  28925. shader: string;
  28926. };
  28927. }
  28928. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28929. /** @hidden */
  28930. export var kernelBlurFragment: {
  28931. name: string;
  28932. shader: string;
  28933. };
  28934. }
  28935. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28936. /** @hidden */
  28937. export var kernelBlurFragment2: {
  28938. name: string;
  28939. shader: string;
  28940. };
  28941. }
  28942. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28943. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28944. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28945. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28946. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28947. /** @hidden */
  28948. export var kernelBlurPixelShader: {
  28949. name: string;
  28950. shader: string;
  28951. };
  28952. }
  28953. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28954. /** @hidden */
  28955. export var kernelBlurVertex: {
  28956. name: string;
  28957. shader: string;
  28958. };
  28959. }
  28960. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28961. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28962. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28963. /** @hidden */
  28964. export var kernelBlurVertexShader: {
  28965. name: string;
  28966. shader: string;
  28967. };
  28968. }
  28969. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28970. import { Vector2 } from "babylonjs/Maths/math.vector";
  28971. import { Nullable } from "babylonjs/types";
  28972. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28973. import { Camera } from "babylonjs/Cameras/camera";
  28974. import { Effect } from "babylonjs/Materials/effect";
  28975. import { Engine } from "babylonjs/Engines/engine";
  28976. import "babylonjs/Shaders/kernelBlur.fragment";
  28977. import "babylonjs/Shaders/kernelBlur.vertex";
  28978. import { Scene } from "babylonjs/scene";
  28979. /**
  28980. * The Blur Post Process which blurs an image based on a kernel and direction.
  28981. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28982. */
  28983. export class BlurPostProcess extends PostProcess {
  28984. private blockCompilation;
  28985. protected _kernel: number;
  28986. protected _idealKernel: number;
  28987. protected _packedFloat: boolean;
  28988. private _staticDefines;
  28989. /** The direction in which to blur the image. */
  28990. direction: Vector2;
  28991. /**
  28992. * Sets the length in pixels of the blur sample region
  28993. */
  28994. set kernel(v: number);
  28995. /**
  28996. * Gets the length in pixels of the blur sample region
  28997. */
  28998. get kernel(): number;
  28999. /**
  29000. * Sets wether or not the blur needs to unpack/repack floats
  29001. */
  29002. set packedFloat(v: boolean);
  29003. /**
  29004. * Gets wether or not the blur is unpacking/repacking floats
  29005. */
  29006. get packedFloat(): boolean;
  29007. /**
  29008. * Gets a string identifying the name of the class
  29009. * @returns "BlurPostProcess" string
  29010. */
  29011. getClassName(): string;
  29012. /**
  29013. * Creates a new instance BlurPostProcess
  29014. * @param name The name of the effect.
  29015. * @param direction The direction in which to blur the image.
  29016. * @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.
  29017. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29018. * @param camera The camera to apply the render pass to.
  29019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29020. * @param engine The engine which the post process will be applied. (default: current engine)
  29021. * @param reusable If the post process can be reused on the same frame. (default: false)
  29022. * @param textureType Type of textures used when performing the post process. (default: 0)
  29023. * @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)
  29024. */
  29025. 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);
  29026. /**
  29027. * Updates the effect with the current post process compile time values and recompiles the shader.
  29028. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29029. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29030. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29031. * @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
  29032. * @param onCompiled Called when the shader has been compiled.
  29033. * @param onError Called if there is an error when compiling a shader.
  29034. */
  29035. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29036. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29037. /**
  29038. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29039. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29040. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29041. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29042. * The gaps between physical kernels are compensated for in the weighting of the samples
  29043. * @param idealKernel Ideal blur kernel.
  29044. * @return Nearest best kernel.
  29045. */
  29046. protected _nearestBestKernel(idealKernel: number): number;
  29047. /**
  29048. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29049. * @param x The point on the Gaussian distribution to sample.
  29050. * @return the value of the Gaussian function at x.
  29051. */
  29052. protected _gaussianWeight(x: number): number;
  29053. /**
  29054. * Generates a string that can be used as a floating point number in GLSL.
  29055. * @param x Value to print.
  29056. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29057. * @return GLSL float string.
  29058. */
  29059. protected _glslFloat(x: number, decimalFigures?: number): string;
  29060. /** @hidden */
  29061. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29062. }
  29063. }
  29064. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29065. import { Scene } from "babylonjs/scene";
  29066. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29067. import { Plane } from "babylonjs/Maths/math.plane";
  29068. /**
  29069. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29070. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29071. * You can then easily use it as a reflectionTexture on a flat surface.
  29072. * In case the surface is not a plane, please consider relying on reflection probes.
  29073. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29074. */
  29075. export class MirrorTexture extends RenderTargetTexture {
  29076. private scene;
  29077. /**
  29078. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29079. * 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.
  29080. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29081. */
  29082. mirrorPlane: Plane;
  29083. /**
  29084. * Define the blur ratio used to blur the reflection if needed.
  29085. */
  29086. set blurRatio(value: number);
  29087. get blurRatio(): number;
  29088. /**
  29089. * Define the adaptive blur kernel used to blur the reflection if needed.
  29090. * This will autocompute the closest best match for the `blurKernel`
  29091. */
  29092. set adaptiveBlurKernel(value: number);
  29093. /**
  29094. * Define the blur kernel used to blur the reflection if needed.
  29095. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29096. */
  29097. set blurKernel(value: number);
  29098. /**
  29099. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29100. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29101. */
  29102. set blurKernelX(value: number);
  29103. get blurKernelX(): number;
  29104. /**
  29105. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29106. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29107. */
  29108. set blurKernelY(value: number);
  29109. get blurKernelY(): number;
  29110. private _autoComputeBlurKernel;
  29111. protected _onRatioRescale(): void;
  29112. private _updateGammaSpace;
  29113. private _imageProcessingConfigChangeObserver;
  29114. private _transformMatrix;
  29115. private _mirrorMatrix;
  29116. private _savedViewMatrix;
  29117. private _blurX;
  29118. private _blurY;
  29119. private _adaptiveBlurKernel;
  29120. private _blurKernelX;
  29121. private _blurKernelY;
  29122. private _blurRatio;
  29123. /**
  29124. * Instantiates a Mirror Texture.
  29125. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29126. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29127. * You can then easily use it as a reflectionTexture on a flat surface.
  29128. * In case the surface is not a plane, please consider relying on reflection probes.
  29129. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29130. * @param name
  29131. * @param size
  29132. * @param scene
  29133. * @param generateMipMaps
  29134. * @param type
  29135. * @param samplingMode
  29136. * @param generateDepthBuffer
  29137. */
  29138. constructor(name: string, size: number | {
  29139. width: number;
  29140. height: number;
  29141. } | {
  29142. ratio: number;
  29143. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29144. private _preparePostProcesses;
  29145. /**
  29146. * Clone the mirror texture.
  29147. * @returns the cloned texture
  29148. */
  29149. clone(): MirrorTexture;
  29150. /**
  29151. * Serialize the texture to a JSON representation you could use in Parse later on
  29152. * @returns the serialized JSON representation
  29153. */
  29154. serialize(): any;
  29155. /**
  29156. * Dispose the texture and release its associated resources.
  29157. */
  29158. dispose(): void;
  29159. }
  29160. }
  29161. declare module "babylonjs/Materials/Textures/texture" {
  29162. import { Observable } from "babylonjs/Misc/observable";
  29163. import { Nullable } from "babylonjs/types";
  29164. import { Matrix } from "babylonjs/Maths/math.vector";
  29165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29166. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29167. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29168. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29169. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29170. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29171. import { Scene } from "babylonjs/scene";
  29172. /**
  29173. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29174. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29175. */
  29176. export class Texture extends BaseTexture {
  29177. /**
  29178. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29179. */
  29180. static SerializeBuffers: boolean;
  29181. /** @hidden */
  29182. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29183. /** @hidden */
  29184. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29185. /** @hidden */
  29186. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29187. /** nearest is mag = nearest and min = nearest and mip = linear */
  29188. static readonly NEAREST_SAMPLINGMODE: number;
  29189. /** nearest is mag = nearest and min = nearest and mip = linear */
  29190. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29192. static readonly BILINEAR_SAMPLINGMODE: number;
  29193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29194. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29195. /** Trilinear is mag = linear and min = linear and mip = linear */
  29196. static readonly TRILINEAR_SAMPLINGMODE: number;
  29197. /** Trilinear is mag = linear and min = linear and mip = linear */
  29198. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29199. /** mag = nearest and min = nearest and mip = nearest */
  29200. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29201. /** mag = nearest and min = linear and mip = nearest */
  29202. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29203. /** mag = nearest and min = linear and mip = linear */
  29204. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29205. /** mag = nearest and min = linear and mip = none */
  29206. static readonly NEAREST_LINEAR: number;
  29207. /** mag = nearest and min = nearest and mip = none */
  29208. static readonly NEAREST_NEAREST: number;
  29209. /** mag = linear and min = nearest and mip = nearest */
  29210. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29211. /** mag = linear and min = nearest and mip = linear */
  29212. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29213. /** mag = linear and min = linear and mip = none */
  29214. static readonly LINEAR_LINEAR: number;
  29215. /** mag = linear and min = nearest and mip = none */
  29216. static readonly LINEAR_NEAREST: number;
  29217. /** Explicit coordinates mode */
  29218. static readonly EXPLICIT_MODE: number;
  29219. /** Spherical coordinates mode */
  29220. static readonly SPHERICAL_MODE: number;
  29221. /** Planar coordinates mode */
  29222. static readonly PLANAR_MODE: number;
  29223. /** Cubic coordinates mode */
  29224. static readonly CUBIC_MODE: number;
  29225. /** Projection coordinates mode */
  29226. static readonly PROJECTION_MODE: number;
  29227. /** Inverse Cubic coordinates mode */
  29228. static readonly SKYBOX_MODE: number;
  29229. /** Inverse Cubic coordinates mode */
  29230. static readonly INVCUBIC_MODE: number;
  29231. /** Equirectangular coordinates mode */
  29232. static readonly EQUIRECTANGULAR_MODE: number;
  29233. /** Equirectangular Fixed coordinates mode */
  29234. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29235. /** Equirectangular Fixed Mirrored coordinates mode */
  29236. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29237. /** Texture is not repeating outside of 0..1 UVs */
  29238. static readonly CLAMP_ADDRESSMODE: number;
  29239. /** Texture is repeating outside of 0..1 UVs */
  29240. static readonly WRAP_ADDRESSMODE: number;
  29241. /** Texture is repeating and mirrored */
  29242. static readonly MIRROR_ADDRESSMODE: number;
  29243. /**
  29244. * 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
  29245. */
  29246. static UseSerializedUrlIfAny: boolean;
  29247. /**
  29248. * Define the url of the texture.
  29249. */
  29250. url: Nullable<string>;
  29251. /**
  29252. * Define an offset on the texture to offset the u coordinates of the UVs
  29253. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29254. */
  29255. uOffset: number;
  29256. /**
  29257. * Define an offset on the texture to offset the v coordinates of the UVs
  29258. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29259. */
  29260. vOffset: number;
  29261. /**
  29262. * Define an offset on the texture to scale the u coordinates of the UVs
  29263. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29264. */
  29265. uScale: number;
  29266. /**
  29267. * Define an offset on the texture to scale the v coordinates of the UVs
  29268. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29269. */
  29270. vScale: number;
  29271. /**
  29272. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29273. * @see https://doc.babylonjs.com/how_to/more_materials
  29274. */
  29275. uAng: number;
  29276. /**
  29277. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29278. * @see https://doc.babylonjs.com/how_to/more_materials
  29279. */
  29280. vAng: number;
  29281. /**
  29282. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29283. * @see https://doc.babylonjs.com/how_to/more_materials
  29284. */
  29285. wAng: number;
  29286. /**
  29287. * Defines the center of rotation (U)
  29288. */
  29289. uRotationCenter: number;
  29290. /**
  29291. * Defines the center of rotation (V)
  29292. */
  29293. vRotationCenter: number;
  29294. /**
  29295. * Defines the center of rotation (W)
  29296. */
  29297. wRotationCenter: number;
  29298. /**
  29299. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29300. */
  29301. homogeneousRotationInUVTransform: boolean;
  29302. /**
  29303. * Are mip maps generated for this texture or not.
  29304. */
  29305. get noMipmap(): boolean;
  29306. /**
  29307. * List of inspectable custom properties (used by the Inspector)
  29308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29309. */
  29310. inspectableCustomProperties: Nullable<IInspectable[]>;
  29311. private _noMipmap;
  29312. /** @hidden */
  29313. _invertY: boolean;
  29314. private _rowGenerationMatrix;
  29315. private _cachedTextureMatrix;
  29316. private _projectionModeMatrix;
  29317. private _t0;
  29318. private _t1;
  29319. private _t2;
  29320. private _cachedUOffset;
  29321. private _cachedVOffset;
  29322. private _cachedUScale;
  29323. private _cachedVScale;
  29324. private _cachedUAng;
  29325. private _cachedVAng;
  29326. private _cachedWAng;
  29327. private _cachedProjectionMatrixId;
  29328. private _cachedURotationCenter;
  29329. private _cachedVRotationCenter;
  29330. private _cachedWRotationCenter;
  29331. private _cachedHomogeneousRotationInUVTransform;
  29332. private _cachedCoordinatesMode;
  29333. /** @hidden */
  29334. protected _initialSamplingMode: number;
  29335. /** @hidden */
  29336. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29337. private _deleteBuffer;
  29338. protected _format: Nullable<number>;
  29339. private _delayedOnLoad;
  29340. private _delayedOnError;
  29341. private _mimeType?;
  29342. private _loaderOptions?;
  29343. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29344. get mimeType(): string | undefined;
  29345. /**
  29346. * Observable triggered once the texture has been loaded.
  29347. */
  29348. onLoadObservable: Observable<Texture>;
  29349. protected _isBlocking: boolean;
  29350. /**
  29351. * Is the texture preventing material to render while loading.
  29352. * If false, a default texture will be used instead of the loading one during the preparation step.
  29353. */
  29354. set isBlocking(value: boolean);
  29355. get isBlocking(): boolean;
  29356. /**
  29357. * Get the current sampling mode associated with the texture.
  29358. */
  29359. get samplingMode(): number;
  29360. /**
  29361. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29362. */
  29363. get invertY(): boolean;
  29364. /**
  29365. * Instantiates a new texture.
  29366. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29367. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29368. * @param url defines the url of the picture to load as a texture
  29369. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29370. * @param noMipmap defines if the texture will require mip maps or not
  29371. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29372. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29373. * @param onLoad defines a callback triggered when the texture has been loaded
  29374. * @param onError defines a callback triggered when an error occurred during the loading session
  29375. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29376. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29377. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29378. * @param mimeType defines an optional mime type information
  29379. * @param loaderOptions options to be passed to the loader
  29380. */
  29381. 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, loaderOptions?: any);
  29382. /**
  29383. * Update the url (and optional buffer) of this texture if url was null during construction.
  29384. * @param url the url of the texture
  29385. * @param buffer the buffer of the texture (defaults to null)
  29386. * @param onLoad callback called when the texture is loaded (defaults to null)
  29387. */
  29388. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29389. /**
  29390. * Finish the loading sequence of a texture flagged as delayed load.
  29391. * @hidden
  29392. */
  29393. delayLoad(): void;
  29394. private _prepareRowForTextureGeneration;
  29395. /**
  29396. * Checks if the texture has the same transform matrix than another texture
  29397. * @param texture texture to check against
  29398. * @returns true if the transforms are the same, else false
  29399. */
  29400. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29401. /**
  29402. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29403. * @returns the transform matrix of the texture.
  29404. */
  29405. getTextureMatrix(uBase?: number): Matrix;
  29406. /**
  29407. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29408. * @returns The reflection texture transform
  29409. */
  29410. getReflectionTextureMatrix(): Matrix;
  29411. /**
  29412. * Clones the texture.
  29413. * @returns the cloned texture
  29414. */
  29415. clone(): Texture;
  29416. /**
  29417. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29418. * @returns The JSON representation of the texture
  29419. */
  29420. serialize(): any;
  29421. /**
  29422. * Get the current class name of the texture useful for serialization or dynamic coding.
  29423. * @returns "Texture"
  29424. */
  29425. getClassName(): string;
  29426. /**
  29427. * Dispose the texture and release its associated resources.
  29428. */
  29429. dispose(): void;
  29430. /**
  29431. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29432. * @param parsedTexture Define the JSON representation of the texture
  29433. * @param scene Define the scene the parsed texture should be instantiated in
  29434. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29435. * @returns The parsed texture if successful
  29436. */
  29437. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29438. /**
  29439. * Creates a texture from its base 64 representation.
  29440. * @param data Define the base64 payload without the data: prefix
  29441. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29442. * @param scene Define the scene the texture should belong to
  29443. * @param noMipmap Forces the texture to not create mip map information if true
  29444. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29445. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29446. * @param onLoad define a callback triggered when the texture has been loaded
  29447. * @param onError define a callback triggered when an error occurred during the loading session
  29448. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29449. * @returns the created texture
  29450. */
  29451. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29452. /**
  29453. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29454. * @param data Define the base64 payload without the data: prefix
  29455. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29456. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29457. * @param scene Define the scene the texture should belong to
  29458. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29459. * @param noMipmap Forces the texture to not create mip map information if true
  29460. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29461. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29462. * @param onLoad define a callback triggered when the texture has been loaded
  29463. * @param onError define a callback triggered when an error occurred during the loading session
  29464. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29465. * @returns the created texture
  29466. */
  29467. 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;
  29468. }
  29469. }
  29470. declare module "babylonjs/PostProcesses/postProcessManager" {
  29471. import { Nullable } from "babylonjs/types";
  29472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29473. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29474. import { Scene } from "babylonjs/scene";
  29475. /**
  29476. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29477. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29478. */
  29479. export class PostProcessManager {
  29480. private _scene;
  29481. private _indexBuffer;
  29482. private _vertexBuffers;
  29483. /**
  29484. * Creates a new instance PostProcess
  29485. * @param scene The scene that the post process is associated with.
  29486. */
  29487. constructor(scene: Scene);
  29488. private _prepareBuffers;
  29489. private _buildIndexBuffer;
  29490. /**
  29491. * Rebuilds the vertex buffers of the manager.
  29492. * @hidden
  29493. */
  29494. _rebuild(): void;
  29495. /**
  29496. * Prepares a frame to be run through a post process.
  29497. * @param sourceTexture The input texture to the post procesess. (default: null)
  29498. * @param postProcesses An array of post processes to be run. (default: null)
  29499. * @returns True if the post processes were able to be run.
  29500. * @hidden
  29501. */
  29502. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29503. /**
  29504. * Manually render a set of post processes to a texture.
  29505. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29506. * @param postProcesses An array of post processes to be run.
  29507. * @param targetTexture The target texture to render to.
  29508. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29509. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29510. * @param lodLevel defines which lod of the texture to render to
  29511. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29512. */
  29513. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29514. /**
  29515. * Finalize the result of the output of the postprocesses.
  29516. * @param doNotPresent If true the result will not be displayed to the screen.
  29517. * @param targetTexture The target texture to render to.
  29518. * @param faceIndex The index of the face to bind the target texture to.
  29519. * @param postProcesses The array of post processes to render.
  29520. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29521. * @hidden
  29522. */
  29523. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29524. /**
  29525. * Disposes of the post process manager.
  29526. */
  29527. dispose(): void;
  29528. }
  29529. }
  29530. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29531. import { Observable } from "babylonjs/Misc/observable";
  29532. import { SmartArray } from "babylonjs/Misc/smartArray";
  29533. import { Nullable, Immutable } from "babylonjs/types";
  29534. import { Camera } from "babylonjs/Cameras/camera";
  29535. import { Scene } from "babylonjs/scene";
  29536. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29537. import { Color4 } from "babylonjs/Maths/math.color";
  29538. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29540. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29542. import { Texture } from "babylonjs/Materials/Textures/texture";
  29543. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29544. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29545. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29546. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29547. import { Engine } from "babylonjs/Engines/engine";
  29548. /**
  29549. * This Helps creating a texture that will be created from a camera in your scene.
  29550. * It is basically a dynamic texture that could be used to create special effects for instance.
  29551. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29552. */
  29553. export class RenderTargetTexture extends Texture {
  29554. /**
  29555. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29556. */
  29557. static readonly REFRESHRATE_RENDER_ONCE: number;
  29558. /**
  29559. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29560. */
  29561. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29562. /**
  29563. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29564. * the central point of your effect and can save a lot of performances.
  29565. */
  29566. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29567. /**
  29568. * Use this predicate to dynamically define the list of mesh you want to render.
  29569. * If set, the renderList property will be overwritten.
  29570. */
  29571. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29572. private _renderList;
  29573. /**
  29574. * Use this list to define the list of mesh you want to render.
  29575. */
  29576. get renderList(): Nullable<Array<AbstractMesh>>;
  29577. set renderList(value: Nullable<Array<AbstractMesh>>);
  29578. /**
  29579. * Use this function to overload the renderList array at rendering time.
  29580. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29581. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29582. * the cube (if the RTT is a cube, else layerOrFace=0).
  29583. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29584. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29585. * hold dummy elements!
  29586. */
  29587. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29588. private _hookArray;
  29589. /**
  29590. * Define if particles should be rendered in your texture.
  29591. */
  29592. renderParticles: boolean;
  29593. /**
  29594. * Define if sprites should be rendered in your texture.
  29595. */
  29596. renderSprites: boolean;
  29597. /**
  29598. * Define the camera used to render the texture.
  29599. */
  29600. activeCamera: Nullable<Camera>;
  29601. /**
  29602. * Override the mesh isReady function with your own one.
  29603. */
  29604. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29605. /**
  29606. * Override the render function of the texture with your own one.
  29607. */
  29608. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29609. /**
  29610. * Define if camera post processes should be use while rendering the texture.
  29611. */
  29612. useCameraPostProcesses: boolean;
  29613. /**
  29614. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29615. */
  29616. ignoreCameraViewport: boolean;
  29617. private _postProcessManager;
  29618. private _postProcesses;
  29619. private _resizeObserver;
  29620. /**
  29621. * An event triggered when the texture is unbind.
  29622. */
  29623. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29624. /**
  29625. * An event triggered when the texture is unbind.
  29626. */
  29627. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29628. private _onAfterUnbindObserver;
  29629. /**
  29630. * Set a after unbind callback in the texture.
  29631. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29632. */
  29633. set onAfterUnbind(callback: () => void);
  29634. /**
  29635. * An event triggered before rendering the texture
  29636. */
  29637. onBeforeRenderObservable: Observable<number>;
  29638. private _onBeforeRenderObserver;
  29639. /**
  29640. * Set a before render callback in the texture.
  29641. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29642. */
  29643. set onBeforeRender(callback: (faceIndex: number) => void);
  29644. /**
  29645. * An event triggered after rendering the texture
  29646. */
  29647. onAfterRenderObservable: Observable<number>;
  29648. private _onAfterRenderObserver;
  29649. /**
  29650. * Set a after render callback in the texture.
  29651. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29652. */
  29653. set onAfterRender(callback: (faceIndex: number) => void);
  29654. /**
  29655. * An event triggered after the texture clear
  29656. */
  29657. onClearObservable: Observable<Engine>;
  29658. private _onClearObserver;
  29659. /**
  29660. * Set a clear callback in the texture.
  29661. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29662. */
  29663. set onClear(callback: (Engine: Engine) => void);
  29664. /**
  29665. * An event triggered when the texture is resized.
  29666. */
  29667. onResizeObservable: Observable<RenderTargetTexture>;
  29668. /**
  29669. * Define the clear color of the Render Target if it should be different from the scene.
  29670. */
  29671. clearColor: Color4;
  29672. protected _size: number | {
  29673. width: number;
  29674. height: number;
  29675. layers?: number;
  29676. };
  29677. protected _initialSizeParameter: number | {
  29678. width: number;
  29679. height: number;
  29680. } | {
  29681. ratio: number;
  29682. };
  29683. protected _sizeRatio: Nullable<number>;
  29684. /** @hidden */
  29685. _generateMipMaps: boolean;
  29686. protected _renderingManager: RenderingManager;
  29687. /** @hidden */
  29688. _waitingRenderList?: string[];
  29689. protected _doNotChangeAspectRatio: boolean;
  29690. protected _currentRefreshId: number;
  29691. protected _refreshRate: number;
  29692. protected _textureMatrix: Matrix;
  29693. protected _samples: number;
  29694. protected _renderTargetOptions: RenderTargetCreationOptions;
  29695. /**
  29696. * Gets render target creation options that were used.
  29697. */
  29698. get renderTargetOptions(): RenderTargetCreationOptions;
  29699. protected _onRatioRescale(): void;
  29700. /**
  29701. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29702. * It must define where the camera used to render the texture is set
  29703. */
  29704. boundingBoxPosition: Vector3;
  29705. private _boundingBoxSize;
  29706. /**
  29707. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29708. * When defined, the cubemap will switch to local mode
  29709. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29710. * @example https://www.babylonjs-playground.com/#RNASML
  29711. */
  29712. set boundingBoxSize(value: Vector3);
  29713. get boundingBoxSize(): Vector3;
  29714. /**
  29715. * In case the RTT has been created with a depth texture, get the associated
  29716. * depth texture.
  29717. * Otherwise, return null.
  29718. */
  29719. get depthStencilTexture(): Nullable<InternalTexture>;
  29720. /**
  29721. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29722. * or used a shadow, depth texture...
  29723. * @param name The friendly name of the texture
  29724. * @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)
  29725. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29726. * @param generateMipMaps True if mip maps need to be generated after render.
  29727. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29728. * @param type The type of the buffer in the RTT (int, half float, float...)
  29729. * @param isCube True if a cube texture needs to be created
  29730. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29731. * @param generateDepthBuffer True to generate a depth buffer
  29732. * @param generateStencilBuffer True to generate a stencil buffer
  29733. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29734. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29735. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29736. */
  29737. constructor(name: string, size: number | {
  29738. width: number;
  29739. height: number;
  29740. layers?: number;
  29741. } | {
  29742. ratio: number;
  29743. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29744. /**
  29745. * Creates a depth stencil texture.
  29746. * This is only available in WebGL 2 or with the depth texture extension available.
  29747. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29748. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29749. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29750. */
  29751. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29752. private _processSizeParameter;
  29753. /**
  29754. * Define the number of samples to use in case of MSAA.
  29755. * It defaults to one meaning no MSAA has been enabled.
  29756. */
  29757. get samples(): number;
  29758. set samples(value: number);
  29759. /**
  29760. * Resets the refresh counter of the texture and start bak from scratch.
  29761. * Could be useful to regenerate the texture if it is setup to render only once.
  29762. */
  29763. resetRefreshCounter(): void;
  29764. /**
  29765. * Define the refresh rate of the texture or the rendering frequency.
  29766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29767. */
  29768. get refreshRate(): number;
  29769. set refreshRate(value: number);
  29770. /**
  29771. * Adds a post process to the render target rendering passes.
  29772. * @param postProcess define the post process to add
  29773. */
  29774. addPostProcess(postProcess: PostProcess): void;
  29775. /**
  29776. * Clear all the post processes attached to the render target
  29777. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29778. */
  29779. clearPostProcesses(dispose?: boolean): void;
  29780. /**
  29781. * Remove one of the post process from the list of attached post processes to the texture
  29782. * @param postProcess define the post process to remove from the list
  29783. */
  29784. removePostProcess(postProcess: PostProcess): void;
  29785. /** @hidden */
  29786. _shouldRender(): boolean;
  29787. /**
  29788. * Gets the actual render size of the texture.
  29789. * @returns the width of the render size
  29790. */
  29791. getRenderSize(): number;
  29792. /**
  29793. * Gets the actual render width of the texture.
  29794. * @returns the width of the render size
  29795. */
  29796. getRenderWidth(): number;
  29797. /**
  29798. * Gets the actual render height of the texture.
  29799. * @returns the height of the render size
  29800. */
  29801. getRenderHeight(): number;
  29802. /**
  29803. * Gets the actual number of layers of the texture.
  29804. * @returns the number of layers
  29805. */
  29806. getRenderLayers(): number;
  29807. /**
  29808. * Get if the texture can be rescaled or not.
  29809. */
  29810. get canRescale(): boolean;
  29811. /**
  29812. * Resize the texture using a ratio.
  29813. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29814. */
  29815. scale(ratio: number): void;
  29816. /**
  29817. * Get the texture reflection matrix used to rotate/transform the reflection.
  29818. * @returns the reflection matrix
  29819. */
  29820. getReflectionTextureMatrix(): Matrix;
  29821. /**
  29822. * Resize the texture to a new desired size.
  29823. * Be carrefull as it will recreate all the data in the new texture.
  29824. * @param size Define the new size. It can be:
  29825. * - a number for squared texture,
  29826. * - an object containing { width: number, height: number }
  29827. * - or an object containing a ratio { ratio: number }
  29828. */
  29829. resize(size: number | {
  29830. width: number;
  29831. height: number;
  29832. } | {
  29833. ratio: number;
  29834. }): void;
  29835. private _defaultRenderListPrepared;
  29836. /**
  29837. * Renders all the objects from the render list into the texture.
  29838. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29839. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29840. */
  29841. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29842. private _bestReflectionRenderTargetDimension;
  29843. private _prepareRenderingManager;
  29844. /**
  29845. * @hidden
  29846. * @param faceIndex face index to bind to if this is a cubetexture
  29847. * @param layer defines the index of the texture to bind in the array
  29848. */
  29849. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29850. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29851. private renderToTarget;
  29852. /**
  29853. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29854. * This allowed control for front to back rendering or reversly depending of the special needs.
  29855. *
  29856. * @param renderingGroupId The rendering group id corresponding to its index
  29857. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29858. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29859. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29860. */
  29861. 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;
  29862. /**
  29863. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29864. *
  29865. * @param renderingGroupId The rendering group id corresponding to its index
  29866. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29867. */
  29868. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29869. /**
  29870. * Clones the texture.
  29871. * @returns the cloned texture
  29872. */
  29873. clone(): RenderTargetTexture;
  29874. /**
  29875. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29876. * @returns The JSON representation of the texture
  29877. */
  29878. serialize(): any;
  29879. /**
  29880. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29881. */
  29882. disposeFramebufferObjects(): void;
  29883. /**
  29884. * Dispose the texture and release its associated resources.
  29885. */
  29886. dispose(): void;
  29887. /** @hidden */
  29888. _rebuild(): void;
  29889. /**
  29890. * Clear the info related to rendering groups preventing retention point in material dispose.
  29891. */
  29892. freeRenderingGroups(): void;
  29893. /**
  29894. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29895. * @returns the view count
  29896. */
  29897. getViewCount(): number;
  29898. }
  29899. }
  29900. declare module "babylonjs/Misc/guid" {
  29901. /**
  29902. * Class used to manipulate GUIDs
  29903. */
  29904. export class GUID {
  29905. /**
  29906. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29907. * Be aware Math.random() could cause collisions, but:
  29908. * "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"
  29909. * @returns a pseudo random id
  29910. */
  29911. static RandomId(): string;
  29912. }
  29913. }
  29914. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29915. import { Nullable } from "babylonjs/types";
  29916. import { Scene } from "babylonjs/scene";
  29917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29918. import { Material } from "babylonjs/Materials/material";
  29919. import { Effect } from "babylonjs/Materials/effect";
  29920. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29921. /**
  29922. * Options to be used when creating a shadow depth material
  29923. */
  29924. export interface IIOptionShadowDepthMaterial {
  29925. /** Variables in the vertex shader code that need to have their names remapped.
  29926. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29927. * "var_name" should be either: worldPos or vNormalW
  29928. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29929. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29930. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29931. */
  29932. remappedVariables?: string[];
  29933. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29934. standalone?: boolean;
  29935. }
  29936. /**
  29937. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29938. */
  29939. export class ShadowDepthWrapper {
  29940. private _scene;
  29941. private _options?;
  29942. private _baseMaterial;
  29943. private _onEffectCreatedObserver;
  29944. private _subMeshToEffect;
  29945. private _subMeshToDepthEffect;
  29946. private _meshes;
  29947. /** @hidden */
  29948. _matriceNames: any;
  29949. /** Gets the standalone status of the wrapper */
  29950. get standalone(): boolean;
  29951. /** Gets the base material the wrapper is built upon */
  29952. get baseMaterial(): Material;
  29953. /**
  29954. * Instantiate a new shadow depth wrapper.
  29955. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29956. * generate the shadow depth map. For more information, please refer to the documentation:
  29957. * https://doc.babylonjs.com/babylon101/shadows
  29958. * @param baseMaterial Material to wrap
  29959. * @param scene Define the scene the material belongs to
  29960. * @param options Options used to create the wrapper
  29961. */
  29962. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29963. /**
  29964. * Gets the effect to use to generate the depth map
  29965. * @param subMesh subMesh to get the effect for
  29966. * @param shadowGenerator shadow generator to get the effect for
  29967. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29968. */
  29969. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29970. /**
  29971. * Specifies that the submesh is ready to be used for depth rendering
  29972. * @param subMesh submesh to check
  29973. * @param defines the list of defines to take into account when checking the effect
  29974. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29975. * @param useInstances specifies that instances should be used
  29976. * @returns a boolean indicating that the submesh is ready or not
  29977. */
  29978. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29979. /**
  29980. * Disposes the resources
  29981. */
  29982. dispose(): void;
  29983. private _makeEffect;
  29984. }
  29985. }
  29986. declare module "babylonjs/Materials/material" {
  29987. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29988. import { SmartArray } from "babylonjs/Misc/smartArray";
  29989. import { Observable } from "babylonjs/Misc/observable";
  29990. import { Nullable } from "babylonjs/types";
  29991. import { Scene } from "babylonjs/scene";
  29992. import { Matrix } from "babylonjs/Maths/math.vector";
  29993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29995. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29996. import { Effect } from "babylonjs/Materials/effect";
  29997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29998. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29999. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30000. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30001. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30002. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30003. import { Mesh } from "babylonjs/Meshes/mesh";
  30004. import { Animation } from "babylonjs/Animations/animation";
  30005. /**
  30006. * Options for compiling materials.
  30007. */
  30008. export interface IMaterialCompilationOptions {
  30009. /**
  30010. * Defines whether clip planes are enabled.
  30011. */
  30012. clipPlane: boolean;
  30013. /**
  30014. * Defines whether instances are enabled.
  30015. */
  30016. useInstances: boolean;
  30017. }
  30018. /**
  30019. * Options passed when calling customShaderNameResolve
  30020. */
  30021. export interface ICustomShaderNameResolveOptions {
  30022. /**
  30023. * 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
  30024. */
  30025. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30026. }
  30027. /**
  30028. * Base class for the main features of a material in Babylon.js
  30029. */
  30030. export class Material implements IAnimatable {
  30031. /**
  30032. * Returns the triangle fill mode
  30033. */
  30034. static readonly TriangleFillMode: number;
  30035. /**
  30036. * Returns the wireframe mode
  30037. */
  30038. static readonly WireFrameFillMode: number;
  30039. /**
  30040. * Returns the point fill mode
  30041. */
  30042. static readonly PointFillMode: number;
  30043. /**
  30044. * Returns the point list draw mode
  30045. */
  30046. static readonly PointListDrawMode: number;
  30047. /**
  30048. * Returns the line list draw mode
  30049. */
  30050. static readonly LineListDrawMode: number;
  30051. /**
  30052. * Returns the line loop draw mode
  30053. */
  30054. static readonly LineLoopDrawMode: number;
  30055. /**
  30056. * Returns the line strip draw mode
  30057. */
  30058. static readonly LineStripDrawMode: number;
  30059. /**
  30060. * Returns the triangle strip draw mode
  30061. */
  30062. static readonly TriangleStripDrawMode: number;
  30063. /**
  30064. * Returns the triangle fan draw mode
  30065. */
  30066. static readonly TriangleFanDrawMode: number;
  30067. /**
  30068. * Stores the clock-wise side orientation
  30069. */
  30070. static readonly ClockWiseSideOrientation: number;
  30071. /**
  30072. * Stores the counter clock-wise side orientation
  30073. */
  30074. static readonly CounterClockWiseSideOrientation: number;
  30075. /**
  30076. * The dirty texture flag value
  30077. */
  30078. static readonly TextureDirtyFlag: number;
  30079. /**
  30080. * The dirty light flag value
  30081. */
  30082. static readonly LightDirtyFlag: number;
  30083. /**
  30084. * The dirty fresnel flag value
  30085. */
  30086. static readonly FresnelDirtyFlag: number;
  30087. /**
  30088. * The dirty attribute flag value
  30089. */
  30090. static readonly AttributesDirtyFlag: number;
  30091. /**
  30092. * The dirty misc flag value
  30093. */
  30094. static readonly MiscDirtyFlag: number;
  30095. /**
  30096. * The dirty prepass flag value
  30097. */
  30098. static readonly PrePassDirtyFlag: number;
  30099. /**
  30100. * The all dirty flag value
  30101. */
  30102. static readonly AllDirtyFlag: number;
  30103. /**
  30104. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30105. */
  30106. static readonly MATERIAL_OPAQUE: number;
  30107. /**
  30108. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30109. */
  30110. static readonly MATERIAL_ALPHATEST: number;
  30111. /**
  30112. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30113. */
  30114. static readonly MATERIAL_ALPHABLEND: number;
  30115. /**
  30116. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30117. * They are also discarded below the alpha cutoff threshold to improve performances.
  30118. */
  30119. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30120. /**
  30121. * The Whiteout method is used to blend normals.
  30122. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30123. */
  30124. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30125. /**
  30126. * The Reoriented Normal Mapping method is used to blend normals.
  30127. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30128. */
  30129. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30130. /**
  30131. * Custom callback helping to override the default shader used in the material.
  30132. */
  30133. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30134. /**
  30135. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30136. */
  30137. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30138. /**
  30139. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30140. * This means that the material can keep using a previous shader while a new one is being compiled.
  30141. * This is mostly used when shader parallel compilation is supported (true by default)
  30142. */
  30143. allowShaderHotSwapping: boolean;
  30144. /**
  30145. * The ID of the material
  30146. */
  30147. id: string;
  30148. /**
  30149. * Gets or sets the unique id of the material
  30150. */
  30151. uniqueId: number;
  30152. /**
  30153. * The name of the material
  30154. */
  30155. name: string;
  30156. /**
  30157. * Gets or sets user defined metadata
  30158. */
  30159. metadata: any;
  30160. /**
  30161. * For internal use only. Please do not use.
  30162. */
  30163. reservedDataStore: any;
  30164. /**
  30165. * Specifies if the ready state should be checked on each call
  30166. */
  30167. checkReadyOnEveryCall: boolean;
  30168. /**
  30169. * Specifies if the ready state should be checked once
  30170. */
  30171. checkReadyOnlyOnce: boolean;
  30172. /**
  30173. * The state of the material
  30174. */
  30175. state: string;
  30176. /**
  30177. * If the material can be rendered to several textures with MRT extension
  30178. */
  30179. get canRenderToMRT(): boolean;
  30180. /**
  30181. * The alpha value of the material
  30182. */
  30183. protected _alpha: number;
  30184. /**
  30185. * List of inspectable custom properties (used by the Inspector)
  30186. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30187. */
  30188. inspectableCustomProperties: IInspectable[];
  30189. /**
  30190. * Sets the alpha value of the material
  30191. */
  30192. set alpha(value: number);
  30193. /**
  30194. * Gets the alpha value of the material
  30195. */
  30196. get alpha(): number;
  30197. /**
  30198. * Specifies if back face culling is enabled
  30199. */
  30200. protected _backFaceCulling: boolean;
  30201. /**
  30202. * Sets the back-face culling state
  30203. */
  30204. set backFaceCulling(value: boolean);
  30205. /**
  30206. * Gets the back-face culling state
  30207. */
  30208. get backFaceCulling(): boolean;
  30209. /**
  30210. * Stores the value for side orientation
  30211. */
  30212. sideOrientation: number;
  30213. /**
  30214. * Callback triggered when the material is compiled
  30215. */
  30216. onCompiled: Nullable<(effect: Effect) => void>;
  30217. /**
  30218. * Callback triggered when an error occurs
  30219. */
  30220. onError: Nullable<(effect: Effect, errors: string) => void>;
  30221. /**
  30222. * Callback triggered to get the render target textures
  30223. */
  30224. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30225. /**
  30226. * Gets a boolean indicating that current material needs to register RTT
  30227. */
  30228. get hasRenderTargetTextures(): boolean;
  30229. /**
  30230. * Specifies if the material should be serialized
  30231. */
  30232. doNotSerialize: boolean;
  30233. /**
  30234. * @hidden
  30235. */
  30236. _storeEffectOnSubMeshes: boolean;
  30237. /**
  30238. * Stores the animations for the material
  30239. */
  30240. animations: Nullable<Array<Animation>>;
  30241. /**
  30242. * An event triggered when the material is disposed
  30243. */
  30244. onDisposeObservable: Observable<Material>;
  30245. /**
  30246. * An observer which watches for dispose events
  30247. */
  30248. private _onDisposeObserver;
  30249. private _onUnBindObservable;
  30250. /**
  30251. * Called during a dispose event
  30252. */
  30253. set onDispose(callback: () => void);
  30254. private _onBindObservable;
  30255. /**
  30256. * An event triggered when the material is bound
  30257. */
  30258. get onBindObservable(): Observable<AbstractMesh>;
  30259. /**
  30260. * An observer which watches for bind events
  30261. */
  30262. private _onBindObserver;
  30263. /**
  30264. * Called during a bind event
  30265. */
  30266. set onBind(callback: (Mesh: AbstractMesh) => void);
  30267. /**
  30268. * An event triggered when the material is unbound
  30269. */
  30270. get onUnBindObservable(): Observable<Material>;
  30271. protected _onEffectCreatedObservable: Nullable<Observable<{
  30272. effect: Effect;
  30273. subMesh: Nullable<SubMesh>;
  30274. }>>;
  30275. /**
  30276. * An event triggered when the effect is (re)created
  30277. */
  30278. get onEffectCreatedObservable(): Observable<{
  30279. effect: Effect;
  30280. subMesh: Nullable<SubMesh>;
  30281. }>;
  30282. /**
  30283. * Stores the value of the alpha mode
  30284. */
  30285. private _alphaMode;
  30286. /**
  30287. * Sets the value of the alpha mode.
  30288. *
  30289. * | Value | Type | Description |
  30290. * | --- | --- | --- |
  30291. * | 0 | ALPHA_DISABLE | |
  30292. * | 1 | ALPHA_ADD | |
  30293. * | 2 | ALPHA_COMBINE | |
  30294. * | 3 | ALPHA_SUBTRACT | |
  30295. * | 4 | ALPHA_MULTIPLY | |
  30296. * | 5 | ALPHA_MAXIMIZED | |
  30297. * | 6 | ALPHA_ONEONE | |
  30298. * | 7 | ALPHA_PREMULTIPLIED | |
  30299. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30300. * | 9 | ALPHA_INTERPOLATE | |
  30301. * | 10 | ALPHA_SCREENMODE | |
  30302. *
  30303. */
  30304. set alphaMode(value: number);
  30305. /**
  30306. * Gets the value of the alpha mode
  30307. */
  30308. get alphaMode(): number;
  30309. /**
  30310. * Stores the state of the need depth pre-pass value
  30311. */
  30312. private _needDepthPrePass;
  30313. /**
  30314. * Sets the need depth pre-pass value
  30315. */
  30316. set needDepthPrePass(value: boolean);
  30317. /**
  30318. * Gets the depth pre-pass value
  30319. */
  30320. get needDepthPrePass(): boolean;
  30321. /**
  30322. * Specifies if depth writing should be disabled
  30323. */
  30324. disableDepthWrite: boolean;
  30325. /**
  30326. * Specifies if color writing should be disabled
  30327. */
  30328. disableColorWrite: boolean;
  30329. /**
  30330. * Specifies if depth writing should be forced
  30331. */
  30332. forceDepthWrite: boolean;
  30333. /**
  30334. * Specifies the depth function that should be used. 0 means the default engine function
  30335. */
  30336. depthFunction: number;
  30337. /**
  30338. * Specifies if there should be a separate pass for culling
  30339. */
  30340. separateCullingPass: boolean;
  30341. /**
  30342. * Stores the state specifing if fog should be enabled
  30343. */
  30344. private _fogEnabled;
  30345. /**
  30346. * Sets the state for enabling fog
  30347. */
  30348. set fogEnabled(value: boolean);
  30349. /**
  30350. * Gets the value of the fog enabled state
  30351. */
  30352. get fogEnabled(): boolean;
  30353. /**
  30354. * Stores the size of points
  30355. */
  30356. pointSize: number;
  30357. /**
  30358. * Stores the z offset value
  30359. */
  30360. zOffset: number;
  30361. get wireframe(): boolean;
  30362. /**
  30363. * Sets the state of wireframe mode
  30364. */
  30365. set wireframe(value: boolean);
  30366. /**
  30367. * Gets the value specifying if point clouds are enabled
  30368. */
  30369. get pointsCloud(): boolean;
  30370. /**
  30371. * Sets the state of point cloud mode
  30372. */
  30373. set pointsCloud(value: boolean);
  30374. /**
  30375. * Gets the material fill mode
  30376. */
  30377. get fillMode(): number;
  30378. /**
  30379. * Sets the material fill mode
  30380. */
  30381. set fillMode(value: number);
  30382. /**
  30383. * @hidden
  30384. * Stores the effects for the material
  30385. */
  30386. _effect: Nullable<Effect>;
  30387. /**
  30388. * Specifies if uniform buffers should be used
  30389. */
  30390. private _useUBO;
  30391. /**
  30392. * Stores a reference to the scene
  30393. */
  30394. private _scene;
  30395. /**
  30396. * Stores the fill mode state
  30397. */
  30398. private _fillMode;
  30399. /**
  30400. * Specifies if the depth write state should be cached
  30401. */
  30402. private _cachedDepthWriteState;
  30403. /**
  30404. * Specifies if the color write state should be cached
  30405. */
  30406. private _cachedColorWriteState;
  30407. /**
  30408. * Specifies if the depth function state should be cached
  30409. */
  30410. private _cachedDepthFunctionState;
  30411. /**
  30412. * Stores the uniform buffer
  30413. */
  30414. protected _uniformBuffer: UniformBuffer;
  30415. /** @hidden */
  30416. _indexInSceneMaterialArray: number;
  30417. /** @hidden */
  30418. meshMap: Nullable<{
  30419. [id: string]: AbstractMesh | undefined;
  30420. }>;
  30421. /**
  30422. * Creates a material instance
  30423. * @param name defines the name of the material
  30424. * @param scene defines the scene to reference
  30425. * @param doNotAdd specifies if the material should be added to the scene
  30426. */
  30427. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30428. /**
  30429. * Returns a string representation of the current material
  30430. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30431. * @returns a string with material information
  30432. */
  30433. toString(fullDetails?: boolean): string;
  30434. /**
  30435. * Gets the class name of the material
  30436. * @returns a string with the class name of the material
  30437. */
  30438. getClassName(): string;
  30439. /**
  30440. * Specifies if updates for the material been locked
  30441. */
  30442. get isFrozen(): boolean;
  30443. /**
  30444. * Locks updates for the material
  30445. */
  30446. freeze(): void;
  30447. /**
  30448. * Unlocks updates for the material
  30449. */
  30450. unfreeze(): void;
  30451. /**
  30452. * Specifies if the material is ready to be used
  30453. * @param mesh defines the mesh to check
  30454. * @param useInstances specifies if instances should be used
  30455. * @returns a boolean indicating if the material is ready to be used
  30456. */
  30457. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30458. /**
  30459. * Specifies that the submesh is ready to be used
  30460. * @param mesh defines the mesh to check
  30461. * @param subMesh defines which submesh to check
  30462. * @param useInstances specifies that instances should be used
  30463. * @returns a boolean indicating that the submesh is ready or not
  30464. */
  30465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30466. /**
  30467. * Returns the material effect
  30468. * @returns the effect associated with the material
  30469. */
  30470. getEffect(): Nullable<Effect>;
  30471. /**
  30472. * Returns the current scene
  30473. * @returns a Scene
  30474. */
  30475. getScene(): Scene;
  30476. /**
  30477. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30478. */
  30479. protected _forceAlphaTest: boolean;
  30480. /**
  30481. * The transparency mode of the material.
  30482. */
  30483. protected _transparencyMode: Nullable<number>;
  30484. /**
  30485. * Gets the current transparency mode.
  30486. */
  30487. get transparencyMode(): Nullable<number>;
  30488. /**
  30489. * Sets the transparency mode of the material.
  30490. *
  30491. * | Value | Type | Description |
  30492. * | ----- | ----------------------------------- | ----------- |
  30493. * | 0 | OPAQUE | |
  30494. * | 1 | ALPHATEST | |
  30495. * | 2 | ALPHABLEND | |
  30496. * | 3 | ALPHATESTANDBLEND | |
  30497. *
  30498. */
  30499. set transparencyMode(value: Nullable<number>);
  30500. /**
  30501. * Returns true if alpha blending should be disabled.
  30502. */
  30503. protected get _disableAlphaBlending(): boolean;
  30504. /**
  30505. * Specifies whether or not this material should be rendered in alpha blend mode.
  30506. * @returns a boolean specifying if alpha blending is needed
  30507. */
  30508. needAlphaBlending(): boolean;
  30509. /**
  30510. * Specifies if the mesh will require alpha blending
  30511. * @param mesh defines the mesh to check
  30512. * @returns a boolean specifying if alpha blending is needed for the mesh
  30513. */
  30514. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30515. /**
  30516. * Specifies whether or not this material should be rendered in alpha test mode.
  30517. * @returns a boolean specifying if an alpha test is needed.
  30518. */
  30519. needAlphaTesting(): boolean;
  30520. /**
  30521. * Specifies if material alpha testing should be turned on for the mesh
  30522. * @param mesh defines the mesh to check
  30523. */
  30524. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30525. /**
  30526. * Gets the texture used for the alpha test
  30527. * @returns the texture to use for alpha testing
  30528. */
  30529. getAlphaTestTexture(): Nullable<BaseTexture>;
  30530. /**
  30531. * Marks the material to indicate that it needs to be re-calculated
  30532. */
  30533. markDirty(): void;
  30534. /** @hidden */
  30535. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30536. /**
  30537. * Binds the material to the mesh
  30538. * @param world defines the world transformation matrix
  30539. * @param mesh defines the mesh to bind the material to
  30540. */
  30541. bind(world: Matrix, mesh?: Mesh): void;
  30542. /**
  30543. * Binds the submesh to the material
  30544. * @param world defines the world transformation matrix
  30545. * @param mesh defines the mesh containing the submesh
  30546. * @param subMesh defines the submesh to bind the material to
  30547. */
  30548. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30549. /**
  30550. * Binds the world matrix to the material
  30551. * @param world defines the world transformation matrix
  30552. */
  30553. bindOnlyWorldMatrix(world: Matrix): void;
  30554. /**
  30555. * Binds the scene's uniform buffer to the effect.
  30556. * @param effect defines the effect to bind to the scene uniform buffer
  30557. * @param sceneUbo defines the uniform buffer storing scene data
  30558. */
  30559. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30560. /**
  30561. * Binds the view matrix to the effect
  30562. * @param effect defines the effect to bind the view matrix to
  30563. */
  30564. bindView(effect: Effect): void;
  30565. /**
  30566. * Binds the view projection matrix to the effect
  30567. * @param effect defines the effect to bind the view projection matrix to
  30568. */
  30569. bindViewProjection(effect: Effect): void;
  30570. /**
  30571. * Processes to execute after binding the material to a mesh
  30572. * @param mesh defines the rendered mesh
  30573. */
  30574. protected _afterBind(mesh?: Mesh): void;
  30575. /**
  30576. * Unbinds the material from the mesh
  30577. */
  30578. unbind(): void;
  30579. /**
  30580. * Gets the active textures from the material
  30581. * @returns an array of textures
  30582. */
  30583. getActiveTextures(): BaseTexture[];
  30584. /**
  30585. * Specifies if the material uses a texture
  30586. * @param texture defines the texture to check against the material
  30587. * @returns a boolean specifying if the material uses the texture
  30588. */
  30589. hasTexture(texture: BaseTexture): boolean;
  30590. /**
  30591. * Makes a duplicate of the material, and gives it a new name
  30592. * @param name defines the new name for the duplicated material
  30593. * @returns the cloned material
  30594. */
  30595. clone(name: string): Nullable<Material>;
  30596. /**
  30597. * Gets the meshes bound to the material
  30598. * @returns an array of meshes bound to the material
  30599. */
  30600. getBindedMeshes(): AbstractMesh[];
  30601. /**
  30602. * Force shader compilation
  30603. * @param mesh defines the mesh associated with this material
  30604. * @param onCompiled defines a function to execute once the material is compiled
  30605. * @param options defines the options to configure the compilation
  30606. * @param onError defines a function to execute if the material fails compiling
  30607. */
  30608. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30609. /**
  30610. * Force shader compilation
  30611. * @param mesh defines the mesh that will use this material
  30612. * @param options defines additional options for compiling the shaders
  30613. * @returns a promise that resolves when the compilation completes
  30614. */
  30615. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30616. private static readonly _AllDirtyCallBack;
  30617. private static readonly _ImageProcessingDirtyCallBack;
  30618. private static readonly _TextureDirtyCallBack;
  30619. private static readonly _FresnelDirtyCallBack;
  30620. private static readonly _MiscDirtyCallBack;
  30621. private static readonly _PrePassDirtyCallBack;
  30622. private static readonly _LightsDirtyCallBack;
  30623. private static readonly _AttributeDirtyCallBack;
  30624. private static _FresnelAndMiscDirtyCallBack;
  30625. private static _TextureAndMiscDirtyCallBack;
  30626. private static readonly _DirtyCallbackArray;
  30627. private static readonly _RunDirtyCallBacks;
  30628. /**
  30629. * Marks a define in the material to indicate that it needs to be re-computed
  30630. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30631. */
  30632. markAsDirty(flag: number): void;
  30633. /**
  30634. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30635. * @param func defines a function which checks material defines against the submeshes
  30636. */
  30637. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30638. /**
  30639. * Indicates that the scene should check if the rendering now needs a prepass
  30640. */
  30641. protected _markScenePrePassDirty(): void;
  30642. /**
  30643. * Indicates that we need to re-calculated for all submeshes
  30644. */
  30645. protected _markAllSubMeshesAsAllDirty(): void;
  30646. /**
  30647. * Indicates that image processing needs to be re-calculated for all submeshes
  30648. */
  30649. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30650. /**
  30651. * Indicates that textures need to be re-calculated for all submeshes
  30652. */
  30653. protected _markAllSubMeshesAsTexturesDirty(): void;
  30654. /**
  30655. * Indicates that fresnel needs to be re-calculated for all submeshes
  30656. */
  30657. protected _markAllSubMeshesAsFresnelDirty(): void;
  30658. /**
  30659. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30660. */
  30661. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30662. /**
  30663. * Indicates that lights need to be re-calculated for all submeshes
  30664. */
  30665. protected _markAllSubMeshesAsLightsDirty(): void;
  30666. /**
  30667. * Indicates that attributes need to be re-calculated for all submeshes
  30668. */
  30669. protected _markAllSubMeshesAsAttributesDirty(): void;
  30670. /**
  30671. * Indicates that misc needs to be re-calculated for all submeshes
  30672. */
  30673. protected _markAllSubMeshesAsMiscDirty(): void;
  30674. /**
  30675. * Indicates that prepass needs to be re-calculated for all submeshes
  30676. */
  30677. protected _markAllSubMeshesAsPrePassDirty(): void;
  30678. /**
  30679. * Indicates that textures and misc need to be re-calculated for all submeshes
  30680. */
  30681. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30682. /**
  30683. * Sets the required values to the prepass renderer.
  30684. * @param prePassRenderer defines the prepass renderer to setup.
  30685. * @returns true if the pre pass is needed.
  30686. */
  30687. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30688. /**
  30689. * Disposes the material
  30690. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30691. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30692. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30693. */
  30694. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30695. /** @hidden */
  30696. private releaseVertexArrayObject;
  30697. /**
  30698. * Serializes this material
  30699. * @returns the serialized material object
  30700. */
  30701. serialize(): any;
  30702. /**
  30703. * Creates a material from parsed material data
  30704. * @param parsedMaterial defines parsed material data
  30705. * @param scene defines the hosting scene
  30706. * @param rootUrl defines the root URL to use to load textures
  30707. * @returns a new material
  30708. */
  30709. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30710. }
  30711. }
  30712. declare module "babylonjs/Materials/multiMaterial" {
  30713. import { Nullable } from "babylonjs/types";
  30714. import { Scene } from "babylonjs/scene";
  30715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30716. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30718. import { Material } from "babylonjs/Materials/material";
  30719. /**
  30720. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30721. * separate meshes. This can be use to improve performances.
  30722. * @see https://doc.babylonjs.com/how_to/multi_materials
  30723. */
  30724. export class MultiMaterial extends Material {
  30725. private _subMaterials;
  30726. /**
  30727. * Gets or Sets the list of Materials used within the multi material.
  30728. * They need to be ordered according to the submeshes order in the associated mesh
  30729. */
  30730. get subMaterials(): Nullable<Material>[];
  30731. set subMaterials(value: Nullable<Material>[]);
  30732. /**
  30733. * Function used to align with Node.getChildren()
  30734. * @returns the list of Materials used within the multi material
  30735. */
  30736. getChildren(): Nullable<Material>[];
  30737. /**
  30738. * Instantiates a new Multi Material
  30739. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30740. * separate meshes. This can be use to improve performances.
  30741. * @see https://doc.babylonjs.com/how_to/multi_materials
  30742. * @param name Define the name in the scene
  30743. * @param scene Define the scene the material belongs to
  30744. */
  30745. constructor(name: string, scene: Scene);
  30746. private _hookArray;
  30747. /**
  30748. * Get one of the submaterial by its index in the submaterials array
  30749. * @param index The index to look the sub material at
  30750. * @returns The Material if the index has been defined
  30751. */
  30752. getSubMaterial(index: number): Nullable<Material>;
  30753. /**
  30754. * Get the list of active textures for the whole sub materials list.
  30755. * @returns All the textures that will be used during the rendering
  30756. */
  30757. getActiveTextures(): BaseTexture[];
  30758. /**
  30759. * Gets the current class name of the material e.g. "MultiMaterial"
  30760. * Mainly use in serialization.
  30761. * @returns the class name
  30762. */
  30763. getClassName(): string;
  30764. /**
  30765. * Checks if the material is ready to render the requested sub mesh
  30766. * @param mesh Define the mesh the submesh belongs to
  30767. * @param subMesh Define the sub mesh to look readyness for
  30768. * @param useInstances Define whether or not the material is used with instances
  30769. * @returns true if ready, otherwise false
  30770. */
  30771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30772. /**
  30773. * Clones the current material and its related sub materials
  30774. * @param name Define the name of the newly cloned material
  30775. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30776. * @returns the cloned material
  30777. */
  30778. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30779. /**
  30780. * Serializes the materials into a JSON representation.
  30781. * @returns the JSON representation
  30782. */
  30783. serialize(): any;
  30784. /**
  30785. * Dispose the material and release its associated resources
  30786. * @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)
  30787. * @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)
  30788. * @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)
  30789. */
  30790. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30791. /**
  30792. * Creates a MultiMaterial from parsed MultiMaterial data.
  30793. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30794. * @param scene defines the hosting scene
  30795. * @returns a new MultiMaterial
  30796. */
  30797. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30798. }
  30799. }
  30800. declare module "babylonjs/Meshes/subMesh" {
  30801. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30802. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30803. import { Engine } from "babylonjs/Engines/engine";
  30804. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30805. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30806. import { Effect } from "babylonjs/Materials/effect";
  30807. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30808. import { Plane } from "babylonjs/Maths/math.plane";
  30809. import { Collider } from "babylonjs/Collisions/collider";
  30810. import { Material } from "babylonjs/Materials/material";
  30811. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30813. import { Mesh } from "babylonjs/Meshes/mesh";
  30814. import { Ray } from "babylonjs/Culling/ray";
  30815. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30816. /**
  30817. * Defines a subdivision inside a mesh
  30818. */
  30819. export class SubMesh implements ICullable {
  30820. /** the material index to use */
  30821. materialIndex: number;
  30822. /** vertex index start */
  30823. verticesStart: number;
  30824. /** vertices count */
  30825. verticesCount: number;
  30826. /** index start */
  30827. indexStart: number;
  30828. /** indices count */
  30829. indexCount: number;
  30830. /** @hidden */
  30831. _materialDefines: Nullable<MaterialDefines>;
  30832. /** @hidden */
  30833. _materialEffect: Nullable<Effect>;
  30834. /** @hidden */
  30835. _effectOverride: Nullable<Effect>;
  30836. /**
  30837. * Gets material defines used by the effect associated to the sub mesh
  30838. */
  30839. get materialDefines(): Nullable<MaterialDefines>;
  30840. /**
  30841. * Sets material defines used by the effect associated to the sub mesh
  30842. */
  30843. set materialDefines(defines: Nullable<MaterialDefines>);
  30844. /**
  30845. * Gets associated effect
  30846. */
  30847. get effect(): Nullable<Effect>;
  30848. /**
  30849. * Sets associated effect (effect used to render this submesh)
  30850. * @param effect defines the effect to associate with
  30851. * @param defines defines the set of defines used to compile this effect
  30852. */
  30853. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30854. /** @hidden */
  30855. _linesIndexCount: number;
  30856. private _mesh;
  30857. private _renderingMesh;
  30858. private _boundingInfo;
  30859. private _linesIndexBuffer;
  30860. /** @hidden */
  30861. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30862. /** @hidden */
  30863. _trianglePlanes: Plane[];
  30864. /** @hidden */
  30865. _lastColliderTransformMatrix: Nullable<Matrix>;
  30866. /** @hidden */
  30867. _renderId: number;
  30868. /** @hidden */
  30869. _alphaIndex: number;
  30870. /** @hidden */
  30871. _distanceToCamera: number;
  30872. /** @hidden */
  30873. _id: number;
  30874. private _currentMaterial;
  30875. /**
  30876. * Add a new submesh to a mesh
  30877. * @param materialIndex defines the material index to use
  30878. * @param verticesStart defines vertex index start
  30879. * @param verticesCount defines vertices count
  30880. * @param indexStart defines index start
  30881. * @param indexCount defines indices count
  30882. * @param mesh defines the parent mesh
  30883. * @param renderingMesh defines an optional rendering mesh
  30884. * @param createBoundingBox defines if bounding box should be created for this submesh
  30885. * @returns the new submesh
  30886. */
  30887. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30888. /**
  30889. * Creates a new submesh
  30890. * @param materialIndex defines the material index to use
  30891. * @param verticesStart defines vertex index start
  30892. * @param verticesCount defines vertices count
  30893. * @param indexStart defines index start
  30894. * @param indexCount defines indices count
  30895. * @param mesh defines the parent mesh
  30896. * @param renderingMesh defines an optional rendering mesh
  30897. * @param createBoundingBox defines if bounding box should be created for this submesh
  30898. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30899. */
  30900. constructor(
  30901. /** the material index to use */
  30902. materialIndex: number,
  30903. /** vertex index start */
  30904. verticesStart: number,
  30905. /** vertices count */
  30906. verticesCount: number,
  30907. /** index start */
  30908. indexStart: number,
  30909. /** indices count */
  30910. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30911. /**
  30912. * Returns true if this submesh covers the entire parent mesh
  30913. * @ignorenaming
  30914. */
  30915. get IsGlobal(): boolean;
  30916. /**
  30917. * Returns the submesh BoudingInfo object
  30918. * @returns current bounding info (or mesh's one if the submesh is global)
  30919. */
  30920. getBoundingInfo(): BoundingInfo;
  30921. /**
  30922. * Sets the submesh BoundingInfo
  30923. * @param boundingInfo defines the new bounding info to use
  30924. * @returns the SubMesh
  30925. */
  30926. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30927. /**
  30928. * Returns the mesh of the current submesh
  30929. * @return the parent mesh
  30930. */
  30931. getMesh(): AbstractMesh;
  30932. /**
  30933. * Returns the rendering mesh of the submesh
  30934. * @returns the rendering mesh (could be different from parent mesh)
  30935. */
  30936. getRenderingMesh(): Mesh;
  30937. /**
  30938. * Returns the replacement mesh of the submesh
  30939. * @returns the replacement mesh (could be different from parent mesh)
  30940. */
  30941. getReplacementMesh(): Nullable<AbstractMesh>;
  30942. /**
  30943. * Returns the effective mesh of the submesh
  30944. * @returns the effective mesh (could be different from parent mesh)
  30945. */
  30946. getEffectiveMesh(): AbstractMesh;
  30947. /**
  30948. * Returns the submesh material
  30949. * @returns null or the current material
  30950. */
  30951. getMaterial(): Nullable<Material>;
  30952. private _IsMultiMaterial;
  30953. /**
  30954. * Sets a new updated BoundingInfo object to the submesh
  30955. * @param data defines an optional position array to use to determine the bounding info
  30956. * @returns the SubMesh
  30957. */
  30958. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30959. /** @hidden */
  30960. _checkCollision(collider: Collider): boolean;
  30961. /**
  30962. * Updates the submesh BoundingInfo
  30963. * @param world defines the world matrix to use to update the bounding info
  30964. * @returns the submesh
  30965. */
  30966. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30967. /**
  30968. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30969. * @param frustumPlanes defines the frustum planes
  30970. * @returns true if the submesh is intersecting with the frustum
  30971. */
  30972. isInFrustum(frustumPlanes: Plane[]): boolean;
  30973. /**
  30974. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30975. * @param frustumPlanes defines the frustum planes
  30976. * @returns true if the submesh is inside the frustum
  30977. */
  30978. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30979. /**
  30980. * Renders the submesh
  30981. * @param enableAlphaMode defines if alpha needs to be used
  30982. * @returns the submesh
  30983. */
  30984. render(enableAlphaMode: boolean): SubMesh;
  30985. /**
  30986. * @hidden
  30987. */
  30988. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30989. /**
  30990. * Checks if the submesh intersects with a ray
  30991. * @param ray defines the ray to test
  30992. * @returns true is the passed ray intersects the submesh bounding box
  30993. */
  30994. canIntersects(ray: Ray): boolean;
  30995. /**
  30996. * Intersects current submesh with a ray
  30997. * @param ray defines the ray to test
  30998. * @param positions defines mesh's positions array
  30999. * @param indices defines mesh's indices array
  31000. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31001. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31002. * @returns intersection info or null if no intersection
  31003. */
  31004. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31005. /** @hidden */
  31006. private _intersectLines;
  31007. /** @hidden */
  31008. private _intersectUnIndexedLines;
  31009. /** @hidden */
  31010. private _intersectTriangles;
  31011. /** @hidden */
  31012. private _intersectUnIndexedTriangles;
  31013. /** @hidden */
  31014. _rebuild(): void;
  31015. /**
  31016. * Creates a new submesh from the passed mesh
  31017. * @param newMesh defines the new hosting mesh
  31018. * @param newRenderingMesh defines an optional rendering mesh
  31019. * @returns the new submesh
  31020. */
  31021. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31022. /**
  31023. * Release associated resources
  31024. */
  31025. dispose(): void;
  31026. /**
  31027. * Gets the class name
  31028. * @returns the string "SubMesh".
  31029. */
  31030. getClassName(): string;
  31031. /**
  31032. * Creates a new submesh from indices data
  31033. * @param materialIndex the index of the main mesh material
  31034. * @param startIndex the index where to start the copy in the mesh indices array
  31035. * @param indexCount the number of indices to copy then from the startIndex
  31036. * @param mesh the main mesh to create the submesh from
  31037. * @param renderingMesh the optional rendering mesh
  31038. * @returns a new submesh
  31039. */
  31040. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31041. }
  31042. }
  31043. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31044. /**
  31045. * Class used to represent data loading progression
  31046. */
  31047. export class SceneLoaderFlags {
  31048. private static _ForceFullSceneLoadingForIncremental;
  31049. private static _ShowLoadingScreen;
  31050. private static _CleanBoneMatrixWeights;
  31051. private static _loggingLevel;
  31052. /**
  31053. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31054. */
  31055. static get ForceFullSceneLoadingForIncremental(): boolean;
  31056. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31057. /**
  31058. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31059. */
  31060. static get ShowLoadingScreen(): boolean;
  31061. static set ShowLoadingScreen(value: boolean);
  31062. /**
  31063. * Defines the current logging level (while loading the scene)
  31064. * @ignorenaming
  31065. */
  31066. static get loggingLevel(): number;
  31067. static set loggingLevel(value: number);
  31068. /**
  31069. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31070. */
  31071. static get CleanBoneMatrixWeights(): boolean;
  31072. static set CleanBoneMatrixWeights(value: boolean);
  31073. }
  31074. }
  31075. declare module "babylonjs/Meshes/geometry" {
  31076. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31077. import { Scene } from "babylonjs/scene";
  31078. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31079. import { Engine } from "babylonjs/Engines/engine";
  31080. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31081. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31082. import { Effect } from "babylonjs/Materials/effect";
  31083. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31084. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31085. import { Mesh } from "babylonjs/Meshes/mesh";
  31086. /**
  31087. * Class used to store geometry data (vertex buffers + index buffer)
  31088. */
  31089. export class Geometry implements IGetSetVerticesData {
  31090. /**
  31091. * Gets or sets the ID of the geometry
  31092. */
  31093. id: string;
  31094. /**
  31095. * Gets or sets the unique ID of the geometry
  31096. */
  31097. uniqueId: number;
  31098. /**
  31099. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31100. */
  31101. delayLoadState: number;
  31102. /**
  31103. * Gets the file containing the data to load when running in delay load state
  31104. */
  31105. delayLoadingFile: Nullable<string>;
  31106. /**
  31107. * Callback called when the geometry is updated
  31108. */
  31109. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31110. private _scene;
  31111. private _engine;
  31112. private _meshes;
  31113. private _totalVertices;
  31114. /** @hidden */
  31115. _indices: IndicesArray;
  31116. /** @hidden */
  31117. _vertexBuffers: {
  31118. [key: string]: VertexBuffer;
  31119. };
  31120. private _isDisposed;
  31121. private _extend;
  31122. private _boundingBias;
  31123. /** @hidden */
  31124. _delayInfo: Array<string>;
  31125. private _indexBuffer;
  31126. private _indexBufferIsUpdatable;
  31127. /** @hidden */
  31128. _boundingInfo: Nullable<BoundingInfo>;
  31129. /** @hidden */
  31130. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31131. /** @hidden */
  31132. _softwareSkinningFrameId: number;
  31133. private _vertexArrayObjects;
  31134. private _updatable;
  31135. /** @hidden */
  31136. _positions: Nullable<Vector3[]>;
  31137. /**
  31138. * 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
  31139. */
  31140. get boundingBias(): Vector2;
  31141. /**
  31142. * 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
  31143. */
  31144. set boundingBias(value: Vector2);
  31145. /**
  31146. * Static function used to attach a new empty geometry to a mesh
  31147. * @param mesh defines the mesh to attach the geometry to
  31148. * @returns the new Geometry
  31149. */
  31150. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31151. /** Get the list of meshes using this geometry */
  31152. get meshes(): Mesh[];
  31153. /**
  31154. * 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
  31155. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31156. */
  31157. useBoundingInfoFromGeometry: boolean;
  31158. /**
  31159. * Creates a new geometry
  31160. * @param id defines the unique ID
  31161. * @param scene defines the hosting scene
  31162. * @param vertexData defines the VertexData used to get geometry data
  31163. * @param updatable defines if geometry must be updatable (false by default)
  31164. * @param mesh defines the mesh that will be associated with the geometry
  31165. */
  31166. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31167. /**
  31168. * Gets the current extend of the geometry
  31169. */
  31170. get extend(): {
  31171. minimum: Vector3;
  31172. maximum: Vector3;
  31173. };
  31174. /**
  31175. * Gets the hosting scene
  31176. * @returns the hosting Scene
  31177. */
  31178. getScene(): Scene;
  31179. /**
  31180. * Gets the hosting engine
  31181. * @returns the hosting Engine
  31182. */
  31183. getEngine(): Engine;
  31184. /**
  31185. * Defines if the geometry is ready to use
  31186. * @returns true if the geometry is ready to be used
  31187. */
  31188. isReady(): boolean;
  31189. /**
  31190. * Gets a value indicating that the geometry should not be serialized
  31191. */
  31192. get doNotSerialize(): boolean;
  31193. /** @hidden */
  31194. _rebuild(): void;
  31195. /**
  31196. * Affects all geometry data in one call
  31197. * @param vertexData defines the geometry data
  31198. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31199. */
  31200. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31201. /**
  31202. * Set specific vertex data
  31203. * @param kind defines the data kind (Position, normal, etc...)
  31204. * @param data defines the vertex data to use
  31205. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31206. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31207. */
  31208. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31209. /**
  31210. * Removes a specific vertex data
  31211. * @param kind defines the data kind (Position, normal, etc...)
  31212. */
  31213. removeVerticesData(kind: string): void;
  31214. /**
  31215. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31216. * @param buffer defines the vertex buffer to use
  31217. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31218. */
  31219. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31220. /**
  31221. * Update a specific vertex buffer
  31222. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31223. * It will do nothing if the buffer is not updatable
  31224. * @param kind defines the data kind (Position, normal, etc...)
  31225. * @param data defines the data to use
  31226. * @param offset defines the offset in the target buffer where to store the data
  31227. * @param useBytes set to true if the offset is in bytes
  31228. */
  31229. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31230. /**
  31231. * Update a specific vertex buffer
  31232. * This function will create a new buffer if the current one is not updatable
  31233. * @param kind defines the data kind (Position, normal, etc...)
  31234. * @param data defines the data to use
  31235. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31236. */
  31237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31238. private _updateBoundingInfo;
  31239. /** @hidden */
  31240. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31241. /**
  31242. * Gets total number of vertices
  31243. * @returns the total number of vertices
  31244. */
  31245. getTotalVertices(): number;
  31246. /**
  31247. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31248. * @param kind defines the data kind (Position, normal, etc...)
  31249. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31251. * @returns a float array containing vertex data
  31252. */
  31253. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31254. /**
  31255. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31256. * @param kind defines the data kind (Position, normal, etc...)
  31257. * @returns true if the vertex buffer with the specified kind is updatable
  31258. */
  31259. isVertexBufferUpdatable(kind: string): boolean;
  31260. /**
  31261. * Gets a specific vertex buffer
  31262. * @param kind defines the data kind (Position, normal, etc...)
  31263. * @returns a VertexBuffer
  31264. */
  31265. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31266. /**
  31267. * Returns all vertex buffers
  31268. * @return an object holding all vertex buffers indexed by kind
  31269. */
  31270. getVertexBuffers(): Nullable<{
  31271. [key: string]: VertexBuffer;
  31272. }>;
  31273. /**
  31274. * Gets a boolean indicating if specific vertex buffer is present
  31275. * @param kind defines the data kind (Position, normal, etc...)
  31276. * @returns true if data is present
  31277. */
  31278. isVerticesDataPresent(kind: string): boolean;
  31279. /**
  31280. * Gets a list of all attached data kinds (Position, normal, etc...)
  31281. * @returns a list of string containing all kinds
  31282. */
  31283. getVerticesDataKinds(): string[];
  31284. /**
  31285. * Update index buffer
  31286. * @param indices defines the indices to store in the index buffer
  31287. * @param offset defines the offset in the target buffer where to store the data
  31288. * @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)
  31289. */
  31290. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31291. /**
  31292. * Creates a new index buffer
  31293. * @param indices defines the indices to store in the index buffer
  31294. * @param totalVertices defines the total number of vertices (could be null)
  31295. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31296. */
  31297. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31298. /**
  31299. * Return the total number of indices
  31300. * @returns the total number of indices
  31301. */
  31302. getTotalIndices(): number;
  31303. /**
  31304. * Gets the index buffer array
  31305. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31307. * @returns the index buffer array
  31308. */
  31309. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31310. /**
  31311. * Gets the index buffer
  31312. * @return the index buffer
  31313. */
  31314. getIndexBuffer(): Nullable<DataBuffer>;
  31315. /** @hidden */
  31316. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31317. /**
  31318. * Release the associated resources for a specific mesh
  31319. * @param mesh defines the source mesh
  31320. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31321. */
  31322. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31323. /**
  31324. * Apply current geometry to a given mesh
  31325. * @param mesh defines the mesh to apply geometry to
  31326. */
  31327. applyToMesh(mesh: Mesh): void;
  31328. private _updateExtend;
  31329. private _applyToMesh;
  31330. private notifyUpdate;
  31331. /**
  31332. * Load the geometry if it was flagged as delay loaded
  31333. * @param scene defines the hosting scene
  31334. * @param onLoaded defines a callback called when the geometry is loaded
  31335. */
  31336. load(scene: Scene, onLoaded?: () => void): void;
  31337. private _queueLoad;
  31338. /**
  31339. * Invert the geometry to move from a right handed system to a left handed one.
  31340. */
  31341. toLeftHanded(): void;
  31342. /** @hidden */
  31343. _resetPointsArrayCache(): void;
  31344. /** @hidden */
  31345. _generatePointsArray(): boolean;
  31346. /**
  31347. * Gets a value indicating if the geometry is disposed
  31348. * @returns true if the geometry was disposed
  31349. */
  31350. isDisposed(): boolean;
  31351. private _disposeVertexArrayObjects;
  31352. /**
  31353. * Free all associated resources
  31354. */
  31355. dispose(): void;
  31356. /**
  31357. * Clone the current geometry into a new geometry
  31358. * @param id defines the unique ID of the new geometry
  31359. * @returns a new geometry object
  31360. */
  31361. copy(id: string): Geometry;
  31362. /**
  31363. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31364. * @return a JSON representation of the current geometry data (without the vertices data)
  31365. */
  31366. serialize(): any;
  31367. private toNumberArray;
  31368. /**
  31369. * Serialize all vertices data into a JSON oject
  31370. * @returns a JSON representation of the current geometry data
  31371. */
  31372. serializeVerticeData(): any;
  31373. /**
  31374. * Extracts a clone of a mesh geometry
  31375. * @param mesh defines the source mesh
  31376. * @param id defines the unique ID of the new geometry object
  31377. * @returns the new geometry object
  31378. */
  31379. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31380. /**
  31381. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31382. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31383. * Be aware Math.random() could cause collisions, but:
  31384. * "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"
  31385. * @returns a string containing a new GUID
  31386. */
  31387. static RandomId(): string;
  31388. /** @hidden */
  31389. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31390. private static _CleanMatricesWeights;
  31391. /**
  31392. * Create a new geometry from persisted data (Using .babylon file format)
  31393. * @param parsedVertexData defines the persisted data
  31394. * @param scene defines the hosting scene
  31395. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31396. * @returns the new geometry object
  31397. */
  31398. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31399. }
  31400. }
  31401. declare module "babylonjs/Meshes/mesh.vertexData" {
  31402. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31403. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31404. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31405. import { Geometry } from "babylonjs/Meshes/geometry";
  31406. import { Mesh } from "babylonjs/Meshes/mesh";
  31407. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31408. /**
  31409. * Define an interface for all classes that will get and set the data on vertices
  31410. */
  31411. export interface IGetSetVerticesData {
  31412. /**
  31413. * Gets a boolean indicating if specific vertex data is present
  31414. * @param kind defines the vertex data kind to use
  31415. * @returns true is data kind is present
  31416. */
  31417. isVerticesDataPresent(kind: string): boolean;
  31418. /**
  31419. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31420. * @param kind defines the data kind (Position, normal, etc...)
  31421. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31423. * @returns a float array containing vertex data
  31424. */
  31425. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31426. /**
  31427. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31428. * @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.
  31429. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31430. * @returns the indices array or an empty array if the mesh has no geometry
  31431. */
  31432. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31433. /**
  31434. * Set specific vertex data
  31435. * @param kind defines the data kind (Position, normal, etc...)
  31436. * @param data defines the vertex data to use
  31437. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31438. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31439. */
  31440. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31441. /**
  31442. * Update a specific associated vertex buffer
  31443. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31444. * - VertexBuffer.PositionKind
  31445. * - VertexBuffer.UVKind
  31446. * - VertexBuffer.UV2Kind
  31447. * - VertexBuffer.UV3Kind
  31448. * - VertexBuffer.UV4Kind
  31449. * - VertexBuffer.UV5Kind
  31450. * - VertexBuffer.UV6Kind
  31451. * - VertexBuffer.ColorKind
  31452. * - VertexBuffer.MatricesIndicesKind
  31453. * - VertexBuffer.MatricesIndicesExtraKind
  31454. * - VertexBuffer.MatricesWeightsKind
  31455. * - VertexBuffer.MatricesWeightsExtraKind
  31456. * @param data defines the data source
  31457. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31458. * @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)
  31459. */
  31460. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31461. /**
  31462. * Creates a new index buffer
  31463. * @param indices defines the indices to store in the index buffer
  31464. * @param totalVertices defines the total number of vertices (could be null)
  31465. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31466. */
  31467. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31468. }
  31469. /**
  31470. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31471. */
  31472. export class VertexData {
  31473. /**
  31474. * Mesh side orientation : usually the external or front surface
  31475. */
  31476. static readonly FRONTSIDE: number;
  31477. /**
  31478. * Mesh side orientation : usually the internal or back surface
  31479. */
  31480. static readonly BACKSIDE: number;
  31481. /**
  31482. * Mesh side orientation : both internal and external or front and back surfaces
  31483. */
  31484. static readonly DOUBLESIDE: number;
  31485. /**
  31486. * Mesh side orientation : by default, `FRONTSIDE`
  31487. */
  31488. static readonly DEFAULTSIDE: number;
  31489. /**
  31490. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31491. */
  31492. positions: Nullable<FloatArray>;
  31493. /**
  31494. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31495. */
  31496. normals: Nullable<FloatArray>;
  31497. /**
  31498. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31499. */
  31500. tangents: Nullable<FloatArray>;
  31501. /**
  31502. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31503. */
  31504. uvs: Nullable<FloatArray>;
  31505. /**
  31506. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31507. */
  31508. uvs2: Nullable<FloatArray>;
  31509. /**
  31510. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31511. */
  31512. uvs3: Nullable<FloatArray>;
  31513. /**
  31514. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31515. */
  31516. uvs4: Nullable<FloatArray>;
  31517. /**
  31518. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31519. */
  31520. uvs5: Nullable<FloatArray>;
  31521. /**
  31522. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31523. */
  31524. uvs6: Nullable<FloatArray>;
  31525. /**
  31526. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31527. */
  31528. colors: Nullable<FloatArray>;
  31529. /**
  31530. * 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).
  31531. */
  31532. matricesIndices: Nullable<FloatArray>;
  31533. /**
  31534. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31535. */
  31536. matricesWeights: Nullable<FloatArray>;
  31537. /**
  31538. * An array extending the number of possible indices
  31539. */
  31540. matricesIndicesExtra: Nullable<FloatArray>;
  31541. /**
  31542. * An array extending the number of possible weights when the number of indices is extended
  31543. */
  31544. matricesWeightsExtra: Nullable<FloatArray>;
  31545. /**
  31546. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31547. */
  31548. indices: Nullable<IndicesArray>;
  31549. /**
  31550. * Uses the passed data array to set the set the values for the specified kind of data
  31551. * @param data a linear array of floating numbers
  31552. * @param kind the type of data that is being set, eg positions, colors etc
  31553. */
  31554. set(data: FloatArray, kind: string): void;
  31555. /**
  31556. * Associates the vertexData to the passed Mesh.
  31557. * Sets it as updatable or not (default `false`)
  31558. * @param mesh the mesh the vertexData is applied to
  31559. * @param updatable when used and having the value true allows new data to update the vertexData
  31560. * @returns the VertexData
  31561. */
  31562. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31563. /**
  31564. * Associates the vertexData to the passed Geometry.
  31565. * Sets it as updatable or not (default `false`)
  31566. * @param geometry the geometry the vertexData is applied to
  31567. * @param updatable when used and having the value true allows new data to update the vertexData
  31568. * @returns VertexData
  31569. */
  31570. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31571. /**
  31572. * Updates the associated mesh
  31573. * @param mesh the mesh to be updated
  31574. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31575. * @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
  31576. * @returns VertexData
  31577. */
  31578. updateMesh(mesh: Mesh): VertexData;
  31579. /**
  31580. * Updates the associated geometry
  31581. * @param geometry the geometry to be updated
  31582. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31583. * @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
  31584. * @returns VertexData.
  31585. */
  31586. updateGeometry(geometry: Geometry): VertexData;
  31587. private _applyTo;
  31588. private _update;
  31589. /**
  31590. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31591. * @param matrix the transforming matrix
  31592. * @returns the VertexData
  31593. */
  31594. transform(matrix: Matrix): VertexData;
  31595. /**
  31596. * Merges the passed VertexData into the current one
  31597. * @param other the VertexData to be merged into the current one
  31598. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31599. * @returns the modified VertexData
  31600. */
  31601. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31602. private _mergeElement;
  31603. private _validate;
  31604. /**
  31605. * Serializes the VertexData
  31606. * @returns a serialized object
  31607. */
  31608. serialize(): any;
  31609. /**
  31610. * Extracts the vertexData from a mesh
  31611. * @param mesh the mesh from which to extract the VertexData
  31612. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31613. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31614. * @returns the object VertexData associated to the passed mesh
  31615. */
  31616. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31617. /**
  31618. * Extracts the vertexData from the geometry
  31619. * @param geometry the geometry from which to extract the VertexData
  31620. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31621. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31622. * @returns the object VertexData associated to the passed mesh
  31623. */
  31624. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31625. private static _ExtractFrom;
  31626. /**
  31627. * Creates the VertexData for a Ribbon
  31628. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31629. * * pathArray array of paths, each of which an array of successive Vector3
  31630. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31631. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31632. * * 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
  31633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31634. * * 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)
  31635. * * 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)
  31636. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31637. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31638. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31639. * @returns the VertexData of the ribbon
  31640. */
  31641. static CreateRibbon(options: {
  31642. pathArray: Vector3[][];
  31643. closeArray?: boolean;
  31644. closePath?: boolean;
  31645. offset?: number;
  31646. sideOrientation?: number;
  31647. frontUVs?: Vector4;
  31648. backUVs?: Vector4;
  31649. invertUV?: boolean;
  31650. uvs?: Vector2[];
  31651. colors?: Color4[];
  31652. }): VertexData;
  31653. /**
  31654. * Creates the VertexData for a box
  31655. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31656. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31657. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31658. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31659. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31660. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31661. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31663. * * 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)
  31664. * * 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)
  31665. * @returns the VertexData of the box
  31666. */
  31667. static CreateBox(options: {
  31668. size?: number;
  31669. width?: number;
  31670. height?: number;
  31671. depth?: number;
  31672. faceUV?: Vector4[];
  31673. faceColors?: Color4[];
  31674. sideOrientation?: number;
  31675. frontUVs?: Vector4;
  31676. backUVs?: Vector4;
  31677. }): VertexData;
  31678. /**
  31679. * Creates the VertexData for a tiled box
  31680. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31681. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31682. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31683. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31685. * @returns the VertexData of the box
  31686. */
  31687. static CreateTiledBox(options: {
  31688. pattern?: number;
  31689. width?: number;
  31690. height?: number;
  31691. depth?: number;
  31692. tileSize?: number;
  31693. tileWidth?: number;
  31694. tileHeight?: number;
  31695. alignHorizontal?: number;
  31696. alignVertical?: number;
  31697. faceUV?: Vector4[];
  31698. faceColors?: Color4[];
  31699. sideOrientation?: number;
  31700. }): VertexData;
  31701. /**
  31702. * Creates the VertexData for a tiled plane
  31703. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31704. * * pattern a limited pattern arrangement depending on the number
  31705. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31706. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31707. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31709. * * 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)
  31710. * * 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)
  31711. * @returns the VertexData of the tiled plane
  31712. */
  31713. static CreateTiledPlane(options: {
  31714. pattern?: number;
  31715. tileSize?: number;
  31716. tileWidth?: number;
  31717. tileHeight?: number;
  31718. size?: number;
  31719. width?: number;
  31720. height?: number;
  31721. alignHorizontal?: number;
  31722. alignVertical?: number;
  31723. sideOrientation?: number;
  31724. frontUVs?: Vector4;
  31725. backUVs?: Vector4;
  31726. }): VertexData;
  31727. /**
  31728. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31729. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31730. * * segments sets the number of horizontal strips optional, default 32
  31731. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31732. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31733. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31734. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31735. * * 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
  31736. * * 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
  31737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31738. * * 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)
  31739. * * 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)
  31740. * @returns the VertexData of the ellipsoid
  31741. */
  31742. static CreateSphere(options: {
  31743. segments?: number;
  31744. diameter?: number;
  31745. diameterX?: number;
  31746. diameterY?: number;
  31747. diameterZ?: number;
  31748. arc?: number;
  31749. slice?: number;
  31750. sideOrientation?: number;
  31751. frontUVs?: Vector4;
  31752. backUVs?: Vector4;
  31753. }): VertexData;
  31754. /**
  31755. * Creates the VertexData for a cylinder, cone or prism
  31756. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31757. * * height sets the height (y direction) of the cylinder, optional, default 2
  31758. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31759. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31760. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31761. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31762. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31763. * * 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
  31764. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31765. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31766. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31767. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31769. * * 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)
  31770. * * 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)
  31771. * @returns the VertexData of the cylinder, cone or prism
  31772. */
  31773. static CreateCylinder(options: {
  31774. height?: number;
  31775. diameterTop?: number;
  31776. diameterBottom?: number;
  31777. diameter?: number;
  31778. tessellation?: number;
  31779. subdivisions?: number;
  31780. arc?: number;
  31781. faceColors?: Color4[];
  31782. faceUV?: Vector4[];
  31783. hasRings?: boolean;
  31784. enclose?: boolean;
  31785. sideOrientation?: number;
  31786. frontUVs?: Vector4;
  31787. backUVs?: Vector4;
  31788. }): VertexData;
  31789. /**
  31790. * Creates the VertexData for a torus
  31791. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31792. * * diameter the diameter of the torus, optional default 1
  31793. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31794. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31796. * * 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)
  31797. * * 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)
  31798. * @returns the VertexData of the torus
  31799. */
  31800. static CreateTorus(options: {
  31801. diameter?: number;
  31802. thickness?: number;
  31803. tessellation?: number;
  31804. sideOrientation?: number;
  31805. frontUVs?: Vector4;
  31806. backUVs?: Vector4;
  31807. }): VertexData;
  31808. /**
  31809. * Creates the VertexData of the LineSystem
  31810. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31811. * - lines an array of lines, each line being an array of successive Vector3
  31812. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31813. * @returns the VertexData of the LineSystem
  31814. */
  31815. static CreateLineSystem(options: {
  31816. lines: Vector3[][];
  31817. colors?: Nullable<Color4[][]>;
  31818. }): VertexData;
  31819. /**
  31820. * Create the VertexData for a DashedLines
  31821. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31822. * - points an array successive Vector3
  31823. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31824. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31825. * - dashNb the intended total number of dashes, optional, default 200
  31826. * @returns the VertexData for the DashedLines
  31827. */
  31828. static CreateDashedLines(options: {
  31829. points: Vector3[];
  31830. dashSize?: number;
  31831. gapSize?: number;
  31832. dashNb?: number;
  31833. }): VertexData;
  31834. /**
  31835. * Creates the VertexData for a Ground
  31836. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31837. * - width the width (x direction) of the ground, optional, default 1
  31838. * - height the height (z direction) of the ground, optional, default 1
  31839. * - subdivisions the number of subdivisions per side, optional, default 1
  31840. * @returns the VertexData of the Ground
  31841. */
  31842. static CreateGround(options: {
  31843. width?: number;
  31844. height?: number;
  31845. subdivisions?: number;
  31846. subdivisionsX?: number;
  31847. subdivisionsY?: number;
  31848. }): VertexData;
  31849. /**
  31850. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31851. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31852. * * xmin the ground minimum X coordinate, optional, default -1
  31853. * * zmin the ground minimum Z coordinate, optional, default -1
  31854. * * xmax the ground maximum X coordinate, optional, default 1
  31855. * * zmax the ground maximum Z coordinate, optional, default 1
  31856. * * 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}
  31857. * * 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}
  31858. * @returns the VertexData of the TiledGround
  31859. */
  31860. static CreateTiledGround(options: {
  31861. xmin: number;
  31862. zmin: number;
  31863. xmax: number;
  31864. zmax: number;
  31865. subdivisions?: {
  31866. w: number;
  31867. h: number;
  31868. };
  31869. precision?: {
  31870. w: number;
  31871. h: number;
  31872. };
  31873. }): VertexData;
  31874. /**
  31875. * Creates the VertexData of the Ground designed from a heightmap
  31876. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31877. * * width the width (x direction) of the ground
  31878. * * height the height (z direction) of the ground
  31879. * * subdivisions the number of subdivisions per side
  31880. * * minHeight the minimum altitude on the ground, optional, default 0
  31881. * * maxHeight the maximum altitude on the ground, optional default 1
  31882. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31883. * * buffer the array holding the image color data
  31884. * * bufferWidth the width of image
  31885. * * bufferHeight the height of image
  31886. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31887. * @returns the VertexData of the Ground designed from a heightmap
  31888. */
  31889. static CreateGroundFromHeightMap(options: {
  31890. width: number;
  31891. height: number;
  31892. subdivisions: number;
  31893. minHeight: number;
  31894. maxHeight: number;
  31895. colorFilter: Color3;
  31896. buffer: Uint8Array;
  31897. bufferWidth: number;
  31898. bufferHeight: number;
  31899. alphaFilter: number;
  31900. }): VertexData;
  31901. /**
  31902. * Creates the VertexData for a Plane
  31903. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31904. * * size sets the width and height of the plane to the value of size, optional default 1
  31905. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31906. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31907. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31908. * * 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)
  31909. * * 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)
  31910. * @returns the VertexData of the box
  31911. */
  31912. static CreatePlane(options: {
  31913. size?: number;
  31914. width?: number;
  31915. height?: number;
  31916. sideOrientation?: number;
  31917. frontUVs?: Vector4;
  31918. backUVs?: Vector4;
  31919. }): VertexData;
  31920. /**
  31921. * Creates the VertexData of the Disc or regular Polygon
  31922. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31923. * * radius the radius of the disc, optional default 0.5
  31924. * * tessellation the number of polygon sides, optional, default 64
  31925. * * 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
  31926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31927. * * 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)
  31928. * * 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)
  31929. * @returns the VertexData of the box
  31930. */
  31931. static CreateDisc(options: {
  31932. radius?: number;
  31933. tessellation?: number;
  31934. arc?: number;
  31935. sideOrientation?: number;
  31936. frontUVs?: Vector4;
  31937. backUVs?: Vector4;
  31938. }): VertexData;
  31939. /**
  31940. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31941. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31942. * @param polygon a mesh built from polygonTriangulation.build()
  31943. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31944. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31945. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31946. * @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)
  31947. * @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)
  31948. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31949. * @returns the VertexData of the Polygon
  31950. */
  31951. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31952. /**
  31953. * Creates the VertexData of the IcoSphere
  31954. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31955. * * radius the radius of the IcoSphere, optional default 1
  31956. * * radiusX allows stretching in the x direction, optional, default radius
  31957. * * radiusY allows stretching in the y direction, optional, default radius
  31958. * * radiusZ allows stretching in the z direction, optional, default radius
  31959. * * flat when true creates a flat shaded mesh, optional, default true
  31960. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31962. * * 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)
  31963. * * 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)
  31964. * @returns the VertexData of the IcoSphere
  31965. */
  31966. static CreateIcoSphere(options: {
  31967. radius?: number;
  31968. radiusX?: number;
  31969. radiusY?: number;
  31970. radiusZ?: number;
  31971. flat?: boolean;
  31972. subdivisions?: number;
  31973. sideOrientation?: number;
  31974. frontUVs?: Vector4;
  31975. backUVs?: Vector4;
  31976. }): VertexData;
  31977. /**
  31978. * Creates the VertexData for a Polyhedron
  31979. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31980. * * type provided types are:
  31981. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31982. * * 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)
  31983. * * size the size of the IcoSphere, optional default 1
  31984. * * sizeX allows stretching in the x direction, optional, default size
  31985. * * sizeY allows stretching in the y direction, optional, default size
  31986. * * sizeZ allows stretching in the z direction, optional, default size
  31987. * * 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
  31988. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31989. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31990. * * flat when true creates a flat shaded mesh, optional, default true
  31991. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31993. * * 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)
  31994. * * 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)
  31995. * @returns the VertexData of the Polyhedron
  31996. */
  31997. static CreatePolyhedron(options: {
  31998. type?: number;
  31999. size?: number;
  32000. sizeX?: number;
  32001. sizeY?: number;
  32002. sizeZ?: number;
  32003. custom?: any;
  32004. faceUV?: Vector4[];
  32005. faceColors?: Color4[];
  32006. flat?: boolean;
  32007. sideOrientation?: number;
  32008. frontUVs?: Vector4;
  32009. backUVs?: Vector4;
  32010. }): VertexData;
  32011. /**
  32012. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32013. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32014. * @returns the VertexData of the Capsule
  32015. */
  32016. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32017. /**
  32018. * Creates the VertexData for a TorusKnot
  32019. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32020. * * radius the radius of the torus knot, optional, default 2
  32021. * * tube the thickness of the tube, optional, default 0.5
  32022. * * radialSegments the number of sides on each tube segments, optional, default 32
  32023. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32024. * * p the number of windings around the z axis, optional, default 2
  32025. * * q the number of windings around the x axis, optional, default 3
  32026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32027. * * 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)
  32028. * * 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)
  32029. * @returns the VertexData of the Torus Knot
  32030. */
  32031. static CreateTorusKnot(options: {
  32032. radius?: number;
  32033. tube?: number;
  32034. radialSegments?: number;
  32035. tubularSegments?: number;
  32036. p?: number;
  32037. q?: number;
  32038. sideOrientation?: number;
  32039. frontUVs?: Vector4;
  32040. backUVs?: Vector4;
  32041. }): VertexData;
  32042. /**
  32043. * Compute normals for given positions and indices
  32044. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32045. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32046. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32047. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32048. * * facetNormals : optional array of facet normals (vector3)
  32049. * * facetPositions : optional array of facet positions (vector3)
  32050. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32051. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32052. * * bInfo : optional bounding info, required for facetPartitioning computation
  32053. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32054. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32055. * * useRightHandedSystem: optional boolean to for right handed system computation
  32056. * * depthSort : optional boolean to enable the facet depth sort computation
  32057. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32058. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32059. */
  32060. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32061. facetNormals?: any;
  32062. facetPositions?: any;
  32063. facetPartitioning?: any;
  32064. ratio?: number;
  32065. bInfo?: any;
  32066. bbSize?: Vector3;
  32067. subDiv?: any;
  32068. useRightHandedSystem?: boolean;
  32069. depthSort?: boolean;
  32070. distanceTo?: Vector3;
  32071. depthSortedFacets?: any;
  32072. }): void;
  32073. /** @hidden */
  32074. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32075. /**
  32076. * Applies VertexData created from the imported parameters to the geometry
  32077. * @param parsedVertexData the parsed data from an imported file
  32078. * @param geometry the geometry to apply the VertexData to
  32079. */
  32080. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32081. }
  32082. }
  32083. declare module "babylonjs/Morph/morphTarget" {
  32084. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32085. import { Observable } from "babylonjs/Misc/observable";
  32086. import { Nullable, FloatArray } from "babylonjs/types";
  32087. import { Scene } from "babylonjs/scene";
  32088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32089. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32090. /**
  32091. * Defines a target to use with MorphTargetManager
  32092. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32093. */
  32094. export class MorphTarget implements IAnimatable {
  32095. /** defines the name of the target */
  32096. name: string;
  32097. /**
  32098. * Gets or sets the list of animations
  32099. */
  32100. animations: import("babylonjs/Animations/animation").Animation[];
  32101. private _scene;
  32102. private _positions;
  32103. private _normals;
  32104. private _tangents;
  32105. private _uvs;
  32106. private _influence;
  32107. private _uniqueId;
  32108. /**
  32109. * Observable raised when the influence changes
  32110. */
  32111. onInfluenceChanged: Observable<boolean>;
  32112. /** @hidden */
  32113. _onDataLayoutChanged: Observable<void>;
  32114. /**
  32115. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32116. */
  32117. get influence(): number;
  32118. set influence(influence: number);
  32119. /**
  32120. * Gets or sets the id of the morph Target
  32121. */
  32122. id: string;
  32123. private _animationPropertiesOverride;
  32124. /**
  32125. * Gets or sets the animation properties override
  32126. */
  32127. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32128. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32129. /**
  32130. * Creates a new MorphTarget
  32131. * @param name defines the name of the target
  32132. * @param influence defines the influence to use
  32133. * @param scene defines the scene the morphtarget belongs to
  32134. */
  32135. constructor(
  32136. /** defines the name of the target */
  32137. name: string, influence?: number, scene?: Nullable<Scene>);
  32138. /**
  32139. * Gets the unique ID of this manager
  32140. */
  32141. get uniqueId(): number;
  32142. /**
  32143. * Gets a boolean defining if the target contains position data
  32144. */
  32145. get hasPositions(): boolean;
  32146. /**
  32147. * Gets a boolean defining if the target contains normal data
  32148. */
  32149. get hasNormals(): boolean;
  32150. /**
  32151. * Gets a boolean defining if the target contains tangent data
  32152. */
  32153. get hasTangents(): boolean;
  32154. /**
  32155. * Gets a boolean defining if the target contains texture coordinates data
  32156. */
  32157. get hasUVs(): boolean;
  32158. /**
  32159. * Affects position data to this target
  32160. * @param data defines the position data to use
  32161. */
  32162. setPositions(data: Nullable<FloatArray>): void;
  32163. /**
  32164. * Gets the position data stored in this target
  32165. * @returns a FloatArray containing the position data (or null if not present)
  32166. */
  32167. getPositions(): Nullable<FloatArray>;
  32168. /**
  32169. * Affects normal data to this target
  32170. * @param data defines the normal data to use
  32171. */
  32172. setNormals(data: Nullable<FloatArray>): void;
  32173. /**
  32174. * Gets the normal data stored in this target
  32175. * @returns a FloatArray containing the normal data (or null if not present)
  32176. */
  32177. getNormals(): Nullable<FloatArray>;
  32178. /**
  32179. * Affects tangent data to this target
  32180. * @param data defines the tangent data to use
  32181. */
  32182. setTangents(data: Nullable<FloatArray>): void;
  32183. /**
  32184. * Gets the tangent data stored in this target
  32185. * @returns a FloatArray containing the tangent data (or null if not present)
  32186. */
  32187. getTangents(): Nullable<FloatArray>;
  32188. /**
  32189. * Affects texture coordinates data to this target
  32190. * @param data defines the texture coordinates data to use
  32191. */
  32192. setUVs(data: Nullable<FloatArray>): void;
  32193. /**
  32194. * Gets the texture coordinates data stored in this target
  32195. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32196. */
  32197. getUVs(): Nullable<FloatArray>;
  32198. /**
  32199. * Clone the current target
  32200. * @returns a new MorphTarget
  32201. */
  32202. clone(): MorphTarget;
  32203. /**
  32204. * Serializes the current target into a Serialization object
  32205. * @returns the serialized object
  32206. */
  32207. serialize(): any;
  32208. /**
  32209. * Returns the string "MorphTarget"
  32210. * @returns "MorphTarget"
  32211. */
  32212. getClassName(): string;
  32213. /**
  32214. * Creates a new target from serialized data
  32215. * @param serializationObject defines the serialized data to use
  32216. * @returns a new MorphTarget
  32217. */
  32218. static Parse(serializationObject: any): MorphTarget;
  32219. /**
  32220. * Creates a MorphTarget from mesh data
  32221. * @param mesh defines the source mesh
  32222. * @param name defines the name to use for the new target
  32223. * @param influence defines the influence to attach to the target
  32224. * @returns a new MorphTarget
  32225. */
  32226. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32227. }
  32228. }
  32229. declare module "babylonjs/Morph/morphTargetManager" {
  32230. import { Nullable } from "babylonjs/types";
  32231. import { Scene } from "babylonjs/scene";
  32232. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32233. /**
  32234. * This class is used to deform meshes using morphing between different targets
  32235. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32236. */
  32237. export class MorphTargetManager {
  32238. private _targets;
  32239. private _targetInfluenceChangedObservers;
  32240. private _targetDataLayoutChangedObservers;
  32241. private _activeTargets;
  32242. private _scene;
  32243. private _influences;
  32244. private _supportsNormals;
  32245. private _supportsTangents;
  32246. private _supportsUVs;
  32247. private _vertexCount;
  32248. private _uniqueId;
  32249. private _tempInfluences;
  32250. /**
  32251. * Gets or sets a boolean indicating if normals must be morphed
  32252. */
  32253. enableNormalMorphing: boolean;
  32254. /**
  32255. * Gets or sets a boolean indicating if tangents must be morphed
  32256. */
  32257. enableTangentMorphing: boolean;
  32258. /**
  32259. * Gets or sets a boolean indicating if UV must be morphed
  32260. */
  32261. enableUVMorphing: boolean;
  32262. /**
  32263. * Creates a new MorphTargetManager
  32264. * @param scene defines the current scene
  32265. */
  32266. constructor(scene?: Nullable<Scene>);
  32267. /**
  32268. * Gets the unique ID of this manager
  32269. */
  32270. get uniqueId(): number;
  32271. /**
  32272. * Gets the number of vertices handled by this manager
  32273. */
  32274. get vertexCount(): number;
  32275. /**
  32276. * Gets a boolean indicating if this manager supports morphing of normals
  32277. */
  32278. get supportsNormals(): boolean;
  32279. /**
  32280. * Gets a boolean indicating if this manager supports morphing of tangents
  32281. */
  32282. get supportsTangents(): boolean;
  32283. /**
  32284. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32285. */
  32286. get supportsUVs(): boolean;
  32287. /**
  32288. * Gets the number of targets stored in this manager
  32289. */
  32290. get numTargets(): number;
  32291. /**
  32292. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32293. */
  32294. get numInfluencers(): number;
  32295. /**
  32296. * Gets the list of influences (one per target)
  32297. */
  32298. get influences(): Float32Array;
  32299. /**
  32300. * Gets the active target at specified index. An active target is a target with an influence > 0
  32301. * @param index defines the index to check
  32302. * @returns the requested target
  32303. */
  32304. getActiveTarget(index: number): MorphTarget;
  32305. /**
  32306. * Gets the target at specified index
  32307. * @param index defines the index to check
  32308. * @returns the requested target
  32309. */
  32310. getTarget(index: number): MorphTarget;
  32311. /**
  32312. * Add a new target to this manager
  32313. * @param target defines the target to add
  32314. */
  32315. addTarget(target: MorphTarget): void;
  32316. /**
  32317. * Removes a target from the manager
  32318. * @param target defines the target to remove
  32319. */
  32320. removeTarget(target: MorphTarget): void;
  32321. /**
  32322. * Clone the current manager
  32323. * @returns a new MorphTargetManager
  32324. */
  32325. clone(): MorphTargetManager;
  32326. /**
  32327. * Serializes the current manager into a Serialization object
  32328. * @returns the serialized object
  32329. */
  32330. serialize(): any;
  32331. private _syncActiveTargets;
  32332. /**
  32333. * Syncrhonize the targets with all the meshes using this morph target manager
  32334. */
  32335. synchronize(): void;
  32336. /**
  32337. * Creates a new MorphTargetManager from serialized data
  32338. * @param serializationObject defines the serialized data
  32339. * @param scene defines the hosting scene
  32340. * @returns the new MorphTargetManager
  32341. */
  32342. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32343. }
  32344. }
  32345. declare module "babylonjs/Meshes/meshLODLevel" {
  32346. import { Mesh } from "babylonjs/Meshes/mesh";
  32347. import { Nullable } from "babylonjs/types";
  32348. /**
  32349. * Class used to represent a specific level of detail of a mesh
  32350. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32351. */
  32352. export class MeshLODLevel {
  32353. /** Defines the distance where this level should start being displayed */
  32354. distance: number;
  32355. /** Defines the mesh to use to render this level */
  32356. mesh: Nullable<Mesh>;
  32357. /**
  32358. * Creates a new LOD level
  32359. * @param distance defines the distance where this level should star being displayed
  32360. * @param mesh defines the mesh to use to render this level
  32361. */
  32362. constructor(
  32363. /** Defines the distance where this level should start being displayed */
  32364. distance: number,
  32365. /** Defines the mesh to use to render this level */
  32366. mesh: Nullable<Mesh>);
  32367. }
  32368. }
  32369. declare module "babylonjs/Misc/canvasGenerator" {
  32370. /**
  32371. * Helper class used to generate a canvas to manipulate images
  32372. */
  32373. export class CanvasGenerator {
  32374. /**
  32375. * Create a new canvas (or offscreen canvas depending on the context)
  32376. * @param width defines the expected width
  32377. * @param height defines the expected height
  32378. * @return a new canvas or offscreen canvas
  32379. */
  32380. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32381. }
  32382. }
  32383. declare module "babylonjs/Meshes/groundMesh" {
  32384. import { Scene } from "babylonjs/scene";
  32385. import { Vector3 } from "babylonjs/Maths/math.vector";
  32386. import { Mesh } from "babylonjs/Meshes/mesh";
  32387. /**
  32388. * Mesh representing the gorund
  32389. */
  32390. export class GroundMesh extends Mesh {
  32391. /** If octree should be generated */
  32392. generateOctree: boolean;
  32393. private _heightQuads;
  32394. /** @hidden */
  32395. _subdivisionsX: number;
  32396. /** @hidden */
  32397. _subdivisionsY: number;
  32398. /** @hidden */
  32399. _width: number;
  32400. /** @hidden */
  32401. _height: number;
  32402. /** @hidden */
  32403. _minX: number;
  32404. /** @hidden */
  32405. _maxX: number;
  32406. /** @hidden */
  32407. _minZ: number;
  32408. /** @hidden */
  32409. _maxZ: number;
  32410. constructor(name: string, scene: Scene);
  32411. /**
  32412. * "GroundMesh"
  32413. * @returns "GroundMesh"
  32414. */
  32415. getClassName(): string;
  32416. /**
  32417. * The minimum of x and y subdivisions
  32418. */
  32419. get subdivisions(): number;
  32420. /**
  32421. * X subdivisions
  32422. */
  32423. get subdivisionsX(): number;
  32424. /**
  32425. * Y subdivisions
  32426. */
  32427. get subdivisionsY(): number;
  32428. /**
  32429. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32430. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32431. * @param chunksCount the number of subdivisions for x and y
  32432. * @param octreeBlocksSize (Default: 32)
  32433. */
  32434. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32435. /**
  32436. * Returns a height (y) value in the Worl system :
  32437. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32438. * @param x x coordinate
  32439. * @param z z coordinate
  32440. * @returns the ground y position if (x, z) are outside the ground surface.
  32441. */
  32442. getHeightAtCoordinates(x: number, z: number): number;
  32443. /**
  32444. * Returns a normalized vector (Vector3) orthogonal to the ground
  32445. * at the ground coordinates (x, z) expressed in the World system.
  32446. * @param x x coordinate
  32447. * @param z z coordinate
  32448. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32449. */
  32450. getNormalAtCoordinates(x: number, z: number): Vector3;
  32451. /**
  32452. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32453. * at the ground coordinates (x, z) expressed in the World system.
  32454. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32455. * @param x x coordinate
  32456. * @param z z coordinate
  32457. * @param ref vector to store the result
  32458. * @returns the GroundMesh.
  32459. */
  32460. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32461. /**
  32462. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32463. * if the ground has been updated.
  32464. * This can be used in the render loop.
  32465. * @returns the GroundMesh.
  32466. */
  32467. updateCoordinateHeights(): GroundMesh;
  32468. private _getFacetAt;
  32469. private _initHeightQuads;
  32470. private _computeHeightQuads;
  32471. /**
  32472. * Serializes this ground mesh
  32473. * @param serializationObject object to write serialization to
  32474. */
  32475. serialize(serializationObject: any): void;
  32476. /**
  32477. * Parses a serialized ground mesh
  32478. * @param parsedMesh the serialized mesh
  32479. * @param scene the scene to create the ground mesh in
  32480. * @returns the created ground mesh
  32481. */
  32482. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32483. }
  32484. }
  32485. declare module "babylonjs/Physics/physicsJoint" {
  32486. import { Vector3 } from "babylonjs/Maths/math.vector";
  32487. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32488. /**
  32489. * Interface for Physics-Joint data
  32490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32491. */
  32492. export interface PhysicsJointData {
  32493. /**
  32494. * The main pivot of the joint
  32495. */
  32496. mainPivot?: Vector3;
  32497. /**
  32498. * The connected pivot of the joint
  32499. */
  32500. connectedPivot?: Vector3;
  32501. /**
  32502. * The main axis of the joint
  32503. */
  32504. mainAxis?: Vector3;
  32505. /**
  32506. * The connected axis of the joint
  32507. */
  32508. connectedAxis?: Vector3;
  32509. /**
  32510. * The collision of the joint
  32511. */
  32512. collision?: boolean;
  32513. /**
  32514. * Native Oimo/Cannon/Energy data
  32515. */
  32516. nativeParams?: any;
  32517. }
  32518. /**
  32519. * This is a holder class for the physics joint created by the physics plugin
  32520. * It holds a set of functions to control the underlying joint
  32521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32522. */
  32523. export class PhysicsJoint {
  32524. /**
  32525. * The type of the physics joint
  32526. */
  32527. type: number;
  32528. /**
  32529. * The data for the physics joint
  32530. */
  32531. jointData: PhysicsJointData;
  32532. private _physicsJoint;
  32533. protected _physicsPlugin: IPhysicsEnginePlugin;
  32534. /**
  32535. * Initializes the physics joint
  32536. * @param type The type of the physics joint
  32537. * @param jointData The data for the physics joint
  32538. */
  32539. constructor(
  32540. /**
  32541. * The type of the physics joint
  32542. */
  32543. type: number,
  32544. /**
  32545. * The data for the physics joint
  32546. */
  32547. jointData: PhysicsJointData);
  32548. /**
  32549. * Gets the physics joint
  32550. */
  32551. get physicsJoint(): any;
  32552. /**
  32553. * Sets the physics joint
  32554. */
  32555. set physicsJoint(newJoint: any);
  32556. /**
  32557. * Sets the physics plugin
  32558. */
  32559. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32560. /**
  32561. * Execute a function that is physics-plugin specific.
  32562. * @param {Function} func the function that will be executed.
  32563. * It accepts two parameters: the physics world and the physics joint
  32564. */
  32565. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32566. /**
  32567. * Distance-Joint type
  32568. */
  32569. static DistanceJoint: number;
  32570. /**
  32571. * Hinge-Joint type
  32572. */
  32573. static HingeJoint: number;
  32574. /**
  32575. * Ball-and-Socket joint type
  32576. */
  32577. static BallAndSocketJoint: number;
  32578. /**
  32579. * Wheel-Joint type
  32580. */
  32581. static WheelJoint: number;
  32582. /**
  32583. * Slider-Joint type
  32584. */
  32585. static SliderJoint: number;
  32586. /**
  32587. * Prismatic-Joint type
  32588. */
  32589. static PrismaticJoint: number;
  32590. /**
  32591. * Universal-Joint type
  32592. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32593. */
  32594. static UniversalJoint: number;
  32595. /**
  32596. * Hinge-Joint 2 type
  32597. */
  32598. static Hinge2Joint: number;
  32599. /**
  32600. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32601. */
  32602. static PointToPointJoint: number;
  32603. /**
  32604. * Spring-Joint type
  32605. */
  32606. static SpringJoint: number;
  32607. /**
  32608. * Lock-Joint type
  32609. */
  32610. static LockJoint: number;
  32611. }
  32612. /**
  32613. * A class representing a physics distance joint
  32614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32615. */
  32616. export class DistanceJoint extends PhysicsJoint {
  32617. /**
  32618. *
  32619. * @param jointData The data for the Distance-Joint
  32620. */
  32621. constructor(jointData: DistanceJointData);
  32622. /**
  32623. * Update the predefined distance.
  32624. * @param maxDistance The maximum preferred distance
  32625. * @param minDistance The minimum preferred distance
  32626. */
  32627. updateDistance(maxDistance: number, minDistance?: number): void;
  32628. }
  32629. /**
  32630. * Represents a Motor-Enabled Joint
  32631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32632. */
  32633. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32634. /**
  32635. * Initializes the Motor-Enabled Joint
  32636. * @param type The type of the joint
  32637. * @param jointData The physica joint data for the joint
  32638. */
  32639. constructor(type: number, jointData: PhysicsJointData);
  32640. /**
  32641. * Set the motor values.
  32642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32643. * @param force the force to apply
  32644. * @param maxForce max force for this motor.
  32645. */
  32646. setMotor(force?: number, maxForce?: number): void;
  32647. /**
  32648. * Set the motor's limits.
  32649. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32650. * @param upperLimit The upper limit of the motor
  32651. * @param lowerLimit The lower limit of the motor
  32652. */
  32653. setLimit(upperLimit: number, lowerLimit?: number): void;
  32654. }
  32655. /**
  32656. * This class represents a single physics Hinge-Joint
  32657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32658. */
  32659. export class HingeJoint extends MotorEnabledJoint {
  32660. /**
  32661. * Initializes the Hinge-Joint
  32662. * @param jointData The joint data for the Hinge-Joint
  32663. */
  32664. constructor(jointData: PhysicsJointData);
  32665. /**
  32666. * Set the motor values.
  32667. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32668. * @param {number} force the force to apply
  32669. * @param {number} maxForce max force for this motor.
  32670. */
  32671. setMotor(force?: number, maxForce?: number): void;
  32672. /**
  32673. * Set the motor's limits.
  32674. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32675. * @param upperLimit The upper limit of the motor
  32676. * @param lowerLimit The lower limit of the motor
  32677. */
  32678. setLimit(upperLimit: number, lowerLimit?: number): void;
  32679. }
  32680. /**
  32681. * This class represents a dual hinge physics joint (same as wheel joint)
  32682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32683. */
  32684. export class Hinge2Joint extends MotorEnabledJoint {
  32685. /**
  32686. * Initializes the Hinge2-Joint
  32687. * @param jointData The joint data for the Hinge2-Joint
  32688. */
  32689. constructor(jointData: PhysicsJointData);
  32690. /**
  32691. * Set the motor values.
  32692. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32693. * @param {number} targetSpeed the speed the motor is to reach
  32694. * @param {number} maxForce max force for this motor.
  32695. * @param {motorIndex} the motor's index, 0 or 1.
  32696. */
  32697. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32698. /**
  32699. * Set the motor limits.
  32700. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32701. * @param {number} upperLimit the upper limit
  32702. * @param {number} lowerLimit lower limit
  32703. * @param {motorIndex} the motor's index, 0 or 1.
  32704. */
  32705. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32706. }
  32707. /**
  32708. * Interface for a motor enabled joint
  32709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32710. */
  32711. export interface IMotorEnabledJoint {
  32712. /**
  32713. * Physics joint
  32714. */
  32715. physicsJoint: any;
  32716. /**
  32717. * Sets the motor of the motor-enabled joint
  32718. * @param force The force of the motor
  32719. * @param maxForce The maximum force of the motor
  32720. * @param motorIndex The index of the motor
  32721. */
  32722. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32723. /**
  32724. * Sets the limit of the motor
  32725. * @param upperLimit The upper limit of the motor
  32726. * @param lowerLimit The lower limit of the motor
  32727. * @param motorIndex The index of the motor
  32728. */
  32729. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32730. }
  32731. /**
  32732. * Joint data for a Distance-Joint
  32733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32734. */
  32735. export interface DistanceJointData extends PhysicsJointData {
  32736. /**
  32737. * Max distance the 2 joint objects can be apart
  32738. */
  32739. maxDistance: number;
  32740. }
  32741. /**
  32742. * Joint data from a spring joint
  32743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32744. */
  32745. export interface SpringJointData extends PhysicsJointData {
  32746. /**
  32747. * Length of the spring
  32748. */
  32749. length: number;
  32750. /**
  32751. * Stiffness of the spring
  32752. */
  32753. stiffness: number;
  32754. /**
  32755. * Damping of the spring
  32756. */
  32757. damping: number;
  32758. /** this callback will be called when applying the force to the impostors. */
  32759. forceApplicationCallback: () => void;
  32760. }
  32761. }
  32762. declare module "babylonjs/Physics/physicsRaycastResult" {
  32763. import { Vector3 } from "babylonjs/Maths/math.vector";
  32764. /**
  32765. * Holds the data for the raycast result
  32766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32767. */
  32768. export class PhysicsRaycastResult {
  32769. private _hasHit;
  32770. private _hitDistance;
  32771. private _hitNormalWorld;
  32772. private _hitPointWorld;
  32773. private _rayFromWorld;
  32774. private _rayToWorld;
  32775. /**
  32776. * Gets if there was a hit
  32777. */
  32778. get hasHit(): boolean;
  32779. /**
  32780. * Gets the distance from the hit
  32781. */
  32782. get hitDistance(): number;
  32783. /**
  32784. * Gets the hit normal/direction in the world
  32785. */
  32786. get hitNormalWorld(): Vector3;
  32787. /**
  32788. * Gets the hit point in the world
  32789. */
  32790. get hitPointWorld(): Vector3;
  32791. /**
  32792. * Gets the ray "start point" of the ray in the world
  32793. */
  32794. get rayFromWorld(): Vector3;
  32795. /**
  32796. * Gets the ray "end point" of the ray in the world
  32797. */
  32798. get rayToWorld(): Vector3;
  32799. /**
  32800. * Sets the hit data (normal & point in world space)
  32801. * @param hitNormalWorld defines the normal in world space
  32802. * @param hitPointWorld defines the point in world space
  32803. */
  32804. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32805. /**
  32806. * Sets the distance from the start point to the hit point
  32807. * @param distance
  32808. */
  32809. setHitDistance(distance: number): void;
  32810. /**
  32811. * Calculates the distance manually
  32812. */
  32813. calculateHitDistance(): void;
  32814. /**
  32815. * Resets all the values to default
  32816. * @param from The from point on world space
  32817. * @param to The to point on world space
  32818. */
  32819. reset(from?: Vector3, to?: Vector3): void;
  32820. }
  32821. /**
  32822. * Interface for the size containing width and height
  32823. */
  32824. interface IXYZ {
  32825. /**
  32826. * X
  32827. */
  32828. x: number;
  32829. /**
  32830. * Y
  32831. */
  32832. y: number;
  32833. /**
  32834. * Z
  32835. */
  32836. z: number;
  32837. }
  32838. }
  32839. declare module "babylonjs/Physics/IPhysicsEngine" {
  32840. import { Nullable } from "babylonjs/types";
  32841. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32843. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32844. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32845. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32846. /**
  32847. * Interface used to describe a physics joint
  32848. */
  32849. export interface PhysicsImpostorJoint {
  32850. /** Defines the main impostor to which the joint is linked */
  32851. mainImpostor: PhysicsImpostor;
  32852. /** Defines the impostor that is connected to the main impostor using this joint */
  32853. connectedImpostor: PhysicsImpostor;
  32854. /** Defines the joint itself */
  32855. joint: PhysicsJoint;
  32856. }
  32857. /** @hidden */
  32858. export interface IPhysicsEnginePlugin {
  32859. world: any;
  32860. name: string;
  32861. setGravity(gravity: Vector3): void;
  32862. setTimeStep(timeStep: number): void;
  32863. getTimeStep(): number;
  32864. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32865. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32866. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32867. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32868. removePhysicsBody(impostor: PhysicsImpostor): void;
  32869. generateJoint(joint: PhysicsImpostorJoint): void;
  32870. removeJoint(joint: PhysicsImpostorJoint): void;
  32871. isSupported(): boolean;
  32872. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32873. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32874. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32875. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32876. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32877. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32878. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32879. getBodyMass(impostor: PhysicsImpostor): number;
  32880. getBodyFriction(impostor: PhysicsImpostor): number;
  32881. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32882. getBodyRestitution(impostor: PhysicsImpostor): number;
  32883. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32884. getBodyPressure?(impostor: PhysicsImpostor): number;
  32885. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32886. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32887. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32888. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32889. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32890. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32891. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32892. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32893. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32894. sleepBody(impostor: PhysicsImpostor): void;
  32895. wakeUpBody(impostor: PhysicsImpostor): void;
  32896. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32897. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32898. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32899. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32900. getRadius(impostor: PhysicsImpostor): number;
  32901. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32902. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32903. dispose(): void;
  32904. }
  32905. /**
  32906. * Interface used to define a physics engine
  32907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32908. */
  32909. export interface IPhysicsEngine {
  32910. /**
  32911. * Gets the gravity vector used by the simulation
  32912. */
  32913. gravity: Vector3;
  32914. /**
  32915. * Sets the gravity vector used by the simulation
  32916. * @param gravity defines the gravity vector to use
  32917. */
  32918. setGravity(gravity: Vector3): void;
  32919. /**
  32920. * Set the time step of the physics engine.
  32921. * Default is 1/60.
  32922. * To slow it down, enter 1/600 for example.
  32923. * To speed it up, 1/30
  32924. * @param newTimeStep the new timestep to apply to this world.
  32925. */
  32926. setTimeStep(newTimeStep: number): void;
  32927. /**
  32928. * Get the time step of the physics engine.
  32929. * @returns the current time step
  32930. */
  32931. getTimeStep(): number;
  32932. /**
  32933. * Set the sub time step of the physics engine.
  32934. * Default is 0 meaning there is no sub steps
  32935. * To increase physics resolution precision, set a small value (like 1 ms)
  32936. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32937. */
  32938. setSubTimeStep(subTimeStep: number): void;
  32939. /**
  32940. * Get the sub time step of the physics engine.
  32941. * @returns the current sub time step
  32942. */
  32943. getSubTimeStep(): number;
  32944. /**
  32945. * Release all resources
  32946. */
  32947. dispose(): void;
  32948. /**
  32949. * Gets the name of the current physics plugin
  32950. * @returns the name of the plugin
  32951. */
  32952. getPhysicsPluginName(): string;
  32953. /**
  32954. * Adding a new impostor for the impostor tracking.
  32955. * This will be done by the impostor itself.
  32956. * @param impostor the impostor to add
  32957. */
  32958. addImpostor(impostor: PhysicsImpostor): void;
  32959. /**
  32960. * Remove an impostor from the engine.
  32961. * This impostor and its mesh will not longer be updated by the physics engine.
  32962. * @param impostor the impostor to remove
  32963. */
  32964. removeImpostor(impostor: PhysicsImpostor): void;
  32965. /**
  32966. * Add a joint to the physics engine
  32967. * @param mainImpostor defines the main impostor to which the joint is added.
  32968. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32969. * @param joint defines the joint that will connect both impostors.
  32970. */
  32971. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32972. /**
  32973. * Removes a joint from the simulation
  32974. * @param mainImpostor defines the impostor used with the joint
  32975. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32976. * @param joint defines the joint to remove
  32977. */
  32978. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32979. /**
  32980. * Gets the current plugin used to run the simulation
  32981. * @returns current plugin
  32982. */
  32983. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32984. /**
  32985. * Gets the list of physic impostors
  32986. * @returns an array of PhysicsImpostor
  32987. */
  32988. getImpostors(): Array<PhysicsImpostor>;
  32989. /**
  32990. * Gets the impostor for a physics enabled object
  32991. * @param object defines the object impersonated by the impostor
  32992. * @returns the PhysicsImpostor or null if not found
  32993. */
  32994. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32995. /**
  32996. * Gets the impostor for a physics body object
  32997. * @param body defines physics body used by the impostor
  32998. * @returns the PhysicsImpostor or null if not found
  32999. */
  33000. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33001. /**
  33002. * Does a raycast in the physics world
  33003. * @param from when should the ray start?
  33004. * @param to when should the ray end?
  33005. * @returns PhysicsRaycastResult
  33006. */
  33007. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33008. /**
  33009. * Called by the scene. No need to call it.
  33010. * @param delta defines the timespam between frames
  33011. */
  33012. _step(delta: number): void;
  33013. }
  33014. }
  33015. declare module "babylonjs/Physics/physicsImpostor" {
  33016. import { Nullable, IndicesArray } from "babylonjs/types";
  33017. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33020. import { Scene } from "babylonjs/scene";
  33021. import { Bone } from "babylonjs/Bones/bone";
  33022. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33023. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33024. import { Space } from "babylonjs/Maths/math.axis";
  33025. /**
  33026. * The interface for the physics imposter parameters
  33027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33028. */
  33029. export interface PhysicsImpostorParameters {
  33030. /**
  33031. * The mass of the physics imposter
  33032. */
  33033. mass: number;
  33034. /**
  33035. * The friction of the physics imposter
  33036. */
  33037. friction?: number;
  33038. /**
  33039. * The coefficient of restitution of the physics imposter
  33040. */
  33041. restitution?: number;
  33042. /**
  33043. * The native options of the physics imposter
  33044. */
  33045. nativeOptions?: any;
  33046. /**
  33047. * Specifies if the parent should be ignored
  33048. */
  33049. ignoreParent?: boolean;
  33050. /**
  33051. * Specifies if bi-directional transformations should be disabled
  33052. */
  33053. disableBidirectionalTransformation?: boolean;
  33054. /**
  33055. * The pressure inside the physics imposter, soft object only
  33056. */
  33057. pressure?: number;
  33058. /**
  33059. * The stiffness the physics imposter, soft object only
  33060. */
  33061. stiffness?: number;
  33062. /**
  33063. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33064. */
  33065. velocityIterations?: number;
  33066. /**
  33067. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33068. */
  33069. positionIterations?: number;
  33070. /**
  33071. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33072. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33073. * Add to fix multiple points
  33074. */
  33075. fixedPoints?: number;
  33076. /**
  33077. * The collision margin around a soft object
  33078. */
  33079. margin?: number;
  33080. /**
  33081. * The collision margin around a soft object
  33082. */
  33083. damping?: number;
  33084. /**
  33085. * The path for a rope based on an extrusion
  33086. */
  33087. path?: any;
  33088. /**
  33089. * The shape of an extrusion used for a rope based on an extrusion
  33090. */
  33091. shape?: any;
  33092. }
  33093. /**
  33094. * Interface for a physics-enabled object
  33095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33096. */
  33097. export interface IPhysicsEnabledObject {
  33098. /**
  33099. * The position of the physics-enabled object
  33100. */
  33101. position: Vector3;
  33102. /**
  33103. * The rotation of the physics-enabled object
  33104. */
  33105. rotationQuaternion: Nullable<Quaternion>;
  33106. /**
  33107. * The scale of the physics-enabled object
  33108. */
  33109. scaling: Vector3;
  33110. /**
  33111. * The rotation of the physics-enabled object
  33112. */
  33113. rotation?: Vector3;
  33114. /**
  33115. * The parent of the physics-enabled object
  33116. */
  33117. parent?: any;
  33118. /**
  33119. * The bounding info of the physics-enabled object
  33120. * @returns The bounding info of the physics-enabled object
  33121. */
  33122. getBoundingInfo(): BoundingInfo;
  33123. /**
  33124. * Computes the world matrix
  33125. * @param force Specifies if the world matrix should be computed by force
  33126. * @returns A world matrix
  33127. */
  33128. computeWorldMatrix(force: boolean): Matrix;
  33129. /**
  33130. * Gets the world matrix
  33131. * @returns A world matrix
  33132. */
  33133. getWorldMatrix?(): Matrix;
  33134. /**
  33135. * Gets the child meshes
  33136. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33137. * @returns An array of abstract meshes
  33138. */
  33139. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33140. /**
  33141. * Gets the vertex data
  33142. * @param kind The type of vertex data
  33143. * @returns A nullable array of numbers, or a float32 array
  33144. */
  33145. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33146. /**
  33147. * Gets the indices from the mesh
  33148. * @returns A nullable array of index arrays
  33149. */
  33150. getIndices?(): Nullable<IndicesArray>;
  33151. /**
  33152. * Gets the scene from the mesh
  33153. * @returns the indices array or null
  33154. */
  33155. getScene?(): Scene;
  33156. /**
  33157. * Gets the absolute position from the mesh
  33158. * @returns the absolute position
  33159. */
  33160. getAbsolutePosition(): Vector3;
  33161. /**
  33162. * Gets the absolute pivot point from the mesh
  33163. * @returns the absolute pivot point
  33164. */
  33165. getAbsolutePivotPoint(): Vector3;
  33166. /**
  33167. * Rotates the mesh
  33168. * @param axis The axis of rotation
  33169. * @param amount The amount of rotation
  33170. * @param space The space of the rotation
  33171. * @returns The rotation transform node
  33172. */
  33173. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33174. /**
  33175. * Translates the mesh
  33176. * @param axis The axis of translation
  33177. * @param distance The distance of translation
  33178. * @param space The space of the translation
  33179. * @returns The transform node
  33180. */
  33181. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33182. /**
  33183. * Sets the absolute position of the mesh
  33184. * @param absolutePosition The absolute position of the mesh
  33185. * @returns The transform node
  33186. */
  33187. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33188. /**
  33189. * Gets the class name of the mesh
  33190. * @returns The class name
  33191. */
  33192. getClassName(): string;
  33193. }
  33194. /**
  33195. * Represents a physics imposter
  33196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33197. */
  33198. export class PhysicsImpostor {
  33199. /**
  33200. * The physics-enabled object used as the physics imposter
  33201. */
  33202. object: IPhysicsEnabledObject;
  33203. /**
  33204. * The type of the physics imposter
  33205. */
  33206. type: number;
  33207. private _options;
  33208. private _scene?;
  33209. /**
  33210. * The default object size of the imposter
  33211. */
  33212. static DEFAULT_OBJECT_SIZE: Vector3;
  33213. /**
  33214. * The identity quaternion of the imposter
  33215. */
  33216. static IDENTITY_QUATERNION: Quaternion;
  33217. /** @hidden */
  33218. _pluginData: any;
  33219. private _physicsEngine;
  33220. private _physicsBody;
  33221. private _bodyUpdateRequired;
  33222. private _onBeforePhysicsStepCallbacks;
  33223. private _onAfterPhysicsStepCallbacks;
  33224. /** @hidden */
  33225. _onPhysicsCollideCallbacks: Array<{
  33226. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33227. otherImpostors: Array<PhysicsImpostor>;
  33228. }>;
  33229. private _deltaPosition;
  33230. private _deltaRotation;
  33231. private _deltaRotationConjugated;
  33232. /** @hidden */
  33233. _isFromLine: boolean;
  33234. private _parent;
  33235. private _isDisposed;
  33236. private static _tmpVecs;
  33237. private static _tmpQuat;
  33238. /**
  33239. * Specifies if the physics imposter is disposed
  33240. */
  33241. get isDisposed(): boolean;
  33242. /**
  33243. * Gets the mass of the physics imposter
  33244. */
  33245. get mass(): number;
  33246. set mass(value: number);
  33247. /**
  33248. * Gets the coefficient of friction
  33249. */
  33250. get friction(): number;
  33251. /**
  33252. * Sets the coefficient of friction
  33253. */
  33254. set friction(value: number);
  33255. /**
  33256. * Gets the coefficient of restitution
  33257. */
  33258. get restitution(): number;
  33259. /**
  33260. * Sets the coefficient of restitution
  33261. */
  33262. set restitution(value: number);
  33263. /**
  33264. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33265. */
  33266. get pressure(): number;
  33267. /**
  33268. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33269. */
  33270. set pressure(value: number);
  33271. /**
  33272. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33273. */
  33274. get stiffness(): number;
  33275. /**
  33276. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33277. */
  33278. set stiffness(value: number);
  33279. /**
  33280. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33281. */
  33282. get velocityIterations(): number;
  33283. /**
  33284. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33285. */
  33286. set velocityIterations(value: number);
  33287. /**
  33288. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33289. */
  33290. get positionIterations(): number;
  33291. /**
  33292. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33293. */
  33294. set positionIterations(value: number);
  33295. /**
  33296. * The unique id of the physics imposter
  33297. * set by the physics engine when adding this impostor to the array
  33298. */
  33299. uniqueId: number;
  33300. /**
  33301. * @hidden
  33302. */
  33303. soft: boolean;
  33304. /**
  33305. * @hidden
  33306. */
  33307. segments: number;
  33308. private _joints;
  33309. /**
  33310. * Initializes the physics imposter
  33311. * @param object The physics-enabled object used as the physics imposter
  33312. * @param type The type of the physics imposter
  33313. * @param _options The options for the physics imposter
  33314. * @param _scene The Babylon scene
  33315. */
  33316. constructor(
  33317. /**
  33318. * The physics-enabled object used as the physics imposter
  33319. */
  33320. object: IPhysicsEnabledObject,
  33321. /**
  33322. * The type of the physics imposter
  33323. */
  33324. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33325. /**
  33326. * This function will completly initialize this impostor.
  33327. * It will create a new body - but only if this mesh has no parent.
  33328. * If it has, this impostor will not be used other than to define the impostor
  33329. * of the child mesh.
  33330. * @hidden
  33331. */
  33332. _init(): void;
  33333. private _getPhysicsParent;
  33334. /**
  33335. * Should a new body be generated.
  33336. * @returns boolean specifying if body initialization is required
  33337. */
  33338. isBodyInitRequired(): boolean;
  33339. /**
  33340. * Sets the updated scaling
  33341. * @param updated Specifies if the scaling is updated
  33342. */
  33343. setScalingUpdated(): void;
  33344. /**
  33345. * Force a regeneration of this or the parent's impostor's body.
  33346. * Use under cautious - This will remove all joints already implemented.
  33347. */
  33348. forceUpdate(): void;
  33349. /**
  33350. * Gets the body that holds this impostor. Either its own, or its parent.
  33351. */
  33352. get physicsBody(): any;
  33353. /**
  33354. * Get the parent of the physics imposter
  33355. * @returns Physics imposter or null
  33356. */
  33357. get parent(): Nullable<PhysicsImpostor>;
  33358. /**
  33359. * Sets the parent of the physics imposter
  33360. */
  33361. set parent(value: Nullable<PhysicsImpostor>);
  33362. /**
  33363. * Set the physics body. Used mainly by the physics engine/plugin
  33364. */
  33365. set physicsBody(physicsBody: any);
  33366. /**
  33367. * Resets the update flags
  33368. */
  33369. resetUpdateFlags(): void;
  33370. /**
  33371. * Gets the object extend size
  33372. * @returns the object extend size
  33373. */
  33374. getObjectExtendSize(): Vector3;
  33375. /**
  33376. * Gets the object center
  33377. * @returns The object center
  33378. */
  33379. getObjectCenter(): Vector3;
  33380. /**
  33381. * Get a specific parameter from the options parameters
  33382. * @param paramName The object parameter name
  33383. * @returns The object parameter
  33384. */
  33385. getParam(paramName: string): any;
  33386. /**
  33387. * Sets a specific parameter in the options given to the physics plugin
  33388. * @param paramName The parameter name
  33389. * @param value The value of the parameter
  33390. */
  33391. setParam(paramName: string, value: number): void;
  33392. /**
  33393. * Specifically change the body's mass option. Won't recreate the physics body object
  33394. * @param mass The mass of the physics imposter
  33395. */
  33396. setMass(mass: number): void;
  33397. /**
  33398. * Gets the linear velocity
  33399. * @returns linear velocity or null
  33400. */
  33401. getLinearVelocity(): Nullable<Vector3>;
  33402. /**
  33403. * Sets the linear velocity
  33404. * @param velocity linear velocity or null
  33405. */
  33406. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33407. /**
  33408. * Gets the angular velocity
  33409. * @returns angular velocity or null
  33410. */
  33411. getAngularVelocity(): Nullable<Vector3>;
  33412. /**
  33413. * Sets the angular velocity
  33414. * @param velocity The velocity or null
  33415. */
  33416. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33417. /**
  33418. * Execute a function with the physics plugin native code
  33419. * Provide a function the will have two variables - the world object and the physics body object
  33420. * @param func The function to execute with the physics plugin native code
  33421. */
  33422. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33423. /**
  33424. * Register a function that will be executed before the physics world is stepping forward
  33425. * @param func The function to execute before the physics world is stepped forward
  33426. */
  33427. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33428. /**
  33429. * Unregister a function that will be executed before the physics world is stepping forward
  33430. * @param func The function to execute before the physics world is stepped forward
  33431. */
  33432. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33433. /**
  33434. * Register a function that will be executed after the physics step
  33435. * @param func The function to execute after physics step
  33436. */
  33437. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33438. /**
  33439. * Unregisters a function that will be executed after the physics step
  33440. * @param func The function to execute after physics step
  33441. */
  33442. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33443. /**
  33444. * register a function that will be executed when this impostor collides against a different body
  33445. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33446. * @param func Callback that is executed on collision
  33447. */
  33448. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33449. /**
  33450. * Unregisters the physics imposter on contact
  33451. * @param collideAgainst The physics object to collide against
  33452. * @param func Callback to execute on collision
  33453. */
  33454. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33455. private _tmpQuat;
  33456. private _tmpQuat2;
  33457. /**
  33458. * Get the parent rotation
  33459. * @returns The parent rotation
  33460. */
  33461. getParentsRotation(): Quaternion;
  33462. /**
  33463. * this function is executed by the physics engine.
  33464. */
  33465. beforeStep: () => void;
  33466. /**
  33467. * this function is executed by the physics engine
  33468. */
  33469. afterStep: () => void;
  33470. /**
  33471. * Legacy collision detection event support
  33472. */
  33473. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33474. /**
  33475. * event and body object due to cannon's event-based architecture.
  33476. */
  33477. onCollide: (e: {
  33478. body: any;
  33479. point: Nullable<Vector3>;
  33480. }) => void;
  33481. /**
  33482. * Apply a force
  33483. * @param force The force to apply
  33484. * @param contactPoint The contact point for the force
  33485. * @returns The physics imposter
  33486. */
  33487. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33488. /**
  33489. * Apply an impulse
  33490. * @param force The impulse force
  33491. * @param contactPoint The contact point for the impulse force
  33492. * @returns The physics imposter
  33493. */
  33494. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33495. /**
  33496. * A help function to create a joint
  33497. * @param otherImpostor A physics imposter used to create a joint
  33498. * @param jointType The type of joint
  33499. * @param jointData The data for the joint
  33500. * @returns The physics imposter
  33501. */
  33502. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33503. /**
  33504. * Add a joint to this impostor with a different impostor
  33505. * @param otherImpostor A physics imposter used to add a joint
  33506. * @param joint The joint to add
  33507. * @returns The physics imposter
  33508. */
  33509. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33510. /**
  33511. * Add an anchor to a cloth impostor
  33512. * @param otherImpostor rigid impostor to anchor to
  33513. * @param width ratio across width from 0 to 1
  33514. * @param height ratio up height from 0 to 1
  33515. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33516. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33517. * @returns impostor the soft imposter
  33518. */
  33519. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33520. /**
  33521. * Add a hook to a rope impostor
  33522. * @param otherImpostor rigid impostor to anchor to
  33523. * @param length ratio across rope from 0 to 1
  33524. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33525. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33526. * @returns impostor the rope imposter
  33527. */
  33528. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33529. /**
  33530. * Will keep this body still, in a sleep mode.
  33531. * @returns the physics imposter
  33532. */
  33533. sleep(): PhysicsImpostor;
  33534. /**
  33535. * Wake the body up.
  33536. * @returns The physics imposter
  33537. */
  33538. wakeUp(): PhysicsImpostor;
  33539. /**
  33540. * Clones the physics imposter
  33541. * @param newObject The physics imposter clones to this physics-enabled object
  33542. * @returns A nullable physics imposter
  33543. */
  33544. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33545. /**
  33546. * Disposes the physics imposter
  33547. */
  33548. dispose(): void;
  33549. /**
  33550. * Sets the delta position
  33551. * @param position The delta position amount
  33552. */
  33553. setDeltaPosition(position: Vector3): void;
  33554. /**
  33555. * Sets the delta rotation
  33556. * @param rotation The delta rotation amount
  33557. */
  33558. setDeltaRotation(rotation: Quaternion): void;
  33559. /**
  33560. * Gets the box size of the physics imposter and stores the result in the input parameter
  33561. * @param result Stores the box size
  33562. * @returns The physics imposter
  33563. */
  33564. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33565. /**
  33566. * Gets the radius of the physics imposter
  33567. * @returns Radius of the physics imposter
  33568. */
  33569. getRadius(): number;
  33570. /**
  33571. * Sync a bone with this impostor
  33572. * @param bone The bone to sync to the impostor.
  33573. * @param boneMesh The mesh that the bone is influencing.
  33574. * @param jointPivot The pivot of the joint / bone in local space.
  33575. * @param distToJoint Optional distance from the impostor to the joint.
  33576. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33577. */
  33578. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33579. /**
  33580. * Sync impostor to a bone
  33581. * @param bone The bone that the impostor will be synced to.
  33582. * @param boneMesh The mesh that the bone is influencing.
  33583. * @param jointPivot The pivot of the joint / bone in local space.
  33584. * @param distToJoint Optional distance from the impostor to the joint.
  33585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33586. * @param boneAxis Optional vector3 axis the bone is aligned with
  33587. */
  33588. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33589. /**
  33590. * No-Imposter type
  33591. */
  33592. static NoImpostor: number;
  33593. /**
  33594. * Sphere-Imposter type
  33595. */
  33596. static SphereImpostor: number;
  33597. /**
  33598. * Box-Imposter type
  33599. */
  33600. static BoxImpostor: number;
  33601. /**
  33602. * Plane-Imposter type
  33603. */
  33604. static PlaneImpostor: number;
  33605. /**
  33606. * Mesh-imposter type
  33607. */
  33608. static MeshImpostor: number;
  33609. /**
  33610. * Capsule-Impostor type (Ammo.js plugin only)
  33611. */
  33612. static CapsuleImpostor: number;
  33613. /**
  33614. * Cylinder-Imposter type
  33615. */
  33616. static CylinderImpostor: number;
  33617. /**
  33618. * Particle-Imposter type
  33619. */
  33620. static ParticleImpostor: number;
  33621. /**
  33622. * Heightmap-Imposter type
  33623. */
  33624. static HeightmapImpostor: number;
  33625. /**
  33626. * ConvexHull-Impostor type (Ammo.js plugin only)
  33627. */
  33628. static ConvexHullImpostor: number;
  33629. /**
  33630. * Custom-Imposter type (Ammo.js plugin only)
  33631. */
  33632. static CustomImpostor: number;
  33633. /**
  33634. * Rope-Imposter type
  33635. */
  33636. static RopeImpostor: number;
  33637. /**
  33638. * Cloth-Imposter type
  33639. */
  33640. static ClothImpostor: number;
  33641. /**
  33642. * Softbody-Imposter type
  33643. */
  33644. static SoftbodyImpostor: number;
  33645. }
  33646. }
  33647. declare module "babylonjs/Meshes/mesh" {
  33648. import { Observable } from "babylonjs/Misc/observable";
  33649. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33651. import { Camera } from "babylonjs/Cameras/camera";
  33652. import { Scene } from "babylonjs/scene";
  33653. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33654. import { Color4 } from "babylonjs/Maths/math.color";
  33655. import { Engine } from "babylonjs/Engines/engine";
  33656. import { Node } from "babylonjs/node";
  33657. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33658. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33659. import { Buffer } from "babylonjs/Meshes/buffer";
  33660. import { Geometry } from "babylonjs/Meshes/geometry";
  33661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33662. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33663. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33664. import { Effect } from "babylonjs/Materials/effect";
  33665. import { Material } from "babylonjs/Materials/material";
  33666. import { Skeleton } from "babylonjs/Bones/skeleton";
  33667. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33668. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33669. import { Path3D } from "babylonjs/Maths/math.path";
  33670. import { Plane } from "babylonjs/Maths/math.plane";
  33671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33672. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33673. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33674. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33675. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33676. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33677. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33678. /**
  33679. * @hidden
  33680. **/
  33681. export class _CreationDataStorage {
  33682. closePath?: boolean;
  33683. closeArray?: boolean;
  33684. idx: number[];
  33685. dashSize: number;
  33686. gapSize: number;
  33687. path3D: Path3D;
  33688. pathArray: Vector3[][];
  33689. arc: number;
  33690. radius: number;
  33691. cap: number;
  33692. tessellation: number;
  33693. }
  33694. /**
  33695. * @hidden
  33696. **/
  33697. class _InstanceDataStorage {
  33698. visibleInstances: any;
  33699. batchCache: _InstancesBatch;
  33700. instancesBufferSize: number;
  33701. instancesBuffer: Nullable<Buffer>;
  33702. instancesData: Float32Array;
  33703. overridenInstanceCount: number;
  33704. isFrozen: boolean;
  33705. previousBatch: Nullable<_InstancesBatch>;
  33706. hardwareInstancedRendering: boolean;
  33707. sideOrientation: number;
  33708. manualUpdate: boolean;
  33709. previousRenderId: number;
  33710. }
  33711. /**
  33712. * @hidden
  33713. **/
  33714. export class _InstancesBatch {
  33715. mustReturn: boolean;
  33716. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33717. renderSelf: boolean[];
  33718. hardwareInstancedRendering: boolean[];
  33719. }
  33720. /**
  33721. * @hidden
  33722. **/
  33723. class _ThinInstanceDataStorage {
  33724. instancesCount: number;
  33725. matrixBuffer: Nullable<Buffer>;
  33726. matrixBufferSize: number;
  33727. matrixData: Nullable<Float32Array>;
  33728. boundingVectors: Array<Vector3>;
  33729. worldMatrices: Nullable<Matrix[]>;
  33730. }
  33731. /**
  33732. * Class used to represent renderable models
  33733. */
  33734. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33735. /**
  33736. * Mesh side orientation : usually the external or front surface
  33737. */
  33738. static readonly FRONTSIDE: number;
  33739. /**
  33740. * Mesh side orientation : usually the internal or back surface
  33741. */
  33742. static readonly BACKSIDE: number;
  33743. /**
  33744. * Mesh side orientation : both internal and external or front and back surfaces
  33745. */
  33746. static readonly DOUBLESIDE: number;
  33747. /**
  33748. * Mesh side orientation : by default, `FRONTSIDE`
  33749. */
  33750. static readonly DEFAULTSIDE: number;
  33751. /**
  33752. * Mesh cap setting : no cap
  33753. */
  33754. static readonly NO_CAP: number;
  33755. /**
  33756. * Mesh cap setting : one cap at the beginning of the mesh
  33757. */
  33758. static readonly CAP_START: number;
  33759. /**
  33760. * Mesh cap setting : one cap at the end of the mesh
  33761. */
  33762. static readonly CAP_END: number;
  33763. /**
  33764. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33765. */
  33766. static readonly CAP_ALL: number;
  33767. /**
  33768. * Mesh pattern setting : no flip or rotate
  33769. */
  33770. static readonly NO_FLIP: number;
  33771. /**
  33772. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33773. */
  33774. static readonly FLIP_TILE: number;
  33775. /**
  33776. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33777. */
  33778. static readonly ROTATE_TILE: number;
  33779. /**
  33780. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33781. */
  33782. static readonly FLIP_ROW: number;
  33783. /**
  33784. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33785. */
  33786. static readonly ROTATE_ROW: number;
  33787. /**
  33788. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33789. */
  33790. static readonly FLIP_N_ROTATE_TILE: number;
  33791. /**
  33792. * Mesh pattern setting : rotate pattern and rotate
  33793. */
  33794. static readonly FLIP_N_ROTATE_ROW: number;
  33795. /**
  33796. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33797. */
  33798. static readonly CENTER: number;
  33799. /**
  33800. * Mesh tile positioning : part tiles on left
  33801. */
  33802. static readonly LEFT: number;
  33803. /**
  33804. * Mesh tile positioning : part tiles on right
  33805. */
  33806. static readonly RIGHT: number;
  33807. /**
  33808. * Mesh tile positioning : part tiles on top
  33809. */
  33810. static readonly TOP: number;
  33811. /**
  33812. * Mesh tile positioning : part tiles on bottom
  33813. */
  33814. static readonly BOTTOM: number;
  33815. /**
  33816. * Gets the default side orientation.
  33817. * @param orientation the orientation to value to attempt to get
  33818. * @returns the default orientation
  33819. * @hidden
  33820. */
  33821. static _GetDefaultSideOrientation(orientation?: number): number;
  33822. private _internalMeshDataInfo;
  33823. get computeBonesUsingShaders(): boolean;
  33824. set computeBonesUsingShaders(value: boolean);
  33825. /**
  33826. * An event triggered before rendering the mesh
  33827. */
  33828. get onBeforeRenderObservable(): Observable<Mesh>;
  33829. /**
  33830. * An event triggered before binding the mesh
  33831. */
  33832. get onBeforeBindObservable(): Observable<Mesh>;
  33833. /**
  33834. * An event triggered after rendering the mesh
  33835. */
  33836. get onAfterRenderObservable(): Observable<Mesh>;
  33837. /**
  33838. * An event triggered before drawing the mesh
  33839. */
  33840. get onBeforeDrawObservable(): Observable<Mesh>;
  33841. private _onBeforeDrawObserver;
  33842. /**
  33843. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33844. */
  33845. set onBeforeDraw(callback: () => void);
  33846. get hasInstances(): boolean;
  33847. get hasThinInstances(): boolean;
  33848. /**
  33849. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33850. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33851. */
  33852. delayLoadState: number;
  33853. /**
  33854. * Gets the list of instances created from this mesh
  33855. * it is not supposed to be modified manually.
  33856. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33857. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33858. */
  33859. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33860. /**
  33861. * Gets the file containing delay loading data for this mesh
  33862. */
  33863. delayLoadingFile: string;
  33864. /** @hidden */
  33865. _binaryInfo: any;
  33866. /**
  33867. * User defined function used to change how LOD level selection is done
  33868. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33869. */
  33870. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33871. /**
  33872. * Gets or sets the morph target manager
  33873. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33874. */
  33875. get morphTargetManager(): Nullable<MorphTargetManager>;
  33876. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33877. /** @hidden */
  33878. _creationDataStorage: Nullable<_CreationDataStorage>;
  33879. /** @hidden */
  33880. _geometry: Nullable<Geometry>;
  33881. /** @hidden */
  33882. _delayInfo: Array<string>;
  33883. /** @hidden */
  33884. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33885. /** @hidden */
  33886. _instanceDataStorage: _InstanceDataStorage;
  33887. /** @hidden */
  33888. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33889. private _effectiveMaterial;
  33890. /** @hidden */
  33891. _shouldGenerateFlatShading: boolean;
  33892. /** @hidden */
  33893. _originalBuilderSideOrientation: number;
  33894. /**
  33895. * Use this property to change the original side orientation defined at construction time
  33896. */
  33897. overrideMaterialSideOrientation: Nullable<number>;
  33898. /**
  33899. * Gets the source mesh (the one used to clone this one from)
  33900. */
  33901. get source(): Nullable<Mesh>;
  33902. /**
  33903. * Gets the list of clones of this mesh
  33904. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33905. * Note that useClonedMeshMap=true is the default setting
  33906. */
  33907. get cloneMeshMap(): Nullable<{
  33908. [id: string]: Mesh | undefined;
  33909. }>;
  33910. /**
  33911. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33912. */
  33913. get isUnIndexed(): boolean;
  33914. set isUnIndexed(value: boolean);
  33915. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33916. get worldMatrixInstancedBuffer(): Float32Array;
  33917. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33918. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33919. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33920. /**
  33921. * @constructor
  33922. * @param name The value used by scene.getMeshByName() to do a lookup.
  33923. * @param scene The scene to add this mesh to.
  33924. * @param parent The parent of this mesh, if it has one
  33925. * @param source An optional Mesh from which geometry is shared, cloned.
  33926. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33927. * When false, achieved by calling a clone(), also passing False.
  33928. * This will make creation of children, recursive.
  33929. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33930. */
  33931. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33932. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33933. doNotInstantiate: boolean;
  33934. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33935. /**
  33936. * Gets the class name
  33937. * @returns the string "Mesh".
  33938. */
  33939. getClassName(): string;
  33940. /** @hidden */
  33941. get _isMesh(): boolean;
  33942. /**
  33943. * Returns a description of this mesh
  33944. * @param fullDetails define if full details about this mesh must be used
  33945. * @returns a descriptive string representing this mesh
  33946. */
  33947. toString(fullDetails?: boolean): string;
  33948. /** @hidden */
  33949. _unBindEffect(): void;
  33950. /**
  33951. * Gets a boolean indicating if this mesh has LOD
  33952. */
  33953. get hasLODLevels(): boolean;
  33954. /**
  33955. * Gets the list of MeshLODLevel associated with the current mesh
  33956. * @returns an array of MeshLODLevel
  33957. */
  33958. getLODLevels(): MeshLODLevel[];
  33959. private _sortLODLevels;
  33960. /**
  33961. * Add a mesh as LOD level triggered at the given distance.
  33962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33963. * @param distance The distance from the center of the object to show this level
  33964. * @param mesh The mesh to be added as LOD level (can be null)
  33965. * @return This mesh (for chaining)
  33966. */
  33967. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33968. /**
  33969. * Returns the LOD level mesh at the passed distance or null if not found.
  33970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33971. * @param distance The distance from the center of the object to show this level
  33972. * @returns a Mesh or `null`
  33973. */
  33974. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33975. /**
  33976. * Remove a mesh from the LOD array
  33977. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33978. * @param mesh defines the mesh to be removed
  33979. * @return This mesh (for chaining)
  33980. */
  33981. removeLODLevel(mesh: Mesh): Mesh;
  33982. /**
  33983. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33984. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33985. * @param camera defines the camera to use to compute distance
  33986. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33987. * @return This mesh (for chaining)
  33988. */
  33989. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33990. /**
  33991. * Gets the mesh internal Geometry object
  33992. */
  33993. get geometry(): Nullable<Geometry>;
  33994. /**
  33995. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33996. * @returns the total number of vertices
  33997. */
  33998. getTotalVertices(): number;
  33999. /**
  34000. * Returns the content of an associated vertex buffer
  34001. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34002. * - VertexBuffer.PositionKind
  34003. * - VertexBuffer.UVKind
  34004. * - VertexBuffer.UV2Kind
  34005. * - VertexBuffer.UV3Kind
  34006. * - VertexBuffer.UV4Kind
  34007. * - VertexBuffer.UV5Kind
  34008. * - VertexBuffer.UV6Kind
  34009. * - VertexBuffer.ColorKind
  34010. * - VertexBuffer.MatricesIndicesKind
  34011. * - VertexBuffer.MatricesIndicesExtraKind
  34012. * - VertexBuffer.MatricesWeightsKind
  34013. * - VertexBuffer.MatricesWeightsExtraKind
  34014. * @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
  34015. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34016. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34017. */
  34018. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34019. /**
  34020. * Returns the mesh VertexBuffer object from the requested `kind`
  34021. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34022. * - VertexBuffer.PositionKind
  34023. * - VertexBuffer.NormalKind
  34024. * - VertexBuffer.UVKind
  34025. * - VertexBuffer.UV2Kind
  34026. * - VertexBuffer.UV3Kind
  34027. * - VertexBuffer.UV4Kind
  34028. * - VertexBuffer.UV5Kind
  34029. * - VertexBuffer.UV6Kind
  34030. * - VertexBuffer.ColorKind
  34031. * - VertexBuffer.MatricesIndicesKind
  34032. * - VertexBuffer.MatricesIndicesExtraKind
  34033. * - VertexBuffer.MatricesWeightsKind
  34034. * - VertexBuffer.MatricesWeightsExtraKind
  34035. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34036. */
  34037. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34038. /**
  34039. * Tests if a specific vertex buffer is associated with this mesh
  34040. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34041. * - VertexBuffer.PositionKind
  34042. * - VertexBuffer.NormalKind
  34043. * - VertexBuffer.UVKind
  34044. * - VertexBuffer.UV2Kind
  34045. * - VertexBuffer.UV3Kind
  34046. * - VertexBuffer.UV4Kind
  34047. * - VertexBuffer.UV5Kind
  34048. * - VertexBuffer.UV6Kind
  34049. * - VertexBuffer.ColorKind
  34050. * - VertexBuffer.MatricesIndicesKind
  34051. * - VertexBuffer.MatricesIndicesExtraKind
  34052. * - VertexBuffer.MatricesWeightsKind
  34053. * - VertexBuffer.MatricesWeightsExtraKind
  34054. * @returns a boolean
  34055. */
  34056. isVerticesDataPresent(kind: string): boolean;
  34057. /**
  34058. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34059. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34060. * - VertexBuffer.PositionKind
  34061. * - VertexBuffer.UVKind
  34062. * - VertexBuffer.UV2Kind
  34063. * - VertexBuffer.UV3Kind
  34064. * - VertexBuffer.UV4Kind
  34065. * - VertexBuffer.UV5Kind
  34066. * - VertexBuffer.UV6Kind
  34067. * - VertexBuffer.ColorKind
  34068. * - VertexBuffer.MatricesIndicesKind
  34069. * - VertexBuffer.MatricesIndicesExtraKind
  34070. * - VertexBuffer.MatricesWeightsKind
  34071. * - VertexBuffer.MatricesWeightsExtraKind
  34072. * @returns a boolean
  34073. */
  34074. isVertexBufferUpdatable(kind: string): boolean;
  34075. /**
  34076. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34077. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34078. * - VertexBuffer.PositionKind
  34079. * - VertexBuffer.NormalKind
  34080. * - VertexBuffer.UVKind
  34081. * - VertexBuffer.UV2Kind
  34082. * - VertexBuffer.UV3Kind
  34083. * - VertexBuffer.UV4Kind
  34084. * - VertexBuffer.UV5Kind
  34085. * - VertexBuffer.UV6Kind
  34086. * - VertexBuffer.ColorKind
  34087. * - VertexBuffer.MatricesIndicesKind
  34088. * - VertexBuffer.MatricesIndicesExtraKind
  34089. * - VertexBuffer.MatricesWeightsKind
  34090. * - VertexBuffer.MatricesWeightsExtraKind
  34091. * @returns an array of strings
  34092. */
  34093. getVerticesDataKinds(): string[];
  34094. /**
  34095. * Returns a positive integer : the total number of indices in this mesh geometry.
  34096. * @returns the numner of indices or zero if the mesh has no geometry.
  34097. */
  34098. getTotalIndices(): number;
  34099. /**
  34100. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34101. * @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.
  34102. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34103. * @returns the indices array or an empty array if the mesh has no geometry
  34104. */
  34105. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34106. get isBlocked(): boolean;
  34107. /**
  34108. * Determine if the current mesh is ready to be rendered
  34109. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34110. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34111. * @returns true if all associated assets are ready (material, textures, shaders)
  34112. */
  34113. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34114. /**
  34115. * 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.
  34116. */
  34117. get areNormalsFrozen(): boolean;
  34118. /**
  34119. * 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.
  34120. * @returns the current mesh
  34121. */
  34122. freezeNormals(): Mesh;
  34123. /**
  34124. * 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
  34125. * @returns the current mesh
  34126. */
  34127. unfreezeNormals(): Mesh;
  34128. /**
  34129. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34130. */
  34131. set overridenInstanceCount(count: number);
  34132. /** @hidden */
  34133. _preActivate(): Mesh;
  34134. /** @hidden */
  34135. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34136. /** @hidden */
  34137. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34138. protected _afterComputeWorldMatrix(): void;
  34139. /** @hidden */
  34140. _postActivate(): void;
  34141. /**
  34142. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34143. * This means the mesh underlying bounding box and sphere are recomputed.
  34144. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34145. * @returns the current mesh
  34146. */
  34147. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34148. /** @hidden */
  34149. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34150. /**
  34151. * This function will subdivide the mesh into multiple submeshes
  34152. * @param count defines the expected number of submeshes
  34153. */
  34154. subdivide(count: number): void;
  34155. /**
  34156. * Copy a FloatArray into a specific associated vertex buffer
  34157. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34158. * - VertexBuffer.PositionKind
  34159. * - VertexBuffer.UVKind
  34160. * - VertexBuffer.UV2Kind
  34161. * - VertexBuffer.UV3Kind
  34162. * - VertexBuffer.UV4Kind
  34163. * - VertexBuffer.UV5Kind
  34164. * - VertexBuffer.UV6Kind
  34165. * - VertexBuffer.ColorKind
  34166. * - VertexBuffer.MatricesIndicesKind
  34167. * - VertexBuffer.MatricesIndicesExtraKind
  34168. * - VertexBuffer.MatricesWeightsKind
  34169. * - VertexBuffer.MatricesWeightsExtraKind
  34170. * @param data defines the data source
  34171. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34172. * @param stride defines the data stride size (can be null)
  34173. * @returns the current mesh
  34174. */
  34175. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34176. /**
  34177. * Delete a vertex buffer associated with this mesh
  34178. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34179. * - VertexBuffer.PositionKind
  34180. * - VertexBuffer.UVKind
  34181. * - VertexBuffer.UV2Kind
  34182. * - VertexBuffer.UV3Kind
  34183. * - VertexBuffer.UV4Kind
  34184. * - VertexBuffer.UV5Kind
  34185. * - VertexBuffer.UV6Kind
  34186. * - VertexBuffer.ColorKind
  34187. * - VertexBuffer.MatricesIndicesKind
  34188. * - VertexBuffer.MatricesIndicesExtraKind
  34189. * - VertexBuffer.MatricesWeightsKind
  34190. * - VertexBuffer.MatricesWeightsExtraKind
  34191. */
  34192. removeVerticesData(kind: string): void;
  34193. /**
  34194. * Flags an associated vertex buffer as updatable
  34195. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34196. * - VertexBuffer.PositionKind
  34197. * - VertexBuffer.UVKind
  34198. * - VertexBuffer.UV2Kind
  34199. * - VertexBuffer.UV3Kind
  34200. * - VertexBuffer.UV4Kind
  34201. * - VertexBuffer.UV5Kind
  34202. * - VertexBuffer.UV6Kind
  34203. * - VertexBuffer.ColorKind
  34204. * - VertexBuffer.MatricesIndicesKind
  34205. * - VertexBuffer.MatricesIndicesExtraKind
  34206. * - VertexBuffer.MatricesWeightsKind
  34207. * - VertexBuffer.MatricesWeightsExtraKind
  34208. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34209. */
  34210. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34211. /**
  34212. * Sets the mesh global Vertex Buffer
  34213. * @param buffer defines the buffer to use
  34214. * @returns the current mesh
  34215. */
  34216. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34217. /**
  34218. * Update a specific associated vertex buffer
  34219. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34220. * - VertexBuffer.PositionKind
  34221. * - VertexBuffer.UVKind
  34222. * - VertexBuffer.UV2Kind
  34223. * - VertexBuffer.UV3Kind
  34224. * - VertexBuffer.UV4Kind
  34225. * - VertexBuffer.UV5Kind
  34226. * - VertexBuffer.UV6Kind
  34227. * - VertexBuffer.ColorKind
  34228. * - VertexBuffer.MatricesIndicesKind
  34229. * - VertexBuffer.MatricesIndicesExtraKind
  34230. * - VertexBuffer.MatricesWeightsKind
  34231. * - VertexBuffer.MatricesWeightsExtraKind
  34232. * @param data defines the data source
  34233. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34234. * @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)
  34235. * @returns the current mesh
  34236. */
  34237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34238. /**
  34239. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34240. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34241. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34242. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34243. * @returns the current mesh
  34244. */
  34245. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34246. /**
  34247. * Creates a un-shared specific occurence of the geometry for the mesh.
  34248. * @returns the current mesh
  34249. */
  34250. makeGeometryUnique(): Mesh;
  34251. /**
  34252. * Set the index buffer of this mesh
  34253. * @param indices defines the source data
  34254. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34255. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34256. * @returns the current mesh
  34257. */
  34258. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34259. /**
  34260. * Update the current index buffer
  34261. * @param indices defines the source data
  34262. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34263. * @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)
  34264. * @returns the current mesh
  34265. */
  34266. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34267. /**
  34268. * Invert the geometry to move from a right handed system to a left handed one.
  34269. * @returns the current mesh
  34270. */
  34271. toLeftHanded(): Mesh;
  34272. /** @hidden */
  34273. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34274. /** @hidden */
  34275. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34276. /**
  34277. * Registers for this mesh a javascript function called just before the rendering process
  34278. * @param func defines the function to call before rendering this mesh
  34279. * @returns the current mesh
  34280. */
  34281. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34282. /**
  34283. * Disposes a previously registered javascript function called before the rendering
  34284. * @param func defines the function to remove
  34285. * @returns the current mesh
  34286. */
  34287. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34288. /**
  34289. * Registers for this mesh a javascript function called just after the rendering is complete
  34290. * @param func defines the function to call after rendering this mesh
  34291. * @returns the current mesh
  34292. */
  34293. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34294. /**
  34295. * Disposes a previously registered javascript function called after the rendering.
  34296. * @param func defines the function to remove
  34297. * @returns the current mesh
  34298. */
  34299. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34300. /** @hidden */
  34301. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34302. /** @hidden */
  34303. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34304. /** @hidden */
  34305. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34306. /** @hidden */
  34307. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34308. /** @hidden */
  34309. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34310. /** @hidden */
  34311. _rebuild(): void;
  34312. /** @hidden */
  34313. _freeze(): void;
  34314. /** @hidden */
  34315. _unFreeze(): void;
  34316. /**
  34317. * 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
  34318. * @param subMesh defines the subMesh to render
  34319. * @param enableAlphaMode defines if alpha mode can be changed
  34320. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34321. * @returns the current mesh
  34322. */
  34323. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34324. private _onBeforeDraw;
  34325. /**
  34326. * Renormalize the mesh and patch it up if there are no weights
  34327. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34328. * However in the case of zero weights then we set just a single influence to 1.
  34329. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34330. */
  34331. cleanMatrixWeights(): void;
  34332. private normalizeSkinFourWeights;
  34333. private normalizeSkinWeightsAndExtra;
  34334. /**
  34335. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34336. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34337. * the user know there was an issue with importing the mesh
  34338. * @returns a validation object with skinned, valid and report string
  34339. */
  34340. validateSkinning(): {
  34341. skinned: boolean;
  34342. valid: boolean;
  34343. report: string;
  34344. };
  34345. /** @hidden */
  34346. _checkDelayState(): Mesh;
  34347. private _queueLoad;
  34348. /**
  34349. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34350. * A mesh is in the frustum if its bounding box intersects the frustum
  34351. * @param frustumPlanes defines the frustum to test
  34352. * @returns true if the mesh is in the frustum planes
  34353. */
  34354. isInFrustum(frustumPlanes: Plane[]): boolean;
  34355. /**
  34356. * Sets the mesh material by the material or multiMaterial `id` property
  34357. * @param id is a string identifying the material or the multiMaterial
  34358. * @returns the current mesh
  34359. */
  34360. setMaterialByID(id: string): Mesh;
  34361. /**
  34362. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34363. * @returns an array of IAnimatable
  34364. */
  34365. getAnimatables(): IAnimatable[];
  34366. /**
  34367. * Modifies the mesh geometry according to the passed transformation matrix.
  34368. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34369. * The mesh normals are modified using the same transformation.
  34370. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34371. * @param transform defines the transform matrix to use
  34372. * @see https://doc.babylonjs.com/resources/baking_transformations
  34373. * @returns the current mesh
  34374. */
  34375. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34376. /**
  34377. * Modifies the mesh geometry according to its own current World Matrix.
  34378. * The mesh World Matrix is then reset.
  34379. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34380. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34381. * @see https://doc.babylonjs.com/resources/baking_transformations
  34382. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34383. * @returns the current mesh
  34384. */
  34385. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34386. /** @hidden */
  34387. get _positions(): Nullable<Vector3[]>;
  34388. /** @hidden */
  34389. _resetPointsArrayCache(): Mesh;
  34390. /** @hidden */
  34391. _generatePointsArray(): boolean;
  34392. /**
  34393. * Returns a new Mesh object generated from the current mesh properties.
  34394. * This method must not get confused with createInstance()
  34395. * @param name is a string, the name given to the new mesh
  34396. * @param newParent can be any Node object (default `null`)
  34397. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34398. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34399. * @returns a new mesh
  34400. */
  34401. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34402. /**
  34403. * Releases resources associated with this mesh.
  34404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34406. */
  34407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34408. /** @hidden */
  34409. _disposeInstanceSpecificData(): void;
  34410. /** @hidden */
  34411. _disposeThinInstanceSpecificData(): void;
  34412. /**
  34413. * Modifies the mesh geometry according to a displacement map.
  34414. * 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.
  34415. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34416. * @param url is a string, the URL from the image file is to be downloaded.
  34417. * @param minHeight is the lower limit of the displacement.
  34418. * @param maxHeight is the upper limit of the displacement.
  34419. * @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.
  34420. * @param uvOffset is an optional vector2 used to offset UV.
  34421. * @param uvScale is an optional vector2 used to scale UV.
  34422. * @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.
  34423. * @returns the Mesh.
  34424. */
  34425. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34426. /**
  34427. * Modifies the mesh geometry according to a displacementMap buffer.
  34428. * 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.
  34429. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34430. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34431. * @param heightMapWidth is the width of the buffer image.
  34432. * @param heightMapHeight is the height of the buffer image.
  34433. * @param minHeight is the lower limit of the displacement.
  34434. * @param maxHeight is the upper limit of the displacement.
  34435. * @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.
  34436. * @param uvOffset is an optional vector2 used to offset UV.
  34437. * @param uvScale is an optional vector2 used to scale UV.
  34438. * @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.
  34439. * @returns the Mesh.
  34440. */
  34441. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34442. /**
  34443. * Modify the mesh to get a flat shading rendering.
  34444. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34445. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34446. * @returns current mesh
  34447. */
  34448. convertToFlatShadedMesh(): Mesh;
  34449. /**
  34450. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34451. * In other words, more vertices, no more indices and a single bigger VBO.
  34452. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34453. * @returns current mesh
  34454. */
  34455. convertToUnIndexedMesh(): Mesh;
  34456. /**
  34457. * Inverses facet orientations.
  34458. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34459. * @param flipNormals will also inverts the normals
  34460. * @returns current mesh
  34461. */
  34462. flipFaces(flipNormals?: boolean): Mesh;
  34463. /**
  34464. * Increase the number of facets and hence vertices in a mesh
  34465. * Vertex normals are interpolated from existing vertex normals
  34466. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34467. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34468. */
  34469. increaseVertices(numberPerEdge: number): void;
  34470. /**
  34471. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34472. * This will undo any application of covertToFlatShadedMesh
  34473. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34474. */
  34475. forceSharedVertices(): void;
  34476. /** @hidden */
  34477. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34478. /** @hidden */
  34479. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34480. /**
  34481. * Creates a new InstancedMesh object from the mesh model.
  34482. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34483. * @param name defines the name of the new instance
  34484. * @returns a new InstancedMesh
  34485. */
  34486. createInstance(name: string): InstancedMesh;
  34487. /**
  34488. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34489. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34490. * @returns the current mesh
  34491. */
  34492. synchronizeInstances(): Mesh;
  34493. /**
  34494. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34495. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34496. * This should be used together with the simplification to avoid disappearing triangles.
  34497. * @param successCallback an optional success callback to be called after the optimization finished.
  34498. * @returns the current mesh
  34499. */
  34500. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34501. /**
  34502. * Serialize current mesh
  34503. * @param serializationObject defines the object which will receive the serialization data
  34504. */
  34505. serialize(serializationObject: any): void;
  34506. /** @hidden */
  34507. _syncGeometryWithMorphTargetManager(): void;
  34508. /** @hidden */
  34509. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34510. /**
  34511. * Returns a new Mesh object parsed from the source provided.
  34512. * @param parsedMesh is the source
  34513. * @param scene defines the hosting scene
  34514. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34515. * @returns a new Mesh
  34516. */
  34517. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34518. /**
  34519. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34520. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34521. * @param name defines the name of the mesh to create
  34522. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34523. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34524. * @param closePath creates a seam between the first and the last points of each path of the path array
  34525. * @param offset is taken in account only if the `pathArray` is containing a single path
  34526. * @param scene defines the hosting scene
  34527. * @param updatable defines if the mesh must be flagged as updatable
  34528. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34529. * @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)
  34530. * @returns a new Mesh
  34531. */
  34532. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34533. /**
  34534. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34535. * @param name defines the name of the mesh to create
  34536. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34537. * @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
  34538. * @param scene defines the hosting scene
  34539. * @param updatable defines if the mesh must be flagged as updatable
  34540. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34541. * @returns a new Mesh
  34542. */
  34543. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34544. /**
  34545. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34546. * @param name defines the name of the mesh to create
  34547. * @param size sets the size (float) of each box side (default 1)
  34548. * @param scene defines the hosting scene
  34549. * @param updatable defines if the mesh must be flagged as updatable
  34550. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34551. * @returns a new Mesh
  34552. */
  34553. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34554. /**
  34555. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34556. * @param name defines the name of the mesh to create
  34557. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34558. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34559. * @param scene defines the hosting scene
  34560. * @param updatable defines if the mesh must be flagged as updatable
  34561. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34562. * @returns a new Mesh
  34563. */
  34564. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34565. /**
  34566. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34567. * @param name defines the name of the mesh to create
  34568. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34569. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34570. * @param scene defines the hosting scene
  34571. * @returns a new Mesh
  34572. */
  34573. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34574. /**
  34575. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34576. * @param name defines the name of the mesh to create
  34577. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34578. * @param diameterTop set the top cap diameter (floats, default 1)
  34579. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34580. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34581. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34582. * @param scene defines the hosting scene
  34583. * @param updatable defines if the mesh must be flagged as updatable
  34584. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34585. * @returns a new Mesh
  34586. */
  34587. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34588. /**
  34589. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34590. * @param name defines the name of the mesh to create
  34591. * @param diameter sets the diameter size (float) of the torus (default 1)
  34592. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34593. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34594. * @param scene defines the hosting scene
  34595. * @param updatable defines if the mesh must be flagged as updatable
  34596. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34597. * @returns a new Mesh
  34598. */
  34599. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34600. /**
  34601. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34602. * @param name defines the name of the mesh to create
  34603. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34604. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34605. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34606. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34607. * @param p the number of windings on X axis (positive integers, default 2)
  34608. * @param q the number of windings on Y axis (positive integers, default 3)
  34609. * @param scene defines the hosting scene
  34610. * @param updatable defines if the mesh must be flagged as updatable
  34611. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34612. * @returns a new Mesh
  34613. */
  34614. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34615. /**
  34616. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34617. * @param name defines the name of the mesh to create
  34618. * @param points is an array successive Vector3
  34619. * @param scene defines the hosting scene
  34620. * @param updatable defines if the mesh must be flagged as updatable
  34621. * @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).
  34622. * @returns a new Mesh
  34623. */
  34624. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34625. /**
  34626. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34627. * @param name defines the name of the mesh to create
  34628. * @param points is an array successive Vector3
  34629. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34630. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34631. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34632. * @param scene defines the hosting scene
  34633. * @param updatable defines if the mesh must be flagged as updatable
  34634. * @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)
  34635. * @returns a new Mesh
  34636. */
  34637. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34638. /**
  34639. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34640. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34641. * 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.
  34642. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34643. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34644. * Remember you can only change the shape positions, not their number when updating a polygon.
  34645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34646. * @param name defines the name of the mesh to create
  34647. * @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
  34648. * @param scene defines the hosting scene
  34649. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34650. * @param updatable defines if the mesh must be flagged as updatable
  34651. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34652. * @param earcutInjection can be used to inject your own earcut reference
  34653. * @returns a new Mesh
  34654. */
  34655. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34656. /**
  34657. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34659. * @param name defines the name of the mesh to create
  34660. * @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
  34661. * @param depth defines the height of extrusion
  34662. * @param scene defines the hosting scene
  34663. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34664. * @param updatable defines if the mesh must be flagged as updatable
  34665. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34666. * @param earcutInjection can be used to inject your own earcut reference
  34667. * @returns a new Mesh
  34668. */
  34669. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34670. /**
  34671. * Creates an extruded shape mesh.
  34672. * 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
  34673. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34675. * @param name defines the name of the mesh to create
  34676. * @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
  34677. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34678. * @param scale is the value to scale the shape
  34679. * @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
  34680. * @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
  34681. * @param scene defines the hosting scene
  34682. * @param updatable defines if the mesh must be flagged as updatable
  34683. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34684. * @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)
  34685. * @returns a new Mesh
  34686. */
  34687. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34688. /**
  34689. * Creates an custom extruded shape mesh.
  34690. * The custom extrusion is a parametric shape.
  34691. * It has no predefined shape. Its final shape will depend on the input parameters.
  34692. * Please consider using the same method from the MeshBuilder class instead
  34693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34694. * @param name defines the name of the mesh to create
  34695. * @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
  34696. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34697. * @param scaleFunction is a custom Javascript function called on each path point
  34698. * @param rotationFunction is a custom Javascript function called on each path point
  34699. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34700. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34701. * @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
  34702. * @param scene defines the hosting scene
  34703. * @param updatable defines if the mesh must be flagged as updatable
  34704. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34705. * @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)
  34706. * @returns a new Mesh
  34707. */
  34708. 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;
  34709. /**
  34710. * Creates lathe mesh.
  34711. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34712. * Please consider using the same method from the MeshBuilder class instead
  34713. * @param name defines the name of the mesh to create
  34714. * @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
  34715. * @param radius is the radius value of the lathe
  34716. * @param tessellation is the side number of the lathe.
  34717. * @param scene defines the hosting scene
  34718. * @param updatable defines if the mesh must be flagged as updatable
  34719. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34720. * @returns a new Mesh
  34721. */
  34722. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34723. /**
  34724. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34725. * @param name defines the name of the mesh to create
  34726. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34727. * @param scene defines the hosting scene
  34728. * @param updatable defines if the mesh must be flagged as updatable
  34729. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34730. * @returns a new Mesh
  34731. */
  34732. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34733. /**
  34734. * Creates a ground mesh.
  34735. * Please consider using the same method from the MeshBuilder class instead
  34736. * @param name defines the name of the mesh to create
  34737. * @param width set the width of the ground
  34738. * @param height set the height of the ground
  34739. * @param subdivisions sets the number of subdivisions per side
  34740. * @param scene defines the hosting scene
  34741. * @param updatable defines if the mesh must be flagged as updatable
  34742. * @returns a new Mesh
  34743. */
  34744. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34745. /**
  34746. * Creates a tiled ground mesh.
  34747. * Please consider using the same method from the MeshBuilder class instead
  34748. * @param name defines the name of the mesh to create
  34749. * @param xmin set the ground minimum X coordinate
  34750. * @param zmin set the ground minimum Y coordinate
  34751. * @param xmax set the ground maximum X coordinate
  34752. * @param zmax set the ground maximum Z coordinate
  34753. * @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
  34754. * @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
  34755. * @param scene defines the hosting scene
  34756. * @param updatable defines if the mesh must be flagged as updatable
  34757. * @returns a new Mesh
  34758. */
  34759. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34760. w: number;
  34761. h: number;
  34762. }, precision: {
  34763. w: number;
  34764. h: number;
  34765. }, scene: Scene, updatable?: boolean): Mesh;
  34766. /**
  34767. * Creates a ground mesh from a height map.
  34768. * Please consider using the same method from the MeshBuilder class instead
  34769. * @see https://doc.babylonjs.com/babylon101/height_map
  34770. * @param name defines the name of the mesh to create
  34771. * @param url sets the URL of the height map image resource
  34772. * @param width set the ground width size
  34773. * @param height set the ground height size
  34774. * @param subdivisions sets the number of subdivision per side
  34775. * @param minHeight is the minimum altitude on the ground
  34776. * @param maxHeight is the maximum altitude on the ground
  34777. * @param scene defines the hosting scene
  34778. * @param updatable defines if the mesh must be flagged as updatable
  34779. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34780. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34781. * @returns a new Mesh
  34782. */
  34783. 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;
  34784. /**
  34785. * Creates a tube mesh.
  34786. * The tube is a parametric shape.
  34787. * It has no predefined shape. Its final shape will depend on the input parameters.
  34788. * Please consider using the same method from the MeshBuilder class instead
  34789. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34790. * @param name defines the name of the mesh to create
  34791. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34792. * @param radius sets the tube radius size
  34793. * @param tessellation is the number of sides on the tubular surface
  34794. * @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
  34795. * @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
  34796. * @param scene defines the hosting scene
  34797. * @param updatable defines if the mesh must be flagged as updatable
  34798. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34799. * @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)
  34800. * @returns a new Mesh
  34801. */
  34802. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34803. (i: number, distance: number): number;
  34804. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34805. /**
  34806. * Creates a polyhedron mesh.
  34807. * Please consider using the same method from the MeshBuilder class instead.
  34808. * * 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
  34809. * * The parameter `size` (positive float, default 1) sets the polygon size
  34810. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34811. * * 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`
  34812. * * 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
  34813. * * 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)`)
  34814. * * 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
  34815. * * 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
  34816. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34819. * @param name defines the name of the mesh to create
  34820. * @param options defines the options used to create the mesh
  34821. * @param scene defines the hosting scene
  34822. * @returns a new Mesh
  34823. */
  34824. static CreatePolyhedron(name: string, options: {
  34825. type?: number;
  34826. size?: number;
  34827. sizeX?: number;
  34828. sizeY?: number;
  34829. sizeZ?: number;
  34830. custom?: any;
  34831. faceUV?: Vector4[];
  34832. faceColors?: Color4[];
  34833. updatable?: boolean;
  34834. sideOrientation?: number;
  34835. }, scene: Scene): Mesh;
  34836. /**
  34837. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34838. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34839. * * 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`)
  34840. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34841. * * 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
  34842. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34845. * @param name defines the name of the mesh
  34846. * @param options defines the options used to create the mesh
  34847. * @param scene defines the hosting scene
  34848. * @returns a new Mesh
  34849. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34850. */
  34851. static CreateIcoSphere(name: string, options: {
  34852. radius?: number;
  34853. flat?: boolean;
  34854. subdivisions?: number;
  34855. sideOrientation?: number;
  34856. updatable?: boolean;
  34857. }, scene: Scene): Mesh;
  34858. /**
  34859. * Creates a decal mesh.
  34860. * Please consider using the same method from the MeshBuilder class instead.
  34861. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34862. * @param name defines the name of the mesh
  34863. * @param sourceMesh defines the mesh receiving the decal
  34864. * @param position sets the position of the decal in world coordinates
  34865. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34866. * @param size sets the decal scaling
  34867. * @param angle sets the angle to rotate the decal
  34868. * @returns a new Mesh
  34869. */
  34870. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34871. /** Creates a Capsule Mesh
  34872. * @param name defines the name of the mesh.
  34873. * @param options the constructors options used to shape the mesh.
  34874. * @param scene defines the scene the mesh is scoped to.
  34875. * @returns the capsule mesh
  34876. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34877. */
  34878. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34879. /**
  34880. * Prepare internal position array for software CPU skinning
  34881. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34882. */
  34883. setPositionsForCPUSkinning(): Float32Array;
  34884. /**
  34885. * Prepare internal normal array for software CPU skinning
  34886. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34887. */
  34888. setNormalsForCPUSkinning(): Float32Array;
  34889. /**
  34890. * Updates the vertex buffer by applying transformation from the bones
  34891. * @param skeleton defines the skeleton to apply to current mesh
  34892. * @returns the current mesh
  34893. */
  34894. applySkeleton(skeleton: Skeleton): Mesh;
  34895. /**
  34896. * 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
  34897. * @param meshes defines the list of meshes to scan
  34898. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34899. */
  34900. static MinMax(meshes: AbstractMesh[]): {
  34901. min: Vector3;
  34902. max: Vector3;
  34903. };
  34904. /**
  34905. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34906. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34907. * @returns a vector3
  34908. */
  34909. static Center(meshesOrMinMaxVector: {
  34910. min: Vector3;
  34911. max: Vector3;
  34912. } | AbstractMesh[]): Vector3;
  34913. /**
  34914. * Merge the array of meshes into a single mesh for performance reasons.
  34915. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34916. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34917. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34918. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34919. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34920. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34921. * @returns a new mesh
  34922. */
  34923. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34924. /** @hidden */
  34925. addInstance(instance: InstancedMesh): void;
  34926. /** @hidden */
  34927. removeInstance(instance: InstancedMesh): void;
  34928. }
  34929. }
  34930. declare module "babylonjs/Cameras/camera" {
  34931. import { SmartArray } from "babylonjs/Misc/smartArray";
  34932. import { Observable } from "babylonjs/Misc/observable";
  34933. import { Nullable } from "babylonjs/types";
  34934. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34935. import { Scene } from "babylonjs/scene";
  34936. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34937. import { Node } from "babylonjs/node";
  34938. import { Mesh } from "babylonjs/Meshes/mesh";
  34939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34940. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34941. import { Viewport } from "babylonjs/Maths/math.viewport";
  34942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34945. import { Ray } from "babylonjs/Culling/ray";
  34946. /**
  34947. * This is the base class of all the camera used in the application.
  34948. * @see https://doc.babylonjs.com/features/cameras
  34949. */
  34950. export class Camera extends Node {
  34951. /** @hidden */
  34952. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34953. /**
  34954. * This is the default projection mode used by the cameras.
  34955. * It helps recreating a feeling of perspective and better appreciate depth.
  34956. * This is the best way to simulate real life cameras.
  34957. */
  34958. static readonly PERSPECTIVE_CAMERA: number;
  34959. /**
  34960. * This helps creating camera with an orthographic mode.
  34961. * 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.
  34962. */
  34963. static readonly ORTHOGRAPHIC_CAMERA: number;
  34964. /**
  34965. * This is the default FOV mode for perspective cameras.
  34966. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34967. */
  34968. static readonly FOVMODE_VERTICAL_FIXED: number;
  34969. /**
  34970. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34971. */
  34972. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34973. /**
  34974. * This specifies ther is no need for a camera rig.
  34975. * Basically only one eye is rendered corresponding to the camera.
  34976. */
  34977. static readonly RIG_MODE_NONE: number;
  34978. /**
  34979. * Simulates a camera Rig with one blue eye and one red eye.
  34980. * This can be use with 3d blue and red glasses.
  34981. */
  34982. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34983. /**
  34984. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34985. */
  34986. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34987. /**
  34988. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34989. */
  34990. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34991. /**
  34992. * Defines that both eyes of the camera will be rendered over under each other.
  34993. */
  34994. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34995. /**
  34996. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34997. */
  34998. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34999. /**
  35000. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  35001. */
  35002. static readonly RIG_MODE_VR: number;
  35003. /**
  35004. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  35005. */
  35006. static readonly RIG_MODE_WEBVR: number;
  35007. /**
  35008. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35009. */
  35010. static readonly RIG_MODE_CUSTOM: number;
  35011. /**
  35012. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35013. */
  35014. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35015. /**
  35016. * Define the input manager associated with the camera.
  35017. */
  35018. inputs: CameraInputsManager<Camera>;
  35019. /** @hidden */
  35020. _position: Vector3;
  35021. /**
  35022. * Define the current local position of the camera in the scene
  35023. */
  35024. get position(): Vector3;
  35025. set position(newPosition: Vector3);
  35026. protected _upVector: Vector3;
  35027. /**
  35028. * The vector the camera should consider as up.
  35029. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35030. */
  35031. set upVector(vec: Vector3);
  35032. get upVector(): Vector3;
  35033. /**
  35034. * Define the current limit on the left side for an orthographic camera
  35035. * In scene unit
  35036. */
  35037. orthoLeft: Nullable<number>;
  35038. /**
  35039. * Define the current limit on the right side for an orthographic camera
  35040. * In scene unit
  35041. */
  35042. orthoRight: Nullable<number>;
  35043. /**
  35044. * Define the current limit on the bottom side for an orthographic camera
  35045. * In scene unit
  35046. */
  35047. orthoBottom: Nullable<number>;
  35048. /**
  35049. * Define the current limit on the top side for an orthographic camera
  35050. * In scene unit
  35051. */
  35052. orthoTop: Nullable<number>;
  35053. /**
  35054. * Field Of View is set in Radians. (default is 0.8)
  35055. */
  35056. fov: number;
  35057. /**
  35058. * Define the minimum distance the camera can see from.
  35059. * This is important to note that the depth buffer are not infinite and the closer it starts
  35060. * the more your scene might encounter depth fighting issue.
  35061. */
  35062. minZ: number;
  35063. /**
  35064. * Define the maximum distance the camera can see to.
  35065. * This is important to note that the depth buffer are not infinite and the further it end
  35066. * the more your scene might encounter depth fighting issue.
  35067. */
  35068. maxZ: number;
  35069. /**
  35070. * Define the default inertia of the camera.
  35071. * This helps giving a smooth feeling to the camera movement.
  35072. */
  35073. inertia: number;
  35074. /**
  35075. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35076. */
  35077. mode: number;
  35078. /**
  35079. * Define whether the camera is intermediate.
  35080. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35081. */
  35082. isIntermediate: boolean;
  35083. /**
  35084. * Define the viewport of the camera.
  35085. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35086. */
  35087. viewport: Viewport;
  35088. /**
  35089. * Restricts the camera to viewing objects with the same layerMask.
  35090. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35091. */
  35092. layerMask: number;
  35093. /**
  35094. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35095. */
  35096. fovMode: number;
  35097. /**
  35098. * Rig mode of the camera.
  35099. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35100. * This is normally controlled byt the camera themselves as internal use.
  35101. */
  35102. cameraRigMode: number;
  35103. /**
  35104. * Defines the distance between both "eyes" in case of a RIG
  35105. */
  35106. interaxialDistance: number;
  35107. /**
  35108. * Defines if stereoscopic rendering is done side by side or over under.
  35109. */
  35110. isStereoscopicSideBySide: boolean;
  35111. /**
  35112. * 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
  35113. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35114. * else in the scene. (Eg. security camera)
  35115. *
  35116. * 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)
  35117. */
  35118. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35119. /**
  35120. * When set, the camera will render to this render target instead of the default canvas
  35121. *
  35122. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35123. */
  35124. outputRenderTarget: Nullable<RenderTargetTexture>;
  35125. /**
  35126. * Observable triggered when the camera view matrix has changed.
  35127. */
  35128. onViewMatrixChangedObservable: Observable<Camera>;
  35129. /**
  35130. * Observable triggered when the camera Projection matrix has changed.
  35131. */
  35132. onProjectionMatrixChangedObservable: Observable<Camera>;
  35133. /**
  35134. * Observable triggered when the inputs have been processed.
  35135. */
  35136. onAfterCheckInputsObservable: Observable<Camera>;
  35137. /**
  35138. * Observable triggered when reset has been called and applied to the camera.
  35139. */
  35140. onRestoreStateObservable: Observable<Camera>;
  35141. /**
  35142. * Is this camera a part of a rig system?
  35143. */
  35144. isRigCamera: boolean;
  35145. /**
  35146. * If isRigCamera set to true this will be set with the parent camera.
  35147. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35148. */
  35149. rigParent?: Camera;
  35150. /** @hidden */
  35151. _cameraRigParams: any;
  35152. /** @hidden */
  35153. _rigCameras: Camera[];
  35154. /** @hidden */
  35155. _rigPostProcess: Nullable<PostProcess>;
  35156. protected _webvrViewMatrix: Matrix;
  35157. /** @hidden */
  35158. _skipRendering: boolean;
  35159. /** @hidden */
  35160. _projectionMatrix: Matrix;
  35161. /** @hidden */
  35162. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35163. /** @hidden */
  35164. _activeMeshes: SmartArray<AbstractMesh>;
  35165. protected _globalPosition: Vector3;
  35166. /** @hidden */
  35167. _computedViewMatrix: Matrix;
  35168. private _doNotComputeProjectionMatrix;
  35169. private _transformMatrix;
  35170. private _frustumPlanes;
  35171. private _refreshFrustumPlanes;
  35172. private _storedFov;
  35173. private _stateStored;
  35174. /**
  35175. * Instantiates a new camera object.
  35176. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35177. * @see https://doc.babylonjs.com/features/cameras
  35178. * @param name Defines the name of the camera in the scene
  35179. * @param position Defines the position of the camera
  35180. * @param scene Defines the scene the camera belongs too
  35181. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35182. */
  35183. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35184. /**
  35185. * Store current camera state (fov, position, etc..)
  35186. * @returns the camera
  35187. */
  35188. storeState(): Camera;
  35189. /**
  35190. * Restores the camera state values if it has been stored. You must call storeState() first
  35191. */
  35192. protected _restoreStateValues(): boolean;
  35193. /**
  35194. * Restored camera state. You must call storeState() first.
  35195. * @returns true if restored and false otherwise
  35196. */
  35197. restoreState(): boolean;
  35198. /**
  35199. * Gets the class name of the camera.
  35200. * @returns the class name
  35201. */
  35202. getClassName(): string;
  35203. /** @hidden */
  35204. readonly _isCamera: boolean;
  35205. /**
  35206. * Gets a string representation of the camera useful for debug purpose.
  35207. * @param fullDetails Defines that a more verboe level of logging is required
  35208. * @returns the string representation
  35209. */
  35210. toString(fullDetails?: boolean): string;
  35211. /**
  35212. * Gets the current world space position of the camera.
  35213. */
  35214. get globalPosition(): Vector3;
  35215. /**
  35216. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35217. * @returns the active meshe list
  35218. */
  35219. getActiveMeshes(): SmartArray<AbstractMesh>;
  35220. /**
  35221. * Check whether a mesh is part of the current active mesh list of the camera
  35222. * @param mesh Defines the mesh to check
  35223. * @returns true if active, false otherwise
  35224. */
  35225. isActiveMesh(mesh: Mesh): boolean;
  35226. /**
  35227. * Is this camera ready to be used/rendered
  35228. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35229. * @return true if the camera is ready
  35230. */
  35231. isReady(completeCheck?: boolean): boolean;
  35232. /** @hidden */
  35233. _initCache(): void;
  35234. /** @hidden */
  35235. _updateCache(ignoreParentClass?: boolean): void;
  35236. /** @hidden */
  35237. _isSynchronized(): boolean;
  35238. /** @hidden */
  35239. _isSynchronizedViewMatrix(): boolean;
  35240. /** @hidden */
  35241. _isSynchronizedProjectionMatrix(): boolean;
  35242. /**
  35243. * Attach the input controls to a specific dom element to get the input from.
  35244. * @param element Defines the element the controls should be listened from
  35245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35246. */
  35247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35248. /**
  35249. * Detach the current controls from the specified dom element.
  35250. * @param element Defines the element to stop listening the inputs from
  35251. */
  35252. detachControl(element: HTMLElement): void;
  35253. /**
  35254. * Update the camera state according to the different inputs gathered during the frame.
  35255. */
  35256. update(): void;
  35257. /** @hidden */
  35258. _checkInputs(): void;
  35259. /** @hidden */
  35260. get rigCameras(): Camera[];
  35261. /**
  35262. * Gets the post process used by the rig cameras
  35263. */
  35264. get rigPostProcess(): Nullable<PostProcess>;
  35265. /**
  35266. * Internal, gets the first post proces.
  35267. * @returns the first post process to be run on this camera.
  35268. */
  35269. _getFirstPostProcess(): Nullable<PostProcess>;
  35270. private _cascadePostProcessesToRigCams;
  35271. /**
  35272. * Attach a post process to the camera.
  35273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35274. * @param postProcess The post process to attach to the camera
  35275. * @param insertAt The position of the post process in case several of them are in use in the scene
  35276. * @returns the position the post process has been inserted at
  35277. */
  35278. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35279. /**
  35280. * Detach a post process to the camera.
  35281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35282. * @param postProcess The post process to detach from the camera
  35283. */
  35284. detachPostProcess(postProcess: PostProcess): void;
  35285. /**
  35286. * Gets the current world matrix of the camera
  35287. */
  35288. getWorldMatrix(): Matrix;
  35289. /** @hidden */
  35290. _getViewMatrix(): Matrix;
  35291. /**
  35292. * Gets the current view matrix of the camera.
  35293. * @param force forces the camera to recompute the matrix without looking at the cached state
  35294. * @returns the view matrix
  35295. */
  35296. getViewMatrix(force?: boolean): Matrix;
  35297. /**
  35298. * Freeze the projection matrix.
  35299. * It will prevent the cache check of the camera projection compute and can speed up perf
  35300. * if no parameter of the camera are meant to change
  35301. * @param projection Defines manually a projection if necessary
  35302. */
  35303. freezeProjectionMatrix(projection?: Matrix): void;
  35304. /**
  35305. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35306. */
  35307. unfreezeProjectionMatrix(): void;
  35308. /**
  35309. * Gets the current projection matrix of the camera.
  35310. * @param force forces the camera to recompute the matrix without looking at the cached state
  35311. * @returns the projection matrix
  35312. */
  35313. getProjectionMatrix(force?: boolean): Matrix;
  35314. /**
  35315. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35316. * @returns a Matrix
  35317. */
  35318. getTransformationMatrix(): Matrix;
  35319. private _updateFrustumPlanes;
  35320. /**
  35321. * Checks if a cullable object (mesh...) is in the camera frustum
  35322. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35323. * @param target The object to check
  35324. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35325. * @returns true if the object is in frustum otherwise false
  35326. */
  35327. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35328. /**
  35329. * Checks if a cullable object (mesh...) is in the camera frustum
  35330. * Unlike isInFrustum this cheks the full bounding box
  35331. * @param target The object to check
  35332. * @returns true if the object is in frustum otherwise false
  35333. */
  35334. isCompletelyInFrustum(target: ICullable): boolean;
  35335. /**
  35336. * Gets a ray in the forward direction from the camera.
  35337. * @param length Defines the length of the ray to create
  35338. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35339. * @param origin Defines the start point of the ray which defaults to the camera position
  35340. * @returns the forward ray
  35341. */
  35342. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35343. /**
  35344. * Gets a ray in the forward direction from the camera.
  35345. * @param refRay the ray to (re)use when setting the values
  35346. * @param length Defines the length of the ray to create
  35347. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35348. * @param origin Defines the start point of the ray which defaults to the camera position
  35349. * @returns the forward ray
  35350. */
  35351. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35352. /**
  35353. * Releases resources associated with this node.
  35354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35356. */
  35357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35358. /** @hidden */
  35359. _isLeftCamera: boolean;
  35360. /**
  35361. * Gets the left camera of a rig setup in case of Rigged Camera
  35362. */
  35363. get isLeftCamera(): boolean;
  35364. /** @hidden */
  35365. _isRightCamera: boolean;
  35366. /**
  35367. * Gets the right camera of a rig setup in case of Rigged Camera
  35368. */
  35369. get isRightCamera(): boolean;
  35370. /**
  35371. * Gets the left camera of a rig setup in case of Rigged Camera
  35372. */
  35373. get leftCamera(): Nullable<FreeCamera>;
  35374. /**
  35375. * Gets the right camera of a rig setup in case of Rigged Camera
  35376. */
  35377. get rightCamera(): Nullable<FreeCamera>;
  35378. /**
  35379. * Gets the left camera target of a rig setup in case of Rigged Camera
  35380. * @returns the target position
  35381. */
  35382. getLeftTarget(): Nullable<Vector3>;
  35383. /**
  35384. * Gets the right camera target of a rig setup in case of Rigged Camera
  35385. * @returns the target position
  35386. */
  35387. getRightTarget(): Nullable<Vector3>;
  35388. /**
  35389. * @hidden
  35390. */
  35391. setCameraRigMode(mode: number, rigParams: any): void;
  35392. /** @hidden */
  35393. static _setStereoscopicRigMode(camera: Camera): void;
  35394. /** @hidden */
  35395. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35396. /** @hidden */
  35397. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35398. /** @hidden */
  35399. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35400. /** @hidden */
  35401. _getVRProjectionMatrix(): Matrix;
  35402. protected _updateCameraRotationMatrix(): void;
  35403. protected _updateWebVRCameraRotationMatrix(): void;
  35404. /**
  35405. * This function MUST be overwritten by the different WebVR cameras available.
  35406. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35407. * @hidden
  35408. */
  35409. _getWebVRProjectionMatrix(): Matrix;
  35410. /**
  35411. * This function MUST be overwritten by the different WebVR cameras available.
  35412. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35413. * @hidden
  35414. */
  35415. _getWebVRViewMatrix(): Matrix;
  35416. /** @hidden */
  35417. setCameraRigParameter(name: string, value: any): void;
  35418. /**
  35419. * needs to be overridden by children so sub has required properties to be copied
  35420. * @hidden
  35421. */
  35422. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35423. /**
  35424. * May need to be overridden by children
  35425. * @hidden
  35426. */
  35427. _updateRigCameras(): void;
  35428. /** @hidden */
  35429. _setupInputs(): void;
  35430. /**
  35431. * Serialiaze the camera setup to a json represention
  35432. * @returns the JSON representation
  35433. */
  35434. serialize(): any;
  35435. /**
  35436. * Clones the current camera.
  35437. * @param name The cloned camera name
  35438. * @returns the cloned camera
  35439. */
  35440. clone(name: string): Camera;
  35441. /**
  35442. * Gets the direction of the camera relative to a given local axis.
  35443. * @param localAxis Defines the reference axis to provide a relative direction.
  35444. * @return the direction
  35445. */
  35446. getDirection(localAxis: Vector3): Vector3;
  35447. /**
  35448. * Returns the current camera absolute rotation
  35449. */
  35450. get absoluteRotation(): Quaternion;
  35451. /**
  35452. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35453. * @param localAxis Defines the reference axis to provide a relative direction.
  35454. * @param result Defines the vector to store the result in
  35455. */
  35456. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35457. /**
  35458. * Gets a camera constructor for a given camera type
  35459. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35460. * @param name The name of the camera the result will be able to instantiate
  35461. * @param scene The scene the result will construct the camera in
  35462. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35463. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35464. * @returns a factory method to construc the camera
  35465. */
  35466. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35467. /**
  35468. * Compute the world matrix of the camera.
  35469. * @returns the camera world matrix
  35470. */
  35471. computeWorldMatrix(): Matrix;
  35472. /**
  35473. * Parse a JSON and creates the camera from the parsed information
  35474. * @param parsedCamera The JSON to parse
  35475. * @param scene The scene to instantiate the camera in
  35476. * @returns the newly constructed camera
  35477. */
  35478. static Parse(parsedCamera: any, scene: Scene): Camera;
  35479. }
  35480. }
  35481. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35482. import { Nullable } from "babylonjs/types";
  35483. import { Scene } from "babylonjs/scene";
  35484. import { Vector4 } from "babylonjs/Maths/math.vector";
  35485. import { Mesh } from "babylonjs/Meshes/mesh";
  35486. /**
  35487. * Class containing static functions to help procedurally build meshes
  35488. */
  35489. export class DiscBuilder {
  35490. /**
  35491. * Creates a plane polygonal mesh. By default, this is a disc
  35492. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35493. * * 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
  35494. * * 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
  35495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35498. * @param name defines the name of the mesh
  35499. * @param options defines the options used to create the mesh
  35500. * @param scene defines the hosting scene
  35501. * @returns the plane polygonal mesh
  35502. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35503. */
  35504. static CreateDisc(name: string, options: {
  35505. radius?: number;
  35506. tessellation?: number;
  35507. arc?: number;
  35508. updatable?: boolean;
  35509. sideOrientation?: number;
  35510. frontUVs?: Vector4;
  35511. backUVs?: Vector4;
  35512. }, scene?: Nullable<Scene>): Mesh;
  35513. }
  35514. }
  35515. declare module "babylonjs/Particles/solidParticleSystem" {
  35516. import { Nullable } from "babylonjs/types";
  35517. import { Mesh } from "babylonjs/Meshes/mesh";
  35518. import { Scene, IDisposable } from "babylonjs/scene";
  35519. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35520. import { Material } from "babylonjs/Materials/material";
  35521. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35522. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35523. /**
  35524. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35525. *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.
  35526. * The SPS is also a particle system. It provides some methods to manage the particles.
  35527. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35528. *
  35529. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35530. */
  35531. export class SolidParticleSystem implements IDisposable {
  35532. /**
  35533. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35534. * Example : var p = SPS.particles[i];
  35535. */
  35536. particles: SolidParticle[];
  35537. /**
  35538. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35539. */
  35540. nbParticles: number;
  35541. /**
  35542. * If the particles must ever face the camera (default false). Useful for planar particles.
  35543. */
  35544. billboard: boolean;
  35545. /**
  35546. * Recompute normals when adding a shape
  35547. */
  35548. recomputeNormals: boolean;
  35549. /**
  35550. * This a counter ofr your own usage. It's not set by any SPS functions.
  35551. */
  35552. counter: number;
  35553. /**
  35554. * The SPS name. This name is also given to the underlying mesh.
  35555. */
  35556. name: string;
  35557. /**
  35558. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35559. */
  35560. mesh: Mesh;
  35561. /**
  35562. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35563. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35564. */
  35565. vars: any;
  35566. /**
  35567. * This array is populated when the SPS is set as 'pickable'.
  35568. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35569. * Each element of this array is an object `{idx: int, faceId: int}`.
  35570. * `idx` is the picked particle index in the `SPS.particles` array
  35571. * `faceId` is the picked face index counted within this particle.
  35572. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35573. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35574. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35575. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35576. */
  35577. pickedParticles: {
  35578. idx: number;
  35579. faceId: number;
  35580. }[];
  35581. /**
  35582. * This array is populated when the SPS is set as 'pickable'
  35583. * Each key of this array is a submesh index.
  35584. * Each element of this array is a second array defined like this :
  35585. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35586. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35587. * `idx` is the picked particle index in the `SPS.particles` array
  35588. * `faceId` is the picked face index counted within this particle.
  35589. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35590. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35591. */
  35592. pickedBySubMesh: {
  35593. idx: number;
  35594. faceId: number;
  35595. }[][];
  35596. /**
  35597. * This array is populated when `enableDepthSort` is set to true.
  35598. * Each element of this array is an instance of the class DepthSortedParticle.
  35599. */
  35600. depthSortedParticles: DepthSortedParticle[];
  35601. /**
  35602. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35603. * @hidden
  35604. */
  35605. _bSphereOnly: boolean;
  35606. /**
  35607. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35608. * @hidden
  35609. */
  35610. _bSphereRadiusFactor: number;
  35611. private _scene;
  35612. private _positions;
  35613. private _indices;
  35614. private _normals;
  35615. private _colors;
  35616. private _uvs;
  35617. private _indices32;
  35618. private _positions32;
  35619. private _normals32;
  35620. private _fixedNormal32;
  35621. private _colors32;
  35622. private _uvs32;
  35623. private _index;
  35624. private _updatable;
  35625. private _pickable;
  35626. private _isVisibilityBoxLocked;
  35627. private _alwaysVisible;
  35628. private _depthSort;
  35629. private _expandable;
  35630. private _shapeCounter;
  35631. private _copy;
  35632. private _color;
  35633. private _computeParticleColor;
  35634. private _computeParticleTexture;
  35635. private _computeParticleRotation;
  35636. private _computeParticleVertex;
  35637. private _computeBoundingBox;
  35638. private _depthSortParticles;
  35639. private _camera;
  35640. private _mustUnrotateFixedNormals;
  35641. private _particlesIntersect;
  35642. private _needs32Bits;
  35643. private _isNotBuilt;
  35644. private _lastParticleId;
  35645. private _idxOfId;
  35646. private _multimaterialEnabled;
  35647. private _useModelMaterial;
  35648. private _indicesByMaterial;
  35649. private _materialIndexes;
  35650. private _depthSortFunction;
  35651. private _materialSortFunction;
  35652. private _materials;
  35653. private _multimaterial;
  35654. private _materialIndexesById;
  35655. private _defaultMaterial;
  35656. private _autoUpdateSubMeshes;
  35657. private _tmpVertex;
  35658. /**
  35659. * Creates a SPS (Solid Particle System) object.
  35660. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35661. * @param scene (Scene) is the scene in which the SPS is added.
  35662. * @param options defines the options of the sps e.g.
  35663. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35664. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35665. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35666. * * 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.
  35667. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35668. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35669. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35670. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35671. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35672. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35673. */
  35674. constructor(name: string, scene: Scene, options?: {
  35675. updatable?: boolean;
  35676. isPickable?: boolean;
  35677. enableDepthSort?: boolean;
  35678. particleIntersection?: boolean;
  35679. boundingSphereOnly?: boolean;
  35680. bSphereRadiusFactor?: number;
  35681. expandable?: boolean;
  35682. useModelMaterial?: boolean;
  35683. enableMultiMaterial?: boolean;
  35684. });
  35685. /**
  35686. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35687. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35688. * @returns the created mesh
  35689. */
  35690. buildMesh(): Mesh;
  35691. /**
  35692. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35693. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35694. * Thus the particles generated from `digest()` have their property `position` set yet.
  35695. * @param mesh ( Mesh ) is the mesh to be digested
  35696. * @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
  35697. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35698. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35699. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35700. * @returns the current SPS
  35701. */
  35702. digest(mesh: Mesh, options?: {
  35703. facetNb?: number;
  35704. number?: number;
  35705. delta?: number;
  35706. storage?: [];
  35707. }): SolidParticleSystem;
  35708. /**
  35709. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35710. * @hidden
  35711. */
  35712. private _unrotateFixedNormals;
  35713. /**
  35714. * Resets the temporary working copy particle
  35715. * @hidden
  35716. */
  35717. private _resetCopy;
  35718. /**
  35719. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35720. * @param p the current index in the positions array to be updated
  35721. * @param ind the current index in the indices array
  35722. * @param shape a Vector3 array, the shape geometry
  35723. * @param positions the positions array to be updated
  35724. * @param meshInd the shape indices array
  35725. * @param indices the indices array to be updated
  35726. * @param meshUV the shape uv array
  35727. * @param uvs the uv array to be updated
  35728. * @param meshCol the shape color array
  35729. * @param colors the color array to be updated
  35730. * @param meshNor the shape normals array
  35731. * @param normals the normals array to be updated
  35732. * @param idx the particle index
  35733. * @param idxInShape the particle index in its shape
  35734. * @param options the addShape() method passed options
  35735. * @model the particle model
  35736. * @hidden
  35737. */
  35738. private _meshBuilder;
  35739. /**
  35740. * Returns a shape Vector3 array from positions float array
  35741. * @param positions float array
  35742. * @returns a vector3 array
  35743. * @hidden
  35744. */
  35745. private _posToShape;
  35746. /**
  35747. * Returns a shapeUV array from a float uvs (array deep copy)
  35748. * @param uvs as a float array
  35749. * @returns a shapeUV array
  35750. * @hidden
  35751. */
  35752. private _uvsToShapeUV;
  35753. /**
  35754. * Adds a new particle object in the particles array
  35755. * @param idx particle index in particles array
  35756. * @param id particle id
  35757. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35758. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35759. * @param model particle ModelShape object
  35760. * @param shapeId model shape identifier
  35761. * @param idxInShape index of the particle in the current model
  35762. * @param bInfo model bounding info object
  35763. * @param storage target storage array, if any
  35764. * @hidden
  35765. */
  35766. private _addParticle;
  35767. /**
  35768. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35769. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35770. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35771. * @param nb (positive integer) the number of particles to be created from this model
  35772. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35773. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35774. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35775. * @returns the number of shapes in the system
  35776. */
  35777. addShape(mesh: Mesh, nb: number, options?: {
  35778. positionFunction?: any;
  35779. vertexFunction?: any;
  35780. storage?: [];
  35781. }): number;
  35782. /**
  35783. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35784. * @hidden
  35785. */
  35786. private _rebuildParticle;
  35787. /**
  35788. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35789. * @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.
  35790. * @returns the SPS.
  35791. */
  35792. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35793. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35794. * Returns an array with the removed particles.
  35795. * 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.
  35796. * The SPS can't be empty so at least one particle needs to remain in place.
  35797. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35798. * @param start index of the first particle to remove
  35799. * @param end index of the last particle to remove (included)
  35800. * @returns an array populated with the removed particles
  35801. */
  35802. removeParticles(start: number, end: number): SolidParticle[];
  35803. /**
  35804. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35805. * @param solidParticleArray an array populated with Solid Particles objects
  35806. * @returns the SPS
  35807. */
  35808. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35809. /**
  35810. * Creates a new particle and modifies the SPS mesh geometry :
  35811. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35812. * - calls _addParticle() to populate the particle array
  35813. * factorized code from addShape() and insertParticlesFromArray()
  35814. * @param idx particle index in the particles array
  35815. * @param i particle index in its shape
  35816. * @param modelShape particle ModelShape object
  35817. * @param shape shape vertex array
  35818. * @param meshInd shape indices array
  35819. * @param meshUV shape uv array
  35820. * @param meshCol shape color array
  35821. * @param meshNor shape normals array
  35822. * @param bbInfo shape bounding info
  35823. * @param storage target particle storage
  35824. * @options addShape() passed options
  35825. * @hidden
  35826. */
  35827. private _insertNewParticle;
  35828. /**
  35829. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35830. * This method calls `updateParticle()` for each particle of the SPS.
  35831. * For an animated SPS, it is usually called within the render loop.
  35832. * 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.
  35833. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35834. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35835. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35836. * @returns the SPS.
  35837. */
  35838. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35839. /**
  35840. * Disposes the SPS.
  35841. */
  35842. dispose(): void;
  35843. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35844. * idx is the particle index in the SPS
  35845. * faceId is the picked face index counted within this particle.
  35846. * Returns null if the pickInfo can't identify a picked particle.
  35847. * @param pickingInfo (PickingInfo object)
  35848. * @returns {idx: number, faceId: number} or null
  35849. */
  35850. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35851. idx: number;
  35852. faceId: number;
  35853. }>;
  35854. /**
  35855. * Returns a SolidParticle object from its identifier : particle.id
  35856. * @param id (integer) the particle Id
  35857. * @returns the searched particle or null if not found in the SPS.
  35858. */
  35859. getParticleById(id: number): Nullable<SolidParticle>;
  35860. /**
  35861. * Returns a new array populated with the particles having the passed shapeId.
  35862. * @param shapeId (integer) the shape identifier
  35863. * @returns a new solid particle array
  35864. */
  35865. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35866. /**
  35867. * Populates the passed array "ref" with the particles having the passed shapeId.
  35868. * @param shapeId the shape identifier
  35869. * @returns the SPS
  35870. * @param ref
  35871. */
  35872. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35873. /**
  35874. * Computes the required SubMeshes according the materials assigned to the particles.
  35875. * @returns the solid particle system.
  35876. * Does nothing if called before the SPS mesh is built.
  35877. */
  35878. computeSubMeshes(): SolidParticleSystem;
  35879. /**
  35880. * Sorts the solid particles by material when MultiMaterial is enabled.
  35881. * Updates the indices32 array.
  35882. * Updates the indicesByMaterial array.
  35883. * Updates the mesh indices array.
  35884. * @returns the SPS
  35885. * @hidden
  35886. */
  35887. private _sortParticlesByMaterial;
  35888. /**
  35889. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35890. * @hidden
  35891. */
  35892. private _setMaterialIndexesById;
  35893. /**
  35894. * Returns an array with unique values of Materials from the passed array
  35895. * @param array the material array to be checked and filtered
  35896. * @hidden
  35897. */
  35898. private _filterUniqueMaterialId;
  35899. /**
  35900. * Sets a new Standard Material as _defaultMaterial if not already set.
  35901. * @hidden
  35902. */
  35903. private _setDefaultMaterial;
  35904. /**
  35905. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35906. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35907. * @returns the SPS.
  35908. */
  35909. refreshVisibleSize(): SolidParticleSystem;
  35910. /**
  35911. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35912. * @param size the size (float) of the visibility box
  35913. * note : this doesn't lock the SPS mesh bounding box.
  35914. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35915. */
  35916. setVisibilityBox(size: number): void;
  35917. /**
  35918. * Gets whether the SPS as always visible or not
  35919. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35920. */
  35921. get isAlwaysVisible(): boolean;
  35922. /**
  35923. * Sets the SPS as always visible or not
  35924. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35925. */
  35926. set isAlwaysVisible(val: boolean);
  35927. /**
  35928. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35929. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35930. */
  35931. set isVisibilityBoxLocked(val: boolean);
  35932. /**
  35933. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35934. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35935. */
  35936. get isVisibilityBoxLocked(): boolean;
  35937. /**
  35938. * Tells to `setParticles()` to compute the particle rotations or not.
  35939. * Default value : true. The SPS is faster when it's set to false.
  35940. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35941. */
  35942. set computeParticleRotation(val: boolean);
  35943. /**
  35944. * Tells to `setParticles()` to compute the particle colors or not.
  35945. * Default value : true. The SPS is faster when it's set to false.
  35946. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35947. */
  35948. set computeParticleColor(val: boolean);
  35949. set computeParticleTexture(val: boolean);
  35950. /**
  35951. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35952. * Default value : false. The SPS is faster when it's set to false.
  35953. * Note : the particle custom vertex positions aren't stored values.
  35954. */
  35955. set computeParticleVertex(val: boolean);
  35956. /**
  35957. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35958. */
  35959. set computeBoundingBox(val: boolean);
  35960. /**
  35961. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35962. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35963. * Default : `true`
  35964. */
  35965. set depthSortParticles(val: boolean);
  35966. /**
  35967. * Gets if `setParticles()` computes the particle rotations or not.
  35968. * Default value : true. The SPS is faster when it's set to false.
  35969. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35970. */
  35971. get computeParticleRotation(): boolean;
  35972. /**
  35973. * Gets if `setParticles()` computes the particle colors or not.
  35974. * Default value : true. The SPS is faster when it's set to false.
  35975. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35976. */
  35977. get computeParticleColor(): boolean;
  35978. /**
  35979. * Gets if `setParticles()` computes the particle textures or not.
  35980. * Default value : true. The SPS is faster when it's set to false.
  35981. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35982. */
  35983. get computeParticleTexture(): boolean;
  35984. /**
  35985. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35986. * Default value : false. The SPS is faster when it's set to false.
  35987. * Note : the particle custom vertex positions aren't stored values.
  35988. */
  35989. get computeParticleVertex(): boolean;
  35990. /**
  35991. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35992. */
  35993. get computeBoundingBox(): boolean;
  35994. /**
  35995. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35996. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35997. * Default : `true`
  35998. */
  35999. get depthSortParticles(): boolean;
  36000. /**
  36001. * Gets if the SPS is created as expandable at construction time.
  36002. * Default : `false`
  36003. */
  36004. get expandable(): boolean;
  36005. /**
  36006. * Gets if the SPS supports the Multi Materials
  36007. */
  36008. get multimaterialEnabled(): boolean;
  36009. /**
  36010. * Gets if the SPS uses the model materials for its own multimaterial.
  36011. */
  36012. get useModelMaterial(): boolean;
  36013. /**
  36014. * The SPS used material array.
  36015. */
  36016. get materials(): Material[];
  36017. /**
  36018. * Sets the SPS MultiMaterial from the passed materials.
  36019. * Note : the passed array is internally copied and not used then by reference.
  36020. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36021. */
  36022. setMultiMaterial(materials: Material[]): void;
  36023. /**
  36024. * The SPS computed multimaterial object
  36025. */
  36026. get multimaterial(): MultiMaterial;
  36027. set multimaterial(mm: MultiMaterial);
  36028. /**
  36029. * If the subMeshes must be updated on the next call to setParticles()
  36030. */
  36031. get autoUpdateSubMeshes(): boolean;
  36032. set autoUpdateSubMeshes(val: boolean);
  36033. /**
  36034. * This function does nothing. It may be overwritten to set all the particle first values.
  36035. * The SPS doesn't call this function, you may have to call it by your own.
  36036. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36037. */
  36038. initParticles(): void;
  36039. /**
  36040. * This function does nothing. It may be overwritten to recycle a particle.
  36041. * The SPS doesn't call this function, you may have to call it by your own.
  36042. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36043. * @param particle The particle to recycle
  36044. * @returns the recycled particle
  36045. */
  36046. recycleParticle(particle: SolidParticle): SolidParticle;
  36047. /**
  36048. * Updates a particle : this function should be overwritten by the user.
  36049. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36050. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36051. * @example : just set a particle position or velocity and recycle conditions
  36052. * @param particle The particle to update
  36053. * @returns the updated particle
  36054. */
  36055. updateParticle(particle: SolidParticle): SolidParticle;
  36056. /**
  36057. * Updates a vertex of a particle : it can be overwritten by the user.
  36058. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36059. * @param particle the current particle
  36060. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36061. * @param pt the index of the current vertex in the particle shape
  36062. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36063. * @example : just set a vertex particle position or color
  36064. * @returns the sps
  36065. */
  36066. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36067. /**
  36068. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36069. * This does nothing and may be overwritten by the user.
  36070. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36071. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36072. * @param update the boolean update value actually passed to setParticles()
  36073. */
  36074. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36075. /**
  36076. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36077. * This will be passed three parameters.
  36078. * This does nothing and may be overwritten by the user.
  36079. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36080. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36081. * @param update the boolean update value actually passed to setParticles()
  36082. */
  36083. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36084. }
  36085. }
  36086. declare module "babylonjs/Particles/solidParticle" {
  36087. import { Nullable } from "babylonjs/types";
  36088. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36089. import { Color4 } from "babylonjs/Maths/math.color";
  36090. import { Mesh } from "babylonjs/Meshes/mesh";
  36091. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36092. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36093. import { Plane } from "babylonjs/Maths/math.plane";
  36094. import { Material } from "babylonjs/Materials/material";
  36095. /**
  36096. * Represents one particle of a solid particle system.
  36097. */
  36098. export class SolidParticle {
  36099. /**
  36100. * particle global index
  36101. */
  36102. idx: number;
  36103. /**
  36104. * particle identifier
  36105. */
  36106. id: number;
  36107. /**
  36108. * The color of the particle
  36109. */
  36110. color: Nullable<Color4>;
  36111. /**
  36112. * The world space position of the particle.
  36113. */
  36114. position: Vector3;
  36115. /**
  36116. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36117. */
  36118. rotation: Vector3;
  36119. /**
  36120. * The world space rotation quaternion of the particle.
  36121. */
  36122. rotationQuaternion: Nullable<Quaternion>;
  36123. /**
  36124. * The scaling of the particle.
  36125. */
  36126. scaling: Vector3;
  36127. /**
  36128. * The uvs of the particle.
  36129. */
  36130. uvs: Vector4;
  36131. /**
  36132. * The current speed of the particle.
  36133. */
  36134. velocity: Vector3;
  36135. /**
  36136. * The pivot point in the particle local space.
  36137. */
  36138. pivot: Vector3;
  36139. /**
  36140. * Must the particle be translated from its pivot point in its local space ?
  36141. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36142. * Default : false
  36143. */
  36144. translateFromPivot: boolean;
  36145. /**
  36146. * Is the particle active or not ?
  36147. */
  36148. alive: boolean;
  36149. /**
  36150. * Is the particle visible or not ?
  36151. */
  36152. isVisible: boolean;
  36153. /**
  36154. * Index of this particle in the global "positions" array (Internal use)
  36155. * @hidden
  36156. */
  36157. _pos: number;
  36158. /**
  36159. * @hidden Index of this particle in the global "indices" array (Internal use)
  36160. */
  36161. _ind: number;
  36162. /**
  36163. * @hidden ModelShape of this particle (Internal use)
  36164. */
  36165. _model: ModelShape;
  36166. /**
  36167. * ModelShape id of this particle
  36168. */
  36169. shapeId: number;
  36170. /**
  36171. * Index of the particle in its shape id
  36172. */
  36173. idxInShape: number;
  36174. /**
  36175. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36176. */
  36177. _modelBoundingInfo: BoundingInfo;
  36178. /**
  36179. * @hidden Particle BoundingInfo object (Internal use)
  36180. */
  36181. _boundingInfo: BoundingInfo;
  36182. /**
  36183. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36184. */
  36185. _sps: SolidParticleSystem;
  36186. /**
  36187. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36188. */
  36189. _stillInvisible: boolean;
  36190. /**
  36191. * @hidden Last computed particle rotation matrix
  36192. */
  36193. _rotationMatrix: number[];
  36194. /**
  36195. * Parent particle Id, if any.
  36196. * Default null.
  36197. */
  36198. parentId: Nullable<number>;
  36199. /**
  36200. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36201. */
  36202. materialIndex: Nullable<number>;
  36203. /**
  36204. * Custom object or properties.
  36205. */
  36206. props: Nullable<any>;
  36207. /**
  36208. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36209. * The possible values are :
  36210. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36211. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36212. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36213. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36214. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36215. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36216. * */
  36217. cullingStrategy: number;
  36218. /**
  36219. * @hidden Internal global position in the SPS.
  36220. */
  36221. _globalPosition: Vector3;
  36222. /**
  36223. * Creates a Solid Particle object.
  36224. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36225. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36226. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36227. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36228. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36229. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36230. * @param shapeId (integer) is the model shape identifier in the SPS.
  36231. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36232. * @param sps defines the sps it is associated to
  36233. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36234. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36235. */
  36236. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36237. /**
  36238. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36239. * @param target the particle target
  36240. * @returns the current particle
  36241. */
  36242. copyToRef(target: SolidParticle): SolidParticle;
  36243. /**
  36244. * Legacy support, changed scale to scaling
  36245. */
  36246. get scale(): Vector3;
  36247. /**
  36248. * Legacy support, changed scale to scaling
  36249. */
  36250. set scale(scale: Vector3);
  36251. /**
  36252. * Legacy support, changed quaternion to rotationQuaternion
  36253. */
  36254. get quaternion(): Nullable<Quaternion>;
  36255. /**
  36256. * Legacy support, changed quaternion to rotationQuaternion
  36257. */
  36258. set quaternion(q: Nullable<Quaternion>);
  36259. /**
  36260. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36261. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36262. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36263. * @returns true if it intersects
  36264. */
  36265. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36266. /**
  36267. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36268. * A particle is in the frustum if its bounding box intersects the frustum
  36269. * @param frustumPlanes defines the frustum to test
  36270. * @returns true if the particle is in the frustum planes
  36271. */
  36272. isInFrustum(frustumPlanes: Plane[]): boolean;
  36273. /**
  36274. * get the rotation matrix of the particle
  36275. * @hidden
  36276. */
  36277. getRotationMatrix(m: Matrix): void;
  36278. }
  36279. /**
  36280. * Represents the shape of the model used by one particle of a solid particle system.
  36281. * SPS internal tool, don't use it manually.
  36282. */
  36283. export class ModelShape {
  36284. /**
  36285. * The shape id
  36286. * @hidden
  36287. */
  36288. shapeID: number;
  36289. /**
  36290. * flat array of model positions (internal use)
  36291. * @hidden
  36292. */
  36293. _shape: Vector3[];
  36294. /**
  36295. * flat array of model UVs (internal use)
  36296. * @hidden
  36297. */
  36298. _shapeUV: number[];
  36299. /**
  36300. * color array of the model
  36301. * @hidden
  36302. */
  36303. _shapeColors: number[];
  36304. /**
  36305. * indices array of the model
  36306. * @hidden
  36307. */
  36308. _indices: number[];
  36309. /**
  36310. * normals array of the model
  36311. * @hidden
  36312. */
  36313. _normals: number[];
  36314. /**
  36315. * length of the shape in the model indices array (internal use)
  36316. * @hidden
  36317. */
  36318. _indicesLength: number;
  36319. /**
  36320. * Custom position function (internal use)
  36321. * @hidden
  36322. */
  36323. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36324. /**
  36325. * Custom vertex function (internal use)
  36326. * @hidden
  36327. */
  36328. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36329. /**
  36330. * Model material (internal use)
  36331. * @hidden
  36332. */
  36333. _material: Nullable<Material>;
  36334. /**
  36335. * 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.
  36336. * SPS internal tool, don't use it manually.
  36337. * @hidden
  36338. */
  36339. 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>);
  36340. }
  36341. /**
  36342. * Represents a Depth Sorted Particle in the solid particle system.
  36343. * @hidden
  36344. */
  36345. export class DepthSortedParticle {
  36346. /**
  36347. * Particle index
  36348. */
  36349. idx: number;
  36350. /**
  36351. * Index of the particle in the "indices" array
  36352. */
  36353. ind: number;
  36354. /**
  36355. * Length of the particle shape in the "indices" array
  36356. */
  36357. indicesLength: number;
  36358. /**
  36359. * Squared distance from the particle to the camera
  36360. */
  36361. sqDistance: number;
  36362. /**
  36363. * Material index when used with MultiMaterials
  36364. */
  36365. materialIndex: number;
  36366. /**
  36367. * Creates a new sorted particle
  36368. * @param materialIndex
  36369. */
  36370. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36371. }
  36372. /**
  36373. * Represents a solid particle vertex
  36374. */
  36375. export class SolidParticleVertex {
  36376. /**
  36377. * Vertex position
  36378. */
  36379. position: Vector3;
  36380. /**
  36381. * Vertex color
  36382. */
  36383. color: Color4;
  36384. /**
  36385. * Vertex UV
  36386. */
  36387. uv: Vector2;
  36388. /**
  36389. * Creates a new solid particle vertex
  36390. */
  36391. constructor();
  36392. /** Vertex x coordinate */
  36393. get x(): number;
  36394. set x(val: number);
  36395. /** Vertex y coordinate */
  36396. get y(): number;
  36397. set y(val: number);
  36398. /** Vertex z coordinate */
  36399. get z(): number;
  36400. set z(val: number);
  36401. }
  36402. }
  36403. declare module "babylonjs/Collisions/meshCollisionData" {
  36404. import { Collider } from "babylonjs/Collisions/collider";
  36405. import { Vector3 } from "babylonjs/Maths/math.vector";
  36406. import { Nullable } from "babylonjs/types";
  36407. import { Observer } from "babylonjs/Misc/observable";
  36408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36409. /**
  36410. * @hidden
  36411. */
  36412. export class _MeshCollisionData {
  36413. _checkCollisions: boolean;
  36414. _collisionMask: number;
  36415. _collisionGroup: number;
  36416. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36417. _collider: Nullable<Collider>;
  36418. _oldPositionForCollisions: Vector3;
  36419. _diffPositionForCollisions: Vector3;
  36420. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36421. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36422. _collisionResponse: boolean;
  36423. }
  36424. }
  36425. declare module "babylonjs/Meshes/abstractMesh" {
  36426. import { Observable } from "babylonjs/Misc/observable";
  36427. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36428. import { Camera } from "babylonjs/Cameras/camera";
  36429. import { Scene, IDisposable } from "babylonjs/scene";
  36430. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36431. import { Node } from "babylonjs/node";
  36432. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36435. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36436. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36437. import { Material } from "babylonjs/Materials/material";
  36438. import { Light } from "babylonjs/Lights/light";
  36439. import { Skeleton } from "babylonjs/Bones/skeleton";
  36440. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36441. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36442. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36443. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36444. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36445. import { Plane } from "babylonjs/Maths/math.plane";
  36446. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36447. import { Ray } from "babylonjs/Culling/ray";
  36448. import { Collider } from "babylonjs/Collisions/collider";
  36449. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36450. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36451. /** @hidden */
  36452. class _FacetDataStorage {
  36453. facetPositions: Vector3[];
  36454. facetNormals: Vector3[];
  36455. facetPartitioning: number[][];
  36456. facetNb: number;
  36457. partitioningSubdivisions: number;
  36458. partitioningBBoxRatio: number;
  36459. facetDataEnabled: boolean;
  36460. facetParameters: any;
  36461. bbSize: Vector3;
  36462. subDiv: {
  36463. max: number;
  36464. X: number;
  36465. Y: number;
  36466. Z: number;
  36467. };
  36468. facetDepthSort: boolean;
  36469. facetDepthSortEnabled: boolean;
  36470. depthSortedIndices: IndicesArray;
  36471. depthSortedFacets: {
  36472. ind: number;
  36473. sqDistance: number;
  36474. }[];
  36475. facetDepthSortFunction: (f1: {
  36476. ind: number;
  36477. sqDistance: number;
  36478. }, f2: {
  36479. ind: number;
  36480. sqDistance: number;
  36481. }) => number;
  36482. facetDepthSortFrom: Vector3;
  36483. facetDepthSortOrigin: Vector3;
  36484. invertedMatrix: Matrix;
  36485. }
  36486. /**
  36487. * @hidden
  36488. **/
  36489. class _InternalAbstractMeshDataInfo {
  36490. _hasVertexAlpha: boolean;
  36491. _useVertexColors: boolean;
  36492. _numBoneInfluencers: number;
  36493. _applyFog: boolean;
  36494. _receiveShadows: boolean;
  36495. _facetData: _FacetDataStorage;
  36496. _visibility: number;
  36497. _skeleton: Nullable<Skeleton>;
  36498. _layerMask: number;
  36499. _computeBonesUsingShaders: boolean;
  36500. _isActive: boolean;
  36501. _onlyForInstances: boolean;
  36502. _isActiveIntermediate: boolean;
  36503. _onlyForInstancesIntermediate: boolean;
  36504. _actAsRegularMesh: boolean;
  36505. _currentLOD: Nullable<AbstractMesh>;
  36506. }
  36507. /**
  36508. * Class used to store all common mesh properties
  36509. */
  36510. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36511. /** No occlusion */
  36512. static OCCLUSION_TYPE_NONE: number;
  36513. /** Occlusion set to optimisitic */
  36514. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36515. /** Occlusion set to strict */
  36516. static OCCLUSION_TYPE_STRICT: number;
  36517. /** Use an accurante occlusion algorithm */
  36518. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36519. /** Use a conservative occlusion algorithm */
  36520. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36521. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36522. * Test order :
  36523. * Is the bounding sphere outside the frustum ?
  36524. * If not, are the bounding box vertices outside the frustum ?
  36525. * It not, then the cullable object is in the frustum.
  36526. */
  36527. static readonly CULLINGSTRATEGY_STANDARD: number;
  36528. /** Culling strategy : Bounding Sphere Only.
  36529. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36530. * It's also less accurate than the standard because some not visible objects can still be selected.
  36531. * Test : is the bounding sphere outside the frustum ?
  36532. * If not, then the cullable object is in the frustum.
  36533. */
  36534. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36535. /** Culling strategy : Optimistic Inclusion.
  36536. * This in an inclusion test first, then the standard exclusion test.
  36537. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36538. * 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.
  36539. * Anyway, it's as accurate as the standard strategy.
  36540. * Test :
  36541. * Is the cullable object bounding sphere center in the frustum ?
  36542. * If not, apply the default culling strategy.
  36543. */
  36544. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36545. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36546. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36547. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36548. * 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.
  36549. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36550. * Test :
  36551. * Is the cullable object bounding sphere center in the frustum ?
  36552. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36553. */
  36554. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36555. /**
  36556. * No billboard
  36557. */
  36558. static get BILLBOARDMODE_NONE(): number;
  36559. /** Billboard on X axis */
  36560. static get BILLBOARDMODE_X(): number;
  36561. /** Billboard on Y axis */
  36562. static get BILLBOARDMODE_Y(): number;
  36563. /** Billboard on Z axis */
  36564. static get BILLBOARDMODE_Z(): number;
  36565. /** Billboard on all axes */
  36566. static get BILLBOARDMODE_ALL(): number;
  36567. /** Billboard on using position instead of orientation */
  36568. static get BILLBOARDMODE_USE_POSITION(): number;
  36569. /** @hidden */
  36570. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36571. /**
  36572. * The culling strategy to use to check whether the mesh must be rendered or not.
  36573. * This value can be changed at any time and will be used on the next render mesh selection.
  36574. * The possible values are :
  36575. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36576. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36577. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36579. * Please read each static variable documentation to get details about the culling process.
  36580. * */
  36581. cullingStrategy: number;
  36582. /**
  36583. * Gets the number of facets in the mesh
  36584. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36585. */
  36586. get facetNb(): number;
  36587. /**
  36588. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36589. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36590. */
  36591. get partitioningSubdivisions(): number;
  36592. set partitioningSubdivisions(nb: number);
  36593. /**
  36594. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36595. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36596. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36597. */
  36598. get partitioningBBoxRatio(): number;
  36599. set partitioningBBoxRatio(ratio: number);
  36600. /**
  36601. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36602. * Works only for updatable meshes.
  36603. * Doesn't work with multi-materials
  36604. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36605. */
  36606. get mustDepthSortFacets(): boolean;
  36607. set mustDepthSortFacets(sort: boolean);
  36608. /**
  36609. * The location (Vector3) where the facet depth sort must be computed from.
  36610. * By default, the active camera position.
  36611. * Used only when facet depth sort is enabled
  36612. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36613. */
  36614. get facetDepthSortFrom(): Vector3;
  36615. set facetDepthSortFrom(location: Vector3);
  36616. /**
  36617. * gets a boolean indicating if facetData is enabled
  36618. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36619. */
  36620. get isFacetDataEnabled(): boolean;
  36621. /** @hidden */
  36622. _updateNonUniformScalingState(value: boolean): boolean;
  36623. /**
  36624. * An event triggered when this mesh collides with another one
  36625. */
  36626. onCollideObservable: Observable<AbstractMesh>;
  36627. /** Set a function to call when this mesh collides with another one */
  36628. set onCollide(callback: () => void);
  36629. /**
  36630. * An event triggered when the collision's position changes
  36631. */
  36632. onCollisionPositionChangeObservable: Observable<Vector3>;
  36633. /** Set a function to call when the collision's position changes */
  36634. set onCollisionPositionChange(callback: () => void);
  36635. /**
  36636. * An event triggered when material is changed
  36637. */
  36638. onMaterialChangedObservable: Observable<AbstractMesh>;
  36639. /**
  36640. * Gets or sets the orientation for POV movement & rotation
  36641. */
  36642. definedFacingForward: boolean;
  36643. /** @hidden */
  36644. _occlusionQuery: Nullable<WebGLQuery>;
  36645. /** @hidden */
  36646. _renderingGroup: Nullable<RenderingGroup>;
  36647. /**
  36648. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36649. */
  36650. get visibility(): number;
  36651. /**
  36652. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36653. */
  36654. set visibility(value: number);
  36655. /** Gets or sets the alpha index used to sort transparent meshes
  36656. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36657. */
  36658. alphaIndex: number;
  36659. /**
  36660. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36661. */
  36662. isVisible: boolean;
  36663. /**
  36664. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36665. */
  36666. isPickable: boolean;
  36667. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36668. showSubMeshesBoundingBox: boolean;
  36669. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36670. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36671. */
  36672. isBlocker: boolean;
  36673. /**
  36674. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36675. */
  36676. enablePointerMoveEvents: boolean;
  36677. private _renderingGroupId;
  36678. /**
  36679. * Specifies the rendering group id for this mesh (0 by default)
  36680. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36681. */
  36682. get renderingGroupId(): number;
  36683. set renderingGroupId(value: number);
  36684. private _material;
  36685. /** Gets or sets current material */
  36686. get material(): Nullable<Material>;
  36687. set material(value: Nullable<Material>);
  36688. /**
  36689. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36690. * @see https://doc.babylonjs.com/babylon101/shadows
  36691. */
  36692. get receiveShadows(): boolean;
  36693. set receiveShadows(value: boolean);
  36694. /** Defines color to use when rendering outline */
  36695. outlineColor: Color3;
  36696. /** Define width to use when rendering outline */
  36697. outlineWidth: number;
  36698. /** Defines color to use when rendering overlay */
  36699. overlayColor: Color3;
  36700. /** Defines alpha to use when rendering overlay */
  36701. overlayAlpha: number;
  36702. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36703. get hasVertexAlpha(): boolean;
  36704. set hasVertexAlpha(value: boolean);
  36705. /** 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) */
  36706. get useVertexColors(): boolean;
  36707. set useVertexColors(value: boolean);
  36708. /**
  36709. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36710. */
  36711. get computeBonesUsingShaders(): boolean;
  36712. set computeBonesUsingShaders(value: boolean);
  36713. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36714. get numBoneInfluencers(): number;
  36715. set numBoneInfluencers(value: number);
  36716. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36717. get applyFog(): boolean;
  36718. set applyFog(value: boolean);
  36719. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36720. useOctreeForRenderingSelection: boolean;
  36721. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36722. useOctreeForPicking: boolean;
  36723. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36724. useOctreeForCollisions: boolean;
  36725. /**
  36726. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36727. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36728. */
  36729. get layerMask(): number;
  36730. set layerMask(value: number);
  36731. /**
  36732. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36733. */
  36734. alwaysSelectAsActiveMesh: boolean;
  36735. /**
  36736. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36737. */
  36738. doNotSyncBoundingInfo: boolean;
  36739. /**
  36740. * Gets or sets the current action manager
  36741. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36742. */
  36743. actionManager: Nullable<AbstractActionManager>;
  36744. private _meshCollisionData;
  36745. /**
  36746. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36747. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36748. */
  36749. ellipsoid: Vector3;
  36750. /**
  36751. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36752. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36753. */
  36754. ellipsoidOffset: Vector3;
  36755. /**
  36756. * Gets or sets a collision mask used to mask collisions (default is -1).
  36757. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36758. */
  36759. get collisionMask(): number;
  36760. set collisionMask(mask: number);
  36761. /**
  36762. * Gets or sets a collision response flag (default is true).
  36763. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36764. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36765. * to respond to the collision.
  36766. */
  36767. get collisionResponse(): boolean;
  36768. set collisionResponse(response: boolean);
  36769. /**
  36770. * Gets or sets the current collision group mask (-1 by default).
  36771. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36772. */
  36773. get collisionGroup(): number;
  36774. set collisionGroup(mask: number);
  36775. /**
  36776. * Gets or sets current surrounding meshes (null by default).
  36777. *
  36778. * By default collision detection is tested against every mesh in the scene.
  36779. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36780. * meshes will be tested for the collision.
  36781. *
  36782. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36783. */
  36784. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36785. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36786. /**
  36787. * Defines edge width used when edgesRenderer is enabled
  36788. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36789. */
  36790. edgesWidth: number;
  36791. /**
  36792. * Defines edge color used when edgesRenderer is enabled
  36793. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36794. */
  36795. edgesColor: Color4;
  36796. /** @hidden */
  36797. _edgesRenderer: Nullable<IEdgesRenderer>;
  36798. /** @hidden */
  36799. _masterMesh: Nullable<AbstractMesh>;
  36800. /** @hidden */
  36801. _boundingInfo: Nullable<BoundingInfo>;
  36802. /** @hidden */
  36803. _renderId: number;
  36804. /**
  36805. * Gets or sets the list of subMeshes
  36806. * @see https://doc.babylonjs.com/how_to/multi_materials
  36807. */
  36808. subMeshes: SubMesh[];
  36809. /** @hidden */
  36810. _intersectionsInProgress: AbstractMesh[];
  36811. /** @hidden */
  36812. _unIndexed: boolean;
  36813. /** @hidden */
  36814. _lightSources: Light[];
  36815. /** Gets the list of lights affecting that mesh */
  36816. get lightSources(): Light[];
  36817. /** @hidden */
  36818. get _positions(): Nullable<Vector3[]>;
  36819. /** @hidden */
  36820. _waitingData: {
  36821. lods: Nullable<any>;
  36822. actions: Nullable<any>;
  36823. freezeWorldMatrix: Nullable<boolean>;
  36824. };
  36825. /** @hidden */
  36826. _bonesTransformMatrices: Nullable<Float32Array>;
  36827. /** @hidden */
  36828. _transformMatrixTexture: Nullable<RawTexture>;
  36829. /**
  36830. * Gets or sets a skeleton to apply skining transformations
  36831. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36832. */
  36833. set skeleton(value: Nullable<Skeleton>);
  36834. get skeleton(): Nullable<Skeleton>;
  36835. /**
  36836. * An event triggered when the mesh is rebuilt.
  36837. */
  36838. onRebuildObservable: Observable<AbstractMesh>;
  36839. /**
  36840. * Creates a new AbstractMesh
  36841. * @param name defines the name of the mesh
  36842. * @param scene defines the hosting scene
  36843. */
  36844. constructor(name: string, scene?: Nullable<Scene>);
  36845. /**
  36846. * Returns the string "AbstractMesh"
  36847. * @returns "AbstractMesh"
  36848. */
  36849. getClassName(): string;
  36850. /**
  36851. * Gets a string representation of the current mesh
  36852. * @param fullDetails defines a boolean indicating if full details must be included
  36853. * @returns a string representation of the current mesh
  36854. */
  36855. toString(fullDetails?: boolean): string;
  36856. /**
  36857. * @hidden
  36858. */
  36859. protected _getEffectiveParent(): Nullable<Node>;
  36860. /** @hidden */
  36861. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36862. /** @hidden */
  36863. _rebuild(): void;
  36864. /** @hidden */
  36865. _resyncLightSources(): void;
  36866. /** @hidden */
  36867. _resyncLightSource(light: Light): void;
  36868. /** @hidden */
  36869. _unBindEffect(): void;
  36870. /** @hidden */
  36871. _removeLightSource(light: Light, dispose: boolean): void;
  36872. private _markSubMeshesAsDirty;
  36873. /** @hidden */
  36874. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36875. /** @hidden */
  36876. _markSubMeshesAsAttributesDirty(): void;
  36877. /** @hidden */
  36878. _markSubMeshesAsMiscDirty(): void;
  36879. /**
  36880. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36881. */
  36882. get scaling(): Vector3;
  36883. set scaling(newScaling: Vector3);
  36884. /**
  36885. * Returns true if the mesh is blocked. Implemented by child classes
  36886. */
  36887. get isBlocked(): boolean;
  36888. /**
  36889. * Returns the mesh itself by default. Implemented by child classes
  36890. * @param camera defines the camera to use to pick the right LOD level
  36891. * @returns the currentAbstractMesh
  36892. */
  36893. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36894. /**
  36895. * Returns 0 by default. Implemented by child classes
  36896. * @returns an integer
  36897. */
  36898. getTotalVertices(): number;
  36899. /**
  36900. * Returns a positive integer : the total number of indices in this mesh geometry.
  36901. * @returns the numner of indices or zero if the mesh has no geometry.
  36902. */
  36903. getTotalIndices(): number;
  36904. /**
  36905. * Returns null by default. Implemented by child classes
  36906. * @returns null
  36907. */
  36908. getIndices(): Nullable<IndicesArray>;
  36909. /**
  36910. * Returns the array of the requested vertex data kind. Implemented by child classes
  36911. * @param kind defines the vertex data kind to use
  36912. * @returns null
  36913. */
  36914. getVerticesData(kind: string): Nullable<FloatArray>;
  36915. /**
  36916. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36917. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36918. * Note that a new underlying VertexBuffer object is created each call.
  36919. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36920. * @param kind defines vertex data kind:
  36921. * * VertexBuffer.PositionKind
  36922. * * VertexBuffer.UVKind
  36923. * * VertexBuffer.UV2Kind
  36924. * * VertexBuffer.UV3Kind
  36925. * * VertexBuffer.UV4Kind
  36926. * * VertexBuffer.UV5Kind
  36927. * * VertexBuffer.UV6Kind
  36928. * * VertexBuffer.ColorKind
  36929. * * VertexBuffer.MatricesIndicesKind
  36930. * * VertexBuffer.MatricesIndicesExtraKind
  36931. * * VertexBuffer.MatricesWeightsKind
  36932. * * VertexBuffer.MatricesWeightsExtraKind
  36933. * @param data defines the data source
  36934. * @param updatable defines if the data must be flagged as updatable (or static)
  36935. * @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
  36936. * @returns the current mesh
  36937. */
  36938. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36939. /**
  36940. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36941. * If the mesh has no geometry, it is simply returned as it is.
  36942. * @param kind defines vertex data kind:
  36943. * * VertexBuffer.PositionKind
  36944. * * VertexBuffer.UVKind
  36945. * * VertexBuffer.UV2Kind
  36946. * * VertexBuffer.UV3Kind
  36947. * * VertexBuffer.UV4Kind
  36948. * * VertexBuffer.UV5Kind
  36949. * * VertexBuffer.UV6Kind
  36950. * * VertexBuffer.ColorKind
  36951. * * VertexBuffer.MatricesIndicesKind
  36952. * * VertexBuffer.MatricesIndicesExtraKind
  36953. * * VertexBuffer.MatricesWeightsKind
  36954. * * VertexBuffer.MatricesWeightsExtraKind
  36955. * @param data defines the data source
  36956. * @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
  36957. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36958. * @returns the current mesh
  36959. */
  36960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36961. /**
  36962. * Sets the mesh indices,
  36963. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36964. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36965. * @param totalVertices Defines the total number of vertices
  36966. * @returns the current mesh
  36967. */
  36968. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36969. /**
  36970. * Gets a boolean indicating if specific vertex data is present
  36971. * @param kind defines the vertex data kind to use
  36972. * @returns true is data kind is present
  36973. */
  36974. isVerticesDataPresent(kind: string): boolean;
  36975. /**
  36976. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36977. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36978. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36979. * @returns a BoundingInfo
  36980. */
  36981. getBoundingInfo(): BoundingInfo;
  36982. /**
  36983. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36984. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36985. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36986. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36987. * @returns the current mesh
  36988. */
  36989. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36990. /**
  36991. * Overwrite the current bounding info
  36992. * @param boundingInfo defines the new bounding info
  36993. * @returns the current mesh
  36994. */
  36995. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36996. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36997. get useBones(): boolean;
  36998. /** @hidden */
  36999. _preActivate(): void;
  37000. /** @hidden */
  37001. _preActivateForIntermediateRendering(renderId: number): void;
  37002. /** @hidden */
  37003. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37004. /** @hidden */
  37005. _postActivate(): void;
  37006. /** @hidden */
  37007. _freeze(): void;
  37008. /** @hidden */
  37009. _unFreeze(): void;
  37010. /**
  37011. * Gets the current world matrix
  37012. * @returns a Matrix
  37013. */
  37014. getWorldMatrix(): Matrix;
  37015. /** @hidden */
  37016. _getWorldMatrixDeterminant(): number;
  37017. /**
  37018. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37019. */
  37020. get isAnInstance(): boolean;
  37021. /**
  37022. * Gets a boolean indicating if this mesh has instances
  37023. */
  37024. get hasInstances(): boolean;
  37025. /**
  37026. * Gets a boolean indicating if this mesh has thin instances
  37027. */
  37028. get hasThinInstances(): boolean;
  37029. /**
  37030. * Perform relative position change from the point of view of behind the front of the mesh.
  37031. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37032. * Supports definition of mesh facing forward or backward
  37033. * @param amountRight defines the distance on the right axis
  37034. * @param amountUp defines the distance on the up axis
  37035. * @param amountForward defines the distance on the forward axis
  37036. * @returns the current mesh
  37037. */
  37038. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37039. /**
  37040. * Calculate relative position change from the point of view of behind the front of the mesh.
  37041. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37042. * Supports definition of mesh facing forward or backward
  37043. * @param amountRight defines the distance on the right axis
  37044. * @param amountUp defines the distance on the up axis
  37045. * @param amountForward defines the distance on the forward axis
  37046. * @returns the new displacement vector
  37047. */
  37048. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37049. /**
  37050. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37051. * Supports definition of mesh facing forward or backward
  37052. * @param flipBack defines the flip
  37053. * @param twirlClockwise defines the twirl
  37054. * @param tiltRight defines the tilt
  37055. * @returns the current mesh
  37056. */
  37057. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37058. /**
  37059. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37060. * Supports definition of mesh facing forward or backward.
  37061. * @param flipBack defines the flip
  37062. * @param twirlClockwise defines the twirl
  37063. * @param tiltRight defines the tilt
  37064. * @returns the new rotation vector
  37065. */
  37066. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37067. /**
  37068. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37069. * This means the mesh underlying bounding box and sphere are recomputed.
  37070. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37071. * @returns the current mesh
  37072. */
  37073. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37074. /** @hidden */
  37075. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37076. /** @hidden */
  37077. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37078. /** @hidden */
  37079. _updateBoundingInfo(): AbstractMesh;
  37080. /** @hidden */
  37081. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37082. /** @hidden */
  37083. protected _afterComputeWorldMatrix(): void;
  37084. /** @hidden */
  37085. get _effectiveMesh(): AbstractMesh;
  37086. /**
  37087. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37088. * A mesh is in the frustum if its bounding box intersects the frustum
  37089. * @param frustumPlanes defines the frustum to test
  37090. * @returns true if the mesh is in the frustum planes
  37091. */
  37092. isInFrustum(frustumPlanes: Plane[]): boolean;
  37093. /**
  37094. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37095. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37096. * @param frustumPlanes defines the frustum to test
  37097. * @returns true if the mesh is completely in the frustum planes
  37098. */
  37099. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37100. /**
  37101. * True if the mesh intersects another mesh or a SolidParticle object
  37102. * @param mesh defines a target mesh or SolidParticle to test
  37103. * @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)
  37104. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37105. * @returns true if there is an intersection
  37106. */
  37107. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37108. /**
  37109. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37110. * @param point defines the point to test
  37111. * @returns true if there is an intersection
  37112. */
  37113. intersectsPoint(point: Vector3): boolean;
  37114. /**
  37115. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37116. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37117. */
  37118. get checkCollisions(): boolean;
  37119. set checkCollisions(collisionEnabled: boolean);
  37120. /**
  37121. * Gets Collider object used to compute collisions (not physics)
  37122. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37123. */
  37124. get collider(): Nullable<Collider>;
  37125. /**
  37126. * Move the mesh using collision engine
  37127. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37128. * @param displacement defines the requested displacement vector
  37129. * @returns the current mesh
  37130. */
  37131. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37132. private _onCollisionPositionChange;
  37133. /** @hidden */
  37134. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37135. /** @hidden */
  37136. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37137. /** @hidden */
  37138. _checkCollision(collider: Collider): AbstractMesh;
  37139. /** @hidden */
  37140. _generatePointsArray(): boolean;
  37141. /**
  37142. * Checks if the passed Ray intersects with the mesh
  37143. * @param ray defines the ray to use
  37144. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37145. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37146. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37147. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37148. * @returns the picking info
  37149. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37150. */
  37151. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37152. /**
  37153. * Clones the current mesh
  37154. * @param name defines the mesh name
  37155. * @param newParent defines the new mesh parent
  37156. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37157. * @returns the new mesh
  37158. */
  37159. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37160. /**
  37161. * Disposes all the submeshes of the current meshnp
  37162. * @returns the current mesh
  37163. */
  37164. releaseSubMeshes(): AbstractMesh;
  37165. /**
  37166. * Releases resources associated with this abstract mesh.
  37167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37169. */
  37170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37171. /**
  37172. * Adds the passed mesh as a child to the current mesh
  37173. * @param mesh defines the child mesh
  37174. * @returns the current mesh
  37175. */
  37176. addChild(mesh: AbstractMesh): AbstractMesh;
  37177. /**
  37178. * Removes the passed mesh from the current mesh children list
  37179. * @param mesh defines the child mesh
  37180. * @returns the current mesh
  37181. */
  37182. removeChild(mesh: AbstractMesh): AbstractMesh;
  37183. /** @hidden */
  37184. private _initFacetData;
  37185. /**
  37186. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37187. * This method can be called within the render loop.
  37188. * 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
  37189. * @returns the current mesh
  37190. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37191. */
  37192. updateFacetData(): AbstractMesh;
  37193. /**
  37194. * Returns the facetLocalNormals array.
  37195. * The normals are expressed in the mesh local spac
  37196. * @returns an array of Vector3
  37197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37198. */
  37199. getFacetLocalNormals(): Vector3[];
  37200. /**
  37201. * Returns the facetLocalPositions array.
  37202. * The facet positions are expressed in the mesh local space
  37203. * @returns an array of Vector3
  37204. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37205. */
  37206. getFacetLocalPositions(): Vector3[];
  37207. /**
  37208. * Returns the facetLocalPartioning array
  37209. * @returns an array of array of numbers
  37210. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37211. */
  37212. getFacetLocalPartitioning(): number[][];
  37213. /**
  37214. * Returns the i-th facet position in the world system.
  37215. * This method allocates a new Vector3 per call
  37216. * @param i defines the facet index
  37217. * @returns a new Vector3
  37218. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37219. */
  37220. getFacetPosition(i: number): Vector3;
  37221. /**
  37222. * Sets the reference Vector3 with the i-th facet position in the world system
  37223. * @param i defines the facet index
  37224. * @param ref defines the target vector
  37225. * @returns the current mesh
  37226. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37227. */
  37228. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37229. /**
  37230. * Returns the i-th facet normal in the world system.
  37231. * This method allocates a new Vector3 per call
  37232. * @param i defines the facet index
  37233. * @returns a new Vector3
  37234. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37235. */
  37236. getFacetNormal(i: number): Vector3;
  37237. /**
  37238. * Sets the reference Vector3 with the i-th facet normal in the world system
  37239. * @param i defines the facet index
  37240. * @param ref defines the target vector
  37241. * @returns the current mesh
  37242. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37243. */
  37244. getFacetNormalToRef(i: number, ref: Vector3): this;
  37245. /**
  37246. * 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)
  37247. * @param x defines x coordinate
  37248. * @param y defines y coordinate
  37249. * @param z defines z coordinate
  37250. * @returns the array of facet indexes
  37251. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37252. */
  37253. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37254. /**
  37255. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37256. * @param projected sets as the (x,y,z) world projection on the facet
  37257. * @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
  37258. * @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
  37259. * @param x defines x coordinate
  37260. * @param y defines y coordinate
  37261. * @param z defines z coordinate
  37262. * @returns the face index if found (or null instead)
  37263. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37264. */
  37265. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37266. /**
  37267. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37268. * @param projected sets as the (x,y,z) local projection on the facet
  37269. * @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
  37270. * @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
  37271. * @param x defines x coordinate
  37272. * @param y defines y coordinate
  37273. * @param z defines z coordinate
  37274. * @returns the face index if found (or null instead)
  37275. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37276. */
  37277. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37278. /**
  37279. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37280. * @returns the parameters
  37281. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37282. */
  37283. getFacetDataParameters(): any;
  37284. /**
  37285. * Disables the feature FacetData and frees the related memory
  37286. * @returns the current mesh
  37287. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37288. */
  37289. disableFacetData(): AbstractMesh;
  37290. /**
  37291. * Updates the AbstractMesh indices array
  37292. * @param indices defines the data source
  37293. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37294. * @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)
  37295. * @returns the current mesh
  37296. */
  37297. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37298. /**
  37299. * Creates new normals data for the mesh
  37300. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37301. * @returns the current mesh
  37302. */
  37303. createNormals(updatable: boolean): AbstractMesh;
  37304. /**
  37305. * Align the mesh with a normal
  37306. * @param normal defines the normal to use
  37307. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37308. * @returns the current mesh
  37309. */
  37310. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37311. /** @hidden */
  37312. _checkOcclusionQuery(): boolean;
  37313. /**
  37314. * Disables the mesh edge rendering mode
  37315. * @returns the currentAbstractMesh
  37316. */
  37317. disableEdgesRendering(): AbstractMesh;
  37318. /**
  37319. * Enables the edge rendering mode on the mesh.
  37320. * This mode makes the mesh edges visible
  37321. * @param epsilon defines the maximal distance between two angles to detect a face
  37322. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37323. * @returns the currentAbstractMesh
  37324. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37325. */
  37326. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37327. /**
  37328. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37329. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37330. */
  37331. getConnectedParticleSystems(): IParticleSystem[];
  37332. }
  37333. }
  37334. declare module "babylonjs/Actions/actionEvent" {
  37335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37336. import { Nullable } from "babylonjs/types";
  37337. import { Sprite } from "babylonjs/Sprites/sprite";
  37338. import { Scene } from "babylonjs/scene";
  37339. import { Vector2 } from "babylonjs/Maths/math.vector";
  37340. /**
  37341. * Interface used to define ActionEvent
  37342. */
  37343. export interface IActionEvent {
  37344. /** The mesh or sprite that triggered the action */
  37345. source: any;
  37346. /** The X mouse cursor position at the time of the event */
  37347. pointerX: number;
  37348. /** The Y mouse cursor position at the time of the event */
  37349. pointerY: number;
  37350. /** The mesh that is currently pointed at (can be null) */
  37351. meshUnderPointer: Nullable<AbstractMesh>;
  37352. /** the original (browser) event that triggered the ActionEvent */
  37353. sourceEvent?: any;
  37354. /** additional data for the event */
  37355. additionalData?: any;
  37356. }
  37357. /**
  37358. * ActionEvent is the event being sent when an action is triggered.
  37359. */
  37360. export class ActionEvent implements IActionEvent {
  37361. /** The mesh or sprite that triggered the action */
  37362. source: any;
  37363. /** The X mouse cursor position at the time of the event */
  37364. pointerX: number;
  37365. /** The Y mouse cursor position at the time of the event */
  37366. pointerY: number;
  37367. /** The mesh that is currently pointed at (can be null) */
  37368. meshUnderPointer: Nullable<AbstractMesh>;
  37369. /** the original (browser) event that triggered the ActionEvent */
  37370. sourceEvent?: any;
  37371. /** additional data for the event */
  37372. additionalData?: any;
  37373. /**
  37374. * Creates a new ActionEvent
  37375. * @param source The mesh or sprite that triggered the action
  37376. * @param pointerX The X mouse cursor position at the time of the event
  37377. * @param pointerY The Y mouse cursor position at the time of the event
  37378. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37379. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37380. * @param additionalData additional data for the event
  37381. */
  37382. constructor(
  37383. /** The mesh or sprite that triggered the action */
  37384. source: any,
  37385. /** The X mouse cursor position at the time of the event */
  37386. pointerX: number,
  37387. /** The Y mouse cursor position at the time of the event */
  37388. pointerY: number,
  37389. /** The mesh that is currently pointed at (can be null) */
  37390. meshUnderPointer: Nullable<AbstractMesh>,
  37391. /** the original (browser) event that triggered the ActionEvent */
  37392. sourceEvent?: any,
  37393. /** additional data for the event */
  37394. additionalData?: any);
  37395. /**
  37396. * Helper function to auto-create an ActionEvent from a source mesh.
  37397. * @param source The source mesh that triggered the event
  37398. * @param evt The original (browser) event
  37399. * @param additionalData additional data for the event
  37400. * @returns the new ActionEvent
  37401. */
  37402. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37403. /**
  37404. * Helper function to auto-create an ActionEvent from a source sprite
  37405. * @param source The source sprite that triggered the event
  37406. * @param scene Scene associated with the sprite
  37407. * @param evt The original (browser) event
  37408. * @param additionalData additional data for the event
  37409. * @returns the new ActionEvent
  37410. */
  37411. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37412. /**
  37413. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37414. * @param scene the scene where the event occurred
  37415. * @param evt The original (browser) event
  37416. * @returns the new ActionEvent
  37417. */
  37418. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37419. /**
  37420. * Helper function to auto-create an ActionEvent from a primitive
  37421. * @param prim defines the target primitive
  37422. * @param pointerPos defines the pointer position
  37423. * @param evt The original (browser) event
  37424. * @param additionalData additional data for the event
  37425. * @returns the new ActionEvent
  37426. */
  37427. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37428. }
  37429. }
  37430. declare module "babylonjs/Actions/abstractActionManager" {
  37431. import { IDisposable } from "babylonjs/scene";
  37432. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37433. import { IAction } from "babylonjs/Actions/action";
  37434. import { Nullable } from "babylonjs/types";
  37435. /**
  37436. * Abstract class used to decouple action Manager from scene and meshes.
  37437. * Do not instantiate.
  37438. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37439. */
  37440. export abstract class AbstractActionManager implements IDisposable {
  37441. /** Gets the list of active triggers */
  37442. static Triggers: {
  37443. [key: string]: number;
  37444. };
  37445. /** Gets the cursor to use when hovering items */
  37446. hoverCursor: string;
  37447. /** Gets the list of actions */
  37448. actions: IAction[];
  37449. /**
  37450. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37451. */
  37452. isRecursive: boolean;
  37453. /**
  37454. * Releases all associated resources
  37455. */
  37456. abstract dispose(): void;
  37457. /**
  37458. * Does this action manager has pointer triggers
  37459. */
  37460. abstract get hasPointerTriggers(): boolean;
  37461. /**
  37462. * Does this action manager has pick triggers
  37463. */
  37464. abstract get hasPickTriggers(): boolean;
  37465. /**
  37466. * Process a specific trigger
  37467. * @param trigger defines the trigger to process
  37468. * @param evt defines the event details to be processed
  37469. */
  37470. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37471. /**
  37472. * Does this action manager handles actions of any of the given triggers
  37473. * @param triggers defines the triggers to be tested
  37474. * @return a boolean indicating whether one (or more) of the triggers is handled
  37475. */
  37476. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37477. /**
  37478. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37479. * speed.
  37480. * @param triggerA defines the trigger to be tested
  37481. * @param triggerB defines the trigger to be tested
  37482. * @return a boolean indicating whether one (or more) of the triggers is handled
  37483. */
  37484. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37485. /**
  37486. * Does this action manager handles actions of a given trigger
  37487. * @param trigger defines the trigger to be tested
  37488. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37489. * @return whether the trigger is handled
  37490. */
  37491. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37492. /**
  37493. * Serialize this manager to a JSON object
  37494. * @param name defines the property name to store this manager
  37495. * @returns a JSON representation of this manager
  37496. */
  37497. abstract serialize(name: string): any;
  37498. /**
  37499. * Registers an action to this action manager
  37500. * @param action defines the action to be registered
  37501. * @return the action amended (prepared) after registration
  37502. */
  37503. abstract registerAction(action: IAction): Nullable<IAction>;
  37504. /**
  37505. * Unregisters an action to this action manager
  37506. * @param action defines the action to be unregistered
  37507. * @return a boolean indicating whether the action has been unregistered
  37508. */
  37509. abstract unregisterAction(action: IAction): Boolean;
  37510. /**
  37511. * Does exist one action manager with at least one trigger
  37512. **/
  37513. static get HasTriggers(): boolean;
  37514. /**
  37515. * Does exist one action manager with at least one pick trigger
  37516. **/
  37517. static get HasPickTriggers(): boolean;
  37518. /**
  37519. * Does exist one action manager that handles actions of a given trigger
  37520. * @param trigger defines the trigger to be tested
  37521. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37522. **/
  37523. static HasSpecificTrigger(trigger: number): boolean;
  37524. }
  37525. }
  37526. declare module "babylonjs/node" {
  37527. import { Scene } from "babylonjs/scene";
  37528. import { Nullable } from "babylonjs/types";
  37529. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37530. import { Engine } from "babylonjs/Engines/engine";
  37531. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37532. import { Observable } from "babylonjs/Misc/observable";
  37533. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37534. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37535. import { Animatable } from "babylonjs/Animations/animatable";
  37536. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37537. import { Animation } from "babylonjs/Animations/animation";
  37538. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37540. /**
  37541. * Defines how a node can be built from a string name.
  37542. */
  37543. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37544. /**
  37545. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37546. */
  37547. export class Node implements IBehaviorAware<Node> {
  37548. /** @hidden */
  37549. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37550. private static _NodeConstructors;
  37551. /**
  37552. * Add a new node constructor
  37553. * @param type defines the type name of the node to construct
  37554. * @param constructorFunc defines the constructor function
  37555. */
  37556. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37557. /**
  37558. * Returns a node constructor based on type name
  37559. * @param type defines the type name
  37560. * @param name defines the new node name
  37561. * @param scene defines the hosting scene
  37562. * @param options defines optional options to transmit to constructors
  37563. * @returns the new constructor or null
  37564. */
  37565. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37566. /**
  37567. * Gets or sets the name of the node
  37568. */
  37569. name: string;
  37570. /**
  37571. * Gets or sets the id of the node
  37572. */
  37573. id: string;
  37574. /**
  37575. * Gets or sets the unique id of the node
  37576. */
  37577. uniqueId: number;
  37578. /**
  37579. * Gets or sets a string used to store user defined state for the node
  37580. */
  37581. state: string;
  37582. /**
  37583. * Gets or sets an object used to store user defined information for the node
  37584. */
  37585. metadata: any;
  37586. /**
  37587. * For internal use only. Please do not use.
  37588. */
  37589. reservedDataStore: any;
  37590. /**
  37591. * List of inspectable custom properties (used by the Inspector)
  37592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37593. */
  37594. inspectableCustomProperties: IInspectable[];
  37595. private _doNotSerialize;
  37596. /**
  37597. * Gets or sets a boolean used to define if the node must be serialized
  37598. */
  37599. get doNotSerialize(): boolean;
  37600. set doNotSerialize(value: boolean);
  37601. /** @hidden */
  37602. _isDisposed: boolean;
  37603. /**
  37604. * Gets a list of Animations associated with the node
  37605. */
  37606. animations: import("babylonjs/Animations/animation").Animation[];
  37607. protected _ranges: {
  37608. [name: string]: Nullable<AnimationRange>;
  37609. };
  37610. /**
  37611. * Callback raised when the node is ready to be used
  37612. */
  37613. onReady: Nullable<(node: Node) => void>;
  37614. private _isEnabled;
  37615. private _isParentEnabled;
  37616. private _isReady;
  37617. /** @hidden */
  37618. _currentRenderId: number;
  37619. private _parentUpdateId;
  37620. /** @hidden */
  37621. _childUpdateId: number;
  37622. /** @hidden */
  37623. _waitingParentId: Nullable<string>;
  37624. /** @hidden */
  37625. _scene: Scene;
  37626. /** @hidden */
  37627. _cache: any;
  37628. private _parentNode;
  37629. private _children;
  37630. /** @hidden */
  37631. _worldMatrix: Matrix;
  37632. /** @hidden */
  37633. _worldMatrixDeterminant: number;
  37634. /** @hidden */
  37635. _worldMatrixDeterminantIsDirty: boolean;
  37636. /** @hidden */
  37637. private _sceneRootNodesIndex;
  37638. /**
  37639. * Gets a boolean indicating if the node has been disposed
  37640. * @returns true if the node was disposed
  37641. */
  37642. isDisposed(): boolean;
  37643. /**
  37644. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37645. * @see https://doc.babylonjs.com/how_to/parenting
  37646. */
  37647. set parent(parent: Nullable<Node>);
  37648. get parent(): Nullable<Node>;
  37649. /** @hidden */
  37650. _addToSceneRootNodes(): void;
  37651. /** @hidden */
  37652. _removeFromSceneRootNodes(): void;
  37653. private _animationPropertiesOverride;
  37654. /**
  37655. * Gets or sets the animation properties override
  37656. */
  37657. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37658. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37659. /**
  37660. * Gets a string identifying the name of the class
  37661. * @returns "Node" string
  37662. */
  37663. getClassName(): string;
  37664. /** @hidden */
  37665. readonly _isNode: boolean;
  37666. /**
  37667. * An event triggered when the mesh is disposed
  37668. */
  37669. onDisposeObservable: Observable<Node>;
  37670. private _onDisposeObserver;
  37671. /**
  37672. * Sets a callback that will be raised when the node will be disposed
  37673. */
  37674. set onDispose(callback: () => void);
  37675. /**
  37676. * Creates a new Node
  37677. * @param name the name and id to be given to this node
  37678. * @param scene the scene this node will be added to
  37679. */
  37680. constructor(name: string, scene?: Nullable<Scene>);
  37681. /**
  37682. * Gets the scene of the node
  37683. * @returns a scene
  37684. */
  37685. getScene(): Scene;
  37686. /**
  37687. * Gets the engine of the node
  37688. * @returns a Engine
  37689. */
  37690. getEngine(): Engine;
  37691. private _behaviors;
  37692. /**
  37693. * Attach a behavior to the node
  37694. * @see https://doc.babylonjs.com/features/behaviour
  37695. * @param behavior defines the behavior to attach
  37696. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37697. * @returns the current Node
  37698. */
  37699. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37700. /**
  37701. * Remove an attached behavior
  37702. * @see https://doc.babylonjs.com/features/behaviour
  37703. * @param behavior defines the behavior to attach
  37704. * @returns the current Node
  37705. */
  37706. removeBehavior(behavior: Behavior<Node>): Node;
  37707. /**
  37708. * Gets the list of attached behaviors
  37709. * @see https://doc.babylonjs.com/features/behaviour
  37710. */
  37711. get behaviors(): Behavior<Node>[];
  37712. /**
  37713. * Gets an attached behavior by name
  37714. * @param name defines the name of the behavior to look for
  37715. * @see https://doc.babylonjs.com/features/behaviour
  37716. * @returns null if behavior was not found else the requested behavior
  37717. */
  37718. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37719. /**
  37720. * Returns the latest update of the World matrix
  37721. * @returns a Matrix
  37722. */
  37723. getWorldMatrix(): Matrix;
  37724. /** @hidden */
  37725. _getWorldMatrixDeterminant(): number;
  37726. /**
  37727. * Returns directly the latest state of the mesh World matrix.
  37728. * A Matrix is returned.
  37729. */
  37730. get worldMatrixFromCache(): Matrix;
  37731. /** @hidden */
  37732. _initCache(): void;
  37733. /** @hidden */
  37734. updateCache(force?: boolean): void;
  37735. /** @hidden */
  37736. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37737. /** @hidden */
  37738. _updateCache(ignoreParentClass?: boolean): void;
  37739. /** @hidden */
  37740. _isSynchronized(): boolean;
  37741. /** @hidden */
  37742. _markSyncedWithParent(): void;
  37743. /** @hidden */
  37744. isSynchronizedWithParent(): boolean;
  37745. /** @hidden */
  37746. isSynchronized(): boolean;
  37747. /**
  37748. * Is this node ready to be used/rendered
  37749. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37750. * @return true if the node is ready
  37751. */
  37752. isReady(completeCheck?: boolean): boolean;
  37753. /**
  37754. * Is this node enabled?
  37755. * 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
  37756. * @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
  37757. * @return whether this node (and its parent) is enabled
  37758. */
  37759. isEnabled(checkAncestors?: boolean): boolean;
  37760. /** @hidden */
  37761. protected _syncParentEnabledState(): void;
  37762. /**
  37763. * Set the enabled state of this node
  37764. * @param value defines the new enabled state
  37765. */
  37766. setEnabled(value: boolean): void;
  37767. /**
  37768. * Is this node a descendant of the given node?
  37769. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37770. * @param ancestor defines the parent node to inspect
  37771. * @returns a boolean indicating if this node is a descendant of the given node
  37772. */
  37773. isDescendantOf(ancestor: Node): boolean;
  37774. /** @hidden */
  37775. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37776. /**
  37777. * Will return all nodes that have this node as ascendant
  37778. * @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
  37779. * @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
  37780. * @return all children nodes of all types
  37781. */
  37782. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37783. /**
  37784. * Get all child-meshes of this node
  37785. * @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)
  37786. * @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
  37787. * @returns an array of AbstractMesh
  37788. */
  37789. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37790. /**
  37791. * Get all direct children of this node
  37792. * @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
  37793. * @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)
  37794. * @returns an array of Node
  37795. */
  37796. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37797. /** @hidden */
  37798. _setReady(state: boolean): void;
  37799. /**
  37800. * Get an animation by name
  37801. * @param name defines the name of the animation to look for
  37802. * @returns null if not found else the requested animation
  37803. */
  37804. getAnimationByName(name: string): Nullable<Animation>;
  37805. /**
  37806. * Creates an animation range for this node
  37807. * @param name defines the name of the range
  37808. * @param from defines the starting key
  37809. * @param to defines the end key
  37810. */
  37811. createAnimationRange(name: string, from: number, to: number): void;
  37812. /**
  37813. * Delete a specific animation range
  37814. * @param name defines the name of the range to delete
  37815. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37816. */
  37817. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37818. /**
  37819. * Get an animation range by name
  37820. * @param name defines the name of the animation range to look for
  37821. * @returns null if not found else the requested animation range
  37822. */
  37823. getAnimationRange(name: string): Nullable<AnimationRange>;
  37824. /**
  37825. * Gets the list of all animation ranges defined on this node
  37826. * @returns an array
  37827. */
  37828. getAnimationRanges(): Nullable<AnimationRange>[];
  37829. /**
  37830. * Will start the animation sequence
  37831. * @param name defines the range frames for animation sequence
  37832. * @param loop defines if the animation should loop (false by default)
  37833. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37834. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37835. * @returns the object created for this animation. If range does not exist, it will return null
  37836. */
  37837. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37838. /**
  37839. * Serialize animation ranges into a JSON compatible object
  37840. * @returns serialization object
  37841. */
  37842. serializeAnimationRanges(): any;
  37843. /**
  37844. * Computes the world matrix of the node
  37845. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37846. * @returns the world matrix
  37847. */
  37848. computeWorldMatrix(force?: boolean): Matrix;
  37849. /**
  37850. * Releases resources associated with this node.
  37851. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37852. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37853. */
  37854. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37855. /**
  37856. * Parse animation range data from a serialization object and store them into a given node
  37857. * @param node defines where to store the animation ranges
  37858. * @param parsedNode defines the serialization object to read data from
  37859. * @param scene defines the hosting scene
  37860. */
  37861. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37862. /**
  37863. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37864. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37865. * @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
  37866. * @returns the new bounding vectors
  37867. */
  37868. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37869. min: Vector3;
  37870. max: Vector3;
  37871. };
  37872. }
  37873. }
  37874. declare module "babylonjs/Animations/animation" {
  37875. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37876. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37877. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37878. import { Nullable } from "babylonjs/types";
  37879. import { Scene } from "babylonjs/scene";
  37880. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37881. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37882. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37883. import { Node } from "babylonjs/node";
  37884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37885. import { Size } from "babylonjs/Maths/math.size";
  37886. import { Animatable } from "babylonjs/Animations/animatable";
  37887. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37888. /**
  37889. * @hidden
  37890. */
  37891. export class _IAnimationState {
  37892. key: number;
  37893. repeatCount: number;
  37894. workValue?: any;
  37895. loopMode?: number;
  37896. offsetValue?: any;
  37897. highLimitValue?: any;
  37898. }
  37899. /**
  37900. * Class used to store any kind of animation
  37901. */
  37902. export class Animation {
  37903. /**Name of the animation */
  37904. name: string;
  37905. /**Property to animate */
  37906. targetProperty: string;
  37907. /**The frames per second of the animation */
  37908. framePerSecond: number;
  37909. /**The data type of the animation */
  37910. dataType: number;
  37911. /**The loop mode of the animation */
  37912. loopMode?: number | undefined;
  37913. /**Specifies if blending should be enabled */
  37914. enableBlending?: boolean | undefined;
  37915. /**
  37916. * Use matrix interpolation instead of using direct key value when animating matrices
  37917. */
  37918. static AllowMatricesInterpolation: boolean;
  37919. /**
  37920. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37921. */
  37922. static AllowMatrixDecomposeForInterpolation: boolean;
  37923. /** Define the Url to load snippets */
  37924. static SnippetUrl: string;
  37925. /** Snippet ID if the animation was created from the snippet server */
  37926. snippetId: string;
  37927. /**
  37928. * Stores the key frames of the animation
  37929. */
  37930. private _keys;
  37931. /**
  37932. * Stores the easing function of the animation
  37933. */
  37934. private _easingFunction;
  37935. /**
  37936. * @hidden Internal use only
  37937. */
  37938. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37939. /**
  37940. * The set of event that will be linked to this animation
  37941. */
  37942. private _events;
  37943. /**
  37944. * Stores an array of target property paths
  37945. */
  37946. targetPropertyPath: string[];
  37947. /**
  37948. * Stores the blending speed of the animation
  37949. */
  37950. blendingSpeed: number;
  37951. /**
  37952. * Stores the animation ranges for the animation
  37953. */
  37954. private _ranges;
  37955. /**
  37956. * @hidden Internal use
  37957. */
  37958. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37959. /**
  37960. * Sets up an animation
  37961. * @param property The property to animate
  37962. * @param animationType The animation type to apply
  37963. * @param framePerSecond The frames per second of the animation
  37964. * @param easingFunction The easing function used in the animation
  37965. * @returns The created animation
  37966. */
  37967. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37968. /**
  37969. * Create and start an animation on a node
  37970. * @param name defines the name of the global animation that will be run on all nodes
  37971. * @param node defines the root node where the animation will take place
  37972. * @param targetProperty defines property to animate
  37973. * @param framePerSecond defines the number of frame per second yo use
  37974. * @param totalFrame defines the number of frames in total
  37975. * @param from defines the initial value
  37976. * @param to defines the final value
  37977. * @param loopMode defines which loop mode you want to use (off by default)
  37978. * @param easingFunction defines the easing function to use (linear by default)
  37979. * @param onAnimationEnd defines the callback to call when animation end
  37980. * @returns the animatable created for this animation
  37981. */
  37982. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37983. /**
  37984. * Create and start an animation on a node and its descendants
  37985. * @param name defines the name of the global animation that will be run on all nodes
  37986. * @param node defines the root node where the animation will take place
  37987. * @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
  37988. * @param targetProperty defines property to animate
  37989. * @param framePerSecond defines the number of frame per second to use
  37990. * @param totalFrame defines the number of frames in total
  37991. * @param from defines the initial value
  37992. * @param to defines the final value
  37993. * @param loopMode defines which loop mode you want to use (off by default)
  37994. * @param easingFunction defines the easing function to use (linear by default)
  37995. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37996. * @returns the list of animatables created for all nodes
  37997. * @example https://www.babylonjs-playground.com/#MH0VLI
  37998. */
  37999. 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[]>;
  38000. /**
  38001. * Creates a new animation, merges it with the existing animations and starts it
  38002. * @param name Name of the animation
  38003. * @param node Node which contains the scene that begins the animations
  38004. * @param targetProperty Specifies which property to animate
  38005. * @param framePerSecond The frames per second of the animation
  38006. * @param totalFrame The total number of frames
  38007. * @param from The frame at the beginning of the animation
  38008. * @param to The frame at the end of the animation
  38009. * @param loopMode Specifies the loop mode of the animation
  38010. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38011. * @param onAnimationEnd Callback to run once the animation is complete
  38012. * @returns Nullable animation
  38013. */
  38014. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38015. /**
  38016. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38017. * @param sourceAnimation defines the Animation containing keyframes to convert
  38018. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38019. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38020. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38021. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38022. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38023. */
  38024. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38025. /**
  38026. * Transition property of an host to the target Value
  38027. * @param property The property to transition
  38028. * @param targetValue The target Value of the property
  38029. * @param host The object where the property to animate belongs
  38030. * @param scene Scene used to run the animation
  38031. * @param frameRate Framerate (in frame/s) to use
  38032. * @param transition The transition type we want to use
  38033. * @param duration The duration of the animation, in milliseconds
  38034. * @param onAnimationEnd Callback trigger at the end of the animation
  38035. * @returns Nullable animation
  38036. */
  38037. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38038. /**
  38039. * Return the array of runtime animations currently using this animation
  38040. */
  38041. get runtimeAnimations(): RuntimeAnimation[];
  38042. /**
  38043. * Specifies if any of the runtime animations are currently running
  38044. */
  38045. get hasRunningRuntimeAnimations(): boolean;
  38046. /**
  38047. * Initializes the animation
  38048. * @param name Name of the animation
  38049. * @param targetProperty Property to animate
  38050. * @param framePerSecond The frames per second of the animation
  38051. * @param dataType The data type of the animation
  38052. * @param loopMode The loop mode of the animation
  38053. * @param enableBlending Specifies if blending should be enabled
  38054. */
  38055. constructor(
  38056. /**Name of the animation */
  38057. name: string,
  38058. /**Property to animate */
  38059. targetProperty: string,
  38060. /**The frames per second of the animation */
  38061. framePerSecond: number,
  38062. /**The data type of the animation */
  38063. dataType: number,
  38064. /**The loop mode of the animation */
  38065. loopMode?: number | undefined,
  38066. /**Specifies if blending should be enabled */
  38067. enableBlending?: boolean | undefined);
  38068. /**
  38069. * Converts the animation to a string
  38070. * @param fullDetails support for multiple levels of logging within scene loading
  38071. * @returns String form of the animation
  38072. */
  38073. toString(fullDetails?: boolean): string;
  38074. /**
  38075. * Add an event to this animation
  38076. * @param event Event to add
  38077. */
  38078. addEvent(event: AnimationEvent): void;
  38079. /**
  38080. * Remove all events found at the given frame
  38081. * @param frame The frame to remove events from
  38082. */
  38083. removeEvents(frame: number): void;
  38084. /**
  38085. * Retrieves all the events from the animation
  38086. * @returns Events from the animation
  38087. */
  38088. getEvents(): AnimationEvent[];
  38089. /**
  38090. * Creates an animation range
  38091. * @param name Name of the animation range
  38092. * @param from Starting frame of the animation range
  38093. * @param to Ending frame of the animation
  38094. */
  38095. createRange(name: string, from: number, to: number): void;
  38096. /**
  38097. * Deletes an animation range by name
  38098. * @param name Name of the animation range to delete
  38099. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38100. */
  38101. deleteRange(name: string, deleteFrames?: boolean): void;
  38102. /**
  38103. * Gets the animation range by name, or null if not defined
  38104. * @param name Name of the animation range
  38105. * @returns Nullable animation range
  38106. */
  38107. getRange(name: string): Nullable<AnimationRange>;
  38108. /**
  38109. * Gets the key frames from the animation
  38110. * @returns The key frames of the animation
  38111. */
  38112. getKeys(): Array<IAnimationKey>;
  38113. /**
  38114. * Gets the highest frame rate of the animation
  38115. * @returns Highest frame rate of the animation
  38116. */
  38117. getHighestFrame(): number;
  38118. /**
  38119. * Gets the easing function of the animation
  38120. * @returns Easing function of the animation
  38121. */
  38122. getEasingFunction(): IEasingFunction;
  38123. /**
  38124. * Sets the easing function of the animation
  38125. * @param easingFunction A custom mathematical formula for animation
  38126. */
  38127. setEasingFunction(easingFunction: EasingFunction): void;
  38128. /**
  38129. * Interpolates a scalar linearly
  38130. * @param startValue Start value of the animation curve
  38131. * @param endValue End value of the animation curve
  38132. * @param gradient Scalar amount to interpolate
  38133. * @returns Interpolated scalar value
  38134. */
  38135. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38136. /**
  38137. * Interpolates a scalar cubically
  38138. * @param startValue Start value of the animation curve
  38139. * @param outTangent End tangent of the animation
  38140. * @param endValue End value of the animation curve
  38141. * @param inTangent Start tangent of the animation curve
  38142. * @param gradient Scalar amount to interpolate
  38143. * @returns Interpolated scalar value
  38144. */
  38145. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38146. /**
  38147. * Interpolates a quaternion using a spherical linear interpolation
  38148. * @param startValue Start value of the animation curve
  38149. * @param endValue End value of the animation curve
  38150. * @param gradient Scalar amount to interpolate
  38151. * @returns Interpolated quaternion value
  38152. */
  38153. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38154. /**
  38155. * Interpolates a quaternion cubically
  38156. * @param startValue Start value of the animation curve
  38157. * @param outTangent End tangent of the animation curve
  38158. * @param endValue End value of the animation curve
  38159. * @param inTangent Start tangent of the animation curve
  38160. * @param gradient Scalar amount to interpolate
  38161. * @returns Interpolated quaternion value
  38162. */
  38163. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38164. /**
  38165. * Interpolates a Vector3 linearl
  38166. * @param startValue Start value of the animation curve
  38167. * @param endValue End value of the animation curve
  38168. * @param gradient Scalar amount to interpolate
  38169. * @returns Interpolated scalar value
  38170. */
  38171. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38172. /**
  38173. * Interpolates a Vector3 cubically
  38174. * @param startValue Start value of the animation curve
  38175. * @param outTangent End tangent of the animation
  38176. * @param endValue End value of the animation curve
  38177. * @param inTangent Start tangent of the animation curve
  38178. * @param gradient Scalar amount to interpolate
  38179. * @returns InterpolatedVector3 value
  38180. */
  38181. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38182. /**
  38183. * Interpolates a Vector2 linearly
  38184. * @param startValue Start value of the animation curve
  38185. * @param endValue End value of the animation curve
  38186. * @param gradient Scalar amount to interpolate
  38187. * @returns Interpolated Vector2 value
  38188. */
  38189. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38190. /**
  38191. * Interpolates a Vector2 cubically
  38192. * @param startValue Start value of the animation curve
  38193. * @param outTangent End tangent of the animation
  38194. * @param endValue End value of the animation curve
  38195. * @param inTangent Start tangent of the animation curve
  38196. * @param gradient Scalar amount to interpolate
  38197. * @returns Interpolated Vector2 value
  38198. */
  38199. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38200. /**
  38201. * Interpolates a size linearly
  38202. * @param startValue Start value of the animation curve
  38203. * @param endValue End value of the animation curve
  38204. * @param gradient Scalar amount to interpolate
  38205. * @returns Interpolated Size value
  38206. */
  38207. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38208. /**
  38209. * Interpolates a Color3 linearly
  38210. * @param startValue Start value of the animation curve
  38211. * @param endValue End value of the animation curve
  38212. * @param gradient Scalar amount to interpolate
  38213. * @returns Interpolated Color3 value
  38214. */
  38215. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38216. /**
  38217. * Interpolates a Color4 linearly
  38218. * @param startValue Start value of the animation curve
  38219. * @param endValue End value of the animation curve
  38220. * @param gradient Scalar amount to interpolate
  38221. * @returns Interpolated Color3 value
  38222. */
  38223. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38224. /**
  38225. * @hidden Internal use only
  38226. */
  38227. _getKeyValue(value: any): any;
  38228. /**
  38229. * @hidden Internal use only
  38230. */
  38231. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38232. /**
  38233. * Defines the function to use to interpolate matrices
  38234. * @param startValue defines the start matrix
  38235. * @param endValue defines the end matrix
  38236. * @param gradient defines the gradient between both matrices
  38237. * @param result defines an optional target matrix where to store the interpolation
  38238. * @returns the interpolated matrix
  38239. */
  38240. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38241. /**
  38242. * Makes a copy of the animation
  38243. * @returns Cloned animation
  38244. */
  38245. clone(): Animation;
  38246. /**
  38247. * Sets the key frames of the animation
  38248. * @param values The animation key frames to set
  38249. */
  38250. setKeys(values: Array<IAnimationKey>): void;
  38251. /**
  38252. * Serializes the animation to an object
  38253. * @returns Serialized object
  38254. */
  38255. serialize(): any;
  38256. /**
  38257. * Float animation type
  38258. */
  38259. static readonly ANIMATIONTYPE_FLOAT: number;
  38260. /**
  38261. * Vector3 animation type
  38262. */
  38263. static readonly ANIMATIONTYPE_VECTOR3: number;
  38264. /**
  38265. * Quaternion animation type
  38266. */
  38267. static readonly ANIMATIONTYPE_QUATERNION: number;
  38268. /**
  38269. * Matrix animation type
  38270. */
  38271. static readonly ANIMATIONTYPE_MATRIX: number;
  38272. /**
  38273. * Color3 animation type
  38274. */
  38275. static readonly ANIMATIONTYPE_COLOR3: number;
  38276. /**
  38277. * Color3 animation type
  38278. */
  38279. static readonly ANIMATIONTYPE_COLOR4: number;
  38280. /**
  38281. * Vector2 animation type
  38282. */
  38283. static readonly ANIMATIONTYPE_VECTOR2: number;
  38284. /**
  38285. * Size animation type
  38286. */
  38287. static readonly ANIMATIONTYPE_SIZE: number;
  38288. /**
  38289. * Relative Loop Mode
  38290. */
  38291. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38292. /**
  38293. * Cycle Loop Mode
  38294. */
  38295. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38296. /**
  38297. * Constant Loop Mode
  38298. */
  38299. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38300. /** @hidden */
  38301. static _UniversalLerp(left: any, right: any, amount: number): any;
  38302. /**
  38303. * Parses an animation object and creates an animation
  38304. * @param parsedAnimation Parsed animation object
  38305. * @returns Animation object
  38306. */
  38307. static Parse(parsedAnimation: any): Animation;
  38308. /**
  38309. * Appends the serialized animations from the source animations
  38310. * @param source Source containing the animations
  38311. * @param destination Target to store the animations
  38312. */
  38313. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38314. /**
  38315. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38316. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38317. * @param url defines the url to load from
  38318. * @returns a promise that will resolve to the new animation or an array of animations
  38319. */
  38320. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38321. /**
  38322. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38323. * @param snippetId defines the snippet to load
  38324. * @returns a promise that will resolve to the new animation or a new array of animations
  38325. */
  38326. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38327. }
  38328. }
  38329. declare module "babylonjs/Animations/animatable.interface" {
  38330. import { Nullable } from "babylonjs/types";
  38331. import { Animation } from "babylonjs/Animations/animation";
  38332. /**
  38333. * Interface containing an array of animations
  38334. */
  38335. export interface IAnimatable {
  38336. /**
  38337. * Array of animations
  38338. */
  38339. animations: Nullable<Array<Animation>>;
  38340. }
  38341. }
  38342. declare module "babylonjs/Misc/decorators" {
  38343. import { Nullable } from "babylonjs/types";
  38344. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38345. import { Scene } from "babylonjs/scene";
  38346. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38347. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38348. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38350. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38351. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38352. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38353. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38354. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38355. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38356. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38357. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38358. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38359. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38360. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38361. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38362. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38363. /**
  38364. * Decorator used to define property that can be serialized as reference to a camera
  38365. * @param sourceName defines the name of the property to decorate
  38366. */
  38367. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38368. /**
  38369. * Class used to help serialization objects
  38370. */
  38371. export class SerializationHelper {
  38372. /** @hidden */
  38373. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38374. /** @hidden */
  38375. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38376. /** @hidden */
  38377. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38378. /** @hidden */
  38379. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38380. /**
  38381. * Appends the serialized animations from the source animations
  38382. * @param source Source containing the animations
  38383. * @param destination Target to store the animations
  38384. */
  38385. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38386. /**
  38387. * Static function used to serialized a specific entity
  38388. * @param entity defines the entity to serialize
  38389. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38390. * @returns a JSON compatible object representing the serialization of the entity
  38391. */
  38392. static Serialize<T>(entity: T, serializationObject?: any): any;
  38393. /**
  38394. * Creates a new entity from a serialization data object
  38395. * @param creationFunction defines a function used to instanciated the new entity
  38396. * @param source defines the source serialization data
  38397. * @param scene defines the hosting scene
  38398. * @param rootUrl defines the root url for resources
  38399. * @returns a new entity
  38400. */
  38401. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38402. /**
  38403. * Clones an object
  38404. * @param creationFunction defines the function used to instanciate the new object
  38405. * @param source defines the source object
  38406. * @returns the cloned object
  38407. */
  38408. static Clone<T>(creationFunction: () => T, source: T): T;
  38409. /**
  38410. * Instanciates a new object based on a source one (some data will be shared between both object)
  38411. * @param creationFunction defines the function used to instanciate the new object
  38412. * @param source defines the source object
  38413. * @returns the new object
  38414. */
  38415. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38416. }
  38417. }
  38418. declare module "babylonjs/Materials/Textures/baseTexture" {
  38419. import { Observable } from "babylonjs/Misc/observable";
  38420. import { Nullable } from "babylonjs/types";
  38421. import { Scene } from "babylonjs/scene";
  38422. import { Matrix } from "babylonjs/Maths/math.vector";
  38423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38425. import { ISize } from "babylonjs/Maths/math.size";
  38426. import "babylonjs/Misc/fileTools";
  38427. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38428. /**
  38429. * Base class of all the textures in babylon.
  38430. * It groups all the common properties the materials, post process, lights... might need
  38431. * in order to make a correct use of the texture.
  38432. */
  38433. export class BaseTexture implements IAnimatable {
  38434. /**
  38435. * Default anisotropic filtering level for the application.
  38436. * It is set to 4 as a good tradeoff between perf and quality.
  38437. */
  38438. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38439. /**
  38440. * Gets or sets the unique id of the texture
  38441. */
  38442. uniqueId: number;
  38443. /**
  38444. * Define the name of the texture.
  38445. */
  38446. name: string;
  38447. /**
  38448. * Gets or sets an object used to store user defined information.
  38449. */
  38450. metadata: any;
  38451. /**
  38452. * For internal use only. Please do not use.
  38453. */
  38454. reservedDataStore: any;
  38455. private _hasAlpha;
  38456. /**
  38457. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38458. */
  38459. set hasAlpha(value: boolean);
  38460. get hasAlpha(): boolean;
  38461. /**
  38462. * Defines if the alpha value should be determined via the rgb values.
  38463. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38464. */
  38465. getAlphaFromRGB: boolean;
  38466. /**
  38467. * Intensity or strength of the texture.
  38468. * It is commonly used by materials to fine tune the intensity of the texture
  38469. */
  38470. level: number;
  38471. /**
  38472. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38473. * This is part of the texture as textures usually maps to one uv set.
  38474. */
  38475. coordinatesIndex: number;
  38476. protected _coordinatesMode: number;
  38477. /**
  38478. * How a texture is mapped.
  38479. *
  38480. * | Value | Type | Description |
  38481. * | ----- | ----------------------------------- | ----------- |
  38482. * | 0 | EXPLICIT_MODE | |
  38483. * | 1 | SPHERICAL_MODE | |
  38484. * | 2 | PLANAR_MODE | |
  38485. * | 3 | CUBIC_MODE | |
  38486. * | 4 | PROJECTION_MODE | |
  38487. * | 5 | SKYBOX_MODE | |
  38488. * | 6 | INVCUBIC_MODE | |
  38489. * | 7 | EQUIRECTANGULAR_MODE | |
  38490. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38491. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38492. */
  38493. set coordinatesMode(value: number);
  38494. get coordinatesMode(): number;
  38495. private _wrapU;
  38496. /**
  38497. * | Value | Type | Description |
  38498. * | ----- | ------------------ | ----------- |
  38499. * | 0 | CLAMP_ADDRESSMODE | |
  38500. * | 1 | WRAP_ADDRESSMODE | |
  38501. * | 2 | MIRROR_ADDRESSMODE | |
  38502. */
  38503. get wrapU(): number;
  38504. set wrapU(value: number);
  38505. private _wrapV;
  38506. /**
  38507. * | Value | Type | Description |
  38508. * | ----- | ------------------ | ----------- |
  38509. * | 0 | CLAMP_ADDRESSMODE | |
  38510. * | 1 | WRAP_ADDRESSMODE | |
  38511. * | 2 | MIRROR_ADDRESSMODE | |
  38512. */
  38513. get wrapV(): number;
  38514. set wrapV(value: number);
  38515. /**
  38516. * | Value | Type | Description |
  38517. * | ----- | ------------------ | ----------- |
  38518. * | 0 | CLAMP_ADDRESSMODE | |
  38519. * | 1 | WRAP_ADDRESSMODE | |
  38520. * | 2 | MIRROR_ADDRESSMODE | |
  38521. */
  38522. wrapR: number;
  38523. /**
  38524. * With compliant hardware and browser (supporting anisotropic filtering)
  38525. * this defines the level of anisotropic filtering in the texture.
  38526. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38527. */
  38528. anisotropicFilteringLevel: number;
  38529. /**
  38530. * Define if the texture is a cube texture or if false a 2d texture.
  38531. */
  38532. get isCube(): boolean;
  38533. set isCube(value: boolean);
  38534. /**
  38535. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38536. */
  38537. get is3D(): boolean;
  38538. set is3D(value: boolean);
  38539. /**
  38540. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38541. */
  38542. get is2DArray(): boolean;
  38543. set is2DArray(value: boolean);
  38544. private _gammaSpace;
  38545. /**
  38546. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38547. * HDR texture are usually stored in linear space.
  38548. * This only impacts the PBR and Background materials
  38549. */
  38550. get gammaSpace(): boolean;
  38551. set gammaSpace(gamma: boolean);
  38552. /**
  38553. * Gets or sets whether or not the texture contains RGBD data.
  38554. */
  38555. get isRGBD(): boolean;
  38556. set isRGBD(value: boolean);
  38557. /**
  38558. * Is Z inverted in the texture (useful in a cube texture).
  38559. */
  38560. invertZ: boolean;
  38561. /**
  38562. * Are mip maps generated for this texture or not.
  38563. */
  38564. get noMipmap(): boolean;
  38565. /**
  38566. * @hidden
  38567. */
  38568. lodLevelInAlpha: boolean;
  38569. /**
  38570. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38571. */
  38572. get lodGenerationOffset(): number;
  38573. set lodGenerationOffset(value: number);
  38574. /**
  38575. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38576. */
  38577. get lodGenerationScale(): number;
  38578. set lodGenerationScale(value: number);
  38579. /**
  38580. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38581. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38582. * average roughness values.
  38583. */
  38584. get linearSpecularLOD(): boolean;
  38585. set linearSpecularLOD(value: boolean);
  38586. /**
  38587. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38588. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38589. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38590. */
  38591. get irradianceTexture(): Nullable<BaseTexture>;
  38592. set irradianceTexture(value: Nullable<BaseTexture>);
  38593. /**
  38594. * Define if the texture is a render target.
  38595. */
  38596. isRenderTarget: boolean;
  38597. /**
  38598. * Define the unique id of the texture in the scene.
  38599. */
  38600. get uid(): string;
  38601. /** @hidden */
  38602. _prefiltered: boolean;
  38603. /**
  38604. * Return a string representation of the texture.
  38605. * @returns the texture as a string
  38606. */
  38607. toString(): string;
  38608. /**
  38609. * Get the class name of the texture.
  38610. * @returns "BaseTexture"
  38611. */
  38612. getClassName(): string;
  38613. /**
  38614. * Define the list of animation attached to the texture.
  38615. */
  38616. animations: import("babylonjs/Animations/animation").Animation[];
  38617. /**
  38618. * An event triggered when the texture is disposed.
  38619. */
  38620. onDisposeObservable: Observable<BaseTexture>;
  38621. private _onDisposeObserver;
  38622. /**
  38623. * Callback triggered when the texture has been disposed.
  38624. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38625. */
  38626. set onDispose(callback: () => void);
  38627. /**
  38628. * Define the current state of the loading sequence when in delayed load mode.
  38629. */
  38630. delayLoadState: number;
  38631. protected _scene: Nullable<Scene>;
  38632. protected _engine: Nullable<ThinEngine>;
  38633. /** @hidden */
  38634. _texture: Nullable<InternalTexture>;
  38635. private _uid;
  38636. /**
  38637. * Define if the texture is preventinga material to render or not.
  38638. * If not and the texture is not ready, the engine will use a default black texture instead.
  38639. */
  38640. get isBlocking(): boolean;
  38641. /**
  38642. * Instantiates a new BaseTexture.
  38643. * Base class of all the textures in babylon.
  38644. * It groups all the common properties the materials, post process, lights... might need
  38645. * in order to make a correct use of the texture.
  38646. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38647. */
  38648. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38649. /**
  38650. * Get the scene the texture belongs to.
  38651. * @returns the scene or null if undefined
  38652. */
  38653. getScene(): Nullable<Scene>;
  38654. /** @hidden */
  38655. protected _getEngine(): Nullable<ThinEngine>;
  38656. /**
  38657. * Checks if the texture has the same transform matrix than another texture
  38658. * @param texture texture to check against
  38659. * @returns true if the transforms are the same, else false
  38660. */
  38661. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38662. /**
  38663. * Get the texture transform matrix used to offset tile the texture for istance.
  38664. * @returns the transformation matrix
  38665. */
  38666. getTextureMatrix(): Matrix;
  38667. /**
  38668. * Get the texture reflection matrix used to rotate/transform the reflection.
  38669. * @returns the reflection matrix
  38670. */
  38671. getReflectionTextureMatrix(): Matrix;
  38672. /**
  38673. * Get the underlying lower level texture from Babylon.
  38674. * @returns the insternal texture
  38675. */
  38676. getInternalTexture(): Nullable<InternalTexture>;
  38677. /**
  38678. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38679. * @returns true if ready or not blocking
  38680. */
  38681. isReadyOrNotBlocking(): boolean;
  38682. /**
  38683. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38684. * @returns true if fully ready
  38685. */
  38686. isReady(): boolean;
  38687. private _cachedSize;
  38688. /**
  38689. * Get the size of the texture.
  38690. * @returns the texture size.
  38691. */
  38692. getSize(): ISize;
  38693. /**
  38694. * Get the base size of the texture.
  38695. * It can be different from the size if the texture has been resized for POT for instance
  38696. * @returns the base size
  38697. */
  38698. getBaseSize(): ISize;
  38699. /**
  38700. * Update the sampling mode of the texture.
  38701. * Default is Trilinear mode.
  38702. *
  38703. * | Value | Type | Description |
  38704. * | ----- | ------------------ | ----------- |
  38705. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38706. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38707. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38708. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38709. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38710. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38711. * | 7 | NEAREST_LINEAR | |
  38712. * | 8 | NEAREST_NEAREST | |
  38713. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38714. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38715. * | 11 | LINEAR_LINEAR | |
  38716. * | 12 | LINEAR_NEAREST | |
  38717. *
  38718. * > _mag_: magnification filter (close to the viewer)
  38719. * > _min_: minification filter (far from the viewer)
  38720. * > _mip_: filter used between mip map levels
  38721. *@param samplingMode Define the new sampling mode of the texture
  38722. */
  38723. updateSamplingMode(samplingMode: number): void;
  38724. /**
  38725. * Scales the texture if is `canRescale()`
  38726. * @param ratio the resize factor we want to use to rescale
  38727. */
  38728. scale(ratio: number): void;
  38729. /**
  38730. * Get if the texture can rescale.
  38731. */
  38732. get canRescale(): boolean;
  38733. /** @hidden */
  38734. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38735. /** @hidden */
  38736. _rebuild(): void;
  38737. /**
  38738. * Triggers the load sequence in delayed load mode.
  38739. */
  38740. delayLoad(): void;
  38741. /**
  38742. * Clones the texture.
  38743. * @returns the cloned texture
  38744. */
  38745. clone(): Nullable<BaseTexture>;
  38746. /**
  38747. * Get the texture underlying type (INT, FLOAT...)
  38748. */
  38749. get textureType(): number;
  38750. /**
  38751. * Get the texture underlying format (RGB, RGBA...)
  38752. */
  38753. get textureFormat(): number;
  38754. /**
  38755. * Indicates that textures need to be re-calculated for all materials
  38756. */
  38757. protected _markAllSubMeshesAsTexturesDirty(): void;
  38758. /**
  38759. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38760. * This will returns an RGBA array buffer containing either in values (0-255) or
  38761. * float values (0-1) depending of the underlying buffer type.
  38762. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38763. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38764. * @param buffer defines a user defined buffer to fill with data (can be null)
  38765. * @returns The Array buffer containing the pixels data.
  38766. */
  38767. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38768. /**
  38769. * Release and destroy the underlying lower level texture aka internalTexture.
  38770. */
  38771. releaseInternalTexture(): void;
  38772. /** @hidden */
  38773. get _lodTextureHigh(): Nullable<BaseTexture>;
  38774. /** @hidden */
  38775. get _lodTextureMid(): Nullable<BaseTexture>;
  38776. /** @hidden */
  38777. get _lodTextureLow(): Nullable<BaseTexture>;
  38778. /**
  38779. * Dispose the texture and release its associated resources.
  38780. */
  38781. dispose(): void;
  38782. /**
  38783. * Serialize the texture into a JSON representation that can be parsed later on.
  38784. * @returns the JSON representation of the texture
  38785. */
  38786. serialize(): any;
  38787. /**
  38788. * Helper function to be called back once a list of texture contains only ready textures.
  38789. * @param textures Define the list of textures to wait for
  38790. * @param callback Define the callback triggered once the entire list will be ready
  38791. */
  38792. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38793. private static _isScene;
  38794. }
  38795. }
  38796. declare module "babylonjs/Materials/effect" {
  38797. import { Observable } from "babylonjs/Misc/observable";
  38798. import { Nullable } from "babylonjs/types";
  38799. import { IDisposable } from "babylonjs/scene";
  38800. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38801. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38802. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38803. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38804. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38805. import { Engine } from "babylonjs/Engines/engine";
  38806. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38809. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38810. /**
  38811. * Options to be used when creating an effect.
  38812. */
  38813. export interface IEffectCreationOptions {
  38814. /**
  38815. * Atrributes that will be used in the shader.
  38816. */
  38817. attributes: string[];
  38818. /**
  38819. * Uniform varible names that will be set in the shader.
  38820. */
  38821. uniformsNames: string[];
  38822. /**
  38823. * Uniform buffer variable names that will be set in the shader.
  38824. */
  38825. uniformBuffersNames: string[];
  38826. /**
  38827. * Sampler texture variable names that will be set in the shader.
  38828. */
  38829. samplers: string[];
  38830. /**
  38831. * Define statements that will be set in the shader.
  38832. */
  38833. defines: any;
  38834. /**
  38835. * Possible fallbacks for this effect to improve performance when needed.
  38836. */
  38837. fallbacks: Nullable<IEffectFallbacks>;
  38838. /**
  38839. * Callback that will be called when the shader is compiled.
  38840. */
  38841. onCompiled: Nullable<(effect: Effect) => void>;
  38842. /**
  38843. * Callback that will be called if an error occurs during shader compilation.
  38844. */
  38845. onError: Nullable<(effect: Effect, errors: string) => void>;
  38846. /**
  38847. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38848. */
  38849. indexParameters?: any;
  38850. /**
  38851. * Max number of lights that can be used in the shader.
  38852. */
  38853. maxSimultaneousLights?: number;
  38854. /**
  38855. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38856. */
  38857. transformFeedbackVaryings?: Nullable<string[]>;
  38858. /**
  38859. * 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
  38860. */
  38861. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38862. /**
  38863. * Is this effect rendering to several color attachments ?
  38864. */
  38865. multiTarget?: boolean;
  38866. }
  38867. /**
  38868. * Effect containing vertex and fragment shader that can be executed on an object.
  38869. */
  38870. export class Effect implements IDisposable {
  38871. /**
  38872. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38873. */
  38874. static ShadersRepository: string;
  38875. /**
  38876. * Enable logging of the shader code when a compilation error occurs
  38877. */
  38878. static LogShaderCodeOnCompilationError: boolean;
  38879. /**
  38880. * Name of the effect.
  38881. */
  38882. name: any;
  38883. /**
  38884. * String container all the define statements that should be set on the shader.
  38885. */
  38886. defines: string;
  38887. /**
  38888. * Callback that will be called when the shader is compiled.
  38889. */
  38890. onCompiled: Nullable<(effect: Effect) => void>;
  38891. /**
  38892. * Callback that will be called if an error occurs during shader compilation.
  38893. */
  38894. onError: Nullable<(effect: Effect, errors: string) => void>;
  38895. /**
  38896. * Callback that will be called when effect is bound.
  38897. */
  38898. onBind: Nullable<(effect: Effect) => void>;
  38899. /**
  38900. * Unique ID of the effect.
  38901. */
  38902. uniqueId: number;
  38903. /**
  38904. * Observable that will be called when the shader is compiled.
  38905. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38906. */
  38907. onCompileObservable: Observable<Effect>;
  38908. /**
  38909. * Observable that will be called if an error occurs during shader compilation.
  38910. */
  38911. onErrorObservable: Observable<Effect>;
  38912. /** @hidden */
  38913. _onBindObservable: Nullable<Observable<Effect>>;
  38914. /**
  38915. * @hidden
  38916. * Specifies if the effect was previously ready
  38917. */
  38918. _wasPreviouslyReady: boolean;
  38919. /**
  38920. * Observable that will be called when effect is bound.
  38921. */
  38922. get onBindObservable(): Observable<Effect>;
  38923. /** @hidden */
  38924. _bonesComputationForcedToCPU: boolean;
  38925. /** @hidden */
  38926. _multiTarget: boolean;
  38927. private static _uniqueIdSeed;
  38928. private _engine;
  38929. private _uniformBuffersNames;
  38930. private _uniformBuffersNamesList;
  38931. private _uniformsNames;
  38932. private _samplerList;
  38933. private _samplers;
  38934. private _isReady;
  38935. private _compilationError;
  38936. private _allFallbacksProcessed;
  38937. private _attributesNames;
  38938. private _attributes;
  38939. private _attributeLocationByName;
  38940. private _uniforms;
  38941. /**
  38942. * Key for the effect.
  38943. * @hidden
  38944. */
  38945. _key: string;
  38946. private _indexParameters;
  38947. private _fallbacks;
  38948. private _vertexSourceCode;
  38949. private _fragmentSourceCode;
  38950. private _vertexSourceCodeOverride;
  38951. private _fragmentSourceCodeOverride;
  38952. private _transformFeedbackVaryings;
  38953. /**
  38954. * Compiled shader to webGL program.
  38955. * @hidden
  38956. */
  38957. _pipelineContext: Nullable<IPipelineContext>;
  38958. private _valueCache;
  38959. private static _baseCache;
  38960. /**
  38961. * Instantiates an effect.
  38962. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38963. * @param baseName Name of the effect.
  38964. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38965. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38966. * @param samplers List of sampler variables that will be passed to the shader.
  38967. * @param engine Engine to be used to render the effect
  38968. * @param defines Define statements to be added to the shader.
  38969. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38970. * @param onCompiled Callback that will be called when the shader is compiled.
  38971. * @param onError Callback that will be called if an error occurs during shader compilation.
  38972. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38973. */
  38974. 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);
  38975. private _useFinalCode;
  38976. /**
  38977. * Unique key for this effect
  38978. */
  38979. get key(): string;
  38980. /**
  38981. * If the effect has been compiled and prepared.
  38982. * @returns if the effect is compiled and prepared.
  38983. */
  38984. isReady(): boolean;
  38985. private _isReadyInternal;
  38986. /**
  38987. * The engine the effect was initialized with.
  38988. * @returns the engine.
  38989. */
  38990. getEngine(): Engine;
  38991. /**
  38992. * The pipeline context for this effect
  38993. * @returns the associated pipeline context
  38994. */
  38995. getPipelineContext(): Nullable<IPipelineContext>;
  38996. /**
  38997. * The set of names of attribute variables for the shader.
  38998. * @returns An array of attribute names.
  38999. */
  39000. getAttributesNames(): string[];
  39001. /**
  39002. * Returns the attribute at the given index.
  39003. * @param index The index of the attribute.
  39004. * @returns The location of the attribute.
  39005. */
  39006. getAttributeLocation(index: number): number;
  39007. /**
  39008. * Returns the attribute based on the name of the variable.
  39009. * @param name of the attribute to look up.
  39010. * @returns the attribute location.
  39011. */
  39012. getAttributeLocationByName(name: string): number;
  39013. /**
  39014. * The number of attributes.
  39015. * @returns the numnber of attributes.
  39016. */
  39017. getAttributesCount(): number;
  39018. /**
  39019. * Gets the index of a uniform variable.
  39020. * @param uniformName of the uniform to look up.
  39021. * @returns the index.
  39022. */
  39023. getUniformIndex(uniformName: string): number;
  39024. /**
  39025. * Returns the attribute based on the name of the variable.
  39026. * @param uniformName of the uniform to look up.
  39027. * @returns the location of the uniform.
  39028. */
  39029. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39030. /**
  39031. * Returns an array of sampler variable names
  39032. * @returns The array of sampler variable names.
  39033. */
  39034. getSamplers(): string[];
  39035. /**
  39036. * Returns an array of uniform variable names
  39037. * @returns The array of uniform variable names.
  39038. */
  39039. getUniformNames(): string[];
  39040. /**
  39041. * Returns an array of uniform buffer variable names
  39042. * @returns The array of uniform buffer variable names.
  39043. */
  39044. getUniformBuffersNames(): string[];
  39045. /**
  39046. * Returns the index parameters used to create the effect
  39047. * @returns The index parameters object
  39048. */
  39049. getIndexParameters(): any;
  39050. /**
  39051. * The error from the last compilation.
  39052. * @returns the error string.
  39053. */
  39054. getCompilationError(): string;
  39055. /**
  39056. * Gets a boolean indicating that all fallbacks were used during compilation
  39057. * @returns true if all fallbacks were used
  39058. */
  39059. allFallbacksProcessed(): boolean;
  39060. /**
  39061. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39062. * @param func The callback to be used.
  39063. */
  39064. executeWhenCompiled(func: (effect: Effect) => void): void;
  39065. private _checkIsReady;
  39066. private _loadShader;
  39067. /**
  39068. * Gets the vertex shader source code of this effect
  39069. */
  39070. get vertexSourceCode(): string;
  39071. /**
  39072. * Gets the fragment shader source code of this effect
  39073. */
  39074. get fragmentSourceCode(): string;
  39075. /**
  39076. * Recompiles the webGL program
  39077. * @param vertexSourceCode The source code for the vertex shader.
  39078. * @param fragmentSourceCode The source code for the fragment shader.
  39079. * @param onCompiled Callback called when completed.
  39080. * @param onError Callback called on error.
  39081. * @hidden
  39082. */
  39083. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39084. /**
  39085. * Prepares the effect
  39086. * @hidden
  39087. */
  39088. _prepareEffect(): void;
  39089. private _getShaderCodeAndErrorLine;
  39090. private _processCompilationErrors;
  39091. /**
  39092. * Checks if the effect is supported. (Must be called after compilation)
  39093. */
  39094. get isSupported(): boolean;
  39095. /**
  39096. * Binds a texture to the engine to be used as output of the shader.
  39097. * @param channel Name of the output variable.
  39098. * @param texture Texture to bind.
  39099. * @hidden
  39100. */
  39101. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39102. /**
  39103. * Sets a texture on the engine to be used in the shader.
  39104. * @param channel Name of the sampler variable.
  39105. * @param texture Texture to set.
  39106. */
  39107. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39108. /**
  39109. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39110. * @param channel Name of the sampler variable.
  39111. * @param texture Texture to set.
  39112. */
  39113. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39114. /**
  39115. * Sets an array of textures on the engine to be used in the shader.
  39116. * @param channel Name of the variable.
  39117. * @param textures Textures to set.
  39118. */
  39119. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39120. /**
  39121. * 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)
  39122. * @param channel Name of the sampler variable.
  39123. * @param postProcess Post process to get the input texture from.
  39124. */
  39125. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39126. /**
  39127. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39128. * 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)
  39129. * @param channel Name of the sampler variable.
  39130. * @param postProcess Post process to get the output texture from.
  39131. */
  39132. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39133. /** @hidden */
  39134. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39135. /** @hidden */
  39136. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39137. /** @hidden */
  39138. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39139. /** @hidden */
  39140. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39141. /**
  39142. * Binds a buffer to a uniform.
  39143. * @param buffer Buffer to bind.
  39144. * @param name Name of the uniform variable to bind to.
  39145. */
  39146. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39147. /**
  39148. * Binds block to a uniform.
  39149. * @param blockName Name of the block to bind.
  39150. * @param index Index to bind.
  39151. */
  39152. bindUniformBlock(blockName: string, index: number): void;
  39153. /**
  39154. * Sets an interger value on a uniform variable.
  39155. * @param uniformName Name of the variable.
  39156. * @param value Value to be set.
  39157. * @returns this effect.
  39158. */
  39159. setInt(uniformName: string, value: number): Effect;
  39160. /**
  39161. * Sets an int array on a uniform variable.
  39162. * @param uniformName Name of the variable.
  39163. * @param array array to be set.
  39164. * @returns this effect.
  39165. */
  39166. setIntArray(uniformName: string, array: Int32Array): Effect;
  39167. /**
  39168. * 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)
  39169. * @param uniformName Name of the variable.
  39170. * @param array array to be set.
  39171. * @returns this effect.
  39172. */
  39173. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39174. /**
  39175. * 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)
  39176. * @param uniformName Name of the variable.
  39177. * @param array array to be set.
  39178. * @returns this effect.
  39179. */
  39180. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39181. /**
  39182. * 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)
  39183. * @param uniformName Name of the variable.
  39184. * @param array array to be set.
  39185. * @returns this effect.
  39186. */
  39187. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39188. /**
  39189. * Sets an float array on a uniform variable.
  39190. * @param uniformName Name of the variable.
  39191. * @param array array to be set.
  39192. * @returns this effect.
  39193. */
  39194. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39195. /**
  39196. * 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)
  39197. * @param uniformName Name of the variable.
  39198. * @param array array to be set.
  39199. * @returns this effect.
  39200. */
  39201. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39202. /**
  39203. * 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)
  39204. * @param uniformName Name of the variable.
  39205. * @param array array to be set.
  39206. * @returns this effect.
  39207. */
  39208. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39209. /**
  39210. * 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)
  39211. * @param uniformName Name of the variable.
  39212. * @param array array to be set.
  39213. * @returns this effect.
  39214. */
  39215. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39216. /**
  39217. * Sets an array on a uniform variable.
  39218. * @param uniformName Name of the variable.
  39219. * @param array array to be set.
  39220. * @returns this effect.
  39221. */
  39222. setArray(uniformName: string, array: number[]): Effect;
  39223. /**
  39224. * 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)
  39225. * @param uniformName Name of the variable.
  39226. * @param array array to be set.
  39227. * @returns this effect.
  39228. */
  39229. setArray2(uniformName: string, array: number[]): Effect;
  39230. /**
  39231. * 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)
  39232. * @param uniformName Name of the variable.
  39233. * @param array array to be set.
  39234. * @returns this effect.
  39235. */
  39236. setArray3(uniformName: string, array: number[]): Effect;
  39237. /**
  39238. * 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)
  39239. * @param uniformName Name of the variable.
  39240. * @param array array to be set.
  39241. * @returns this effect.
  39242. */
  39243. setArray4(uniformName: string, array: number[]): Effect;
  39244. /**
  39245. * Sets matrices on a uniform variable.
  39246. * @param uniformName Name of the variable.
  39247. * @param matrices matrices to be set.
  39248. * @returns this effect.
  39249. */
  39250. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39251. /**
  39252. * Sets matrix on a uniform variable.
  39253. * @param uniformName Name of the variable.
  39254. * @param matrix matrix to be set.
  39255. * @returns this effect.
  39256. */
  39257. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39258. /**
  39259. * 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)
  39260. * @param uniformName Name of the variable.
  39261. * @param matrix matrix to be set.
  39262. * @returns this effect.
  39263. */
  39264. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39265. /**
  39266. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39267. * @param uniformName Name of the variable.
  39268. * @param matrix matrix to be set.
  39269. * @returns this effect.
  39270. */
  39271. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39272. /**
  39273. * Sets a float on a uniform variable.
  39274. * @param uniformName Name of the variable.
  39275. * @param value value to be set.
  39276. * @returns this effect.
  39277. */
  39278. setFloat(uniformName: string, value: number): Effect;
  39279. /**
  39280. * Sets a boolean on a uniform variable.
  39281. * @param uniformName Name of the variable.
  39282. * @param bool value to be set.
  39283. * @returns this effect.
  39284. */
  39285. setBool(uniformName: string, bool: boolean): Effect;
  39286. /**
  39287. * Sets a Vector2 on a uniform variable.
  39288. * @param uniformName Name of the variable.
  39289. * @param vector2 vector2 to be set.
  39290. * @returns this effect.
  39291. */
  39292. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39293. /**
  39294. * Sets a float2 on a uniform variable.
  39295. * @param uniformName Name of the variable.
  39296. * @param x First float in float2.
  39297. * @param y Second float in float2.
  39298. * @returns this effect.
  39299. */
  39300. setFloat2(uniformName: string, x: number, y: number): Effect;
  39301. /**
  39302. * Sets a Vector3 on a uniform variable.
  39303. * @param uniformName Name of the variable.
  39304. * @param vector3 Value to be set.
  39305. * @returns this effect.
  39306. */
  39307. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39308. /**
  39309. * Sets a float3 on a uniform variable.
  39310. * @param uniformName Name of the variable.
  39311. * @param x First float in float3.
  39312. * @param y Second float in float3.
  39313. * @param z Third float in float3.
  39314. * @returns this effect.
  39315. */
  39316. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39317. /**
  39318. * Sets a Vector4 on a uniform variable.
  39319. * @param uniformName Name of the variable.
  39320. * @param vector4 Value to be set.
  39321. * @returns this effect.
  39322. */
  39323. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39324. /**
  39325. * Sets a float4 on a uniform variable.
  39326. * @param uniformName Name of the variable.
  39327. * @param x First float in float4.
  39328. * @param y Second float in float4.
  39329. * @param z Third float in float4.
  39330. * @param w Fourth float in float4.
  39331. * @returns this effect.
  39332. */
  39333. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39334. /**
  39335. * Sets a Color3 on a uniform variable.
  39336. * @param uniformName Name of the variable.
  39337. * @param color3 Value to be set.
  39338. * @returns this effect.
  39339. */
  39340. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39341. /**
  39342. * Sets a Color4 on a uniform variable.
  39343. * @param uniformName Name of the variable.
  39344. * @param color3 Value to be set.
  39345. * @param alpha Alpha value to be set.
  39346. * @returns this effect.
  39347. */
  39348. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39349. /**
  39350. * Sets a Color4 on a uniform variable
  39351. * @param uniformName defines the name of the variable
  39352. * @param color4 defines the value to be set
  39353. * @returns this effect.
  39354. */
  39355. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39356. /** Release all associated resources */
  39357. dispose(): void;
  39358. /**
  39359. * This function will add a new shader to the shader store
  39360. * @param name the name of the shader
  39361. * @param pixelShader optional pixel shader content
  39362. * @param vertexShader optional vertex shader content
  39363. */
  39364. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39365. /**
  39366. * Store of each shader (The can be looked up using effect.key)
  39367. */
  39368. static ShadersStore: {
  39369. [key: string]: string;
  39370. };
  39371. /**
  39372. * Store of each included file for a shader (The can be looked up using effect.key)
  39373. */
  39374. static IncludesShadersStore: {
  39375. [key: string]: string;
  39376. };
  39377. /**
  39378. * Resets the cache of effects.
  39379. */
  39380. static ResetCache(): void;
  39381. }
  39382. }
  39383. declare module "babylonjs/Engines/engineCapabilities" {
  39384. /**
  39385. * Interface used to describe the capabilities of the engine relatively to the current browser
  39386. */
  39387. export interface EngineCapabilities {
  39388. /** Maximum textures units per fragment shader */
  39389. maxTexturesImageUnits: number;
  39390. /** Maximum texture units per vertex shader */
  39391. maxVertexTextureImageUnits: number;
  39392. /** Maximum textures units in the entire pipeline */
  39393. maxCombinedTexturesImageUnits: number;
  39394. /** Maximum texture size */
  39395. maxTextureSize: number;
  39396. /** Maximum texture samples */
  39397. maxSamples?: number;
  39398. /** Maximum cube texture size */
  39399. maxCubemapTextureSize: number;
  39400. /** Maximum render texture size */
  39401. maxRenderTextureSize: number;
  39402. /** Maximum number of vertex attributes */
  39403. maxVertexAttribs: number;
  39404. /** Maximum number of varyings */
  39405. maxVaryingVectors: number;
  39406. /** Maximum number of uniforms per vertex shader */
  39407. maxVertexUniformVectors: number;
  39408. /** Maximum number of uniforms per fragment shader */
  39409. maxFragmentUniformVectors: number;
  39410. /** Defines if standard derivates (dx/dy) are supported */
  39411. standardDerivatives: boolean;
  39412. /** Defines if s3tc texture compression is supported */
  39413. s3tc?: WEBGL_compressed_texture_s3tc;
  39414. /** Defines if pvrtc texture compression is supported */
  39415. pvrtc: any;
  39416. /** Defines if etc1 texture compression is supported */
  39417. etc1: any;
  39418. /** Defines if etc2 texture compression is supported */
  39419. etc2: any;
  39420. /** Defines if astc texture compression is supported */
  39421. astc: any;
  39422. /** Defines if bptc texture compression is supported */
  39423. bptc: any;
  39424. /** Defines if float textures are supported */
  39425. textureFloat: boolean;
  39426. /** Defines if vertex array objects are supported */
  39427. vertexArrayObject: boolean;
  39428. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39429. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39430. /** Gets the maximum level of anisotropy supported */
  39431. maxAnisotropy: number;
  39432. /** Defines if instancing is supported */
  39433. instancedArrays: boolean;
  39434. /** Defines if 32 bits indices are supported */
  39435. uintIndices: boolean;
  39436. /** Defines if high precision shaders are supported */
  39437. highPrecisionShaderSupported: boolean;
  39438. /** Defines if depth reading in the fragment shader is supported */
  39439. fragmentDepthSupported: boolean;
  39440. /** Defines if float texture linear filtering is supported*/
  39441. textureFloatLinearFiltering: boolean;
  39442. /** Defines if rendering to float textures is supported */
  39443. textureFloatRender: boolean;
  39444. /** Defines if half float textures are supported*/
  39445. textureHalfFloat: boolean;
  39446. /** Defines if half float texture linear filtering is supported*/
  39447. textureHalfFloatLinearFiltering: boolean;
  39448. /** Defines if rendering to half float textures is supported */
  39449. textureHalfFloatRender: boolean;
  39450. /** Defines if textureLOD shader command is supported */
  39451. textureLOD: boolean;
  39452. /** Defines if draw buffers extension is supported */
  39453. drawBuffersExtension: boolean;
  39454. /** Defines if depth textures are supported */
  39455. depthTextureExtension: boolean;
  39456. /** Defines if float color buffer are supported */
  39457. colorBufferFloat: boolean;
  39458. /** Gets disjoint timer query extension (null if not supported) */
  39459. timerQuery?: EXT_disjoint_timer_query;
  39460. /** Defines if timestamp can be used with timer query */
  39461. canUseTimestampForTimerQuery: boolean;
  39462. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39463. multiview?: any;
  39464. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39465. oculusMultiview?: any;
  39466. /** Function used to let the system compiles shaders in background */
  39467. parallelShaderCompile?: {
  39468. COMPLETION_STATUS_KHR: number;
  39469. };
  39470. /** Max number of texture samples for MSAA */
  39471. maxMSAASamples: number;
  39472. /** Defines if the blend min max extension is supported */
  39473. blendMinMax: boolean;
  39474. }
  39475. }
  39476. declare module "babylonjs/States/depthCullingState" {
  39477. import { Nullable } from "babylonjs/types";
  39478. /**
  39479. * @hidden
  39480. **/
  39481. export class DepthCullingState {
  39482. private _isDepthTestDirty;
  39483. private _isDepthMaskDirty;
  39484. private _isDepthFuncDirty;
  39485. private _isCullFaceDirty;
  39486. private _isCullDirty;
  39487. private _isZOffsetDirty;
  39488. private _isFrontFaceDirty;
  39489. private _depthTest;
  39490. private _depthMask;
  39491. private _depthFunc;
  39492. private _cull;
  39493. private _cullFace;
  39494. private _zOffset;
  39495. private _frontFace;
  39496. /**
  39497. * Initializes the state.
  39498. */
  39499. constructor();
  39500. get isDirty(): boolean;
  39501. get zOffset(): number;
  39502. set zOffset(value: number);
  39503. get cullFace(): Nullable<number>;
  39504. set cullFace(value: Nullable<number>);
  39505. get cull(): Nullable<boolean>;
  39506. set cull(value: Nullable<boolean>);
  39507. get depthFunc(): Nullable<number>;
  39508. set depthFunc(value: Nullable<number>);
  39509. get depthMask(): boolean;
  39510. set depthMask(value: boolean);
  39511. get depthTest(): boolean;
  39512. set depthTest(value: boolean);
  39513. get frontFace(): Nullable<number>;
  39514. set frontFace(value: Nullable<number>);
  39515. reset(): void;
  39516. apply(gl: WebGLRenderingContext): void;
  39517. }
  39518. }
  39519. declare module "babylonjs/States/stencilState" {
  39520. /**
  39521. * @hidden
  39522. **/
  39523. export class StencilState {
  39524. /** 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 */
  39525. static readonly ALWAYS: number;
  39526. /** Passed to stencilOperation to specify that stencil value must be kept */
  39527. static readonly KEEP: number;
  39528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39529. static readonly REPLACE: number;
  39530. private _isStencilTestDirty;
  39531. private _isStencilMaskDirty;
  39532. private _isStencilFuncDirty;
  39533. private _isStencilOpDirty;
  39534. private _stencilTest;
  39535. private _stencilMask;
  39536. private _stencilFunc;
  39537. private _stencilFuncRef;
  39538. private _stencilFuncMask;
  39539. private _stencilOpStencilFail;
  39540. private _stencilOpDepthFail;
  39541. private _stencilOpStencilDepthPass;
  39542. get isDirty(): boolean;
  39543. get stencilFunc(): number;
  39544. set stencilFunc(value: number);
  39545. get stencilFuncRef(): number;
  39546. set stencilFuncRef(value: number);
  39547. get stencilFuncMask(): number;
  39548. set stencilFuncMask(value: number);
  39549. get stencilOpStencilFail(): number;
  39550. set stencilOpStencilFail(value: number);
  39551. get stencilOpDepthFail(): number;
  39552. set stencilOpDepthFail(value: number);
  39553. get stencilOpStencilDepthPass(): number;
  39554. set stencilOpStencilDepthPass(value: number);
  39555. get stencilMask(): number;
  39556. set stencilMask(value: number);
  39557. get stencilTest(): boolean;
  39558. set stencilTest(value: boolean);
  39559. constructor();
  39560. reset(): void;
  39561. apply(gl: WebGLRenderingContext): void;
  39562. }
  39563. }
  39564. declare module "babylonjs/States/alphaCullingState" {
  39565. /**
  39566. * @hidden
  39567. **/
  39568. export class AlphaState {
  39569. private _isAlphaBlendDirty;
  39570. private _isBlendFunctionParametersDirty;
  39571. private _isBlendEquationParametersDirty;
  39572. private _isBlendConstantsDirty;
  39573. private _alphaBlend;
  39574. private _blendFunctionParameters;
  39575. private _blendEquationParameters;
  39576. private _blendConstants;
  39577. /**
  39578. * Initializes the state.
  39579. */
  39580. constructor();
  39581. get isDirty(): boolean;
  39582. get alphaBlend(): boolean;
  39583. set alphaBlend(value: boolean);
  39584. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39585. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39586. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39587. reset(): void;
  39588. apply(gl: WebGLRenderingContext): void;
  39589. }
  39590. }
  39591. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39592. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39593. /** @hidden */
  39594. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39595. attributeProcessor(attribute: string): string;
  39596. varyingProcessor(varying: string, isFragment: boolean): string;
  39597. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39598. }
  39599. }
  39600. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39601. /**
  39602. * Interface for attribute information associated with buffer instanciation
  39603. */
  39604. export interface InstancingAttributeInfo {
  39605. /**
  39606. * Name of the GLSL attribute
  39607. * if attribute index is not specified, this is used to retrieve the index from the effect
  39608. */
  39609. attributeName: string;
  39610. /**
  39611. * Index/offset of the attribute in the vertex shader
  39612. * if not specified, this will be computes from the name.
  39613. */
  39614. index?: number;
  39615. /**
  39616. * size of the attribute, 1, 2, 3 or 4
  39617. */
  39618. attributeSize: number;
  39619. /**
  39620. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39621. */
  39622. offset: number;
  39623. /**
  39624. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39625. * default to 1
  39626. */
  39627. divisor?: number;
  39628. /**
  39629. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39630. * default is FLOAT
  39631. */
  39632. attributeType?: number;
  39633. /**
  39634. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39635. */
  39636. normalized?: boolean;
  39637. }
  39638. }
  39639. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39640. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39641. import { Nullable } from "babylonjs/types";
  39642. module "babylonjs/Engines/thinEngine" {
  39643. interface ThinEngine {
  39644. /**
  39645. * Update a video texture
  39646. * @param texture defines the texture to update
  39647. * @param video defines the video element to use
  39648. * @param invertY defines if data must be stored with Y axis inverted
  39649. */
  39650. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39651. }
  39652. }
  39653. }
  39654. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39655. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39656. import { Nullable } from "babylonjs/types";
  39657. module "babylonjs/Engines/thinEngine" {
  39658. interface ThinEngine {
  39659. /**
  39660. * Creates a dynamic texture
  39661. * @param width defines the width of the texture
  39662. * @param height defines the height of the texture
  39663. * @param generateMipMaps defines if the engine should generate the mip levels
  39664. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39665. * @returns the dynamic texture inside an InternalTexture
  39666. */
  39667. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39668. /**
  39669. * Update the content of a dynamic texture
  39670. * @param texture defines the texture to update
  39671. * @param canvas defines the canvas containing the source
  39672. * @param invertY defines if data must be stored with Y axis inverted
  39673. * @param premulAlpha defines if alpha is stored as premultiplied
  39674. * @param format defines the format of the data
  39675. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39676. */
  39677. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39678. }
  39679. }
  39680. }
  39681. declare module "babylonjs/Materials/Textures/videoTexture" {
  39682. import { Observable } from "babylonjs/Misc/observable";
  39683. import { Nullable } from "babylonjs/types";
  39684. import { Scene } from "babylonjs/scene";
  39685. import { Texture } from "babylonjs/Materials/Textures/texture";
  39686. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39687. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39688. /**
  39689. * Settings for finer control over video usage
  39690. */
  39691. export interface VideoTextureSettings {
  39692. /**
  39693. * Applies `autoplay` to video, if specified
  39694. */
  39695. autoPlay?: boolean;
  39696. /**
  39697. * Applies `muted` to video, if specified
  39698. */
  39699. muted?: boolean;
  39700. /**
  39701. * Applies `loop` to video, if specified
  39702. */
  39703. loop?: boolean;
  39704. /**
  39705. * Automatically updates internal texture from video at every frame in the render loop
  39706. */
  39707. autoUpdateTexture: boolean;
  39708. /**
  39709. * Image src displayed during the video loading or until the user interacts with the video.
  39710. */
  39711. poster?: string;
  39712. }
  39713. /**
  39714. * If you want to display a video in your scene, this is the special texture for that.
  39715. * This special texture works similar to other textures, with the exception of a few parameters.
  39716. * @see https://doc.babylonjs.com/how_to/video_texture
  39717. */
  39718. export class VideoTexture extends Texture {
  39719. /**
  39720. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39721. */
  39722. readonly autoUpdateTexture: boolean;
  39723. /**
  39724. * The video instance used by the texture internally
  39725. */
  39726. readonly video: HTMLVideoElement;
  39727. private _onUserActionRequestedObservable;
  39728. /**
  39729. * Event triggerd when a dom action is required by the user to play the video.
  39730. * This happens due to recent changes in browser policies preventing video to auto start.
  39731. */
  39732. get onUserActionRequestedObservable(): Observable<Texture>;
  39733. private _generateMipMaps;
  39734. private _stillImageCaptured;
  39735. private _displayingPosterTexture;
  39736. private _settings;
  39737. private _createInternalTextureOnEvent;
  39738. private _frameId;
  39739. private _currentSrc;
  39740. /**
  39741. * Creates a video texture.
  39742. * If you want to display a video in your scene, this is the special texture for that.
  39743. * This special texture works similar to other textures, with the exception of a few parameters.
  39744. * @see https://doc.babylonjs.com/how_to/video_texture
  39745. * @param name optional name, will detect from video source, if not defined
  39746. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39747. * @param scene is obviously the current scene.
  39748. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39749. * @param invertY is false by default but can be used to invert video on Y axis
  39750. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39751. * @param settings allows finer control over video usage
  39752. */
  39753. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39754. private _getName;
  39755. private _getVideo;
  39756. private _createInternalTexture;
  39757. private reset;
  39758. /**
  39759. * @hidden Internal method to initiate `update`.
  39760. */
  39761. _rebuild(): void;
  39762. /**
  39763. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39764. */
  39765. update(): void;
  39766. /**
  39767. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39768. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39769. */
  39770. updateTexture(isVisible: boolean): void;
  39771. protected _updateInternalTexture: () => void;
  39772. /**
  39773. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39774. * @param url New url.
  39775. */
  39776. updateURL(url: string): void;
  39777. /**
  39778. * Clones the texture.
  39779. * @returns the cloned texture
  39780. */
  39781. clone(): VideoTexture;
  39782. /**
  39783. * Dispose the texture and release its associated resources.
  39784. */
  39785. dispose(): void;
  39786. /**
  39787. * Creates a video texture straight from a stream.
  39788. * @param scene Define the scene the texture should be created in
  39789. * @param stream Define the stream the texture should be created from
  39790. * @returns The created video texture as a promise
  39791. */
  39792. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39793. /**
  39794. * Creates a video texture straight from your WebCam video feed.
  39795. * @param scene Define the scene the texture should be created in
  39796. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39797. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39798. * @returns The created video texture as a promise
  39799. */
  39800. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39801. minWidth: number;
  39802. maxWidth: number;
  39803. minHeight: number;
  39804. maxHeight: number;
  39805. deviceId: string;
  39806. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39807. /**
  39808. * Creates a video texture straight from your WebCam video feed.
  39809. * @param scene Define the scene the texture should be created in
  39810. * @param onReady Define a callback to triggered once the texture will be ready
  39811. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39812. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39813. */
  39814. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39815. minWidth: number;
  39816. maxWidth: number;
  39817. minHeight: number;
  39818. maxHeight: number;
  39819. deviceId: string;
  39820. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39821. }
  39822. }
  39823. declare module "babylonjs/Engines/thinEngine" {
  39824. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39825. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39826. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39827. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39828. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39829. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39830. import { Observable } from "babylonjs/Misc/observable";
  39831. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39832. import { StencilState } from "babylonjs/States/stencilState";
  39833. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39835. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39836. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39837. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39838. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39839. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39840. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39841. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39843. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39844. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39845. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39846. import { WebRequest } from "babylonjs/Misc/webRequest";
  39847. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39848. /**
  39849. * Defines the interface used by objects working like Scene
  39850. * @hidden
  39851. */
  39852. export interface ISceneLike {
  39853. _addPendingData(data: any): void;
  39854. _removePendingData(data: any): void;
  39855. offlineProvider: IOfflineProvider;
  39856. }
  39857. /**
  39858. * Information about the current host
  39859. */
  39860. export interface HostInformation {
  39861. /**
  39862. * Defines if the current host is a mobile
  39863. */
  39864. isMobile: boolean;
  39865. }
  39866. /** Interface defining initialization parameters for Engine class */
  39867. export interface EngineOptions extends WebGLContextAttributes {
  39868. /**
  39869. * Defines if the engine should no exceed a specified device ratio
  39870. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39871. */
  39872. limitDeviceRatio?: number;
  39873. /**
  39874. * Defines if webvr should be enabled automatically
  39875. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39876. */
  39877. autoEnableWebVR?: boolean;
  39878. /**
  39879. * Defines if webgl2 should be turned off even if supported
  39880. * @see https://doc.babylonjs.com/features/webgl2
  39881. */
  39882. disableWebGL2Support?: boolean;
  39883. /**
  39884. * Defines if webaudio should be initialized as well
  39885. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39886. */
  39887. audioEngine?: boolean;
  39888. /**
  39889. * Defines if animations should run using a deterministic lock step
  39890. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39891. */
  39892. deterministicLockstep?: boolean;
  39893. /** Defines the maximum steps to use with deterministic lock step mode */
  39894. lockstepMaxSteps?: number;
  39895. /** Defines the seconds between each deterministic lock step */
  39896. timeStep?: number;
  39897. /**
  39898. * Defines that engine should ignore context lost events
  39899. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39900. */
  39901. doNotHandleContextLost?: boolean;
  39902. /**
  39903. * Defines that engine should ignore modifying touch action attribute and style
  39904. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39905. */
  39906. doNotHandleTouchAction?: boolean;
  39907. /**
  39908. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39909. */
  39910. useHighPrecisionFloats?: boolean;
  39911. /**
  39912. * Make the canvas XR Compatible for XR sessions
  39913. */
  39914. xrCompatible?: boolean;
  39915. /**
  39916. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39917. */
  39918. useHighPrecisionMatrix?: boolean;
  39919. /**
  39920. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39921. */
  39922. failIfMajorPerformanceCaveat?: boolean;
  39923. }
  39924. /**
  39925. * The base engine class (root of all engines)
  39926. */
  39927. export class ThinEngine {
  39928. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39929. static ExceptionList: ({
  39930. key: string;
  39931. capture: string;
  39932. captureConstraint: number;
  39933. targets: string[];
  39934. } | {
  39935. key: string;
  39936. capture: null;
  39937. captureConstraint: null;
  39938. targets: string[];
  39939. })[];
  39940. /** @hidden */
  39941. static _TextureLoaders: IInternalTextureLoader[];
  39942. /**
  39943. * Returns the current npm package of the sdk
  39944. */
  39945. static get NpmPackage(): string;
  39946. /**
  39947. * Returns the current version of the framework
  39948. */
  39949. static get Version(): string;
  39950. /**
  39951. * Returns a string describing the current engine
  39952. */
  39953. get description(): string;
  39954. /**
  39955. * Gets or sets the epsilon value used by collision engine
  39956. */
  39957. static CollisionsEpsilon: number;
  39958. /**
  39959. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39960. */
  39961. static get ShadersRepository(): string;
  39962. static set ShadersRepository(value: string);
  39963. /** @hidden */
  39964. _shaderProcessor: IShaderProcessor;
  39965. /**
  39966. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39967. */
  39968. forcePOTTextures: boolean;
  39969. /**
  39970. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39971. */
  39972. isFullscreen: boolean;
  39973. /**
  39974. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39975. */
  39976. cullBackFaces: boolean;
  39977. /**
  39978. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39979. */
  39980. renderEvenInBackground: boolean;
  39981. /**
  39982. * Gets or sets a boolean indicating that cache can be kept between frames
  39983. */
  39984. preventCacheWipeBetweenFrames: boolean;
  39985. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39986. validateShaderPrograms: boolean;
  39987. /**
  39988. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39989. * This can provide greater z depth for distant objects.
  39990. */
  39991. useReverseDepthBuffer: boolean;
  39992. /**
  39993. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39994. */
  39995. disableUniformBuffers: boolean;
  39996. /** @hidden */
  39997. _uniformBuffers: UniformBuffer[];
  39998. /**
  39999. * Gets a boolean indicating that the engine supports uniform buffers
  40000. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40001. */
  40002. get supportsUniformBuffers(): boolean;
  40003. /** @hidden */
  40004. _gl: WebGLRenderingContext;
  40005. /** @hidden */
  40006. _webGLVersion: number;
  40007. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40008. protected _windowIsBackground: boolean;
  40009. protected _creationOptions: EngineOptions;
  40010. protected _highPrecisionShadersAllowed: boolean;
  40011. /** @hidden */
  40012. get _shouldUseHighPrecisionShader(): boolean;
  40013. /**
  40014. * Gets a boolean indicating that only power of 2 textures are supported
  40015. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40016. */
  40017. get needPOTTextures(): boolean;
  40018. /** @hidden */
  40019. _badOS: boolean;
  40020. /** @hidden */
  40021. _badDesktopOS: boolean;
  40022. private _hardwareScalingLevel;
  40023. /** @hidden */
  40024. _caps: EngineCapabilities;
  40025. private _isStencilEnable;
  40026. private _glVersion;
  40027. private _glRenderer;
  40028. private _glVendor;
  40029. /** @hidden */
  40030. _videoTextureSupported: boolean;
  40031. protected _renderingQueueLaunched: boolean;
  40032. protected _activeRenderLoops: (() => void)[];
  40033. /**
  40034. * Observable signaled when a context lost event is raised
  40035. */
  40036. onContextLostObservable: Observable<ThinEngine>;
  40037. /**
  40038. * Observable signaled when a context restored event is raised
  40039. */
  40040. onContextRestoredObservable: Observable<ThinEngine>;
  40041. private _onContextLost;
  40042. private _onContextRestored;
  40043. protected _contextWasLost: boolean;
  40044. /** @hidden */
  40045. _doNotHandleContextLost: boolean;
  40046. /**
  40047. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40048. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40049. */
  40050. get doNotHandleContextLost(): boolean;
  40051. set doNotHandleContextLost(value: boolean);
  40052. /**
  40053. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40054. */
  40055. disableVertexArrayObjects: boolean;
  40056. /** @hidden */
  40057. protected _colorWrite: boolean;
  40058. /** @hidden */
  40059. protected _colorWriteChanged: boolean;
  40060. /** @hidden */
  40061. protected _depthCullingState: DepthCullingState;
  40062. /** @hidden */
  40063. protected _stencilState: StencilState;
  40064. /** @hidden */
  40065. _alphaState: AlphaState;
  40066. /** @hidden */
  40067. _alphaMode: number;
  40068. /** @hidden */
  40069. _alphaEquation: number;
  40070. /** @hidden */
  40071. _internalTexturesCache: InternalTexture[];
  40072. /** @hidden */
  40073. protected _activeChannel: number;
  40074. private _currentTextureChannel;
  40075. /** @hidden */
  40076. protected _boundTexturesCache: {
  40077. [key: string]: Nullable<InternalTexture>;
  40078. };
  40079. /** @hidden */
  40080. protected _currentEffect: Nullable<Effect>;
  40081. /** @hidden */
  40082. protected _currentProgram: Nullable<WebGLProgram>;
  40083. private _compiledEffects;
  40084. private _vertexAttribArraysEnabled;
  40085. /** @hidden */
  40086. protected _cachedViewport: Nullable<IViewportLike>;
  40087. private _cachedVertexArrayObject;
  40088. /** @hidden */
  40089. protected _cachedVertexBuffers: any;
  40090. /** @hidden */
  40091. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40092. /** @hidden */
  40093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40094. /** @hidden */
  40095. _currentRenderTarget: Nullable<InternalTexture>;
  40096. private _uintIndicesCurrentlySet;
  40097. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40098. /** @hidden */
  40099. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40100. /** @hidden */
  40101. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40102. private _currentBufferPointers;
  40103. private _currentInstanceLocations;
  40104. private _currentInstanceBuffers;
  40105. private _textureUnits;
  40106. /** @hidden */
  40107. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40108. /** @hidden */
  40109. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40110. /** @hidden */
  40111. _boundRenderFunction: any;
  40112. private _vaoRecordInProgress;
  40113. private _mustWipeVertexAttributes;
  40114. private _emptyTexture;
  40115. private _emptyCubeTexture;
  40116. private _emptyTexture3D;
  40117. private _emptyTexture2DArray;
  40118. /** @hidden */
  40119. _frameHandler: number;
  40120. private _nextFreeTextureSlots;
  40121. private _maxSimultaneousTextures;
  40122. private _activeRequests;
  40123. /** @hidden */
  40124. _transformTextureUrl: Nullable<(url: string) => string>;
  40125. /**
  40126. * Gets information about the current host
  40127. */
  40128. hostInformation: HostInformation;
  40129. protected get _supportsHardwareTextureRescaling(): boolean;
  40130. private _framebufferDimensionsObject;
  40131. /**
  40132. * sets the object from which width and height will be taken from when getting render width and height
  40133. * Will fallback to the gl object
  40134. * @param dimensions the framebuffer width and height that will be used.
  40135. */
  40136. set framebufferDimensionsObject(dimensions: Nullable<{
  40137. framebufferWidth: number;
  40138. framebufferHeight: number;
  40139. }>);
  40140. /**
  40141. * Gets the current viewport
  40142. */
  40143. get currentViewport(): Nullable<IViewportLike>;
  40144. /**
  40145. * Gets the default empty texture
  40146. */
  40147. get emptyTexture(): InternalTexture;
  40148. /**
  40149. * Gets the default empty 3D texture
  40150. */
  40151. get emptyTexture3D(): InternalTexture;
  40152. /**
  40153. * Gets the default empty 2D array texture
  40154. */
  40155. get emptyTexture2DArray(): InternalTexture;
  40156. /**
  40157. * Gets the default empty cube texture
  40158. */
  40159. get emptyCubeTexture(): InternalTexture;
  40160. /**
  40161. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40162. */
  40163. readonly premultipliedAlpha: boolean;
  40164. /**
  40165. * Observable event triggered before each texture is initialized
  40166. */
  40167. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40168. /**
  40169. * Creates a new engine
  40170. * @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
  40171. * @param antialias defines enable antialiasing (default: false)
  40172. * @param options defines further options to be sent to the getContext() function
  40173. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40174. */
  40175. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40176. private _rebuildInternalTextures;
  40177. private _rebuildEffects;
  40178. /**
  40179. * Gets a boolean indicating if all created effects are ready
  40180. * @returns true if all effects are ready
  40181. */
  40182. areAllEffectsReady(): boolean;
  40183. protected _rebuildBuffers(): void;
  40184. protected _initGLContext(): void;
  40185. /**
  40186. * Gets version of the current webGL context
  40187. */
  40188. get webGLVersion(): number;
  40189. /**
  40190. * Gets a string identifying the name of the class
  40191. * @returns "Engine" string
  40192. */
  40193. getClassName(): string;
  40194. /**
  40195. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40196. */
  40197. get isStencilEnable(): boolean;
  40198. /** @hidden */
  40199. _prepareWorkingCanvas(): void;
  40200. /**
  40201. * Reset the texture cache to empty state
  40202. */
  40203. resetTextureCache(): void;
  40204. /**
  40205. * Gets an object containing information about the current webGL context
  40206. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40207. */
  40208. getGlInfo(): {
  40209. vendor: string;
  40210. renderer: string;
  40211. version: string;
  40212. };
  40213. /**
  40214. * Defines the hardware scaling level.
  40215. * By default the hardware scaling level is computed from the window device ratio.
  40216. * 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.
  40217. * @param level defines the level to use
  40218. */
  40219. setHardwareScalingLevel(level: number): void;
  40220. /**
  40221. * Gets the current hardware scaling level.
  40222. * By default the hardware scaling level is computed from the window device ratio.
  40223. * 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.
  40224. * @returns a number indicating the current hardware scaling level
  40225. */
  40226. getHardwareScalingLevel(): number;
  40227. /**
  40228. * Gets the list of loaded textures
  40229. * @returns an array containing all loaded textures
  40230. */
  40231. getLoadedTexturesCache(): InternalTexture[];
  40232. /**
  40233. * Gets the object containing all engine capabilities
  40234. * @returns the EngineCapabilities object
  40235. */
  40236. getCaps(): EngineCapabilities;
  40237. /**
  40238. * stop executing a render loop function and remove it from the execution array
  40239. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40240. */
  40241. stopRenderLoop(renderFunction?: () => void): void;
  40242. /** @hidden */
  40243. _renderLoop(): void;
  40244. /**
  40245. * Gets the HTML canvas attached with the current webGL context
  40246. * @returns a HTML canvas
  40247. */
  40248. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40249. /**
  40250. * Gets host window
  40251. * @returns the host window object
  40252. */
  40253. getHostWindow(): Nullable<Window>;
  40254. /**
  40255. * Gets the current render width
  40256. * @param useScreen defines if screen size must be used (or the current render target if any)
  40257. * @returns a number defining the current render width
  40258. */
  40259. getRenderWidth(useScreen?: boolean): number;
  40260. /**
  40261. * Gets the current render height
  40262. * @param useScreen defines if screen size must be used (or the current render target if any)
  40263. * @returns a number defining the current render height
  40264. */
  40265. getRenderHeight(useScreen?: boolean): number;
  40266. /**
  40267. * Can be used to override the current requestAnimationFrame requester.
  40268. * @hidden
  40269. */
  40270. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40271. /**
  40272. * Register and execute a render loop. The engine can have more than one render function
  40273. * @param renderFunction defines the function to continuously execute
  40274. */
  40275. runRenderLoop(renderFunction: () => void): void;
  40276. /**
  40277. * Clear the current render buffer or the current render target (if any is set up)
  40278. * @param color defines the color to use
  40279. * @param backBuffer defines if the back buffer must be cleared
  40280. * @param depth defines if the depth buffer must be cleared
  40281. * @param stencil defines if the stencil buffer must be cleared
  40282. */
  40283. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40284. private _viewportCached;
  40285. /** @hidden */
  40286. _viewport(x: number, y: number, width: number, height: number): void;
  40287. /**
  40288. * Set the WebGL's viewport
  40289. * @param viewport defines the viewport element to be used
  40290. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40291. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40292. */
  40293. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40294. /**
  40295. * Begin a new frame
  40296. */
  40297. beginFrame(): void;
  40298. /**
  40299. * Enf the current frame
  40300. */
  40301. endFrame(): void;
  40302. /**
  40303. * Resize the view according to the canvas' size
  40304. */
  40305. resize(): void;
  40306. /**
  40307. * Force a specific size of the canvas
  40308. * @param width defines the new canvas' width
  40309. * @param height defines the new canvas' height
  40310. * @returns true if the size was changed
  40311. */
  40312. setSize(width: number, height: number): boolean;
  40313. /**
  40314. * Binds the frame buffer to the specified texture.
  40315. * @param texture The texture to render to or null for the default canvas
  40316. * @param faceIndex The face of the texture to render to in case of cube texture
  40317. * @param requiredWidth The width of the target to render to
  40318. * @param requiredHeight The height of the target to render to
  40319. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40320. * @param lodLevel defines the lod level to bind to the frame buffer
  40321. * @param layer defines the 2d array index to bind to frame buffer to
  40322. */
  40323. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40324. /** @hidden */
  40325. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40326. /**
  40327. * Unbind the current render target texture from the webGL context
  40328. * @param texture defines the render target texture to unbind
  40329. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40330. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40331. */
  40332. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40333. /**
  40334. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40335. */
  40336. flushFramebuffer(): void;
  40337. /**
  40338. * Unbind the current render target and bind the default framebuffer
  40339. */
  40340. restoreDefaultFramebuffer(): void;
  40341. /** @hidden */
  40342. protected _resetVertexBufferBinding(): void;
  40343. /**
  40344. * Creates a vertex buffer
  40345. * @param data the data for the vertex buffer
  40346. * @returns the new WebGL static buffer
  40347. */
  40348. createVertexBuffer(data: DataArray): DataBuffer;
  40349. private _createVertexBuffer;
  40350. /**
  40351. * Creates a dynamic vertex buffer
  40352. * @param data the data for the dynamic vertex buffer
  40353. * @returns the new WebGL dynamic buffer
  40354. */
  40355. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40356. protected _resetIndexBufferBinding(): void;
  40357. /**
  40358. * Creates a new index buffer
  40359. * @param indices defines the content of the index buffer
  40360. * @param updatable defines if the index buffer must be updatable
  40361. * @returns a new webGL buffer
  40362. */
  40363. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40364. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40365. /**
  40366. * Bind a webGL buffer to the webGL context
  40367. * @param buffer defines the buffer to bind
  40368. */
  40369. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40370. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40371. private bindBuffer;
  40372. /**
  40373. * update the bound buffer with the given data
  40374. * @param data defines the data to update
  40375. */
  40376. updateArrayBuffer(data: Float32Array): void;
  40377. private _vertexAttribPointer;
  40378. /** @hidden */
  40379. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40380. private _bindVertexBuffersAttributes;
  40381. /**
  40382. * Records a vertex array object
  40383. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40384. * @param vertexBuffers defines the list of vertex buffers to store
  40385. * @param indexBuffer defines the index buffer to store
  40386. * @param effect defines the effect to store
  40387. * @returns the new vertex array object
  40388. */
  40389. recordVertexArrayObject(vertexBuffers: {
  40390. [key: string]: VertexBuffer;
  40391. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40392. /**
  40393. * Bind a specific vertex array object
  40394. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40395. * @param vertexArrayObject defines the vertex array object to bind
  40396. * @param indexBuffer defines the index buffer to bind
  40397. */
  40398. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40399. /**
  40400. * Bind webGl buffers directly to the webGL context
  40401. * @param vertexBuffer defines the vertex buffer to bind
  40402. * @param indexBuffer defines the index buffer to bind
  40403. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40404. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40405. * @param effect defines the effect associated with the vertex buffer
  40406. */
  40407. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40408. private _unbindVertexArrayObject;
  40409. /**
  40410. * Bind a list of vertex buffers to the webGL context
  40411. * @param vertexBuffers defines the list of vertex buffers to bind
  40412. * @param indexBuffer defines the index buffer to bind
  40413. * @param effect defines the effect associated with the vertex buffers
  40414. */
  40415. bindBuffers(vertexBuffers: {
  40416. [key: string]: Nullable<VertexBuffer>;
  40417. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40418. /**
  40419. * Unbind all instance attributes
  40420. */
  40421. unbindInstanceAttributes(): void;
  40422. /**
  40423. * Release and free the memory of a vertex array object
  40424. * @param vao defines the vertex array object to delete
  40425. */
  40426. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40427. /** @hidden */
  40428. _releaseBuffer(buffer: DataBuffer): boolean;
  40429. protected _deleteBuffer(buffer: DataBuffer): void;
  40430. /**
  40431. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40432. * @param instancesBuffer defines the webGL buffer to update and bind
  40433. * @param data defines the data to store in the buffer
  40434. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40435. */
  40436. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40437. /**
  40438. * Bind the content of a webGL buffer used with instantiation
  40439. * @param instancesBuffer defines the webGL buffer to bind
  40440. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40441. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40442. */
  40443. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40444. /**
  40445. * Disable the instance attribute corresponding to the name in parameter
  40446. * @param name defines the name of the attribute to disable
  40447. */
  40448. disableInstanceAttributeByName(name: string): void;
  40449. /**
  40450. * Disable the instance attribute corresponding to the location in parameter
  40451. * @param attributeLocation defines the attribute location of the attribute to disable
  40452. */
  40453. disableInstanceAttribute(attributeLocation: number): void;
  40454. /**
  40455. * Disable the attribute corresponding to the location in parameter
  40456. * @param attributeLocation defines the attribute location of the attribute to disable
  40457. */
  40458. disableAttributeByIndex(attributeLocation: number): void;
  40459. /**
  40460. * Send a draw order
  40461. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40462. * @param indexStart defines the starting index
  40463. * @param indexCount defines the number of index to draw
  40464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40465. */
  40466. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40467. /**
  40468. * Draw a list of points
  40469. * @param verticesStart defines the index of first vertex to draw
  40470. * @param verticesCount defines the count of vertices to draw
  40471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40472. */
  40473. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40474. /**
  40475. * Draw a list of unindexed primitives
  40476. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40477. * @param verticesStart defines the index of first vertex to draw
  40478. * @param verticesCount defines the count of vertices to draw
  40479. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40480. */
  40481. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40482. /**
  40483. * Draw a list of indexed primitives
  40484. * @param fillMode defines the primitive to use
  40485. * @param indexStart defines the starting index
  40486. * @param indexCount defines the number of index to draw
  40487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40488. */
  40489. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40490. /**
  40491. * Draw a list of unindexed primitives
  40492. * @param fillMode defines the primitive to use
  40493. * @param verticesStart defines the index of first vertex to draw
  40494. * @param verticesCount defines the count of vertices to draw
  40495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40496. */
  40497. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40498. private _drawMode;
  40499. /** @hidden */
  40500. protected _reportDrawCall(): void;
  40501. /** @hidden */
  40502. _releaseEffect(effect: Effect): void;
  40503. /** @hidden */
  40504. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40505. /**
  40506. * Create a new effect (used to store vertex/fragment shaders)
  40507. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40508. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40509. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40510. * @param samplers defines an array of string used to represent textures
  40511. * @param defines defines the string containing the defines to use to compile the shaders
  40512. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40513. * @param onCompiled defines a function to call when the effect creation is successful
  40514. * @param onError defines a function to call when the effect creation has failed
  40515. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40516. * @returns the new Effect
  40517. */
  40518. 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;
  40519. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40520. private _compileShader;
  40521. private _compileRawShader;
  40522. /** @hidden */
  40523. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40524. /**
  40525. * Directly creates a webGL program
  40526. * @param pipelineContext defines the pipeline context to attach to
  40527. * @param vertexCode defines the vertex shader code to use
  40528. * @param fragmentCode defines the fragment shader code to use
  40529. * @param context defines the webGL context to use (if not set, the current one will be used)
  40530. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40531. * @returns the new webGL program
  40532. */
  40533. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40534. /**
  40535. * Creates a webGL program
  40536. * @param pipelineContext defines the pipeline context to attach to
  40537. * @param vertexCode defines the vertex shader code to use
  40538. * @param fragmentCode defines the fragment shader code to use
  40539. * @param defines defines the string containing the defines to use to compile the shaders
  40540. * @param context defines the webGL context to use (if not set, the current one will be used)
  40541. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40542. * @returns the new webGL program
  40543. */
  40544. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40545. /**
  40546. * Creates a new pipeline context
  40547. * @returns the new pipeline
  40548. */
  40549. createPipelineContext(): IPipelineContext;
  40550. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40551. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40552. /** @hidden */
  40553. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40554. /** @hidden */
  40555. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40556. /** @hidden */
  40557. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40558. /**
  40559. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40560. * @param pipelineContext defines the pipeline context to use
  40561. * @param uniformsNames defines the list of uniform names
  40562. * @returns an array of webGL uniform locations
  40563. */
  40564. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40565. /**
  40566. * Gets the lsit of active attributes for a given webGL program
  40567. * @param pipelineContext defines the pipeline context to use
  40568. * @param attributesNames defines the list of attribute names to get
  40569. * @returns an array of indices indicating the offset of each attribute
  40570. */
  40571. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40572. /**
  40573. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40574. * @param effect defines the effect to activate
  40575. */
  40576. enableEffect(effect: Nullable<Effect>): void;
  40577. /**
  40578. * Set the value of an uniform to a number (int)
  40579. * @param uniform defines the webGL uniform location where to store the value
  40580. * @param value defines the int number to store
  40581. * @returns true if the value was set
  40582. */
  40583. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40584. /**
  40585. * Set the value of an uniform to an array of int32
  40586. * @param uniform defines the webGL uniform location where to store the value
  40587. * @param array defines the array of int32 to store
  40588. * @returns true if the value was set
  40589. */
  40590. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40591. /**
  40592. * Set the value of an uniform to an array of int32 (stored as vec2)
  40593. * @param uniform defines the webGL uniform location where to store the value
  40594. * @param array defines the array of int32 to store
  40595. * @returns true if the value was set
  40596. */
  40597. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40598. /**
  40599. * Set the value of an uniform to an array of int32 (stored as vec3)
  40600. * @param uniform defines the webGL uniform location where to store the value
  40601. * @param array defines the array of int32 to store
  40602. * @returns true if the value was set
  40603. */
  40604. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40605. /**
  40606. * Set the value of an uniform to an array of int32 (stored as vec4)
  40607. * @param uniform defines the webGL uniform location where to store the value
  40608. * @param array defines the array of int32 to store
  40609. * @returns true if the value was set
  40610. */
  40611. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40612. /**
  40613. * Set the value of an uniform to an array of number
  40614. * @param uniform defines the webGL uniform location where to store the value
  40615. * @param array defines the array of number to store
  40616. * @returns true if the value was set
  40617. */
  40618. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40619. /**
  40620. * Set the value of an uniform to an array of number (stored as vec2)
  40621. * @param uniform defines the webGL uniform location where to store the value
  40622. * @param array defines the array of number to store
  40623. * @returns true if the value was set
  40624. */
  40625. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40626. /**
  40627. * Set the value of an uniform to an array of number (stored as vec3)
  40628. * @param uniform defines the webGL uniform location where to store the value
  40629. * @param array defines the array of number to store
  40630. * @returns true if the value was set
  40631. */
  40632. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40633. /**
  40634. * Set the value of an uniform to an array of number (stored as vec4)
  40635. * @param uniform defines the webGL uniform location where to store the value
  40636. * @param array defines the array of number to store
  40637. * @returns true if the value was set
  40638. */
  40639. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40640. /**
  40641. * Set the value of an uniform to an array of float32 (stored as matrices)
  40642. * @param uniform defines the webGL uniform location where to store the value
  40643. * @param matrices defines the array of float32 to store
  40644. * @returns true if the value was set
  40645. */
  40646. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40647. /**
  40648. * Set the value of an uniform to a matrix (3x3)
  40649. * @param uniform defines the webGL uniform location where to store the value
  40650. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40651. * @returns true if the value was set
  40652. */
  40653. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40654. /**
  40655. * Set the value of an uniform to a matrix (2x2)
  40656. * @param uniform defines the webGL uniform location where to store the value
  40657. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40658. * @returns true if the value was set
  40659. */
  40660. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40661. /**
  40662. * Set the value of an uniform to a number (float)
  40663. * @param uniform defines the webGL uniform location where to store the value
  40664. * @param value defines the float number to store
  40665. * @returns true if the value was transfered
  40666. */
  40667. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40668. /**
  40669. * Set the value of an uniform to a vec2
  40670. * @param uniform defines the webGL uniform location where to store the value
  40671. * @param x defines the 1st component of the value
  40672. * @param y defines the 2nd component of the value
  40673. * @returns true if the value was set
  40674. */
  40675. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40676. /**
  40677. * Set the value of an uniform to a vec3
  40678. * @param uniform defines the webGL uniform location where to store the value
  40679. * @param x defines the 1st component of the value
  40680. * @param y defines the 2nd component of the value
  40681. * @param z defines the 3rd component of the value
  40682. * @returns true if the value was set
  40683. */
  40684. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40685. /**
  40686. * Set the value of an uniform to a vec4
  40687. * @param uniform defines the webGL uniform location where to store the value
  40688. * @param x defines the 1st component of the value
  40689. * @param y defines the 2nd component of the value
  40690. * @param z defines the 3rd component of the value
  40691. * @param w defines the 4th component of the value
  40692. * @returns true if the value was set
  40693. */
  40694. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40695. /**
  40696. * Apply all cached states (depth, culling, stencil and alpha)
  40697. */
  40698. applyStates(): void;
  40699. /**
  40700. * Enable or disable color writing
  40701. * @param enable defines the state to set
  40702. */
  40703. setColorWrite(enable: boolean): void;
  40704. /**
  40705. * Gets a boolean indicating if color writing is enabled
  40706. * @returns the current color writing state
  40707. */
  40708. getColorWrite(): boolean;
  40709. /**
  40710. * Gets the depth culling state manager
  40711. */
  40712. get depthCullingState(): DepthCullingState;
  40713. /**
  40714. * Gets the alpha state manager
  40715. */
  40716. get alphaState(): AlphaState;
  40717. /**
  40718. * Gets the stencil state manager
  40719. */
  40720. get stencilState(): StencilState;
  40721. /**
  40722. * Clears the list of texture accessible through engine.
  40723. * This can help preventing texture load conflict due to name collision.
  40724. */
  40725. clearInternalTexturesCache(): void;
  40726. /**
  40727. * Force the entire cache to be cleared
  40728. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40729. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40730. */
  40731. wipeCaches(bruteForce?: boolean): void;
  40732. /** @hidden */
  40733. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40734. min: number;
  40735. mag: number;
  40736. };
  40737. /** @hidden */
  40738. _createTexture(): WebGLTexture;
  40739. /**
  40740. * Usually called from Texture.ts.
  40741. * Passed information to create a WebGLTexture
  40742. * @param url defines a value which contains one of the following:
  40743. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40744. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40745. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40746. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40747. * @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)
  40748. * @param scene needed for loading to the correct scene
  40749. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40750. * @param onLoad optional callback to be called upon successful completion
  40751. * @param onError optional callback to be called upon failure
  40752. * @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
  40753. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40754. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40755. * @param forcedExtension defines the extension to use to pick the right loader
  40756. * @param mimeType defines an optional mime type
  40757. * @param loaderOptions options to be passed to the loader
  40758. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40759. */
  40760. 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, loaderOptions?: any): InternalTexture;
  40761. /**
  40762. * Loads an image as an HTMLImageElement.
  40763. * @param input url string, ArrayBuffer, or Blob to load
  40764. * @param onLoad callback called when the image successfully loads
  40765. * @param onError callback called when the image fails to load
  40766. * @param offlineProvider offline provider for caching
  40767. * @param mimeType optional mime type
  40768. * @returns the HTMLImageElement of the loaded image
  40769. * @hidden
  40770. */
  40771. 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>;
  40772. /**
  40773. * @hidden
  40774. */
  40775. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40776. private _unpackFlipYCached;
  40777. /**
  40778. * In case you are sharing the context with other applications, it might
  40779. * be interested to not cache the unpack flip y state to ensure a consistent
  40780. * value would be set.
  40781. */
  40782. enableUnpackFlipYCached: boolean;
  40783. /** @hidden */
  40784. _unpackFlipY(value: boolean): void;
  40785. /** @hidden */
  40786. _getUnpackAlignement(): number;
  40787. private _getTextureTarget;
  40788. /**
  40789. * Update the sampling mode of a given texture
  40790. * @param samplingMode defines the required sampling mode
  40791. * @param texture defines the texture to update
  40792. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40793. */
  40794. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40795. /**
  40796. * Update the sampling mode of a given texture
  40797. * @param texture defines the texture to update
  40798. * @param wrapU defines the texture wrap mode of the u coordinates
  40799. * @param wrapV defines the texture wrap mode of the v coordinates
  40800. * @param wrapR defines the texture wrap mode of the r coordinates
  40801. */
  40802. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40803. /** @hidden */
  40804. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40805. width: number;
  40806. height: number;
  40807. layers?: number;
  40808. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40809. /** @hidden */
  40810. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40811. /** @hidden */
  40812. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40813. /**
  40814. * Update a portion of an internal texture
  40815. * @param texture defines the texture to update
  40816. * @param imageData defines the data to store into the texture
  40817. * @param xOffset defines the x coordinates of the update rectangle
  40818. * @param yOffset defines the y coordinates of the update rectangle
  40819. * @param width defines the width of the update rectangle
  40820. * @param height defines the height of the update rectangle
  40821. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40822. * @param lod defines the lod level to update (0 by default)
  40823. */
  40824. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40825. /** @hidden */
  40826. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40827. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40828. private _prepareWebGLTexture;
  40829. /** @hidden */
  40830. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40831. private _getDepthStencilBuffer;
  40832. /** @hidden */
  40833. _releaseFramebufferObjects(texture: InternalTexture): void;
  40834. /** @hidden */
  40835. _releaseTexture(texture: InternalTexture): void;
  40836. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40837. protected _setProgram(program: WebGLProgram): void;
  40838. protected _boundUniforms: {
  40839. [key: number]: WebGLUniformLocation;
  40840. };
  40841. /**
  40842. * Binds an effect to the webGL context
  40843. * @param effect defines the effect to bind
  40844. */
  40845. bindSamplers(effect: Effect): void;
  40846. private _activateCurrentTexture;
  40847. /** @hidden */
  40848. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40849. /** @hidden */
  40850. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40851. /**
  40852. * Unbind all textures from the webGL context
  40853. */
  40854. unbindAllTextures(): void;
  40855. /**
  40856. * Sets a texture to the according uniform.
  40857. * @param channel The texture channel
  40858. * @param uniform The uniform to set
  40859. * @param texture The texture to apply
  40860. */
  40861. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40862. private _bindSamplerUniformToChannel;
  40863. private _getTextureWrapMode;
  40864. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40865. /**
  40866. * Sets an array of texture to the webGL context
  40867. * @param channel defines the channel where the texture array must be set
  40868. * @param uniform defines the associated uniform location
  40869. * @param textures defines the array of textures to bind
  40870. */
  40871. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40872. /** @hidden */
  40873. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40874. private _setTextureParameterFloat;
  40875. private _setTextureParameterInteger;
  40876. /**
  40877. * Unbind all vertex attributes from the webGL context
  40878. */
  40879. unbindAllAttributes(): void;
  40880. /**
  40881. * 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
  40882. */
  40883. releaseEffects(): void;
  40884. /**
  40885. * Dispose and release all associated resources
  40886. */
  40887. dispose(): void;
  40888. /**
  40889. * Attach a new callback raised when context lost event is fired
  40890. * @param callback defines the callback to call
  40891. */
  40892. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40893. /**
  40894. * Attach a new callback raised when context restored event is fired
  40895. * @param callback defines the callback to call
  40896. */
  40897. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40898. /**
  40899. * Get the current error code of the webGL context
  40900. * @returns the error code
  40901. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40902. */
  40903. getError(): number;
  40904. private _canRenderToFloatFramebuffer;
  40905. private _canRenderToHalfFloatFramebuffer;
  40906. private _canRenderToFramebuffer;
  40907. /** @hidden */
  40908. _getWebGLTextureType(type: number): number;
  40909. /** @hidden */
  40910. _getInternalFormat(format: number): number;
  40911. /** @hidden */
  40912. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40913. /** @hidden */
  40914. _getRGBAMultiSampleBufferFormat(type: number): number;
  40915. /** @hidden */
  40916. _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;
  40917. /**
  40918. * Loads a file from a url
  40919. * @param url url to load
  40920. * @param onSuccess callback called when the file successfully loads
  40921. * @param onProgress callback called while file is loading (if the server supports this mode)
  40922. * @param offlineProvider defines the offline provider for caching
  40923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40924. * @param onError callback called when the file fails to load
  40925. * @returns a file request object
  40926. * @hidden
  40927. */
  40928. 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;
  40929. /**
  40930. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40931. * @param x defines the x coordinate of the rectangle where pixels must be read
  40932. * @param y defines the y coordinate of the rectangle where pixels must be read
  40933. * @param width defines the width of the rectangle where pixels must be read
  40934. * @param height defines the height of the rectangle where pixels must be read
  40935. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40936. * @returns a Uint8Array containing RGBA colors
  40937. */
  40938. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40939. private static _IsSupported;
  40940. private static _HasMajorPerformanceCaveat;
  40941. /**
  40942. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40943. */
  40944. static get IsSupported(): boolean;
  40945. /**
  40946. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40947. * @returns true if the engine can be created
  40948. * @ignorenaming
  40949. */
  40950. static isSupported(): boolean;
  40951. /**
  40952. * 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)
  40953. */
  40954. static get HasMajorPerformanceCaveat(): boolean;
  40955. /**
  40956. * Find the next highest power of two.
  40957. * @param x Number to start search from.
  40958. * @return Next highest power of two.
  40959. */
  40960. static CeilingPOT(x: number): number;
  40961. /**
  40962. * Find the next lowest power of two.
  40963. * @param x Number to start search from.
  40964. * @return Next lowest power of two.
  40965. */
  40966. static FloorPOT(x: number): number;
  40967. /**
  40968. * Find the nearest power of two.
  40969. * @param x Number to start search from.
  40970. * @return Next nearest power of two.
  40971. */
  40972. static NearestPOT(x: number): number;
  40973. /**
  40974. * Get the closest exponent of two
  40975. * @param value defines the value to approximate
  40976. * @param max defines the maximum value to return
  40977. * @param mode defines how to define the closest value
  40978. * @returns closest exponent of two of the given value
  40979. */
  40980. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40981. /**
  40982. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40983. * @param func - the function to be called
  40984. * @param requester - the object that will request the next frame. Falls back to window.
  40985. * @returns frame number
  40986. */
  40987. static QueueNewFrame(func: () => void, requester?: any): number;
  40988. /**
  40989. * Gets host document
  40990. * @returns the host document object
  40991. */
  40992. getHostDocument(): Nullable<Document>;
  40993. }
  40994. }
  40995. declare module "babylonjs/Materials/Textures/internalTexture" {
  40996. import { Observable } from "babylonjs/Misc/observable";
  40997. import { Nullable, int } from "babylonjs/types";
  40998. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41000. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41001. /**
  41002. * Defines the source of the internal texture
  41003. */
  41004. export enum InternalTextureSource {
  41005. /**
  41006. * The source of the texture data is unknown
  41007. */
  41008. Unknown = 0,
  41009. /**
  41010. * Texture data comes from an URL
  41011. */
  41012. Url = 1,
  41013. /**
  41014. * Texture data is only used for temporary storage
  41015. */
  41016. Temp = 2,
  41017. /**
  41018. * Texture data comes from raw data (ArrayBuffer)
  41019. */
  41020. Raw = 3,
  41021. /**
  41022. * Texture content is dynamic (video or dynamic texture)
  41023. */
  41024. Dynamic = 4,
  41025. /**
  41026. * Texture content is generated by rendering to it
  41027. */
  41028. RenderTarget = 5,
  41029. /**
  41030. * Texture content is part of a multi render target process
  41031. */
  41032. MultiRenderTarget = 6,
  41033. /**
  41034. * Texture data comes from a cube data file
  41035. */
  41036. Cube = 7,
  41037. /**
  41038. * Texture data comes from a raw cube data
  41039. */
  41040. CubeRaw = 8,
  41041. /**
  41042. * Texture data come from a prefiltered cube data file
  41043. */
  41044. CubePrefiltered = 9,
  41045. /**
  41046. * Texture content is raw 3D data
  41047. */
  41048. Raw3D = 10,
  41049. /**
  41050. * Texture content is raw 2D array data
  41051. */
  41052. Raw2DArray = 11,
  41053. /**
  41054. * Texture content is a depth texture
  41055. */
  41056. Depth = 12,
  41057. /**
  41058. * Texture data comes from a raw cube data encoded with RGBD
  41059. */
  41060. CubeRawRGBD = 13
  41061. }
  41062. /**
  41063. * Class used to store data associated with WebGL texture data for the engine
  41064. * This class should not be used directly
  41065. */
  41066. export class InternalTexture {
  41067. /** @hidden */
  41068. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41069. /**
  41070. * Defines if the texture is ready
  41071. */
  41072. isReady: boolean;
  41073. /**
  41074. * Defines if the texture is a cube texture
  41075. */
  41076. isCube: boolean;
  41077. /**
  41078. * Defines if the texture contains 3D data
  41079. */
  41080. is3D: boolean;
  41081. /**
  41082. * Defines if the texture contains 2D array data
  41083. */
  41084. is2DArray: boolean;
  41085. /**
  41086. * Defines if the texture contains multiview data
  41087. */
  41088. isMultiview: boolean;
  41089. /**
  41090. * Gets the URL used to load this texture
  41091. */
  41092. url: string;
  41093. /**
  41094. * Gets the sampling mode of the texture
  41095. */
  41096. samplingMode: number;
  41097. /**
  41098. * Gets a boolean indicating if the texture needs mipmaps generation
  41099. */
  41100. generateMipMaps: boolean;
  41101. /**
  41102. * Gets the number of samples used by the texture (WebGL2+ only)
  41103. */
  41104. samples: number;
  41105. /**
  41106. * Gets the type of the texture (int, float...)
  41107. */
  41108. type: number;
  41109. /**
  41110. * Gets the format of the texture (RGB, RGBA...)
  41111. */
  41112. format: number;
  41113. /**
  41114. * Observable called when the texture is loaded
  41115. */
  41116. onLoadedObservable: Observable<InternalTexture>;
  41117. /**
  41118. * Gets the width of the texture
  41119. */
  41120. width: number;
  41121. /**
  41122. * Gets the height of the texture
  41123. */
  41124. height: number;
  41125. /**
  41126. * Gets the depth of the texture
  41127. */
  41128. depth: number;
  41129. /**
  41130. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41131. */
  41132. baseWidth: number;
  41133. /**
  41134. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41135. */
  41136. baseHeight: number;
  41137. /**
  41138. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41139. */
  41140. baseDepth: number;
  41141. /**
  41142. * Gets a boolean indicating if the texture is inverted on Y axis
  41143. */
  41144. invertY: boolean;
  41145. /** @hidden */
  41146. _invertVScale: boolean;
  41147. /** @hidden */
  41148. _associatedChannel: number;
  41149. /** @hidden */
  41150. _source: InternalTextureSource;
  41151. /** @hidden */
  41152. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41153. /** @hidden */
  41154. _bufferView: Nullable<ArrayBufferView>;
  41155. /** @hidden */
  41156. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41157. /** @hidden */
  41158. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41159. /** @hidden */
  41160. _size: number;
  41161. /** @hidden */
  41162. _extension: string;
  41163. /** @hidden */
  41164. _files: Nullable<string[]>;
  41165. /** @hidden */
  41166. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41167. /** @hidden */
  41168. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41169. /** @hidden */
  41170. _framebuffer: Nullable<WebGLFramebuffer>;
  41171. /** @hidden */
  41172. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41173. /** @hidden */
  41174. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41175. /** @hidden */
  41176. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41177. /** @hidden */
  41178. _attachments: Nullable<number[]>;
  41179. /** @hidden */
  41180. _textureArray: Nullable<InternalTexture[]>;
  41181. /** @hidden */
  41182. _cachedCoordinatesMode: Nullable<number>;
  41183. /** @hidden */
  41184. _cachedWrapU: Nullable<number>;
  41185. /** @hidden */
  41186. _cachedWrapV: Nullable<number>;
  41187. /** @hidden */
  41188. _cachedWrapR: Nullable<number>;
  41189. /** @hidden */
  41190. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41191. /** @hidden */
  41192. _isDisabled: boolean;
  41193. /** @hidden */
  41194. _compression: Nullable<string>;
  41195. /** @hidden */
  41196. _generateStencilBuffer: boolean;
  41197. /** @hidden */
  41198. _generateDepthBuffer: boolean;
  41199. /** @hidden */
  41200. _comparisonFunction: number;
  41201. /** @hidden */
  41202. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41203. /** @hidden */
  41204. _lodGenerationScale: number;
  41205. /** @hidden */
  41206. _lodGenerationOffset: number;
  41207. /** @hidden */
  41208. _depthStencilTexture: Nullable<InternalTexture>;
  41209. /** @hidden */
  41210. _colorTextureArray: Nullable<WebGLTexture>;
  41211. /** @hidden */
  41212. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41213. /** @hidden */
  41214. _lodTextureHigh: Nullable<BaseTexture>;
  41215. /** @hidden */
  41216. _lodTextureMid: Nullable<BaseTexture>;
  41217. /** @hidden */
  41218. _lodTextureLow: Nullable<BaseTexture>;
  41219. /** @hidden */
  41220. _isRGBD: boolean;
  41221. /** @hidden */
  41222. _linearSpecularLOD: boolean;
  41223. /** @hidden */
  41224. _irradianceTexture: Nullable<BaseTexture>;
  41225. /** @hidden */
  41226. _webGLTexture: Nullable<WebGLTexture>;
  41227. /** @hidden */
  41228. _references: number;
  41229. /** @hidden */
  41230. _gammaSpace: Nullable<boolean>;
  41231. private _engine;
  41232. /**
  41233. * Gets the Engine the texture belongs to.
  41234. * @returns The babylon engine
  41235. */
  41236. getEngine(): ThinEngine;
  41237. /**
  41238. * Gets the data source type of the texture
  41239. */
  41240. get source(): InternalTextureSource;
  41241. /**
  41242. * Creates a new InternalTexture
  41243. * @param engine defines the engine to use
  41244. * @param source defines the type of data that will be used
  41245. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41246. */
  41247. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41248. /**
  41249. * Increments the number of references (ie. the number of Texture that point to it)
  41250. */
  41251. incrementReferences(): void;
  41252. /**
  41253. * Change the size of the texture (not the size of the content)
  41254. * @param width defines the new width
  41255. * @param height defines the new height
  41256. * @param depth defines the new depth (1 by default)
  41257. */
  41258. updateSize(width: int, height: int, depth?: int): void;
  41259. /** @hidden */
  41260. _rebuild(): void;
  41261. /** @hidden */
  41262. _swapAndDie(target: InternalTexture): void;
  41263. /**
  41264. * Dispose the current allocated resources
  41265. */
  41266. dispose(): void;
  41267. }
  41268. }
  41269. declare module "babylonjs/Audio/analyser" {
  41270. import { Scene } from "babylonjs/scene";
  41271. /**
  41272. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41274. */
  41275. export class Analyser {
  41276. /**
  41277. * Gets or sets the smoothing
  41278. * @ignorenaming
  41279. */
  41280. SMOOTHING: number;
  41281. /**
  41282. * Gets or sets the FFT table size
  41283. * @ignorenaming
  41284. */
  41285. FFT_SIZE: number;
  41286. /**
  41287. * Gets or sets the bar graph amplitude
  41288. * @ignorenaming
  41289. */
  41290. BARGRAPHAMPLITUDE: number;
  41291. /**
  41292. * Gets or sets the position of the debug canvas
  41293. * @ignorenaming
  41294. */
  41295. DEBUGCANVASPOS: {
  41296. x: number;
  41297. y: number;
  41298. };
  41299. /**
  41300. * Gets or sets the debug canvas size
  41301. * @ignorenaming
  41302. */
  41303. DEBUGCANVASSIZE: {
  41304. width: number;
  41305. height: number;
  41306. };
  41307. private _byteFreqs;
  41308. private _byteTime;
  41309. private _floatFreqs;
  41310. private _webAudioAnalyser;
  41311. private _debugCanvas;
  41312. private _debugCanvasContext;
  41313. private _scene;
  41314. private _registerFunc;
  41315. private _audioEngine;
  41316. /**
  41317. * Creates a new analyser
  41318. * @param scene defines hosting scene
  41319. */
  41320. constructor(scene: Scene);
  41321. /**
  41322. * Get the number of data values you will have to play with for the visualization
  41323. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41324. * @returns a number
  41325. */
  41326. getFrequencyBinCount(): number;
  41327. /**
  41328. * Gets the current frequency data as a byte array
  41329. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41330. * @returns a Uint8Array
  41331. */
  41332. getByteFrequencyData(): Uint8Array;
  41333. /**
  41334. * Gets the current waveform as a byte array
  41335. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41336. * @returns a Uint8Array
  41337. */
  41338. getByteTimeDomainData(): Uint8Array;
  41339. /**
  41340. * Gets the current frequency data as a float array
  41341. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41342. * @returns a Float32Array
  41343. */
  41344. getFloatFrequencyData(): Float32Array;
  41345. /**
  41346. * Renders the debug canvas
  41347. */
  41348. drawDebugCanvas(): void;
  41349. /**
  41350. * Stops rendering the debug canvas and removes it
  41351. */
  41352. stopDebugCanvas(): void;
  41353. /**
  41354. * Connects two audio nodes
  41355. * @param inputAudioNode defines first node to connect
  41356. * @param outputAudioNode defines second node to connect
  41357. */
  41358. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41359. /**
  41360. * Releases all associated resources
  41361. */
  41362. dispose(): void;
  41363. }
  41364. }
  41365. declare module "babylonjs/Audio/audioEngine" {
  41366. import { IDisposable } from "babylonjs/scene";
  41367. import { Analyser } from "babylonjs/Audio/analyser";
  41368. import { Nullable } from "babylonjs/types";
  41369. import { Observable } from "babylonjs/Misc/observable";
  41370. /**
  41371. * This represents an audio engine and it is responsible
  41372. * to play, synchronize and analyse sounds throughout the application.
  41373. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41374. */
  41375. export interface IAudioEngine extends IDisposable {
  41376. /**
  41377. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41378. */
  41379. readonly canUseWebAudio: boolean;
  41380. /**
  41381. * Gets the current AudioContext if available.
  41382. */
  41383. readonly audioContext: Nullable<AudioContext>;
  41384. /**
  41385. * The master gain node defines the global audio volume of your audio engine.
  41386. */
  41387. readonly masterGain: GainNode;
  41388. /**
  41389. * Gets whether or not mp3 are supported by your browser.
  41390. */
  41391. readonly isMP3supported: boolean;
  41392. /**
  41393. * Gets whether or not ogg are supported by your browser.
  41394. */
  41395. readonly isOGGsupported: boolean;
  41396. /**
  41397. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41398. * @ignoreNaming
  41399. */
  41400. WarnedWebAudioUnsupported: boolean;
  41401. /**
  41402. * Defines if the audio engine relies on a custom unlocked button.
  41403. * In this case, the embedded button will not be displayed.
  41404. */
  41405. useCustomUnlockedButton: boolean;
  41406. /**
  41407. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41408. */
  41409. readonly unlocked: boolean;
  41410. /**
  41411. * Event raised when audio has been unlocked on the browser.
  41412. */
  41413. onAudioUnlockedObservable: Observable<AudioEngine>;
  41414. /**
  41415. * Event raised when audio has been locked on the browser.
  41416. */
  41417. onAudioLockedObservable: Observable<AudioEngine>;
  41418. /**
  41419. * Flags the audio engine in Locked state.
  41420. * This happens due to new browser policies preventing audio to autoplay.
  41421. */
  41422. lock(): void;
  41423. /**
  41424. * Unlocks the audio engine once a user action has been done on the dom.
  41425. * This is helpful to resume play once browser policies have been satisfied.
  41426. */
  41427. unlock(): void;
  41428. /**
  41429. * Gets the global volume sets on the master gain.
  41430. * @returns the global volume if set or -1 otherwise
  41431. */
  41432. getGlobalVolume(): number;
  41433. /**
  41434. * Sets the global volume of your experience (sets on the master gain).
  41435. * @param newVolume Defines the new global volume of the application
  41436. */
  41437. setGlobalVolume(newVolume: number): void;
  41438. /**
  41439. * Connect the audio engine to an audio analyser allowing some amazing
  41440. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41441. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41442. * @param analyser The analyser to connect to the engine
  41443. */
  41444. connectToAnalyser(analyser: Analyser): void;
  41445. }
  41446. /**
  41447. * This represents the default audio engine used in babylon.
  41448. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41449. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41450. */
  41451. export class AudioEngine implements IAudioEngine {
  41452. private _audioContext;
  41453. private _audioContextInitialized;
  41454. private _muteButton;
  41455. private _hostElement;
  41456. /**
  41457. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41458. */
  41459. canUseWebAudio: boolean;
  41460. /**
  41461. * The master gain node defines the global audio volume of your audio engine.
  41462. */
  41463. masterGain: GainNode;
  41464. /**
  41465. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41466. * @ignoreNaming
  41467. */
  41468. WarnedWebAudioUnsupported: boolean;
  41469. /**
  41470. * Gets whether or not mp3 are supported by your browser.
  41471. */
  41472. isMP3supported: boolean;
  41473. /**
  41474. * Gets whether or not ogg are supported by your browser.
  41475. */
  41476. isOGGsupported: boolean;
  41477. /**
  41478. * Gets whether audio has been unlocked on the device.
  41479. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41480. * a user interaction has happened.
  41481. */
  41482. unlocked: boolean;
  41483. /**
  41484. * Defines if the audio engine relies on a custom unlocked button.
  41485. * In this case, the embedded button will not be displayed.
  41486. */
  41487. useCustomUnlockedButton: boolean;
  41488. /**
  41489. * Event raised when audio has been unlocked on the browser.
  41490. */
  41491. onAudioUnlockedObservable: Observable<AudioEngine>;
  41492. /**
  41493. * Event raised when audio has been locked on the browser.
  41494. */
  41495. onAudioLockedObservable: Observable<AudioEngine>;
  41496. /**
  41497. * Gets the current AudioContext if available.
  41498. */
  41499. get audioContext(): Nullable<AudioContext>;
  41500. private _connectedAnalyser;
  41501. /**
  41502. * Instantiates a new audio engine.
  41503. *
  41504. * There should be only one per page as some browsers restrict the number
  41505. * of audio contexts you can create.
  41506. * @param hostElement defines the host element where to display the mute icon if necessary
  41507. */
  41508. constructor(hostElement?: Nullable<HTMLElement>);
  41509. /**
  41510. * Flags the audio engine in Locked state.
  41511. * This happens due to new browser policies preventing audio to autoplay.
  41512. */
  41513. lock(): void;
  41514. /**
  41515. * Unlocks the audio engine once a user action has been done on the dom.
  41516. * This is helpful to resume play once browser policies have been satisfied.
  41517. */
  41518. unlock(): void;
  41519. private _resumeAudioContext;
  41520. private _initializeAudioContext;
  41521. private _tryToRun;
  41522. private _triggerRunningState;
  41523. private _triggerSuspendedState;
  41524. private _displayMuteButton;
  41525. private _moveButtonToTopLeft;
  41526. private _onResize;
  41527. private _hideMuteButton;
  41528. /**
  41529. * Destroy and release the resources associated with the audio ccontext.
  41530. */
  41531. dispose(): void;
  41532. /**
  41533. * Gets the global volume sets on the master gain.
  41534. * @returns the global volume if set or -1 otherwise
  41535. */
  41536. getGlobalVolume(): number;
  41537. /**
  41538. * Sets the global volume of your experience (sets on the master gain).
  41539. * @param newVolume Defines the new global volume of the application
  41540. */
  41541. setGlobalVolume(newVolume: number): void;
  41542. /**
  41543. * Connect the audio engine to an audio analyser allowing some amazing
  41544. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41546. * @param analyser The analyser to connect to the engine
  41547. */
  41548. connectToAnalyser(analyser: Analyser): void;
  41549. }
  41550. }
  41551. declare module "babylonjs/Loading/loadingScreen" {
  41552. /**
  41553. * Interface used to present a loading screen while loading a scene
  41554. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41555. */
  41556. export interface ILoadingScreen {
  41557. /**
  41558. * Function called to display the loading screen
  41559. */
  41560. displayLoadingUI: () => void;
  41561. /**
  41562. * Function called to hide the loading screen
  41563. */
  41564. hideLoadingUI: () => void;
  41565. /**
  41566. * Gets or sets the color to use for the background
  41567. */
  41568. loadingUIBackgroundColor: string;
  41569. /**
  41570. * Gets or sets the text to display while loading
  41571. */
  41572. loadingUIText: string;
  41573. }
  41574. /**
  41575. * Class used for the default loading screen
  41576. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41577. */
  41578. export class DefaultLoadingScreen implements ILoadingScreen {
  41579. private _renderingCanvas;
  41580. private _loadingText;
  41581. private _loadingDivBackgroundColor;
  41582. private _loadingDiv;
  41583. private _loadingTextDiv;
  41584. /** Gets or sets the logo url to use for the default loading screen */
  41585. static DefaultLogoUrl: string;
  41586. /** Gets or sets the spinner url to use for the default loading screen */
  41587. static DefaultSpinnerUrl: string;
  41588. /**
  41589. * Creates a new default loading screen
  41590. * @param _renderingCanvas defines the canvas used to render the scene
  41591. * @param _loadingText defines the default text to display
  41592. * @param _loadingDivBackgroundColor defines the default background color
  41593. */
  41594. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41595. /**
  41596. * Function called to display the loading screen
  41597. */
  41598. displayLoadingUI(): void;
  41599. /**
  41600. * Function called to hide the loading screen
  41601. */
  41602. hideLoadingUI(): void;
  41603. /**
  41604. * Gets or sets the text to display while loading
  41605. */
  41606. set loadingUIText(text: string);
  41607. get loadingUIText(): string;
  41608. /**
  41609. * Gets or sets the color to use for the background
  41610. */
  41611. get loadingUIBackgroundColor(): string;
  41612. set loadingUIBackgroundColor(color: string);
  41613. private _resizeLoadingUI;
  41614. }
  41615. }
  41616. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41617. /**
  41618. * Interface for any object that can request an animation frame
  41619. */
  41620. export interface ICustomAnimationFrameRequester {
  41621. /**
  41622. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41623. */
  41624. renderFunction?: Function;
  41625. /**
  41626. * Called to request the next frame to render to
  41627. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41628. */
  41629. requestAnimationFrame: Function;
  41630. /**
  41631. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41632. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41633. */
  41634. requestID?: number;
  41635. }
  41636. }
  41637. declare module "babylonjs/Misc/performanceMonitor" {
  41638. /**
  41639. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41640. */
  41641. export class PerformanceMonitor {
  41642. private _enabled;
  41643. private _rollingFrameTime;
  41644. private _lastFrameTimeMs;
  41645. /**
  41646. * constructor
  41647. * @param frameSampleSize The number of samples required to saturate the sliding window
  41648. */
  41649. constructor(frameSampleSize?: number);
  41650. /**
  41651. * Samples current frame
  41652. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41653. */
  41654. sampleFrame(timeMs?: number): void;
  41655. /**
  41656. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41657. */
  41658. get averageFrameTime(): number;
  41659. /**
  41660. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41661. */
  41662. get averageFrameTimeVariance(): number;
  41663. /**
  41664. * Returns the frame time of the most recent frame
  41665. */
  41666. get instantaneousFrameTime(): number;
  41667. /**
  41668. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41669. */
  41670. get averageFPS(): number;
  41671. /**
  41672. * Returns the average framerate in frames per second using the most recent frame time
  41673. */
  41674. get instantaneousFPS(): number;
  41675. /**
  41676. * Returns true if enough samples have been taken to completely fill the sliding window
  41677. */
  41678. get isSaturated(): boolean;
  41679. /**
  41680. * Enables contributions to the sliding window sample set
  41681. */
  41682. enable(): void;
  41683. /**
  41684. * Disables contributions to the sliding window sample set
  41685. * Samples will not be interpolated over the disabled period
  41686. */
  41687. disable(): void;
  41688. /**
  41689. * Returns true if sampling is enabled
  41690. */
  41691. get isEnabled(): boolean;
  41692. /**
  41693. * Resets performance monitor
  41694. */
  41695. reset(): void;
  41696. }
  41697. /**
  41698. * RollingAverage
  41699. *
  41700. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41701. */
  41702. export class RollingAverage {
  41703. /**
  41704. * Current average
  41705. */
  41706. average: number;
  41707. /**
  41708. * Current variance
  41709. */
  41710. variance: number;
  41711. protected _samples: Array<number>;
  41712. protected _sampleCount: number;
  41713. protected _pos: number;
  41714. protected _m2: number;
  41715. /**
  41716. * constructor
  41717. * @param length The number of samples required to saturate the sliding window
  41718. */
  41719. constructor(length: number);
  41720. /**
  41721. * Adds a sample to the sample set
  41722. * @param v The sample value
  41723. */
  41724. add(v: number): void;
  41725. /**
  41726. * Returns previously added values or null if outside of history or outside the sliding window domain
  41727. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41728. * @return Value previously recorded with add() or null if outside of range
  41729. */
  41730. history(i: number): number;
  41731. /**
  41732. * Returns true if enough samples have been taken to completely fill the sliding window
  41733. * @return true if sample-set saturated
  41734. */
  41735. isSaturated(): boolean;
  41736. /**
  41737. * Resets the rolling average (equivalent to 0 samples taken so far)
  41738. */
  41739. reset(): void;
  41740. /**
  41741. * Wraps a value around the sample range boundaries
  41742. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41743. * @return Wrapped position in sample range
  41744. */
  41745. protected _wrapPosition(i: number): number;
  41746. }
  41747. }
  41748. declare module "babylonjs/Misc/perfCounter" {
  41749. /**
  41750. * This class is used to track a performance counter which is number based.
  41751. * The user has access to many properties which give statistics of different nature.
  41752. *
  41753. * The implementer can track two kinds of Performance Counter: time and count.
  41754. * 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.
  41755. * 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.
  41756. */
  41757. export class PerfCounter {
  41758. /**
  41759. * Gets or sets a global boolean to turn on and off all the counters
  41760. */
  41761. static Enabled: boolean;
  41762. /**
  41763. * Returns the smallest value ever
  41764. */
  41765. get min(): number;
  41766. /**
  41767. * Returns the biggest value ever
  41768. */
  41769. get max(): number;
  41770. /**
  41771. * Returns the average value since the performance counter is running
  41772. */
  41773. get average(): number;
  41774. /**
  41775. * Returns the average value of the last second the counter was monitored
  41776. */
  41777. get lastSecAverage(): number;
  41778. /**
  41779. * Returns the current value
  41780. */
  41781. get current(): number;
  41782. /**
  41783. * Gets the accumulated total
  41784. */
  41785. get total(): number;
  41786. /**
  41787. * Gets the total value count
  41788. */
  41789. get count(): number;
  41790. /**
  41791. * Creates a new counter
  41792. */
  41793. constructor();
  41794. /**
  41795. * Call this method to start monitoring a new frame.
  41796. * 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.
  41797. */
  41798. fetchNewFrame(): void;
  41799. /**
  41800. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41801. * @param newCount the count value to add to the monitored count
  41802. * @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.
  41803. */
  41804. addCount(newCount: number, fetchResult: boolean): void;
  41805. /**
  41806. * Start monitoring this performance counter
  41807. */
  41808. beginMonitoring(): void;
  41809. /**
  41810. * Compute the time lapsed since the previous beginMonitoring() call.
  41811. * @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
  41812. */
  41813. endMonitoring(newFrame?: boolean): void;
  41814. private _fetchResult;
  41815. private _startMonitoringTime;
  41816. private _min;
  41817. private _max;
  41818. private _average;
  41819. private _current;
  41820. private _totalValueCount;
  41821. private _totalAccumulated;
  41822. private _lastSecAverage;
  41823. private _lastSecAccumulated;
  41824. private _lastSecTime;
  41825. private _lastSecValueCount;
  41826. }
  41827. }
  41828. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41829. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41830. import { Nullable } from "babylonjs/types";
  41831. module "babylonjs/Engines/thinEngine" {
  41832. interface ThinEngine {
  41833. /** @hidden */
  41834. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41835. }
  41836. }
  41837. }
  41838. declare module "babylonjs/Engines/engine" {
  41839. import { Observable } from "babylonjs/Misc/observable";
  41840. import { Nullable } from "babylonjs/types";
  41841. import { Scene } from "babylonjs/scene";
  41842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41843. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41844. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41845. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41846. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41847. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41848. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41849. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41850. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41851. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41852. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41853. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41854. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41855. import "babylonjs/Engines/Extensions/engine.alpha";
  41856. import "babylonjs/Engines/Extensions/engine.readTexture";
  41857. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41858. import { Material } from "babylonjs/Materials/material";
  41859. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41860. /**
  41861. * Defines the interface used by display changed events
  41862. */
  41863. export interface IDisplayChangedEventArgs {
  41864. /** Gets the vrDisplay object (if any) */
  41865. vrDisplay: Nullable<any>;
  41866. /** Gets a boolean indicating if webVR is supported */
  41867. vrSupported: boolean;
  41868. }
  41869. /**
  41870. * Defines the interface used by objects containing a viewport (like a camera)
  41871. */
  41872. interface IViewportOwnerLike {
  41873. /**
  41874. * Gets or sets the viewport
  41875. */
  41876. viewport: IViewportLike;
  41877. }
  41878. /**
  41879. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41880. */
  41881. export class Engine extends ThinEngine {
  41882. /** Defines that alpha blending is disabled */
  41883. static readonly ALPHA_DISABLE: number;
  41884. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41885. static readonly ALPHA_ADD: number;
  41886. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41887. static readonly ALPHA_COMBINE: number;
  41888. /** Defines that alpha blending to DEST - SRC * DEST */
  41889. static readonly ALPHA_SUBTRACT: number;
  41890. /** Defines that alpha blending to SRC * DEST */
  41891. static readonly ALPHA_MULTIPLY: number;
  41892. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41893. static readonly ALPHA_MAXIMIZED: number;
  41894. /** Defines that alpha blending to SRC + DEST */
  41895. static readonly ALPHA_ONEONE: number;
  41896. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41897. static readonly ALPHA_PREMULTIPLIED: number;
  41898. /**
  41899. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41900. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41901. */
  41902. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41903. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41904. static readonly ALPHA_INTERPOLATE: number;
  41905. /**
  41906. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41907. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41908. */
  41909. static readonly ALPHA_SCREENMODE: number;
  41910. /** Defines that the ressource is not delayed*/
  41911. static readonly DELAYLOADSTATE_NONE: number;
  41912. /** Defines that the ressource was successfully delay loaded */
  41913. static readonly DELAYLOADSTATE_LOADED: number;
  41914. /** Defines that the ressource is currently delay loading */
  41915. static readonly DELAYLOADSTATE_LOADING: number;
  41916. /** Defines that the ressource is delayed and has not started loading */
  41917. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41918. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41919. static readonly NEVER: number;
  41920. /** 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 */
  41921. static readonly ALWAYS: number;
  41922. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41923. static readonly LESS: number;
  41924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41925. static readonly EQUAL: number;
  41926. /** 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 */
  41927. static readonly LEQUAL: number;
  41928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41929. static readonly GREATER: number;
  41930. /** 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 */
  41931. static readonly GEQUAL: number;
  41932. /** 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 */
  41933. static readonly NOTEQUAL: number;
  41934. /** Passed to stencilOperation to specify that stencil value must be kept */
  41935. static readonly KEEP: number;
  41936. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41937. static readonly REPLACE: number;
  41938. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41939. static readonly INCR: number;
  41940. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41941. static readonly DECR: number;
  41942. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41943. static readonly INVERT: number;
  41944. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41945. static readonly INCR_WRAP: number;
  41946. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41947. static readonly DECR_WRAP: number;
  41948. /** Texture is not repeating outside of 0..1 UVs */
  41949. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41950. /** Texture is repeating outside of 0..1 UVs */
  41951. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41952. /** Texture is repeating and mirrored */
  41953. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41954. /** ALPHA */
  41955. static readonly TEXTUREFORMAT_ALPHA: number;
  41956. /** LUMINANCE */
  41957. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41958. /** LUMINANCE_ALPHA */
  41959. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41960. /** RGB */
  41961. static readonly TEXTUREFORMAT_RGB: number;
  41962. /** RGBA */
  41963. static readonly TEXTUREFORMAT_RGBA: number;
  41964. /** RED */
  41965. static readonly TEXTUREFORMAT_RED: number;
  41966. /** RED (2nd reference) */
  41967. static readonly TEXTUREFORMAT_R: number;
  41968. /** RG */
  41969. static readonly TEXTUREFORMAT_RG: number;
  41970. /** RED_INTEGER */
  41971. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41972. /** RED_INTEGER (2nd reference) */
  41973. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41974. /** RG_INTEGER */
  41975. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41976. /** RGB_INTEGER */
  41977. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41978. /** RGBA_INTEGER */
  41979. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41980. /** UNSIGNED_BYTE */
  41981. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41982. /** UNSIGNED_BYTE (2nd reference) */
  41983. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41984. /** FLOAT */
  41985. static readonly TEXTURETYPE_FLOAT: number;
  41986. /** HALF_FLOAT */
  41987. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41988. /** BYTE */
  41989. static readonly TEXTURETYPE_BYTE: number;
  41990. /** SHORT */
  41991. static readonly TEXTURETYPE_SHORT: number;
  41992. /** UNSIGNED_SHORT */
  41993. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41994. /** INT */
  41995. static readonly TEXTURETYPE_INT: number;
  41996. /** UNSIGNED_INT */
  41997. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41998. /** UNSIGNED_SHORT_4_4_4_4 */
  41999. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42000. /** UNSIGNED_SHORT_5_5_5_1 */
  42001. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42002. /** UNSIGNED_SHORT_5_6_5 */
  42003. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42004. /** UNSIGNED_INT_2_10_10_10_REV */
  42005. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42006. /** UNSIGNED_INT_24_8 */
  42007. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42008. /** UNSIGNED_INT_10F_11F_11F_REV */
  42009. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42010. /** UNSIGNED_INT_5_9_9_9_REV */
  42011. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42012. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42013. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42014. /** nearest is mag = nearest and min = nearest and mip = linear */
  42015. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42016. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42017. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42018. /** Trilinear is mag = linear and min = linear and mip = linear */
  42019. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42020. /** nearest is mag = nearest and min = nearest and mip = linear */
  42021. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42022. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42023. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42024. /** Trilinear is mag = linear and min = linear and mip = linear */
  42025. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42026. /** mag = nearest and min = nearest and mip = nearest */
  42027. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42028. /** mag = nearest and min = linear and mip = nearest */
  42029. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42030. /** mag = nearest and min = linear and mip = linear */
  42031. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42032. /** mag = nearest and min = linear and mip = none */
  42033. static readonly TEXTURE_NEAREST_LINEAR: number;
  42034. /** mag = nearest and min = nearest and mip = none */
  42035. static readonly TEXTURE_NEAREST_NEAREST: number;
  42036. /** mag = linear and min = nearest and mip = nearest */
  42037. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42038. /** mag = linear and min = nearest and mip = linear */
  42039. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42040. /** mag = linear and min = linear and mip = none */
  42041. static readonly TEXTURE_LINEAR_LINEAR: number;
  42042. /** mag = linear and min = nearest and mip = none */
  42043. static readonly TEXTURE_LINEAR_NEAREST: number;
  42044. /** Explicit coordinates mode */
  42045. static readonly TEXTURE_EXPLICIT_MODE: number;
  42046. /** Spherical coordinates mode */
  42047. static readonly TEXTURE_SPHERICAL_MODE: number;
  42048. /** Planar coordinates mode */
  42049. static readonly TEXTURE_PLANAR_MODE: number;
  42050. /** Cubic coordinates mode */
  42051. static readonly TEXTURE_CUBIC_MODE: number;
  42052. /** Projection coordinates mode */
  42053. static readonly TEXTURE_PROJECTION_MODE: number;
  42054. /** Skybox coordinates mode */
  42055. static readonly TEXTURE_SKYBOX_MODE: number;
  42056. /** Inverse Cubic coordinates mode */
  42057. static readonly TEXTURE_INVCUBIC_MODE: number;
  42058. /** Equirectangular coordinates mode */
  42059. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42060. /** Equirectangular Fixed coordinates mode */
  42061. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42062. /** Equirectangular Fixed Mirrored coordinates mode */
  42063. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42064. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42065. static readonly SCALEMODE_FLOOR: number;
  42066. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42067. static readonly SCALEMODE_NEAREST: number;
  42068. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42069. static readonly SCALEMODE_CEILING: number;
  42070. /**
  42071. * Returns the current npm package of the sdk
  42072. */
  42073. static get NpmPackage(): string;
  42074. /**
  42075. * Returns the current version of the framework
  42076. */
  42077. static get Version(): string;
  42078. /** Gets the list of created engines */
  42079. static get Instances(): Engine[];
  42080. /**
  42081. * Gets the latest created engine
  42082. */
  42083. static get LastCreatedEngine(): Nullable<Engine>;
  42084. /**
  42085. * Gets the latest created scene
  42086. */
  42087. static get LastCreatedScene(): Nullable<Scene>;
  42088. /**
  42089. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42090. * @param flag defines which part of the materials must be marked as dirty
  42091. * @param predicate defines a predicate used to filter which materials should be affected
  42092. */
  42093. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42094. /**
  42095. * Method called to create the default loading screen.
  42096. * This can be overriden in your own app.
  42097. * @param canvas The rendering canvas element
  42098. * @returns The loading screen
  42099. */
  42100. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42101. /**
  42102. * Method called to create the default rescale post process on each engine.
  42103. */
  42104. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42105. /**
  42106. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42107. **/
  42108. enableOfflineSupport: boolean;
  42109. /**
  42110. * 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)
  42111. **/
  42112. disableManifestCheck: boolean;
  42113. /**
  42114. * Gets the list of created scenes
  42115. */
  42116. scenes: Scene[];
  42117. /**
  42118. * Event raised when a new scene is created
  42119. */
  42120. onNewSceneAddedObservable: Observable<Scene>;
  42121. /**
  42122. * Gets the list of created postprocesses
  42123. */
  42124. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42125. /**
  42126. * Gets a boolean indicating if the pointer is currently locked
  42127. */
  42128. isPointerLock: boolean;
  42129. /**
  42130. * Observable event triggered each time the rendering canvas is resized
  42131. */
  42132. onResizeObservable: Observable<Engine>;
  42133. /**
  42134. * Observable event triggered each time the canvas loses focus
  42135. */
  42136. onCanvasBlurObservable: Observable<Engine>;
  42137. /**
  42138. * Observable event triggered each time the canvas gains focus
  42139. */
  42140. onCanvasFocusObservable: Observable<Engine>;
  42141. /**
  42142. * Observable event triggered each time the canvas receives pointerout event
  42143. */
  42144. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42145. /**
  42146. * Observable raised when the engine begins a new frame
  42147. */
  42148. onBeginFrameObservable: Observable<Engine>;
  42149. /**
  42150. * If set, will be used to request the next animation frame for the render loop
  42151. */
  42152. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42153. /**
  42154. * Observable raised when the engine ends the current frame
  42155. */
  42156. onEndFrameObservable: Observable<Engine>;
  42157. /**
  42158. * Observable raised when the engine is about to compile a shader
  42159. */
  42160. onBeforeShaderCompilationObservable: Observable<Engine>;
  42161. /**
  42162. * Observable raised when the engine has jsut compiled a shader
  42163. */
  42164. onAfterShaderCompilationObservable: Observable<Engine>;
  42165. /**
  42166. * Gets the audio engine
  42167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42168. * @ignorenaming
  42169. */
  42170. static audioEngine: IAudioEngine;
  42171. /**
  42172. * Default AudioEngine factory responsible of creating the Audio Engine.
  42173. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42174. */
  42175. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42176. /**
  42177. * Default offline support factory responsible of creating a tool used to store data locally.
  42178. * By default, this will create a Database object if the workload has been embedded.
  42179. */
  42180. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42181. private _loadingScreen;
  42182. private _pointerLockRequested;
  42183. private _rescalePostProcess;
  42184. private _deterministicLockstep;
  42185. private _lockstepMaxSteps;
  42186. private _timeStep;
  42187. protected get _supportsHardwareTextureRescaling(): boolean;
  42188. private _fps;
  42189. private _deltaTime;
  42190. /** @hidden */
  42191. _drawCalls: PerfCounter;
  42192. /** 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 */
  42193. canvasTabIndex: number;
  42194. /**
  42195. * Turn this value on if you want to pause FPS computation when in background
  42196. */
  42197. disablePerformanceMonitorInBackground: boolean;
  42198. private _performanceMonitor;
  42199. /**
  42200. * Gets the performance monitor attached to this engine
  42201. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42202. */
  42203. get performanceMonitor(): PerformanceMonitor;
  42204. private _onFocus;
  42205. private _onBlur;
  42206. private _onCanvasPointerOut;
  42207. private _onCanvasBlur;
  42208. private _onCanvasFocus;
  42209. private _onFullscreenChange;
  42210. private _onPointerLockChange;
  42211. /**
  42212. * Gets the HTML element used to attach event listeners
  42213. * @returns a HTML element
  42214. */
  42215. getInputElement(): Nullable<HTMLElement>;
  42216. /**
  42217. * Creates a new engine
  42218. * @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
  42219. * @param antialias defines enable antialiasing (default: false)
  42220. * @param options defines further options to be sent to the getContext() function
  42221. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42222. */
  42223. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42224. /**
  42225. * Gets current aspect ratio
  42226. * @param viewportOwner defines the camera to use to get the aspect ratio
  42227. * @param useScreen defines if screen size must be used (or the current render target if any)
  42228. * @returns a number defining the aspect ratio
  42229. */
  42230. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42231. /**
  42232. * Gets current screen aspect ratio
  42233. * @returns a number defining the aspect ratio
  42234. */
  42235. getScreenAspectRatio(): number;
  42236. /**
  42237. * Gets the client rect of the HTML canvas attached with the current webGL context
  42238. * @returns a client rectanglee
  42239. */
  42240. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42241. /**
  42242. * Gets the client rect of the HTML element used for events
  42243. * @returns a client rectanglee
  42244. */
  42245. getInputElementClientRect(): Nullable<ClientRect>;
  42246. /**
  42247. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42248. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42249. * @returns true if engine is in deterministic lock step mode
  42250. */
  42251. isDeterministicLockStep(): boolean;
  42252. /**
  42253. * Gets the max steps when engine is running in deterministic lock step
  42254. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42255. * @returns the max steps
  42256. */
  42257. getLockstepMaxSteps(): number;
  42258. /**
  42259. * Returns the time in ms between steps when using deterministic lock step.
  42260. * @returns time step in (ms)
  42261. */
  42262. getTimeStep(): number;
  42263. /**
  42264. * Force the mipmap generation for the given render target texture
  42265. * @param texture defines the render target texture to use
  42266. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42267. */
  42268. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42269. /** States */
  42270. /**
  42271. * Set various states to the webGL context
  42272. * @param culling defines backface culling state
  42273. * @param zOffset defines the value to apply to zOffset (0 by default)
  42274. * @param force defines if states must be applied even if cache is up to date
  42275. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42276. */
  42277. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42278. /**
  42279. * Set the z offset to apply to current rendering
  42280. * @param value defines the offset to apply
  42281. */
  42282. setZOffset(value: number): void;
  42283. /**
  42284. * Gets the current value of the zOffset
  42285. * @returns the current zOffset state
  42286. */
  42287. getZOffset(): number;
  42288. /**
  42289. * Enable or disable depth buffering
  42290. * @param enable defines the state to set
  42291. */
  42292. setDepthBuffer(enable: boolean): void;
  42293. /**
  42294. * Gets a boolean indicating if depth writing is enabled
  42295. * @returns the current depth writing state
  42296. */
  42297. getDepthWrite(): boolean;
  42298. /**
  42299. * Enable or disable depth writing
  42300. * @param enable defines the state to set
  42301. */
  42302. setDepthWrite(enable: boolean): void;
  42303. /**
  42304. * Gets a boolean indicating if stencil buffer is enabled
  42305. * @returns the current stencil buffer state
  42306. */
  42307. getStencilBuffer(): boolean;
  42308. /**
  42309. * Enable or disable the stencil buffer
  42310. * @param enable defines if the stencil buffer must be enabled or disabled
  42311. */
  42312. setStencilBuffer(enable: boolean): void;
  42313. /**
  42314. * Gets the current stencil mask
  42315. * @returns a number defining the new stencil mask to use
  42316. */
  42317. getStencilMask(): number;
  42318. /**
  42319. * Sets the current stencil mask
  42320. * @param mask defines the new stencil mask to use
  42321. */
  42322. setStencilMask(mask: number): void;
  42323. /**
  42324. * Gets the current stencil function
  42325. * @returns a number defining the stencil function to use
  42326. */
  42327. getStencilFunction(): number;
  42328. /**
  42329. * Gets the current stencil reference value
  42330. * @returns a number defining the stencil reference value to use
  42331. */
  42332. getStencilFunctionReference(): number;
  42333. /**
  42334. * Gets the current stencil mask
  42335. * @returns a number defining the stencil mask to use
  42336. */
  42337. getStencilFunctionMask(): number;
  42338. /**
  42339. * Sets the current stencil function
  42340. * @param stencilFunc defines the new stencil function to use
  42341. */
  42342. setStencilFunction(stencilFunc: number): void;
  42343. /**
  42344. * Sets the current stencil reference
  42345. * @param reference defines the new stencil reference to use
  42346. */
  42347. setStencilFunctionReference(reference: number): void;
  42348. /**
  42349. * Sets the current stencil mask
  42350. * @param mask defines the new stencil mask to use
  42351. */
  42352. setStencilFunctionMask(mask: number): void;
  42353. /**
  42354. * Gets the current stencil operation when stencil fails
  42355. * @returns a number defining stencil operation to use when stencil fails
  42356. */
  42357. getStencilOperationFail(): number;
  42358. /**
  42359. * Gets the current stencil operation when depth fails
  42360. * @returns a number defining stencil operation to use when depth fails
  42361. */
  42362. getStencilOperationDepthFail(): number;
  42363. /**
  42364. * Gets the current stencil operation when stencil passes
  42365. * @returns a number defining stencil operation to use when stencil passes
  42366. */
  42367. getStencilOperationPass(): number;
  42368. /**
  42369. * Sets the stencil operation to use when stencil fails
  42370. * @param operation defines the stencil operation to use when stencil fails
  42371. */
  42372. setStencilOperationFail(operation: number): void;
  42373. /**
  42374. * Sets the stencil operation to use when depth fails
  42375. * @param operation defines the stencil operation to use when depth fails
  42376. */
  42377. setStencilOperationDepthFail(operation: number): void;
  42378. /**
  42379. * Sets the stencil operation to use when stencil passes
  42380. * @param operation defines the stencil operation to use when stencil passes
  42381. */
  42382. setStencilOperationPass(operation: number): void;
  42383. /**
  42384. * Sets a boolean indicating if the dithering state is enabled or disabled
  42385. * @param value defines the dithering state
  42386. */
  42387. setDitheringState(value: boolean): void;
  42388. /**
  42389. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42390. * @param value defines the rasterizer state
  42391. */
  42392. setRasterizerState(value: boolean): void;
  42393. /**
  42394. * Gets the current depth function
  42395. * @returns a number defining the depth function
  42396. */
  42397. getDepthFunction(): Nullable<number>;
  42398. /**
  42399. * Sets the current depth function
  42400. * @param depthFunc defines the function to use
  42401. */
  42402. setDepthFunction(depthFunc: number): void;
  42403. /**
  42404. * Sets the current depth function to GREATER
  42405. */
  42406. setDepthFunctionToGreater(): void;
  42407. /**
  42408. * Sets the current depth function to GEQUAL
  42409. */
  42410. setDepthFunctionToGreaterOrEqual(): void;
  42411. /**
  42412. * Sets the current depth function to LESS
  42413. */
  42414. setDepthFunctionToLess(): void;
  42415. /**
  42416. * Sets the current depth function to LEQUAL
  42417. */
  42418. setDepthFunctionToLessOrEqual(): void;
  42419. private _cachedStencilBuffer;
  42420. private _cachedStencilFunction;
  42421. private _cachedStencilMask;
  42422. private _cachedStencilOperationPass;
  42423. private _cachedStencilOperationFail;
  42424. private _cachedStencilOperationDepthFail;
  42425. private _cachedStencilReference;
  42426. /**
  42427. * Caches the the state of the stencil buffer
  42428. */
  42429. cacheStencilState(): void;
  42430. /**
  42431. * Restores the state of the stencil buffer
  42432. */
  42433. restoreStencilState(): void;
  42434. /**
  42435. * Directly set the WebGL Viewport
  42436. * @param x defines the x coordinate of the viewport (in screen space)
  42437. * @param y defines the y coordinate of the viewport (in screen space)
  42438. * @param width defines the width of the viewport (in screen space)
  42439. * @param height defines the height of the viewport (in screen space)
  42440. * @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
  42441. */
  42442. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42443. /**
  42444. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42445. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42446. * @param y defines the y-coordinate of the corner of the clear rectangle
  42447. * @param width defines the width of the clear rectangle
  42448. * @param height defines the height of the clear rectangle
  42449. * @param clearColor defines the clear color
  42450. */
  42451. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42452. /**
  42453. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42454. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42455. * @param y defines the y-coordinate of the corner of the clear rectangle
  42456. * @param width defines the width of the clear rectangle
  42457. * @param height defines the height of the clear rectangle
  42458. */
  42459. enableScissor(x: number, y: number, width: number, height: number): void;
  42460. /**
  42461. * Disable previously set scissor test rectangle
  42462. */
  42463. disableScissor(): void;
  42464. protected _reportDrawCall(): void;
  42465. /**
  42466. * Initializes a webVR display and starts listening to display change events
  42467. * The onVRDisplayChangedObservable will be notified upon these changes
  42468. * @returns The onVRDisplayChangedObservable
  42469. */
  42470. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42471. /** @hidden */
  42472. _prepareVRComponent(): void;
  42473. /** @hidden */
  42474. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42475. /** @hidden */
  42476. _submitVRFrame(): void;
  42477. /**
  42478. * Call this function to leave webVR mode
  42479. * Will do nothing if webVR is not supported or if there is no webVR device
  42480. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42481. */
  42482. disableVR(): void;
  42483. /**
  42484. * Gets a boolean indicating that the system is in VR mode and is presenting
  42485. * @returns true if VR mode is engaged
  42486. */
  42487. isVRPresenting(): boolean;
  42488. /** @hidden */
  42489. _requestVRFrame(): void;
  42490. /** @hidden */
  42491. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42492. /**
  42493. * Gets the source code of the vertex shader associated with a specific webGL program
  42494. * @param program defines the program to use
  42495. * @returns a string containing the source code of the vertex shader associated with the program
  42496. */
  42497. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42498. /**
  42499. * Gets the source code of the fragment shader associated with a specific webGL program
  42500. * @param program defines the program to use
  42501. * @returns a string containing the source code of the fragment shader associated with the program
  42502. */
  42503. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42504. /**
  42505. * Sets a depth stencil texture from a render target to the according uniform.
  42506. * @param channel The texture channel
  42507. * @param uniform The uniform to set
  42508. * @param texture The render target texture containing the depth stencil texture to apply
  42509. */
  42510. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42511. /**
  42512. * Sets a texture to the webGL context from a postprocess
  42513. * @param channel defines the channel to use
  42514. * @param postProcess defines the source postprocess
  42515. */
  42516. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42517. /**
  42518. * Binds the output of the passed in post process to the texture channel specified
  42519. * @param channel The channel the texture should be bound to
  42520. * @param postProcess The post process which's output should be bound
  42521. */
  42522. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42523. protected _rebuildBuffers(): void;
  42524. /** @hidden */
  42525. _renderFrame(): void;
  42526. _renderLoop(): void;
  42527. /** @hidden */
  42528. _renderViews(): boolean;
  42529. /**
  42530. * Toggle full screen mode
  42531. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42532. */
  42533. switchFullscreen(requestPointerLock: boolean): void;
  42534. /**
  42535. * Enters full screen mode
  42536. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42537. */
  42538. enterFullscreen(requestPointerLock: boolean): void;
  42539. /**
  42540. * Exits full screen mode
  42541. */
  42542. exitFullscreen(): void;
  42543. /**
  42544. * Enters Pointerlock mode
  42545. */
  42546. enterPointerlock(): void;
  42547. /**
  42548. * Exits Pointerlock mode
  42549. */
  42550. exitPointerlock(): void;
  42551. /**
  42552. * Begin a new frame
  42553. */
  42554. beginFrame(): void;
  42555. /**
  42556. * Enf the current frame
  42557. */
  42558. endFrame(): void;
  42559. resize(): void;
  42560. /**
  42561. * Force a specific size of the canvas
  42562. * @param width defines the new canvas' width
  42563. * @param height defines the new canvas' height
  42564. * @returns true if the size was changed
  42565. */
  42566. setSize(width: number, height: number): boolean;
  42567. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42568. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42569. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42570. _releaseTexture(texture: InternalTexture): void;
  42571. /**
  42572. * @hidden
  42573. * Rescales a texture
  42574. * @param source input texutre
  42575. * @param destination destination texture
  42576. * @param scene scene to use to render the resize
  42577. * @param internalFormat format to use when resizing
  42578. * @param onComplete callback to be called when resize has completed
  42579. */
  42580. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42581. /**
  42582. * Gets the current framerate
  42583. * @returns a number representing the framerate
  42584. */
  42585. getFps(): number;
  42586. /**
  42587. * Gets the time spent between current and previous frame
  42588. * @returns a number representing the delta time in ms
  42589. */
  42590. getDeltaTime(): number;
  42591. private _measureFps;
  42592. /** @hidden */
  42593. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42594. /**
  42595. * Updates the sample count of a render target texture
  42596. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42597. * @param texture defines the texture to update
  42598. * @param samples defines the sample count to set
  42599. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42600. */
  42601. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42602. /**
  42603. * Updates a depth texture Comparison Mode and Function.
  42604. * If the comparison Function is equal to 0, the mode will be set to none.
  42605. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42606. * @param texture The texture to set the comparison function for
  42607. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42608. */
  42609. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42610. /**
  42611. * Creates a webGL buffer to use with instanciation
  42612. * @param capacity defines the size of the buffer
  42613. * @returns the webGL buffer
  42614. */
  42615. createInstancesBuffer(capacity: number): DataBuffer;
  42616. /**
  42617. * Delete a webGL buffer used with instanciation
  42618. * @param buffer defines the webGL buffer to delete
  42619. */
  42620. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42621. private _clientWaitAsync;
  42622. /** @hidden */
  42623. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42624. dispose(): void;
  42625. private _disableTouchAction;
  42626. /**
  42627. * Display the loading screen
  42628. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42629. */
  42630. displayLoadingUI(): void;
  42631. /**
  42632. * Hide the loading screen
  42633. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42634. */
  42635. hideLoadingUI(): void;
  42636. /**
  42637. * Gets the current loading screen object
  42638. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42639. */
  42640. get loadingScreen(): ILoadingScreen;
  42641. /**
  42642. * Sets the current loading screen object
  42643. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42644. */
  42645. set loadingScreen(loadingScreen: ILoadingScreen);
  42646. /**
  42647. * Sets the current loading screen text
  42648. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42649. */
  42650. set loadingUIText(text: string);
  42651. /**
  42652. * Sets the current loading screen background color
  42653. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42654. */
  42655. set loadingUIBackgroundColor(color: string);
  42656. /** Pointerlock and fullscreen */
  42657. /**
  42658. * Ask the browser to promote the current element to pointerlock mode
  42659. * @param element defines the DOM element to promote
  42660. */
  42661. static _RequestPointerlock(element: HTMLElement): void;
  42662. /**
  42663. * Asks the browser to exit pointerlock mode
  42664. */
  42665. static _ExitPointerlock(): void;
  42666. /**
  42667. * Ask the browser to promote the current element to fullscreen rendering mode
  42668. * @param element defines the DOM element to promote
  42669. */
  42670. static _RequestFullscreen(element: HTMLElement): void;
  42671. /**
  42672. * Asks the browser to exit fullscreen mode
  42673. */
  42674. static _ExitFullscreen(): void;
  42675. }
  42676. }
  42677. declare module "babylonjs/Engines/engineStore" {
  42678. import { Nullable } from "babylonjs/types";
  42679. import { Engine } from "babylonjs/Engines/engine";
  42680. import { Scene } from "babylonjs/scene";
  42681. /**
  42682. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42683. * during the life time of the application.
  42684. */
  42685. export class EngineStore {
  42686. /** Gets the list of created engines */
  42687. static Instances: import("babylonjs/Engines/engine").Engine[];
  42688. /** @hidden */
  42689. static _LastCreatedScene: Nullable<Scene>;
  42690. /**
  42691. * Gets the latest created engine
  42692. */
  42693. static get LastCreatedEngine(): Nullable<Engine>;
  42694. /**
  42695. * Gets the latest created scene
  42696. */
  42697. static get LastCreatedScene(): Nullable<Scene>;
  42698. /**
  42699. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42700. * @ignorenaming
  42701. */
  42702. static UseFallbackTexture: boolean;
  42703. /**
  42704. * Texture content used if a texture cannot loaded
  42705. * @ignorenaming
  42706. */
  42707. static FallbackTexture: string;
  42708. }
  42709. }
  42710. declare module "babylonjs/Misc/promise" {
  42711. /**
  42712. * Helper class that provides a small promise polyfill
  42713. */
  42714. export class PromisePolyfill {
  42715. /**
  42716. * Static function used to check if the polyfill is required
  42717. * If this is the case then the function will inject the polyfill to window.Promise
  42718. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42719. */
  42720. static Apply(force?: boolean): void;
  42721. }
  42722. }
  42723. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42724. /**
  42725. * Interface for screenshot methods with describe argument called `size` as object with options
  42726. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42727. */
  42728. export interface IScreenshotSize {
  42729. /**
  42730. * number in pixels for canvas height
  42731. */
  42732. height?: number;
  42733. /**
  42734. * multiplier allowing render at a higher or lower resolution
  42735. * If value is defined then height and width will be ignored and taken from camera
  42736. */
  42737. precision?: number;
  42738. /**
  42739. * number in pixels for canvas width
  42740. */
  42741. width?: number;
  42742. }
  42743. }
  42744. declare module "babylonjs/Misc/tools" {
  42745. import { Nullable, float } from "babylonjs/types";
  42746. import { DomManagement } from "babylonjs/Misc/domManagement";
  42747. import { WebRequest } from "babylonjs/Misc/webRequest";
  42748. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42749. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42750. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42751. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42752. import { Camera } from "babylonjs/Cameras/camera";
  42753. import { Engine } from "babylonjs/Engines/engine";
  42754. interface IColor4Like {
  42755. r: float;
  42756. g: float;
  42757. b: float;
  42758. a: float;
  42759. }
  42760. /**
  42761. * Class containing a set of static utilities functions
  42762. */
  42763. export class Tools {
  42764. /**
  42765. * Gets or sets the base URL to use to load assets
  42766. */
  42767. static get BaseUrl(): string;
  42768. static set BaseUrl(value: string);
  42769. /**
  42770. * Enable/Disable Custom HTTP Request Headers globally.
  42771. * default = false
  42772. * @see CustomRequestHeaders
  42773. */
  42774. static UseCustomRequestHeaders: boolean;
  42775. /**
  42776. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42777. * i.e. when loading files, where the server/service expects an Authorization header
  42778. */
  42779. static CustomRequestHeaders: {
  42780. [key: string]: string;
  42781. };
  42782. /**
  42783. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42784. */
  42785. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42786. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42787. /**
  42788. * Default behaviour for cors in the application.
  42789. * It can be a string if the expected behavior is identical in the entire app.
  42790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42791. */
  42792. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42793. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42794. /**
  42795. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42796. * @ignorenaming
  42797. */
  42798. static get UseFallbackTexture(): boolean;
  42799. static set UseFallbackTexture(value: boolean);
  42800. /**
  42801. * Use this object to register external classes like custom textures or material
  42802. * to allow the laoders to instantiate them
  42803. */
  42804. static get RegisteredExternalClasses(): {
  42805. [key: string]: Object;
  42806. };
  42807. static set RegisteredExternalClasses(classes: {
  42808. [key: string]: Object;
  42809. });
  42810. /**
  42811. * Texture content used if a texture cannot loaded
  42812. * @ignorenaming
  42813. */
  42814. static get fallbackTexture(): string;
  42815. static set fallbackTexture(value: string);
  42816. /**
  42817. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42818. * @param u defines the coordinate on X axis
  42819. * @param v defines the coordinate on Y axis
  42820. * @param width defines the width of the source data
  42821. * @param height defines the height of the source data
  42822. * @param pixels defines the source byte array
  42823. * @param color defines the output color
  42824. */
  42825. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42826. /**
  42827. * Interpolates between a and b via alpha
  42828. * @param a The lower value (returned when alpha = 0)
  42829. * @param b The upper value (returned when alpha = 1)
  42830. * @param alpha The interpolation-factor
  42831. * @return The mixed value
  42832. */
  42833. static Mix(a: number, b: number, alpha: number): number;
  42834. /**
  42835. * Tries to instantiate a new object from a given class name
  42836. * @param className defines the class name to instantiate
  42837. * @returns the new object or null if the system was not able to do the instantiation
  42838. */
  42839. static Instantiate(className: string): any;
  42840. /**
  42841. * Provides a slice function that will work even on IE
  42842. * @param data defines the array to slice
  42843. * @param start defines the start of the data (optional)
  42844. * @param end defines the end of the data (optional)
  42845. * @returns the new sliced array
  42846. */
  42847. static Slice<T>(data: T, start?: number, end?: number): T;
  42848. /**
  42849. * Polyfill for setImmediate
  42850. * @param action defines the action to execute after the current execution block
  42851. */
  42852. static SetImmediate(action: () => void): void;
  42853. /**
  42854. * Function indicating if a number is an exponent of 2
  42855. * @param value defines the value to test
  42856. * @returns true if the value is an exponent of 2
  42857. */
  42858. static IsExponentOfTwo(value: number): boolean;
  42859. private static _tmpFloatArray;
  42860. /**
  42861. * Returns the nearest 32-bit single precision float representation of a Number
  42862. * @param value A Number. If the parameter is of a different type, it will get converted
  42863. * to a number or to NaN if it cannot be converted
  42864. * @returns number
  42865. */
  42866. static FloatRound(value: number): number;
  42867. /**
  42868. * Extracts the filename from a path
  42869. * @param path defines the path to use
  42870. * @returns the filename
  42871. */
  42872. static GetFilename(path: string): string;
  42873. /**
  42874. * Extracts the "folder" part of a path (everything before the filename).
  42875. * @param uri The URI to extract the info from
  42876. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42877. * @returns The "folder" part of the path
  42878. */
  42879. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42880. /**
  42881. * Extracts text content from a DOM element hierarchy
  42882. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42883. */
  42884. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42885. /**
  42886. * Convert an angle in radians to degrees
  42887. * @param angle defines the angle to convert
  42888. * @returns the angle in degrees
  42889. */
  42890. static ToDegrees(angle: number): number;
  42891. /**
  42892. * Convert an angle in degrees to radians
  42893. * @param angle defines the angle to convert
  42894. * @returns the angle in radians
  42895. */
  42896. static ToRadians(angle: number): number;
  42897. /**
  42898. * Returns an array if obj is not an array
  42899. * @param obj defines the object to evaluate as an array
  42900. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42901. * @returns either obj directly if obj is an array or a new array containing obj
  42902. */
  42903. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42904. /**
  42905. * Gets the pointer prefix to use
  42906. * @param engine defines the engine we are finding the prefix for
  42907. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42908. */
  42909. static GetPointerPrefix(engine: Engine): string;
  42910. /**
  42911. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42912. * @param url define the url we are trying
  42913. * @param element define the dom element where to configure the cors policy
  42914. */
  42915. static SetCorsBehavior(url: string | string[], element: {
  42916. crossOrigin: string | null;
  42917. }): void;
  42918. /**
  42919. * Removes unwanted characters from an url
  42920. * @param url defines the url to clean
  42921. * @returns the cleaned url
  42922. */
  42923. static CleanUrl(url: string): string;
  42924. /**
  42925. * Gets or sets a function used to pre-process url before using them to load assets
  42926. */
  42927. static get PreprocessUrl(): (url: string) => string;
  42928. static set PreprocessUrl(processor: (url: string) => string);
  42929. /**
  42930. * Loads an image as an HTMLImageElement.
  42931. * @param input url string, ArrayBuffer, or Blob to load
  42932. * @param onLoad callback called when the image successfully loads
  42933. * @param onError callback called when the image fails to load
  42934. * @param offlineProvider offline provider for caching
  42935. * @param mimeType optional mime type
  42936. * @returns the HTMLImageElement of the loaded image
  42937. */
  42938. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42939. /**
  42940. * Loads a file from a url
  42941. * @param url url string, ArrayBuffer, or Blob to load
  42942. * @param onSuccess callback called when the file successfully loads
  42943. * @param onProgress callback called while file is loading (if the server supports this mode)
  42944. * @param offlineProvider defines the offline provider for caching
  42945. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42946. * @param onError callback called when the file fails to load
  42947. * @returns a file request object
  42948. */
  42949. 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;
  42950. /**
  42951. * Loads a file from a url
  42952. * @param url the file url to load
  42953. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42954. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42955. */
  42956. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42957. /**
  42958. * Load a script (identified by an url). When the url returns, the
  42959. * content of this file is added into a new script element, attached to the DOM (body element)
  42960. * @param scriptUrl defines the url of the script to laod
  42961. * @param onSuccess defines the callback called when the script is loaded
  42962. * @param onError defines the callback to call if an error occurs
  42963. * @param scriptId defines the id of the script element
  42964. */
  42965. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42966. /**
  42967. * Load an asynchronous script (identified by an url). When the url returns, the
  42968. * content of this file is added into a new script element, attached to the DOM (body element)
  42969. * @param scriptUrl defines the url of the script to laod
  42970. * @param scriptId defines the id of the script element
  42971. * @returns a promise request object
  42972. */
  42973. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42974. /**
  42975. * Loads a file from a blob
  42976. * @param fileToLoad defines the blob to use
  42977. * @param callback defines the callback to call when data is loaded
  42978. * @param progressCallback defines the callback to call during loading process
  42979. * @returns a file request object
  42980. */
  42981. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42982. /**
  42983. * Reads a file from a File object
  42984. * @param file defines the file to load
  42985. * @param onSuccess defines the callback to call when data is loaded
  42986. * @param onProgress defines the callback to call during loading process
  42987. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42988. * @param onError defines the callback to call when an error occurs
  42989. * @returns a file request object
  42990. */
  42991. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42992. /**
  42993. * Creates a data url from a given string content
  42994. * @param content defines the content to convert
  42995. * @returns the new data url link
  42996. */
  42997. static FileAsURL(content: string): string;
  42998. /**
  42999. * Format the given number to a specific decimal format
  43000. * @param value defines the number to format
  43001. * @param decimals defines the number of decimals to use
  43002. * @returns the formatted string
  43003. */
  43004. static Format(value: number, decimals?: number): string;
  43005. /**
  43006. * Tries to copy an object by duplicating every property
  43007. * @param source defines the source object
  43008. * @param destination defines the target object
  43009. * @param doNotCopyList defines a list of properties to avoid
  43010. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43011. */
  43012. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43013. /**
  43014. * Gets a boolean indicating if the given object has no own property
  43015. * @param obj defines the object to test
  43016. * @returns true if object has no own property
  43017. */
  43018. static IsEmpty(obj: any): boolean;
  43019. /**
  43020. * Function used to register events at window level
  43021. * @param windowElement defines the Window object to use
  43022. * @param events defines the events to register
  43023. */
  43024. static RegisterTopRootEvents(windowElement: Window, events: {
  43025. name: string;
  43026. handler: Nullable<(e: FocusEvent) => any>;
  43027. }[]): void;
  43028. /**
  43029. * Function used to unregister events from window level
  43030. * @param windowElement defines the Window object to use
  43031. * @param events defines the events to unregister
  43032. */
  43033. static UnregisterTopRootEvents(windowElement: Window, events: {
  43034. name: string;
  43035. handler: Nullable<(e: FocusEvent) => any>;
  43036. }[]): void;
  43037. /**
  43038. * @ignore
  43039. */
  43040. static _ScreenshotCanvas: HTMLCanvasElement;
  43041. /**
  43042. * Dumps the current bound framebuffer
  43043. * @param width defines the rendering width
  43044. * @param height defines the rendering height
  43045. * @param engine defines the hosting engine
  43046. * @param successCallback defines the callback triggered once the data are available
  43047. * @param mimeType defines the mime type of the result
  43048. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43049. */
  43050. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43051. /**
  43052. * Converts the canvas data to blob.
  43053. * This acts as a polyfill for browsers not supporting the to blob function.
  43054. * @param canvas Defines the canvas to extract the data from
  43055. * @param successCallback Defines the callback triggered once the data are available
  43056. * @param mimeType Defines the mime type of the result
  43057. */
  43058. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43059. /**
  43060. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43061. * @param successCallback defines the callback triggered once the data are available
  43062. * @param mimeType defines the mime type of the result
  43063. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43064. */
  43065. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43066. /**
  43067. * Downloads a blob in the browser
  43068. * @param blob defines the blob to download
  43069. * @param fileName defines the name of the downloaded file
  43070. */
  43071. static Download(blob: Blob, fileName: string): void;
  43072. /**
  43073. * Captures a screenshot of the current rendering
  43074. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43075. * @param engine defines the rendering engine
  43076. * @param camera defines the source camera
  43077. * @param size This parameter can be set to a single number or to an object with the
  43078. * following (optional) properties: precision, width, height. If a single number is passed,
  43079. * it will be used for both width and height. If an object is passed, the screenshot size
  43080. * will be derived from the parameters. The precision property is a multiplier allowing
  43081. * rendering at a higher or lower resolution
  43082. * @param successCallback defines the callback receives a single parameter which contains the
  43083. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43084. * src parameter of an <img> to display it
  43085. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43086. * Check your browser for supported MIME types
  43087. */
  43088. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43089. /**
  43090. * Captures a screenshot of the current rendering
  43091. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43092. * @param engine defines the rendering engine
  43093. * @param camera defines the source camera
  43094. * @param size This parameter can be set to a single number or to an object with the
  43095. * following (optional) properties: precision, width, height. If a single number is passed,
  43096. * it will be used for both width and height. If an object is passed, the screenshot size
  43097. * will be derived from the parameters. The precision property is a multiplier allowing
  43098. * rendering at a higher or lower resolution
  43099. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43100. * Check your browser for supported MIME types
  43101. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43102. * to the src parameter of an <img> to display it
  43103. */
  43104. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43105. /**
  43106. * Generates an image screenshot from the specified camera.
  43107. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43108. * @param engine The engine to use for rendering
  43109. * @param camera The camera to use for rendering
  43110. * @param size This parameter can be set to a single number or to an object with the
  43111. * following (optional) properties: precision, width, height. If a single number is passed,
  43112. * it will be used for both width and height. If an object is passed, the screenshot size
  43113. * will be derived from the parameters. The precision property is a multiplier allowing
  43114. * rendering at a higher or lower resolution
  43115. * @param successCallback The callback receives a single parameter which contains the
  43116. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43117. * src parameter of an <img> to display it
  43118. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43119. * Check your browser for supported MIME types
  43120. * @param samples Texture samples (default: 1)
  43121. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43122. * @param fileName A name for for the downloaded file.
  43123. */
  43124. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43125. /**
  43126. * Generates an image screenshot from the specified camera.
  43127. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43128. * @param engine The engine to use for rendering
  43129. * @param camera The camera to use for rendering
  43130. * @param size This parameter can be set to a single number or to an object with the
  43131. * following (optional) properties: precision, width, height. If a single number is passed,
  43132. * it will be used for both width and height. If an object is passed, the screenshot size
  43133. * will be derived from the parameters. The precision property is a multiplier allowing
  43134. * rendering at a higher or lower resolution
  43135. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43136. * Check your browser for supported MIME types
  43137. * @param samples Texture samples (default: 1)
  43138. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43139. * @param fileName A name for for the downloaded file.
  43140. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43141. * to the src parameter of an <img> to display it
  43142. */
  43143. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43144. /**
  43145. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43146. * Be aware Math.random() could cause collisions, but:
  43147. * "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"
  43148. * @returns a pseudo random id
  43149. */
  43150. static RandomId(): string;
  43151. /**
  43152. * Test if the given uri is a base64 string
  43153. * @param uri The uri to test
  43154. * @return True if the uri is a base64 string or false otherwise
  43155. */
  43156. static IsBase64(uri: string): boolean;
  43157. /**
  43158. * Decode the given base64 uri.
  43159. * @param uri The uri to decode
  43160. * @return The decoded base64 data.
  43161. */
  43162. static DecodeBase64(uri: string): ArrayBuffer;
  43163. /**
  43164. * Gets the absolute url.
  43165. * @param url the input url
  43166. * @return the absolute url
  43167. */
  43168. static GetAbsoluteUrl(url: string): string;
  43169. /**
  43170. * No log
  43171. */
  43172. static readonly NoneLogLevel: number;
  43173. /**
  43174. * Only message logs
  43175. */
  43176. static readonly MessageLogLevel: number;
  43177. /**
  43178. * Only warning logs
  43179. */
  43180. static readonly WarningLogLevel: number;
  43181. /**
  43182. * Only error logs
  43183. */
  43184. static readonly ErrorLogLevel: number;
  43185. /**
  43186. * All logs
  43187. */
  43188. static readonly AllLogLevel: number;
  43189. /**
  43190. * Gets a value indicating the number of loading errors
  43191. * @ignorenaming
  43192. */
  43193. static get errorsCount(): number;
  43194. /**
  43195. * Callback called when a new log is added
  43196. */
  43197. static OnNewCacheEntry: (entry: string) => void;
  43198. /**
  43199. * Log a message to the console
  43200. * @param message defines the message to log
  43201. */
  43202. static Log(message: string): void;
  43203. /**
  43204. * Write a warning message to the console
  43205. * @param message defines the message to log
  43206. */
  43207. static Warn(message: string): void;
  43208. /**
  43209. * Write an error message to the console
  43210. * @param message defines the message to log
  43211. */
  43212. static Error(message: string): void;
  43213. /**
  43214. * Gets current log cache (list of logs)
  43215. */
  43216. static get LogCache(): string;
  43217. /**
  43218. * Clears the log cache
  43219. */
  43220. static ClearLogCache(): void;
  43221. /**
  43222. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43223. */
  43224. static set LogLevels(level: number);
  43225. /**
  43226. * Checks if the window object exists
  43227. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43228. */
  43229. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43230. /**
  43231. * No performance log
  43232. */
  43233. static readonly PerformanceNoneLogLevel: number;
  43234. /**
  43235. * Use user marks to log performance
  43236. */
  43237. static readonly PerformanceUserMarkLogLevel: number;
  43238. /**
  43239. * Log performance to the console
  43240. */
  43241. static readonly PerformanceConsoleLogLevel: number;
  43242. private static _performance;
  43243. /**
  43244. * Sets the current performance log level
  43245. */
  43246. static set PerformanceLogLevel(level: number);
  43247. private static _StartPerformanceCounterDisabled;
  43248. private static _EndPerformanceCounterDisabled;
  43249. private static _StartUserMark;
  43250. private static _EndUserMark;
  43251. private static _StartPerformanceConsole;
  43252. private static _EndPerformanceConsole;
  43253. /**
  43254. * Starts a performance counter
  43255. */
  43256. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43257. /**
  43258. * Ends a specific performance coutner
  43259. */
  43260. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43261. /**
  43262. * Gets either window.performance.now() if supported or Date.now() else
  43263. */
  43264. static get Now(): number;
  43265. /**
  43266. * This method will return the name of the class used to create the instance of the given object.
  43267. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43268. * @param object the object to get the class name from
  43269. * @param isType defines if the object is actually a type
  43270. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43271. */
  43272. static GetClassName(object: any, isType?: boolean): string;
  43273. /**
  43274. * Gets the first element of an array satisfying a given predicate
  43275. * @param array defines the array to browse
  43276. * @param predicate defines the predicate to use
  43277. * @returns null if not found or the element
  43278. */
  43279. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43280. /**
  43281. * This method will return the name of the full name of the class, including its owning module (if any).
  43282. * 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).
  43283. * @param object the object to get the class name from
  43284. * @param isType defines if the object is actually a type
  43285. * @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.
  43286. * @ignorenaming
  43287. */
  43288. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43289. /**
  43290. * Returns a promise that resolves after the given amount of time.
  43291. * @param delay Number of milliseconds to delay
  43292. * @returns Promise that resolves after the given amount of time
  43293. */
  43294. static DelayAsync(delay: number): Promise<void>;
  43295. /**
  43296. * Utility function to detect if the current user agent is Safari
  43297. * @returns whether or not the current user agent is safari
  43298. */
  43299. static IsSafari(): boolean;
  43300. }
  43301. /**
  43302. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43303. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43304. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43305. * @param name The name of the class, case should be preserved
  43306. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43307. */
  43308. export function className(name: string, module?: string): (target: Object) => void;
  43309. /**
  43310. * An implementation of a loop for asynchronous functions.
  43311. */
  43312. export class AsyncLoop {
  43313. /**
  43314. * Defines the number of iterations for the loop
  43315. */
  43316. iterations: number;
  43317. /**
  43318. * Defines the current index of the loop.
  43319. */
  43320. index: number;
  43321. private _done;
  43322. private _fn;
  43323. private _successCallback;
  43324. /**
  43325. * Constructor.
  43326. * @param iterations the number of iterations.
  43327. * @param func the function to run each iteration
  43328. * @param successCallback the callback that will be called upon succesful execution
  43329. * @param offset starting offset.
  43330. */
  43331. constructor(
  43332. /**
  43333. * Defines the number of iterations for the loop
  43334. */
  43335. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43336. /**
  43337. * Execute the next iteration. Must be called after the last iteration was finished.
  43338. */
  43339. executeNext(): void;
  43340. /**
  43341. * Break the loop and run the success callback.
  43342. */
  43343. breakLoop(): void;
  43344. /**
  43345. * Create and run an async loop.
  43346. * @param iterations the number of iterations.
  43347. * @param fn the function to run each iteration
  43348. * @param successCallback the callback that will be called upon succesful execution
  43349. * @param offset starting offset.
  43350. * @returns the created async loop object
  43351. */
  43352. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43353. /**
  43354. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43355. * @param iterations total number of iterations
  43356. * @param syncedIterations number of synchronous iterations in each async iteration.
  43357. * @param fn the function to call each iteration.
  43358. * @param callback a success call back that will be called when iterating stops.
  43359. * @param breakFunction a break condition (optional)
  43360. * @param timeout timeout settings for the setTimeout function. default - 0.
  43361. * @returns the created async loop object
  43362. */
  43363. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43364. }
  43365. }
  43366. declare module "babylonjs/Misc/stringDictionary" {
  43367. import { Nullable } from "babylonjs/types";
  43368. /**
  43369. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43370. * The underlying implementation relies on an associative array to ensure the best performances.
  43371. * The value can be anything including 'null' but except 'undefined'
  43372. */
  43373. export class StringDictionary<T> {
  43374. /**
  43375. * This will clear this dictionary and copy the content from the 'source' one.
  43376. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43377. * @param source the dictionary to take the content from and copy to this dictionary
  43378. */
  43379. copyFrom(source: StringDictionary<T>): void;
  43380. /**
  43381. * Get a value based from its key
  43382. * @param key the given key to get the matching value from
  43383. * @return the value if found, otherwise undefined is returned
  43384. */
  43385. get(key: string): T | undefined;
  43386. /**
  43387. * Get a value from its key or add it if it doesn't exist.
  43388. * This method will ensure you that a given key/data will be present in the dictionary.
  43389. * @param key the given key to get the matching value from
  43390. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43391. * The factory will only be invoked if there's no data for the given key.
  43392. * @return the value corresponding to the key.
  43393. */
  43394. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43395. /**
  43396. * Get a value from its key if present in the dictionary otherwise add it
  43397. * @param key the key to get the value from
  43398. * @param val if there's no such key/value pair in the dictionary add it with this value
  43399. * @return the value corresponding to the key
  43400. */
  43401. getOrAdd(key: string, val: T): T;
  43402. /**
  43403. * Check if there's a given key in the dictionary
  43404. * @param key the key to check for
  43405. * @return true if the key is present, false otherwise
  43406. */
  43407. contains(key: string): boolean;
  43408. /**
  43409. * Add a new key and its corresponding value
  43410. * @param key the key to add
  43411. * @param value the value corresponding to the key
  43412. * @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
  43413. */
  43414. add(key: string, value: T): boolean;
  43415. /**
  43416. * Update a specific value associated to a key
  43417. * @param key defines the key to use
  43418. * @param value defines the value to store
  43419. * @returns true if the value was updated (or false if the key was not found)
  43420. */
  43421. set(key: string, value: T): boolean;
  43422. /**
  43423. * Get the element of the given key and remove it from the dictionary
  43424. * @param key defines the key to search
  43425. * @returns the value associated with the key or null if not found
  43426. */
  43427. getAndRemove(key: string): Nullable<T>;
  43428. /**
  43429. * Remove a key/value from the dictionary.
  43430. * @param key the key to remove
  43431. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43432. */
  43433. remove(key: string): boolean;
  43434. /**
  43435. * Clear the whole content of the dictionary
  43436. */
  43437. clear(): void;
  43438. /**
  43439. * Gets the current count
  43440. */
  43441. get count(): number;
  43442. /**
  43443. * Execute a callback on each key/val of the dictionary.
  43444. * Note that you can remove any element in this dictionary in the callback implementation
  43445. * @param callback the callback to execute on a given key/value pair
  43446. */
  43447. forEach(callback: (key: string, val: T) => void): void;
  43448. /**
  43449. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43450. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43451. * Note that you can remove any element in this dictionary in the callback implementation
  43452. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43453. * @returns the first item
  43454. */
  43455. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43456. private _count;
  43457. private _data;
  43458. }
  43459. }
  43460. declare module "babylonjs/Collisions/collisionCoordinator" {
  43461. import { Nullable } from "babylonjs/types";
  43462. import { Scene } from "babylonjs/scene";
  43463. import { Vector3 } from "babylonjs/Maths/math.vector";
  43464. import { Collider } from "babylonjs/Collisions/collider";
  43465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43466. /** @hidden */
  43467. export interface ICollisionCoordinator {
  43468. createCollider(): Collider;
  43469. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43470. init(scene: Scene): void;
  43471. }
  43472. /** @hidden */
  43473. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43474. private _scene;
  43475. private _scaledPosition;
  43476. private _scaledVelocity;
  43477. private _finalPosition;
  43478. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43479. createCollider(): Collider;
  43480. init(scene: Scene): void;
  43481. private _collideWithWorld;
  43482. }
  43483. }
  43484. declare module "babylonjs/Inputs/scene.inputManager" {
  43485. import { Nullable } from "babylonjs/types";
  43486. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43487. import { Vector2 } from "babylonjs/Maths/math.vector";
  43488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43489. import { Scene } from "babylonjs/scene";
  43490. /**
  43491. * Class used to manage all inputs for the scene.
  43492. */
  43493. export class InputManager {
  43494. /** The distance in pixel that you have to move to prevent some events */
  43495. static DragMovementThreshold: number;
  43496. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43497. static LongPressDelay: number;
  43498. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43499. static DoubleClickDelay: number;
  43500. /** If you need to check double click without raising a single click at first click, enable this flag */
  43501. static ExclusiveDoubleClickMode: boolean;
  43502. /** 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. */
  43503. private _alreadyAttached;
  43504. private _alreadyAttachedTo;
  43505. private _wheelEventName;
  43506. private _onPointerMove;
  43507. private _onPointerDown;
  43508. private _onPointerUp;
  43509. private _initClickEvent;
  43510. private _initActionManager;
  43511. private _delayedSimpleClick;
  43512. private _delayedSimpleClickTimeout;
  43513. private _previousDelayedSimpleClickTimeout;
  43514. private _meshPickProceed;
  43515. private _previousButtonPressed;
  43516. private _currentPickResult;
  43517. private _previousPickResult;
  43518. private _totalPointersPressed;
  43519. private _doubleClickOccured;
  43520. private _pointerOverMesh;
  43521. private _pickedDownMesh;
  43522. private _pickedUpMesh;
  43523. private _pointerX;
  43524. private _pointerY;
  43525. private _unTranslatedPointerX;
  43526. private _unTranslatedPointerY;
  43527. private _startingPointerPosition;
  43528. private _previousStartingPointerPosition;
  43529. private _startingPointerTime;
  43530. private _previousStartingPointerTime;
  43531. private _pointerCaptures;
  43532. private _meshUnderPointerId;
  43533. private _onKeyDown;
  43534. private _onKeyUp;
  43535. private _keyboardIsAttached;
  43536. private _onCanvasFocusObserver;
  43537. private _onCanvasBlurObserver;
  43538. private _scene;
  43539. /**
  43540. * Creates a new InputManager
  43541. * @param scene defines the hosting scene
  43542. */
  43543. constructor(scene: Scene);
  43544. /**
  43545. * Gets the mesh that is currently under the pointer
  43546. */
  43547. get meshUnderPointer(): Nullable<AbstractMesh>;
  43548. /**
  43549. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43550. * @param pointerId the pointer id to use
  43551. * @returns The mesh under this pointer id or null if not found
  43552. */
  43553. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43554. /**
  43555. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43556. */
  43557. get unTranslatedPointer(): Vector2;
  43558. /**
  43559. * Gets or sets the current on-screen X position of the pointer
  43560. */
  43561. get pointerX(): number;
  43562. set pointerX(value: number);
  43563. /**
  43564. * Gets or sets the current on-screen Y position of the pointer
  43565. */
  43566. get pointerY(): number;
  43567. set pointerY(value: number);
  43568. private _updatePointerPosition;
  43569. private _processPointerMove;
  43570. private _setRayOnPointerInfo;
  43571. private _checkPrePointerObservable;
  43572. /**
  43573. * Use this method to simulate a pointer move on a mesh
  43574. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43575. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43576. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43577. */
  43578. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43579. /**
  43580. * Use this method to simulate a pointer down on a mesh
  43581. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43582. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43583. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43584. */
  43585. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43586. private _processPointerDown;
  43587. /** @hidden */
  43588. _isPointerSwiping(): boolean;
  43589. /**
  43590. * Use this method to simulate a pointer up on a mesh
  43591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43594. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43595. */
  43596. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43597. private _processPointerUp;
  43598. /**
  43599. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43600. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43601. * @returns true if the pointer was captured
  43602. */
  43603. isPointerCaptured(pointerId?: number): boolean;
  43604. /**
  43605. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43606. * @param attachUp defines if you want to attach events to pointerup
  43607. * @param attachDown defines if you want to attach events to pointerdown
  43608. * @param attachMove defines if you want to attach events to pointermove
  43609. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43610. */
  43611. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43612. /**
  43613. * Detaches all event handlers
  43614. */
  43615. detachControl(): void;
  43616. /**
  43617. * Force the value of meshUnderPointer
  43618. * @param mesh defines the mesh to use
  43619. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43620. */
  43621. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43622. /**
  43623. * Gets the mesh under the pointer
  43624. * @returns a Mesh or null if no mesh is under the pointer
  43625. */
  43626. getPointerOverMesh(): Nullable<AbstractMesh>;
  43627. }
  43628. }
  43629. declare module "babylonjs/Animations/animationGroup" {
  43630. import { Animatable } from "babylonjs/Animations/animatable";
  43631. import { Animation } from "babylonjs/Animations/animation";
  43632. import { Scene, IDisposable } from "babylonjs/scene";
  43633. import { Observable } from "babylonjs/Misc/observable";
  43634. import { Nullable } from "babylonjs/types";
  43635. import "babylonjs/Animations/animatable";
  43636. /**
  43637. * This class defines the direct association between an animation and a target
  43638. */
  43639. export class TargetedAnimation {
  43640. /**
  43641. * Animation to perform
  43642. */
  43643. animation: Animation;
  43644. /**
  43645. * Target to animate
  43646. */
  43647. target: any;
  43648. /**
  43649. * Returns the string "TargetedAnimation"
  43650. * @returns "TargetedAnimation"
  43651. */
  43652. getClassName(): string;
  43653. /**
  43654. * Serialize the object
  43655. * @returns the JSON object representing the current entity
  43656. */
  43657. serialize(): any;
  43658. }
  43659. /**
  43660. * Use this class to create coordinated animations on multiple targets
  43661. */
  43662. export class AnimationGroup implements IDisposable {
  43663. /** The name of the animation group */
  43664. name: string;
  43665. private _scene;
  43666. private _targetedAnimations;
  43667. private _animatables;
  43668. private _from;
  43669. private _to;
  43670. private _isStarted;
  43671. private _isPaused;
  43672. private _speedRatio;
  43673. private _loopAnimation;
  43674. private _isAdditive;
  43675. /**
  43676. * Gets or sets the unique id of the node
  43677. */
  43678. uniqueId: number;
  43679. /**
  43680. * This observable will notify when one animation have ended
  43681. */
  43682. onAnimationEndObservable: Observable<TargetedAnimation>;
  43683. /**
  43684. * Observer raised when one animation loops
  43685. */
  43686. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43687. /**
  43688. * Observer raised when all animations have looped
  43689. */
  43690. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43691. /**
  43692. * This observable will notify when all animations have ended.
  43693. */
  43694. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43695. /**
  43696. * This observable will notify when all animations have paused.
  43697. */
  43698. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43699. /**
  43700. * This observable will notify when all animations are playing.
  43701. */
  43702. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43703. /**
  43704. * Gets the first frame
  43705. */
  43706. get from(): number;
  43707. /**
  43708. * Gets the last frame
  43709. */
  43710. get to(): number;
  43711. /**
  43712. * Define if the animations are started
  43713. */
  43714. get isStarted(): boolean;
  43715. /**
  43716. * Gets a value indicating that the current group is playing
  43717. */
  43718. get isPlaying(): boolean;
  43719. /**
  43720. * Gets or sets the speed ratio to use for all animations
  43721. */
  43722. get speedRatio(): number;
  43723. /**
  43724. * Gets or sets the speed ratio to use for all animations
  43725. */
  43726. set speedRatio(value: number);
  43727. /**
  43728. * Gets or sets if all animations should loop or not
  43729. */
  43730. get loopAnimation(): boolean;
  43731. set loopAnimation(value: boolean);
  43732. /**
  43733. * Gets or sets if all animations should be evaluated additively
  43734. */
  43735. get isAdditive(): boolean;
  43736. set isAdditive(value: boolean);
  43737. /**
  43738. * Gets the targeted animations for this animation group
  43739. */
  43740. get targetedAnimations(): Array<TargetedAnimation>;
  43741. /**
  43742. * returning the list of animatables controlled by this animation group.
  43743. */
  43744. get animatables(): Array<Animatable>;
  43745. /**
  43746. * Gets the list of target animations
  43747. */
  43748. get children(): TargetedAnimation[];
  43749. /**
  43750. * Instantiates a new Animation Group.
  43751. * This helps managing several animations at once.
  43752. * @see https://doc.babylonjs.com/how_to/group
  43753. * @param name Defines the name of the group
  43754. * @param scene Defines the scene the group belongs to
  43755. */
  43756. constructor(
  43757. /** The name of the animation group */
  43758. name: string, scene?: Nullable<Scene>);
  43759. /**
  43760. * Add an animation (with its target) in the group
  43761. * @param animation defines the animation we want to add
  43762. * @param target defines the target of the animation
  43763. * @returns the TargetedAnimation object
  43764. */
  43765. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43766. /**
  43767. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43768. * It can add constant keys at begin or end
  43769. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43770. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43771. * @returns the animation group
  43772. */
  43773. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43774. private _animationLoopCount;
  43775. private _animationLoopFlags;
  43776. private _processLoop;
  43777. /**
  43778. * Start all animations on given targets
  43779. * @param loop defines if animations must loop
  43780. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43781. * @param from defines the from key (optional)
  43782. * @param to defines the to key (optional)
  43783. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43784. * @returns the current animation group
  43785. */
  43786. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43787. /**
  43788. * Pause all animations
  43789. * @returns the animation group
  43790. */
  43791. pause(): AnimationGroup;
  43792. /**
  43793. * Play all animations to initial state
  43794. * This function will start() the animations if they were not started or will restart() them if they were paused
  43795. * @param loop defines if animations must loop
  43796. * @returns the animation group
  43797. */
  43798. play(loop?: boolean): AnimationGroup;
  43799. /**
  43800. * Reset all animations to initial state
  43801. * @returns the animation group
  43802. */
  43803. reset(): AnimationGroup;
  43804. /**
  43805. * Restart animations from key 0
  43806. * @returns the animation group
  43807. */
  43808. restart(): AnimationGroup;
  43809. /**
  43810. * Stop all animations
  43811. * @returns the animation group
  43812. */
  43813. stop(): AnimationGroup;
  43814. /**
  43815. * Set animation weight for all animatables
  43816. * @param weight defines the weight to use
  43817. * @return the animationGroup
  43818. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43819. */
  43820. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43821. /**
  43822. * Synchronize and normalize all animatables with a source animatable
  43823. * @param root defines the root animatable to synchronize with
  43824. * @return the animationGroup
  43825. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43826. */
  43827. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43828. /**
  43829. * Goes to a specific frame in this animation group
  43830. * @param frame the frame number to go to
  43831. * @return the animationGroup
  43832. */
  43833. goToFrame(frame: number): AnimationGroup;
  43834. /**
  43835. * Dispose all associated resources
  43836. */
  43837. dispose(): void;
  43838. private _checkAnimationGroupEnded;
  43839. /**
  43840. * Clone the current animation group and returns a copy
  43841. * @param newName defines the name of the new group
  43842. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43843. * @returns the new aniamtion group
  43844. */
  43845. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43846. /**
  43847. * Serializes the animationGroup to an object
  43848. * @returns Serialized object
  43849. */
  43850. serialize(): any;
  43851. /**
  43852. * Returns a new AnimationGroup object parsed from the source provided.
  43853. * @param parsedAnimationGroup defines the source
  43854. * @param scene defines the scene that will receive the animationGroup
  43855. * @returns a new AnimationGroup
  43856. */
  43857. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43858. /**
  43859. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43860. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43861. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43862. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43863. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43864. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43865. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43866. */
  43867. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43868. /**
  43869. * Returns the string "AnimationGroup"
  43870. * @returns "AnimationGroup"
  43871. */
  43872. getClassName(): string;
  43873. /**
  43874. * Creates a detailled string about the object
  43875. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43876. * @returns a string representing the object
  43877. */
  43878. toString(fullDetails?: boolean): string;
  43879. }
  43880. }
  43881. declare module "babylonjs/scene" {
  43882. import { Nullable } from "babylonjs/types";
  43883. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43884. import { Observable } from "babylonjs/Misc/observable";
  43885. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43886. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43887. import { Geometry } from "babylonjs/Meshes/geometry";
  43888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43889. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43891. import { Mesh } from "babylonjs/Meshes/mesh";
  43892. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43893. import { Bone } from "babylonjs/Bones/bone";
  43894. import { Skeleton } from "babylonjs/Bones/skeleton";
  43895. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43896. import { Camera } from "babylonjs/Cameras/camera";
  43897. import { AbstractScene } from "babylonjs/abstractScene";
  43898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43899. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43900. import { Material } from "babylonjs/Materials/material";
  43901. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43902. import { Effect } from "babylonjs/Materials/effect";
  43903. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43904. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43905. import { Light } from "babylonjs/Lights/light";
  43906. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43907. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43908. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43909. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43910. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43911. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43912. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43913. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43914. import { Engine } from "babylonjs/Engines/engine";
  43915. import { Node } from "babylonjs/node";
  43916. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43917. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43918. import { WebRequest } from "babylonjs/Misc/webRequest";
  43919. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43920. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43921. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43922. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43923. import { Plane } from "babylonjs/Maths/math.plane";
  43924. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43925. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43926. import { Ray } from "babylonjs/Culling/ray";
  43927. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43928. import { Animation } from "babylonjs/Animations/animation";
  43929. import { Animatable } from "babylonjs/Animations/animatable";
  43930. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43931. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43932. import { Collider } from "babylonjs/Collisions/collider";
  43933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43934. /**
  43935. * Define an interface for all classes that will hold resources
  43936. */
  43937. export interface IDisposable {
  43938. /**
  43939. * Releases all held resources
  43940. */
  43941. dispose(): void;
  43942. }
  43943. /** Interface defining initialization parameters for Scene class */
  43944. export interface SceneOptions {
  43945. /**
  43946. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43947. * It will improve performance when the number of geometries becomes important.
  43948. */
  43949. useGeometryUniqueIdsMap?: boolean;
  43950. /**
  43951. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43952. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43953. */
  43954. useMaterialMeshMap?: boolean;
  43955. /**
  43956. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43957. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43958. */
  43959. useClonedMeshMap?: boolean;
  43960. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43961. virtual?: boolean;
  43962. }
  43963. /**
  43964. * Represents a scene to be rendered by the engine.
  43965. * @see https://doc.babylonjs.com/features/scene
  43966. */
  43967. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43968. /** The fog is deactivated */
  43969. static readonly FOGMODE_NONE: number;
  43970. /** The fog density is following an exponential function */
  43971. static readonly FOGMODE_EXP: number;
  43972. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43973. static readonly FOGMODE_EXP2: number;
  43974. /** The fog density is following a linear function. */
  43975. static readonly FOGMODE_LINEAR: number;
  43976. /**
  43977. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43978. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43979. */
  43980. static MinDeltaTime: number;
  43981. /**
  43982. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43984. */
  43985. static MaxDeltaTime: number;
  43986. /**
  43987. * Factory used to create the default material.
  43988. * @param name The name of the material to create
  43989. * @param scene The scene to create the material for
  43990. * @returns The default material
  43991. */
  43992. static DefaultMaterialFactory(scene: Scene): Material;
  43993. /**
  43994. * Factory used to create the a collision coordinator.
  43995. * @returns The collision coordinator
  43996. */
  43997. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43998. /** @hidden */
  43999. _inputManager: InputManager;
  44000. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44001. cameraToUseForPointers: Nullable<Camera>;
  44002. /** @hidden */
  44003. readonly _isScene: boolean;
  44004. /** @hidden */
  44005. _blockEntityCollection: boolean;
  44006. /**
  44007. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44008. */
  44009. autoClear: boolean;
  44010. /**
  44011. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44012. */
  44013. autoClearDepthAndStencil: boolean;
  44014. /**
  44015. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44016. */
  44017. clearColor: Color4;
  44018. /**
  44019. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44020. */
  44021. ambientColor: Color3;
  44022. /**
  44023. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44024. * It should only be one of the following (if not the default embedded one):
  44025. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44026. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44027. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44028. * The material properties need to be setup according to the type of texture in use.
  44029. */
  44030. environmentBRDFTexture: BaseTexture;
  44031. /**
  44032. * Texture used in all pbr material as the reflection texture.
  44033. * As in the majority of the scene they are the same (exception for multi room and so on),
  44034. * this is easier to reference from here than from all the materials.
  44035. */
  44036. get environmentTexture(): Nullable<BaseTexture>;
  44037. /**
  44038. * Texture used in all pbr material as the reflection texture.
  44039. * As in the majority of the scene they are the same (exception for multi room and so on),
  44040. * this is easier to set here than in all the materials.
  44041. */
  44042. set environmentTexture(value: Nullable<BaseTexture>);
  44043. /** @hidden */
  44044. protected _environmentIntensity: number;
  44045. /**
  44046. * Intensity of the environment in all pbr material.
  44047. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44048. * As in the majority of the scene they are the same (exception for multi room and so on),
  44049. * this is easier to reference from here than from all the materials.
  44050. */
  44051. get environmentIntensity(): number;
  44052. /**
  44053. * Intensity of the environment in all pbr material.
  44054. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44055. * As in the majority of the scene they are the same (exception for multi room and so on),
  44056. * this is easier to set here than in all the materials.
  44057. */
  44058. set environmentIntensity(value: number);
  44059. /** @hidden */
  44060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44061. /**
  44062. * Default image processing configuration used either in the rendering
  44063. * Forward main pass or through the imageProcessingPostProcess if present.
  44064. * As in the majority of the scene they are the same (exception for multi camera),
  44065. * this is easier to reference from here than from all the materials and post process.
  44066. *
  44067. * No setter as we it is a shared configuration, you can set the values instead.
  44068. */
  44069. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44070. private _forceWireframe;
  44071. /**
  44072. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44073. */
  44074. set forceWireframe(value: boolean);
  44075. get forceWireframe(): boolean;
  44076. private _skipFrustumClipping;
  44077. /**
  44078. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44079. */
  44080. set skipFrustumClipping(value: boolean);
  44081. get skipFrustumClipping(): boolean;
  44082. private _forcePointsCloud;
  44083. /**
  44084. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44085. */
  44086. set forcePointsCloud(value: boolean);
  44087. get forcePointsCloud(): boolean;
  44088. /**
  44089. * Gets or sets the active clipplane 1
  44090. */
  44091. clipPlane: Nullable<Plane>;
  44092. /**
  44093. * Gets or sets the active clipplane 2
  44094. */
  44095. clipPlane2: Nullable<Plane>;
  44096. /**
  44097. * Gets or sets the active clipplane 3
  44098. */
  44099. clipPlane3: Nullable<Plane>;
  44100. /**
  44101. * Gets or sets the active clipplane 4
  44102. */
  44103. clipPlane4: Nullable<Plane>;
  44104. /**
  44105. * Gets or sets the active clipplane 5
  44106. */
  44107. clipPlane5: Nullable<Plane>;
  44108. /**
  44109. * Gets or sets the active clipplane 6
  44110. */
  44111. clipPlane6: Nullable<Plane>;
  44112. /**
  44113. * Gets or sets a boolean indicating if animations are enabled
  44114. */
  44115. animationsEnabled: boolean;
  44116. private _animationPropertiesOverride;
  44117. /**
  44118. * Gets or sets the animation properties override
  44119. */
  44120. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44121. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44122. /**
  44123. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44124. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44125. */
  44126. useConstantAnimationDeltaTime: boolean;
  44127. /**
  44128. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44129. * Please note that it requires to run a ray cast through the scene on every frame
  44130. */
  44131. constantlyUpdateMeshUnderPointer: boolean;
  44132. /**
  44133. * Defines the HTML cursor to use when hovering over interactive elements
  44134. */
  44135. hoverCursor: string;
  44136. /**
  44137. * Defines the HTML default cursor to use (empty by default)
  44138. */
  44139. defaultCursor: string;
  44140. /**
  44141. * Defines whether cursors are handled by the scene.
  44142. */
  44143. doNotHandleCursors: boolean;
  44144. /**
  44145. * This is used to call preventDefault() on pointer down
  44146. * in order to block unwanted artifacts like system double clicks
  44147. */
  44148. preventDefaultOnPointerDown: boolean;
  44149. /**
  44150. * This is used to call preventDefault() on pointer up
  44151. * in order to block unwanted artifacts like system double clicks
  44152. */
  44153. preventDefaultOnPointerUp: boolean;
  44154. /**
  44155. * Gets or sets user defined metadata
  44156. */
  44157. metadata: any;
  44158. /**
  44159. * For internal use only. Please do not use.
  44160. */
  44161. reservedDataStore: any;
  44162. /**
  44163. * Gets the name of the plugin used to load this scene (null by default)
  44164. */
  44165. loadingPluginName: string;
  44166. /**
  44167. * Use this array to add regular expressions used to disable offline support for specific urls
  44168. */
  44169. disableOfflineSupportExceptionRules: RegExp[];
  44170. /**
  44171. * An event triggered when the scene is disposed.
  44172. */
  44173. onDisposeObservable: Observable<Scene>;
  44174. private _onDisposeObserver;
  44175. /** Sets a function to be executed when this scene is disposed. */
  44176. set onDispose(callback: () => void);
  44177. /**
  44178. * An event triggered before rendering the scene (right after animations and physics)
  44179. */
  44180. onBeforeRenderObservable: Observable<Scene>;
  44181. private _onBeforeRenderObserver;
  44182. /** Sets a function to be executed before rendering this scene */
  44183. set beforeRender(callback: Nullable<() => void>);
  44184. /**
  44185. * An event triggered after rendering the scene
  44186. */
  44187. onAfterRenderObservable: Observable<Scene>;
  44188. /**
  44189. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44190. */
  44191. onAfterRenderCameraObservable: Observable<Camera>;
  44192. private _onAfterRenderObserver;
  44193. /** Sets a function to be executed after rendering this scene */
  44194. set afterRender(callback: Nullable<() => void>);
  44195. /**
  44196. * An event triggered before animating the scene
  44197. */
  44198. onBeforeAnimationsObservable: Observable<Scene>;
  44199. /**
  44200. * An event triggered after animations processing
  44201. */
  44202. onAfterAnimationsObservable: Observable<Scene>;
  44203. /**
  44204. * An event triggered before draw calls are ready to be sent
  44205. */
  44206. onBeforeDrawPhaseObservable: Observable<Scene>;
  44207. /**
  44208. * An event triggered after draw calls have been sent
  44209. */
  44210. onAfterDrawPhaseObservable: Observable<Scene>;
  44211. /**
  44212. * An event triggered when the scene is ready
  44213. */
  44214. onReadyObservable: Observable<Scene>;
  44215. /**
  44216. * An event triggered before rendering a camera
  44217. */
  44218. onBeforeCameraRenderObservable: Observable<Camera>;
  44219. private _onBeforeCameraRenderObserver;
  44220. /** Sets a function to be executed before rendering a camera*/
  44221. set beforeCameraRender(callback: () => void);
  44222. /**
  44223. * An event triggered after rendering a camera
  44224. */
  44225. onAfterCameraRenderObservable: Observable<Camera>;
  44226. private _onAfterCameraRenderObserver;
  44227. /** Sets a function to be executed after rendering a camera*/
  44228. set afterCameraRender(callback: () => void);
  44229. /**
  44230. * An event triggered when active meshes evaluation is about to start
  44231. */
  44232. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44233. /**
  44234. * An event triggered when active meshes evaluation is done
  44235. */
  44236. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44237. /**
  44238. * An event triggered when particles rendering is about to start
  44239. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44240. */
  44241. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44242. /**
  44243. * An event triggered when particles rendering is done
  44244. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44245. */
  44246. onAfterParticlesRenderingObservable: Observable<Scene>;
  44247. /**
  44248. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44249. */
  44250. onDataLoadedObservable: Observable<Scene>;
  44251. /**
  44252. * An event triggered when a camera is created
  44253. */
  44254. onNewCameraAddedObservable: Observable<Camera>;
  44255. /**
  44256. * An event triggered when a camera is removed
  44257. */
  44258. onCameraRemovedObservable: Observable<Camera>;
  44259. /**
  44260. * An event triggered when a light is created
  44261. */
  44262. onNewLightAddedObservable: Observable<Light>;
  44263. /**
  44264. * An event triggered when a light is removed
  44265. */
  44266. onLightRemovedObservable: Observable<Light>;
  44267. /**
  44268. * An event triggered when a geometry is created
  44269. */
  44270. onNewGeometryAddedObservable: Observable<Geometry>;
  44271. /**
  44272. * An event triggered when a geometry is removed
  44273. */
  44274. onGeometryRemovedObservable: Observable<Geometry>;
  44275. /**
  44276. * An event triggered when a transform node is created
  44277. */
  44278. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44279. /**
  44280. * An event triggered when a transform node is removed
  44281. */
  44282. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44283. /**
  44284. * An event triggered when a mesh is created
  44285. */
  44286. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44287. /**
  44288. * An event triggered when a mesh is removed
  44289. */
  44290. onMeshRemovedObservable: Observable<AbstractMesh>;
  44291. /**
  44292. * An event triggered when a skeleton is created
  44293. */
  44294. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44295. /**
  44296. * An event triggered when a skeleton is removed
  44297. */
  44298. onSkeletonRemovedObservable: Observable<Skeleton>;
  44299. /**
  44300. * An event triggered when a material is created
  44301. */
  44302. onNewMaterialAddedObservable: Observable<Material>;
  44303. /**
  44304. * An event triggered when a material is removed
  44305. */
  44306. onMaterialRemovedObservable: Observable<Material>;
  44307. /**
  44308. * An event triggered when a texture is created
  44309. */
  44310. onNewTextureAddedObservable: Observable<BaseTexture>;
  44311. /**
  44312. * An event triggered when a texture is removed
  44313. */
  44314. onTextureRemovedObservable: Observable<BaseTexture>;
  44315. /**
  44316. * An event triggered when render targets are about to be rendered
  44317. * Can happen multiple times per frame.
  44318. */
  44319. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44320. /**
  44321. * An event triggered when render targets were rendered.
  44322. * Can happen multiple times per frame.
  44323. */
  44324. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44325. /**
  44326. * An event triggered before calculating deterministic simulation step
  44327. */
  44328. onBeforeStepObservable: Observable<Scene>;
  44329. /**
  44330. * An event triggered after calculating deterministic simulation step
  44331. */
  44332. onAfterStepObservable: Observable<Scene>;
  44333. /**
  44334. * An event triggered when the activeCamera property is updated
  44335. */
  44336. onActiveCameraChanged: Observable<Scene>;
  44337. /**
  44338. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44339. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44340. * 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)
  44341. */
  44342. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44343. /**
  44344. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44345. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44346. * 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)
  44347. */
  44348. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44349. /**
  44350. * This Observable will when a mesh has been imported into the scene.
  44351. */
  44352. onMeshImportedObservable: Observable<AbstractMesh>;
  44353. /**
  44354. * This Observable will when an animation file has been imported into the scene.
  44355. */
  44356. onAnimationFileImportedObservable: Observable<Scene>;
  44357. /**
  44358. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44359. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44360. */
  44361. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44362. /** @hidden */
  44363. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44364. /**
  44365. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44366. */
  44367. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44368. /**
  44369. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44370. */
  44371. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44372. /**
  44373. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44374. */
  44375. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44376. /** Callback called when a pointer move is detected */
  44377. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44378. /** Callback called when a pointer down is detected */
  44379. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44380. /** Callback called when a pointer up is detected */
  44381. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44382. /** Callback called when a pointer pick is detected */
  44383. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44384. /**
  44385. * 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).
  44386. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44387. */
  44388. onPrePointerObservable: Observable<PointerInfoPre>;
  44389. /**
  44390. * Observable event triggered each time an input event is received from the rendering canvas
  44391. */
  44392. onPointerObservable: Observable<PointerInfo>;
  44393. /**
  44394. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44395. */
  44396. get unTranslatedPointer(): Vector2;
  44397. /**
  44398. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44399. */
  44400. static get DragMovementThreshold(): number;
  44401. static set DragMovementThreshold(value: number);
  44402. /**
  44403. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44404. */
  44405. static get LongPressDelay(): number;
  44406. static set LongPressDelay(value: number);
  44407. /**
  44408. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44409. */
  44410. static get DoubleClickDelay(): number;
  44411. static set DoubleClickDelay(value: number);
  44412. /** If you need to check double click without raising a single click at first click, enable this flag */
  44413. static get ExclusiveDoubleClickMode(): boolean;
  44414. static set ExclusiveDoubleClickMode(value: boolean);
  44415. /** @hidden */
  44416. _mirroredCameraPosition: Nullable<Vector3>;
  44417. /**
  44418. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44419. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44420. */
  44421. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44422. /**
  44423. * Observable event triggered each time an keyboard event is received from the hosting window
  44424. */
  44425. onKeyboardObservable: Observable<KeyboardInfo>;
  44426. private _useRightHandedSystem;
  44427. /**
  44428. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44429. */
  44430. set useRightHandedSystem(value: boolean);
  44431. get useRightHandedSystem(): boolean;
  44432. private _timeAccumulator;
  44433. private _currentStepId;
  44434. private _currentInternalStep;
  44435. /**
  44436. * Sets the step Id used by deterministic lock step
  44437. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44438. * @param newStepId defines the step Id
  44439. */
  44440. setStepId(newStepId: number): void;
  44441. /**
  44442. * Gets the step Id used by deterministic lock step
  44443. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44444. * @returns the step Id
  44445. */
  44446. getStepId(): number;
  44447. /**
  44448. * Gets the internal step used by deterministic lock step
  44449. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44450. * @returns the internal step
  44451. */
  44452. getInternalStep(): number;
  44453. private _fogEnabled;
  44454. /**
  44455. * Gets or sets a boolean indicating if fog is enabled on this scene
  44456. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44457. * (Default is true)
  44458. */
  44459. set fogEnabled(value: boolean);
  44460. get fogEnabled(): boolean;
  44461. private _fogMode;
  44462. /**
  44463. * Gets or sets the fog mode to use
  44464. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44465. * | mode | value |
  44466. * | --- | --- |
  44467. * | FOGMODE_NONE | 0 |
  44468. * | FOGMODE_EXP | 1 |
  44469. * | FOGMODE_EXP2 | 2 |
  44470. * | FOGMODE_LINEAR | 3 |
  44471. */
  44472. set fogMode(value: number);
  44473. get fogMode(): number;
  44474. /**
  44475. * Gets or sets the fog color to use
  44476. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44477. * (Default is Color3(0.2, 0.2, 0.3))
  44478. */
  44479. fogColor: Color3;
  44480. /**
  44481. * Gets or sets the fog density to use
  44482. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44483. * (Default is 0.1)
  44484. */
  44485. fogDensity: number;
  44486. /**
  44487. * Gets or sets the fog start distance to use
  44488. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44489. * (Default is 0)
  44490. */
  44491. fogStart: number;
  44492. /**
  44493. * Gets or sets the fog end distance to use
  44494. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44495. * (Default is 1000)
  44496. */
  44497. fogEnd: number;
  44498. /**
  44499. * Flag indicating that the frame buffer binding is handled by another component
  44500. */
  44501. prePass: boolean;
  44502. private _shadowsEnabled;
  44503. /**
  44504. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44505. */
  44506. set shadowsEnabled(value: boolean);
  44507. get shadowsEnabled(): boolean;
  44508. private _lightsEnabled;
  44509. /**
  44510. * Gets or sets a boolean indicating if lights are enabled on this scene
  44511. */
  44512. set lightsEnabled(value: boolean);
  44513. get lightsEnabled(): boolean;
  44514. /** All of the active cameras added to this scene. */
  44515. activeCameras: Camera[];
  44516. /** @hidden */
  44517. _activeCamera: Nullable<Camera>;
  44518. /** Gets or sets the current active camera */
  44519. get activeCamera(): Nullable<Camera>;
  44520. set activeCamera(value: Nullable<Camera>);
  44521. private _defaultMaterial;
  44522. /** The default material used on meshes when no material is affected */
  44523. get defaultMaterial(): Material;
  44524. /** The default material used on meshes when no material is affected */
  44525. set defaultMaterial(value: Material);
  44526. private _texturesEnabled;
  44527. /**
  44528. * Gets or sets a boolean indicating if textures are enabled on this scene
  44529. */
  44530. set texturesEnabled(value: boolean);
  44531. get texturesEnabled(): boolean;
  44532. /**
  44533. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44534. */
  44535. physicsEnabled: boolean;
  44536. /**
  44537. * Gets or sets a boolean indicating if particles are enabled on this scene
  44538. */
  44539. particlesEnabled: boolean;
  44540. /**
  44541. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44542. */
  44543. spritesEnabled: boolean;
  44544. private _skeletonsEnabled;
  44545. /**
  44546. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44547. */
  44548. set skeletonsEnabled(value: boolean);
  44549. get skeletonsEnabled(): boolean;
  44550. /**
  44551. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44552. */
  44553. lensFlaresEnabled: boolean;
  44554. /**
  44555. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44556. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44557. */
  44558. collisionsEnabled: boolean;
  44559. private _collisionCoordinator;
  44560. /** @hidden */
  44561. get collisionCoordinator(): ICollisionCoordinator;
  44562. /**
  44563. * Defines the gravity applied to this scene (used only for collisions)
  44564. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44565. */
  44566. gravity: Vector3;
  44567. /**
  44568. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44569. */
  44570. postProcessesEnabled: boolean;
  44571. /**
  44572. * Gets the current postprocess manager
  44573. */
  44574. postProcessManager: PostProcessManager;
  44575. /**
  44576. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44577. */
  44578. renderTargetsEnabled: boolean;
  44579. /**
  44580. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44581. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44582. */
  44583. dumpNextRenderTargets: boolean;
  44584. /**
  44585. * The list of user defined render targets added to the scene
  44586. */
  44587. customRenderTargets: RenderTargetTexture[];
  44588. /**
  44589. * Defines if texture loading must be delayed
  44590. * If true, textures will only be loaded when they need to be rendered
  44591. */
  44592. useDelayedTextureLoading: boolean;
  44593. /**
  44594. * Gets the list of meshes imported to the scene through SceneLoader
  44595. */
  44596. importedMeshesFiles: String[];
  44597. /**
  44598. * Gets or sets a boolean indicating if probes are enabled on this scene
  44599. */
  44600. probesEnabled: boolean;
  44601. /**
  44602. * Gets or sets the current offline provider to use to store scene data
  44603. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44604. */
  44605. offlineProvider: IOfflineProvider;
  44606. /**
  44607. * Gets or sets the action manager associated with the scene
  44608. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44609. */
  44610. actionManager: AbstractActionManager;
  44611. private _meshesForIntersections;
  44612. /**
  44613. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44614. */
  44615. proceduralTexturesEnabled: boolean;
  44616. private _engine;
  44617. private _totalVertices;
  44618. /** @hidden */
  44619. _activeIndices: PerfCounter;
  44620. /** @hidden */
  44621. _activeParticles: PerfCounter;
  44622. /** @hidden */
  44623. _activeBones: PerfCounter;
  44624. private _animationRatio;
  44625. /** @hidden */
  44626. _animationTimeLast: number;
  44627. /** @hidden */
  44628. _animationTime: number;
  44629. /**
  44630. * Gets or sets a general scale for animation speed
  44631. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44632. */
  44633. animationTimeScale: number;
  44634. /** @hidden */
  44635. _cachedMaterial: Nullable<Material>;
  44636. /** @hidden */
  44637. _cachedEffect: Nullable<Effect>;
  44638. /** @hidden */
  44639. _cachedVisibility: Nullable<number>;
  44640. private _renderId;
  44641. private _frameId;
  44642. private _executeWhenReadyTimeoutId;
  44643. private _intermediateRendering;
  44644. private _viewUpdateFlag;
  44645. private _projectionUpdateFlag;
  44646. /** @hidden */
  44647. _toBeDisposed: Nullable<IDisposable>[];
  44648. private _activeRequests;
  44649. /** @hidden */
  44650. _pendingData: any[];
  44651. private _isDisposed;
  44652. /**
  44653. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44654. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44655. */
  44656. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44657. private _activeMeshes;
  44658. private _processedMaterials;
  44659. private _renderTargets;
  44660. /** @hidden */
  44661. _activeParticleSystems: SmartArray<IParticleSystem>;
  44662. private _activeSkeletons;
  44663. private _softwareSkinnedMeshes;
  44664. private _renderingManager;
  44665. /** @hidden */
  44666. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44667. private _transformMatrix;
  44668. private _sceneUbo;
  44669. /** @hidden */
  44670. _viewMatrix: Matrix;
  44671. private _projectionMatrix;
  44672. /** @hidden */
  44673. _forcedViewPosition: Nullable<Vector3>;
  44674. /** @hidden */
  44675. _frustumPlanes: Plane[];
  44676. /**
  44677. * Gets the list of frustum planes (built from the active camera)
  44678. */
  44679. get frustumPlanes(): Plane[];
  44680. /**
  44681. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44682. * This is useful if there are more lights that the maximum simulteanous authorized
  44683. */
  44684. requireLightSorting: boolean;
  44685. /** @hidden */
  44686. readonly useMaterialMeshMap: boolean;
  44687. /** @hidden */
  44688. readonly useClonedMeshMap: boolean;
  44689. private _externalData;
  44690. private _uid;
  44691. /**
  44692. * @hidden
  44693. * Backing store of defined scene components.
  44694. */
  44695. _components: ISceneComponent[];
  44696. /**
  44697. * @hidden
  44698. * Backing store of defined scene components.
  44699. */
  44700. _serializableComponents: ISceneSerializableComponent[];
  44701. /**
  44702. * List of components to register on the next registration step.
  44703. */
  44704. private _transientComponents;
  44705. /**
  44706. * Registers the transient components if needed.
  44707. */
  44708. private _registerTransientComponents;
  44709. /**
  44710. * @hidden
  44711. * Add a component to the scene.
  44712. * Note that the ccomponent could be registered on th next frame if this is called after
  44713. * the register component stage.
  44714. * @param component Defines the component to add to the scene
  44715. */
  44716. _addComponent(component: ISceneComponent): void;
  44717. /**
  44718. * @hidden
  44719. * Gets a component from the scene.
  44720. * @param name defines the name of the component to retrieve
  44721. * @returns the component or null if not present
  44722. */
  44723. _getComponent(name: string): Nullable<ISceneComponent>;
  44724. /**
  44725. * @hidden
  44726. * Defines the actions happening before camera updates.
  44727. */
  44728. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44729. /**
  44730. * @hidden
  44731. * Defines the actions happening before clear the canvas.
  44732. */
  44733. _beforeClearStage: Stage<SimpleStageAction>;
  44734. /**
  44735. * @hidden
  44736. * Defines the actions when collecting render targets for the frame.
  44737. */
  44738. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44739. /**
  44740. * @hidden
  44741. * Defines the actions happening for one camera in the frame.
  44742. */
  44743. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44744. /**
  44745. * @hidden
  44746. * Defines the actions happening during the per mesh ready checks.
  44747. */
  44748. _isReadyForMeshStage: Stage<MeshStageAction>;
  44749. /**
  44750. * @hidden
  44751. * Defines the actions happening before evaluate active mesh checks.
  44752. */
  44753. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44754. /**
  44755. * @hidden
  44756. * Defines the actions happening during the evaluate sub mesh checks.
  44757. */
  44758. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44759. /**
  44760. * @hidden
  44761. * Defines the actions happening during the active mesh stage.
  44762. */
  44763. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44764. /**
  44765. * @hidden
  44766. * Defines the actions happening during the per camera render target step.
  44767. */
  44768. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44769. /**
  44770. * @hidden
  44771. * Defines the actions happening just before the active camera is drawing.
  44772. */
  44773. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44774. /**
  44775. * @hidden
  44776. * Defines the actions happening just before a render target is drawing.
  44777. */
  44778. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44779. /**
  44780. * @hidden
  44781. * Defines the actions happening just before a rendering group is drawing.
  44782. */
  44783. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44784. /**
  44785. * @hidden
  44786. * Defines the actions happening just before a mesh is drawing.
  44787. */
  44788. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44789. /**
  44790. * @hidden
  44791. * Defines the actions happening just after a mesh has been drawn.
  44792. */
  44793. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44794. /**
  44795. * @hidden
  44796. * Defines the actions happening just after a rendering group has been drawn.
  44797. */
  44798. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44799. /**
  44800. * @hidden
  44801. * Defines the actions happening just after the active camera has been drawn.
  44802. */
  44803. _afterCameraDrawStage: Stage<CameraStageAction>;
  44804. /**
  44805. * @hidden
  44806. * Defines the actions happening just after a render target has been drawn.
  44807. */
  44808. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44809. /**
  44810. * @hidden
  44811. * Defines the actions happening just after rendering all cameras and computing intersections.
  44812. */
  44813. _afterRenderStage: Stage<SimpleStageAction>;
  44814. /**
  44815. * @hidden
  44816. * Defines the actions happening when a pointer move event happens.
  44817. */
  44818. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44819. /**
  44820. * @hidden
  44821. * Defines the actions happening when a pointer down event happens.
  44822. */
  44823. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44824. /**
  44825. * @hidden
  44826. * Defines the actions happening when a pointer up event happens.
  44827. */
  44828. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44829. /**
  44830. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44831. */
  44832. private geometriesByUniqueId;
  44833. /**
  44834. * Creates a new Scene
  44835. * @param engine defines the engine to use to render this scene
  44836. * @param options defines the scene options
  44837. */
  44838. constructor(engine: Engine, options?: SceneOptions);
  44839. /**
  44840. * Gets a string identifying the name of the class
  44841. * @returns "Scene" string
  44842. */
  44843. getClassName(): string;
  44844. private _defaultMeshCandidates;
  44845. /**
  44846. * @hidden
  44847. */
  44848. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44849. private _defaultSubMeshCandidates;
  44850. /**
  44851. * @hidden
  44852. */
  44853. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44854. /**
  44855. * Sets the default candidate providers for the scene.
  44856. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44857. * and getCollidingSubMeshCandidates to their default function
  44858. */
  44859. setDefaultCandidateProviders(): void;
  44860. /**
  44861. * Gets the mesh that is currently under the pointer
  44862. */
  44863. get meshUnderPointer(): Nullable<AbstractMesh>;
  44864. /**
  44865. * Gets or sets the current on-screen X position of the pointer
  44866. */
  44867. get pointerX(): number;
  44868. set pointerX(value: number);
  44869. /**
  44870. * Gets or sets the current on-screen Y position of the pointer
  44871. */
  44872. get pointerY(): number;
  44873. set pointerY(value: number);
  44874. /**
  44875. * Gets the cached material (ie. the latest rendered one)
  44876. * @returns the cached material
  44877. */
  44878. getCachedMaterial(): Nullable<Material>;
  44879. /**
  44880. * Gets the cached effect (ie. the latest rendered one)
  44881. * @returns the cached effect
  44882. */
  44883. getCachedEffect(): Nullable<Effect>;
  44884. /**
  44885. * Gets the cached visibility state (ie. the latest rendered one)
  44886. * @returns the cached visibility state
  44887. */
  44888. getCachedVisibility(): Nullable<number>;
  44889. /**
  44890. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44891. * @param material defines the current material
  44892. * @param effect defines the current effect
  44893. * @param visibility defines the current visibility state
  44894. * @returns true if one parameter is not cached
  44895. */
  44896. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44897. /**
  44898. * Gets the engine associated with the scene
  44899. * @returns an Engine
  44900. */
  44901. getEngine(): Engine;
  44902. /**
  44903. * Gets the total number of vertices rendered per frame
  44904. * @returns the total number of vertices rendered per frame
  44905. */
  44906. getTotalVertices(): number;
  44907. /**
  44908. * Gets the performance counter for total vertices
  44909. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44910. */
  44911. get totalVerticesPerfCounter(): PerfCounter;
  44912. /**
  44913. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44914. * @returns the total number of active indices rendered per frame
  44915. */
  44916. getActiveIndices(): number;
  44917. /**
  44918. * Gets the performance counter for active indices
  44919. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44920. */
  44921. get totalActiveIndicesPerfCounter(): PerfCounter;
  44922. /**
  44923. * Gets the total number of active particles rendered per frame
  44924. * @returns the total number of active particles rendered per frame
  44925. */
  44926. getActiveParticles(): number;
  44927. /**
  44928. * Gets the performance counter for active particles
  44929. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44930. */
  44931. get activeParticlesPerfCounter(): PerfCounter;
  44932. /**
  44933. * Gets the total number of active bones rendered per frame
  44934. * @returns the total number of active bones rendered per frame
  44935. */
  44936. getActiveBones(): number;
  44937. /**
  44938. * Gets the performance counter for active bones
  44939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44940. */
  44941. get activeBonesPerfCounter(): PerfCounter;
  44942. /**
  44943. * Gets the array of active meshes
  44944. * @returns an array of AbstractMesh
  44945. */
  44946. getActiveMeshes(): SmartArray<AbstractMesh>;
  44947. /**
  44948. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44949. * @returns a number
  44950. */
  44951. getAnimationRatio(): number;
  44952. /**
  44953. * Gets an unique Id for the current render phase
  44954. * @returns a number
  44955. */
  44956. getRenderId(): number;
  44957. /**
  44958. * Gets an unique Id for the current frame
  44959. * @returns a number
  44960. */
  44961. getFrameId(): number;
  44962. /** Call this function if you want to manually increment the render Id*/
  44963. incrementRenderId(): void;
  44964. private _createUbo;
  44965. /**
  44966. * Use this method to simulate a pointer move on a mesh
  44967. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44968. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44969. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44970. * @returns the current scene
  44971. */
  44972. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44973. /**
  44974. * Use this method to simulate a pointer down on a mesh
  44975. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44976. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44977. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44978. * @returns the current scene
  44979. */
  44980. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44981. /**
  44982. * Use this method to simulate a pointer up on a mesh
  44983. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44984. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44985. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44986. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44987. * @returns the current scene
  44988. */
  44989. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44990. /**
  44991. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44992. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44993. * @returns true if the pointer was captured
  44994. */
  44995. isPointerCaptured(pointerId?: number): boolean;
  44996. /**
  44997. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44998. * @param attachUp defines if you want to attach events to pointerup
  44999. * @param attachDown defines if you want to attach events to pointerdown
  45000. * @param attachMove defines if you want to attach events to pointermove
  45001. */
  45002. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45003. /** Detaches all event handlers*/
  45004. detachControl(): void;
  45005. /**
  45006. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45007. * Delay loaded resources are not taking in account
  45008. * @return true if all required resources are ready
  45009. */
  45010. isReady(): boolean;
  45011. /** Resets all cached information relative to material (including effect and visibility) */
  45012. resetCachedMaterial(): void;
  45013. /**
  45014. * Registers a function to be called before every frame render
  45015. * @param func defines the function to register
  45016. */
  45017. registerBeforeRender(func: () => void): void;
  45018. /**
  45019. * Unregisters a function called before every frame render
  45020. * @param func defines the function to unregister
  45021. */
  45022. unregisterBeforeRender(func: () => void): void;
  45023. /**
  45024. * Registers a function to be called after every frame render
  45025. * @param func defines the function to register
  45026. */
  45027. registerAfterRender(func: () => void): void;
  45028. /**
  45029. * Unregisters a function called after every frame render
  45030. * @param func defines the function to unregister
  45031. */
  45032. unregisterAfterRender(func: () => void): void;
  45033. private _executeOnceBeforeRender;
  45034. /**
  45035. * The provided function will run before render once and will be disposed afterwards.
  45036. * A timeout delay can be provided so that the function will be executed in N ms.
  45037. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45038. * @param func The function to be executed.
  45039. * @param timeout optional delay in ms
  45040. */
  45041. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45042. /** @hidden */
  45043. _addPendingData(data: any): void;
  45044. /** @hidden */
  45045. _removePendingData(data: any): void;
  45046. /**
  45047. * Returns the number of items waiting to be loaded
  45048. * @returns the number of items waiting to be loaded
  45049. */
  45050. getWaitingItemsCount(): number;
  45051. /**
  45052. * Returns a boolean indicating if the scene is still loading data
  45053. */
  45054. get isLoading(): boolean;
  45055. /**
  45056. * Registers a function to be executed when the scene is ready
  45057. * @param {Function} func - the function to be executed
  45058. */
  45059. executeWhenReady(func: () => void): void;
  45060. /**
  45061. * Returns a promise that resolves when the scene is ready
  45062. * @returns A promise that resolves when the scene is ready
  45063. */
  45064. whenReadyAsync(): Promise<void>;
  45065. /** @hidden */
  45066. _checkIsReady(): void;
  45067. /**
  45068. * Gets all animatable attached to the scene
  45069. */
  45070. get animatables(): Animatable[];
  45071. /**
  45072. * Resets the last animation time frame.
  45073. * Useful to override when animations start running when loading a scene for the first time.
  45074. */
  45075. resetLastAnimationTimeFrame(): void;
  45076. /**
  45077. * Gets the current view matrix
  45078. * @returns a Matrix
  45079. */
  45080. getViewMatrix(): Matrix;
  45081. /**
  45082. * Gets the current projection matrix
  45083. * @returns a Matrix
  45084. */
  45085. getProjectionMatrix(): Matrix;
  45086. /**
  45087. * Gets the current transform matrix
  45088. * @returns a Matrix made of View * Projection
  45089. */
  45090. getTransformMatrix(): Matrix;
  45091. /**
  45092. * Sets the current transform matrix
  45093. * @param viewL defines the View matrix to use
  45094. * @param projectionL defines the Projection matrix to use
  45095. * @param viewR defines the right View matrix to use (if provided)
  45096. * @param projectionR defines the right Projection matrix to use (if provided)
  45097. */
  45098. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45099. /**
  45100. * Gets the uniform buffer used to store scene data
  45101. * @returns a UniformBuffer
  45102. */
  45103. getSceneUniformBuffer(): UniformBuffer;
  45104. /**
  45105. * Gets an unique (relatively to the current scene) Id
  45106. * @returns an unique number for the scene
  45107. */
  45108. getUniqueId(): number;
  45109. /**
  45110. * Add a mesh to the list of scene's meshes
  45111. * @param newMesh defines the mesh to add
  45112. * @param recursive if all child meshes should also be added to the scene
  45113. */
  45114. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45115. /**
  45116. * Remove a mesh for the list of scene's meshes
  45117. * @param toRemove defines the mesh to remove
  45118. * @param recursive if all child meshes should also be removed from the scene
  45119. * @returns the index where the mesh was in the mesh list
  45120. */
  45121. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45122. /**
  45123. * Add a transform node to the list of scene's transform nodes
  45124. * @param newTransformNode defines the transform node to add
  45125. */
  45126. addTransformNode(newTransformNode: TransformNode): void;
  45127. /**
  45128. * Remove a transform node for the list of scene's transform nodes
  45129. * @param toRemove defines the transform node to remove
  45130. * @returns the index where the transform node was in the transform node list
  45131. */
  45132. removeTransformNode(toRemove: TransformNode): number;
  45133. /**
  45134. * Remove a skeleton for the list of scene's skeletons
  45135. * @param toRemove defines the skeleton to remove
  45136. * @returns the index where the skeleton was in the skeleton list
  45137. */
  45138. removeSkeleton(toRemove: Skeleton): number;
  45139. /**
  45140. * Remove a morph target for the list of scene's morph targets
  45141. * @param toRemove defines the morph target to remove
  45142. * @returns the index where the morph target was in the morph target list
  45143. */
  45144. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45145. /**
  45146. * Remove a light for the list of scene's lights
  45147. * @param toRemove defines the light to remove
  45148. * @returns the index where the light was in the light list
  45149. */
  45150. removeLight(toRemove: Light): number;
  45151. /**
  45152. * Remove a camera for the list of scene's cameras
  45153. * @param toRemove defines the camera to remove
  45154. * @returns the index where the camera was in the camera list
  45155. */
  45156. removeCamera(toRemove: Camera): number;
  45157. /**
  45158. * Remove a particle system for the list of scene's particle systems
  45159. * @param toRemove defines the particle system to remove
  45160. * @returns the index where the particle system was in the particle system list
  45161. */
  45162. removeParticleSystem(toRemove: IParticleSystem): number;
  45163. /**
  45164. * Remove a animation for the list of scene's animations
  45165. * @param toRemove defines the animation to remove
  45166. * @returns the index where the animation was in the animation list
  45167. */
  45168. removeAnimation(toRemove: Animation): number;
  45169. /**
  45170. * Will stop the animation of the given target
  45171. * @param target - the target
  45172. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45173. * @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)
  45174. */
  45175. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45176. /**
  45177. * Removes the given animation group from this scene.
  45178. * @param toRemove The animation group to remove
  45179. * @returns The index of the removed animation group
  45180. */
  45181. removeAnimationGroup(toRemove: AnimationGroup): number;
  45182. /**
  45183. * Removes the given multi-material from this scene.
  45184. * @param toRemove The multi-material to remove
  45185. * @returns The index of the removed multi-material
  45186. */
  45187. removeMultiMaterial(toRemove: MultiMaterial): number;
  45188. /**
  45189. * Removes the given material from this scene.
  45190. * @param toRemove The material to remove
  45191. * @returns The index of the removed material
  45192. */
  45193. removeMaterial(toRemove: Material): number;
  45194. /**
  45195. * Removes the given action manager from this scene.
  45196. * @param toRemove The action manager to remove
  45197. * @returns The index of the removed action manager
  45198. */
  45199. removeActionManager(toRemove: AbstractActionManager): number;
  45200. /**
  45201. * Removes the given texture from this scene.
  45202. * @param toRemove The texture to remove
  45203. * @returns The index of the removed texture
  45204. */
  45205. removeTexture(toRemove: BaseTexture): number;
  45206. /**
  45207. * Adds the given light to this scene
  45208. * @param newLight The light to add
  45209. */
  45210. addLight(newLight: Light): void;
  45211. /**
  45212. * Sorts the list list based on light priorities
  45213. */
  45214. sortLightsByPriority(): void;
  45215. /**
  45216. * Adds the given camera to this scene
  45217. * @param newCamera The camera to add
  45218. */
  45219. addCamera(newCamera: Camera): void;
  45220. /**
  45221. * Adds the given skeleton to this scene
  45222. * @param newSkeleton The skeleton to add
  45223. */
  45224. addSkeleton(newSkeleton: Skeleton): void;
  45225. /**
  45226. * Adds the given particle system to this scene
  45227. * @param newParticleSystem The particle system to add
  45228. */
  45229. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45230. /**
  45231. * Adds the given animation to this scene
  45232. * @param newAnimation The animation to add
  45233. */
  45234. addAnimation(newAnimation: Animation): void;
  45235. /**
  45236. * Adds the given animation group to this scene.
  45237. * @param newAnimationGroup The animation group to add
  45238. */
  45239. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45240. /**
  45241. * Adds the given multi-material to this scene
  45242. * @param newMultiMaterial The multi-material to add
  45243. */
  45244. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45245. /**
  45246. * Adds the given material to this scene
  45247. * @param newMaterial The material to add
  45248. */
  45249. addMaterial(newMaterial: Material): void;
  45250. /**
  45251. * Adds the given morph target to this scene
  45252. * @param newMorphTargetManager The morph target to add
  45253. */
  45254. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45255. /**
  45256. * Adds the given geometry to this scene
  45257. * @param newGeometry The geometry to add
  45258. */
  45259. addGeometry(newGeometry: Geometry): void;
  45260. /**
  45261. * Adds the given action manager to this scene
  45262. * @param newActionManager The action manager to add
  45263. */
  45264. addActionManager(newActionManager: AbstractActionManager): void;
  45265. /**
  45266. * Adds the given texture to this scene.
  45267. * @param newTexture The texture to add
  45268. */
  45269. addTexture(newTexture: BaseTexture): void;
  45270. /**
  45271. * Switch active camera
  45272. * @param newCamera defines the new active camera
  45273. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45274. */
  45275. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45276. /**
  45277. * sets the active camera of the scene using its ID
  45278. * @param id defines the camera's ID
  45279. * @return the new active camera or null if none found.
  45280. */
  45281. setActiveCameraByID(id: string): Nullable<Camera>;
  45282. /**
  45283. * sets the active camera of the scene using its name
  45284. * @param name defines the camera's name
  45285. * @returns the new active camera or null if none found.
  45286. */
  45287. setActiveCameraByName(name: string): Nullable<Camera>;
  45288. /**
  45289. * get an animation group using its name
  45290. * @param name defines the material's name
  45291. * @return the animation group or null if none found.
  45292. */
  45293. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45294. /**
  45295. * Get a material using its unique id
  45296. * @param uniqueId defines the material's unique id
  45297. * @return the material or null if none found.
  45298. */
  45299. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45300. /**
  45301. * get a material using its id
  45302. * @param id defines the material's ID
  45303. * @return the material or null if none found.
  45304. */
  45305. getMaterialByID(id: string): Nullable<Material>;
  45306. /**
  45307. * Gets a the last added material using a given id
  45308. * @param id defines the material's ID
  45309. * @return the last material with the given id or null if none found.
  45310. */
  45311. getLastMaterialByID(id: string): Nullable<Material>;
  45312. /**
  45313. * Gets a material using its name
  45314. * @param name defines the material's name
  45315. * @return the material or null if none found.
  45316. */
  45317. getMaterialByName(name: string): Nullable<Material>;
  45318. /**
  45319. * Get a texture using its unique id
  45320. * @param uniqueId defines the texture's unique id
  45321. * @return the texture or null if none found.
  45322. */
  45323. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45324. /**
  45325. * Gets a camera using its id
  45326. * @param id defines the id to look for
  45327. * @returns the camera or null if not found
  45328. */
  45329. getCameraByID(id: string): Nullable<Camera>;
  45330. /**
  45331. * Gets a camera using its unique id
  45332. * @param uniqueId defines the unique id to look for
  45333. * @returns the camera or null if not found
  45334. */
  45335. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45336. /**
  45337. * Gets a camera using its name
  45338. * @param name defines the camera's name
  45339. * @return the camera or null if none found.
  45340. */
  45341. getCameraByName(name: string): Nullable<Camera>;
  45342. /**
  45343. * Gets a bone using its id
  45344. * @param id defines the bone's id
  45345. * @return the bone or null if not found
  45346. */
  45347. getBoneByID(id: string): Nullable<Bone>;
  45348. /**
  45349. * Gets a bone using its id
  45350. * @param name defines the bone's name
  45351. * @return the bone or null if not found
  45352. */
  45353. getBoneByName(name: string): Nullable<Bone>;
  45354. /**
  45355. * Gets a light node using its name
  45356. * @param name defines the the light's name
  45357. * @return the light or null if none found.
  45358. */
  45359. getLightByName(name: string): Nullable<Light>;
  45360. /**
  45361. * Gets a light node using its id
  45362. * @param id defines the light's id
  45363. * @return the light or null if none found.
  45364. */
  45365. getLightByID(id: string): Nullable<Light>;
  45366. /**
  45367. * Gets a light node using its scene-generated unique ID
  45368. * @param uniqueId defines the light's unique id
  45369. * @return the light or null if none found.
  45370. */
  45371. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45372. /**
  45373. * Gets a particle system by id
  45374. * @param id defines the particle system id
  45375. * @return the corresponding system or null if none found
  45376. */
  45377. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45378. /**
  45379. * Gets a geometry using its ID
  45380. * @param id defines the geometry's id
  45381. * @return the geometry or null if none found.
  45382. */
  45383. getGeometryByID(id: string): Nullable<Geometry>;
  45384. private _getGeometryByUniqueID;
  45385. /**
  45386. * Add a new geometry to this scene
  45387. * @param geometry defines the geometry to be added to the scene.
  45388. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45389. * @return a boolean defining if the geometry was added or not
  45390. */
  45391. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45392. /**
  45393. * Removes an existing geometry
  45394. * @param geometry defines the geometry to be removed from the scene
  45395. * @return a boolean defining if the geometry was removed or not
  45396. */
  45397. removeGeometry(geometry: Geometry): boolean;
  45398. /**
  45399. * Gets the list of geometries attached to the scene
  45400. * @returns an array of Geometry
  45401. */
  45402. getGeometries(): Geometry[];
  45403. /**
  45404. * Gets the first added mesh found of a given ID
  45405. * @param id defines the id to search for
  45406. * @return the mesh found or null if not found at all
  45407. */
  45408. getMeshByID(id: string): Nullable<AbstractMesh>;
  45409. /**
  45410. * Gets a list of meshes using their id
  45411. * @param id defines the id to search for
  45412. * @returns a list of meshes
  45413. */
  45414. getMeshesByID(id: string): Array<AbstractMesh>;
  45415. /**
  45416. * Gets the first added transform node found of a given ID
  45417. * @param id defines the id to search for
  45418. * @return the found transform node or null if not found at all.
  45419. */
  45420. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45421. /**
  45422. * Gets a transform node with its auto-generated unique id
  45423. * @param uniqueId efines the unique id to search for
  45424. * @return the found transform node or null if not found at all.
  45425. */
  45426. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45427. /**
  45428. * Gets a list of transform nodes using their id
  45429. * @param id defines the id to search for
  45430. * @returns a list of transform nodes
  45431. */
  45432. getTransformNodesByID(id: string): Array<TransformNode>;
  45433. /**
  45434. * Gets a mesh with its auto-generated unique id
  45435. * @param uniqueId defines the unique id to search for
  45436. * @return the found mesh or null if not found at all.
  45437. */
  45438. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45439. /**
  45440. * Gets a the last added mesh using a given id
  45441. * @param id defines the id to search for
  45442. * @return the found mesh or null if not found at all.
  45443. */
  45444. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45445. /**
  45446. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45447. * @param id defines the id to search for
  45448. * @return the found node or null if not found at all
  45449. */
  45450. getLastEntryByID(id: string): Nullable<Node>;
  45451. /**
  45452. * Gets a node (Mesh, Camera, Light) using a given id
  45453. * @param id defines the id to search for
  45454. * @return the found node or null if not found at all
  45455. */
  45456. getNodeByID(id: string): Nullable<Node>;
  45457. /**
  45458. * Gets a node (Mesh, Camera, Light) using a given name
  45459. * @param name defines the name to search for
  45460. * @return the found node or null if not found at all.
  45461. */
  45462. getNodeByName(name: string): Nullable<Node>;
  45463. /**
  45464. * Gets a mesh using a given name
  45465. * @param name defines the name to search for
  45466. * @return the found mesh or null if not found at all.
  45467. */
  45468. getMeshByName(name: string): Nullable<AbstractMesh>;
  45469. /**
  45470. * Gets a transform node using a given name
  45471. * @param name defines the name to search for
  45472. * @return the found transform node or null if not found at all.
  45473. */
  45474. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45475. /**
  45476. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45477. * @param id defines the id to search for
  45478. * @return the found skeleton or null if not found at all.
  45479. */
  45480. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45481. /**
  45482. * Gets a skeleton using a given auto generated unique id
  45483. * @param uniqueId defines the unique id to search for
  45484. * @return the found skeleton or null if not found at all.
  45485. */
  45486. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45487. /**
  45488. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45489. * @param id defines the id to search for
  45490. * @return the found skeleton or null if not found at all.
  45491. */
  45492. getSkeletonById(id: string): Nullable<Skeleton>;
  45493. /**
  45494. * Gets a skeleton using a given name
  45495. * @param name defines the name to search for
  45496. * @return the found skeleton or null if not found at all.
  45497. */
  45498. getSkeletonByName(name: string): Nullable<Skeleton>;
  45499. /**
  45500. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45501. * @param id defines the id to search for
  45502. * @return the found morph target manager or null if not found at all.
  45503. */
  45504. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45505. /**
  45506. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45507. * @param id defines the id to search for
  45508. * @return the found morph target or null if not found at all.
  45509. */
  45510. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45511. /**
  45512. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45513. * @param name defines the name to search for
  45514. * @return the found morph target or null if not found at all.
  45515. */
  45516. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45517. /**
  45518. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45519. * @param name defines the name to search for
  45520. * @return the found post process or null if not found at all.
  45521. */
  45522. getPostProcessByName(name: string): Nullable<PostProcess>;
  45523. /**
  45524. * Gets a boolean indicating if the given mesh is active
  45525. * @param mesh defines the mesh to look for
  45526. * @returns true if the mesh is in the active list
  45527. */
  45528. isActiveMesh(mesh: AbstractMesh): boolean;
  45529. /**
  45530. * Return a unique id as a string which can serve as an identifier for the scene
  45531. */
  45532. get uid(): string;
  45533. /**
  45534. * Add an externaly attached data from its key.
  45535. * This method call will fail and return false, if such key already exists.
  45536. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45537. * @param key the unique key that identifies the data
  45538. * @param data the data object to associate to the key for this Engine instance
  45539. * @return true if no such key were already present and the data was added successfully, false otherwise
  45540. */
  45541. addExternalData<T>(key: string, data: T): boolean;
  45542. /**
  45543. * Get an externaly attached data from its key
  45544. * @param key the unique key that identifies the data
  45545. * @return the associated data, if present (can be null), or undefined if not present
  45546. */
  45547. getExternalData<T>(key: string): Nullable<T>;
  45548. /**
  45549. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45550. * @param key the unique key that identifies the data
  45551. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45552. * @return the associated data, can be null if the factory returned null.
  45553. */
  45554. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45555. /**
  45556. * Remove an externaly attached data from the Engine instance
  45557. * @param key the unique key that identifies the data
  45558. * @return true if the data was successfully removed, false if it doesn't exist
  45559. */
  45560. removeExternalData(key: string): boolean;
  45561. private _evaluateSubMesh;
  45562. /**
  45563. * Clear the processed materials smart array preventing retention point in material dispose.
  45564. */
  45565. freeProcessedMaterials(): void;
  45566. private _preventFreeActiveMeshesAndRenderingGroups;
  45567. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45568. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45569. * when disposing several meshes in a row or a hierarchy of meshes.
  45570. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45571. */
  45572. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45573. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45574. /**
  45575. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45576. */
  45577. freeActiveMeshes(): void;
  45578. /**
  45579. * Clear the info related to rendering groups preventing retention points during dispose.
  45580. */
  45581. freeRenderingGroups(): void;
  45582. /** @hidden */
  45583. _isInIntermediateRendering(): boolean;
  45584. /**
  45585. * Lambda returning the list of potentially active meshes.
  45586. */
  45587. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45588. /**
  45589. * Lambda returning the list of potentially active sub meshes.
  45590. */
  45591. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45592. /**
  45593. * Lambda returning the list of potentially intersecting sub meshes.
  45594. */
  45595. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45596. /**
  45597. * Lambda returning the list of potentially colliding sub meshes.
  45598. */
  45599. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45600. private _activeMeshesFrozen;
  45601. private _skipEvaluateActiveMeshesCompletely;
  45602. /**
  45603. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45604. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45605. * @param onSuccess optional success callback
  45606. * @param onError optional error callback
  45607. * @returns the current scene
  45608. */
  45609. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45610. /**
  45611. * Use this function to restart evaluating active meshes on every frame
  45612. * @returns the current scene
  45613. */
  45614. unfreezeActiveMeshes(): Scene;
  45615. private _evaluateActiveMeshes;
  45616. private _activeMesh;
  45617. /**
  45618. * Update the transform matrix to update from the current active camera
  45619. * @param force defines a boolean used to force the update even if cache is up to date
  45620. */
  45621. updateTransformMatrix(force?: boolean): void;
  45622. private _bindFrameBuffer;
  45623. /** @hidden */
  45624. _allowPostProcessClearColor: boolean;
  45625. /** @hidden */
  45626. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45627. private _processSubCameras;
  45628. private _checkIntersections;
  45629. /** @hidden */
  45630. _advancePhysicsEngineStep(step: number): void;
  45631. /**
  45632. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45633. */
  45634. getDeterministicFrameTime: () => number;
  45635. /** @hidden */
  45636. _animate(): void;
  45637. /** Execute all animations (for a frame) */
  45638. animate(): void;
  45639. /**
  45640. * Render the scene
  45641. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45642. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45643. */
  45644. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45645. /**
  45646. * Freeze all materials
  45647. * A frozen material will not be updatable but should be faster to render
  45648. */
  45649. freezeMaterials(): void;
  45650. /**
  45651. * Unfreeze all materials
  45652. * A frozen material will not be updatable but should be faster to render
  45653. */
  45654. unfreezeMaterials(): void;
  45655. /**
  45656. * Releases all held ressources
  45657. */
  45658. dispose(): void;
  45659. /**
  45660. * Gets if the scene is already disposed
  45661. */
  45662. get isDisposed(): boolean;
  45663. /**
  45664. * Call this function to reduce memory footprint of the scene.
  45665. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45666. */
  45667. clearCachedVertexData(): void;
  45668. /**
  45669. * This function will remove the local cached buffer data from texture.
  45670. * It will save memory but will prevent the texture from being rebuilt
  45671. */
  45672. cleanCachedTextureBuffer(): void;
  45673. /**
  45674. * Get the world extend vectors with an optional filter
  45675. *
  45676. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45677. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45678. */
  45679. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45680. min: Vector3;
  45681. max: Vector3;
  45682. };
  45683. /**
  45684. * Creates a ray that can be used to pick in the scene
  45685. * @param x defines the x coordinate of the origin (on-screen)
  45686. * @param y defines the y coordinate of the origin (on-screen)
  45687. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45688. * @param camera defines the camera to use for the picking
  45689. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45690. * @returns a Ray
  45691. */
  45692. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45693. /**
  45694. * Creates a ray that can be used to pick in the scene
  45695. * @param x defines the x coordinate of the origin (on-screen)
  45696. * @param y defines the y coordinate of the origin (on-screen)
  45697. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45698. * @param result defines the ray where to store the picking ray
  45699. * @param camera defines the camera to use for the picking
  45700. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45701. * @returns the current scene
  45702. */
  45703. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45704. /**
  45705. * Creates a ray that can be used to pick in the scene
  45706. * @param x defines the x coordinate of the origin (on-screen)
  45707. * @param y defines the y coordinate of the origin (on-screen)
  45708. * @param camera defines the camera to use for the picking
  45709. * @returns a Ray
  45710. */
  45711. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45712. /**
  45713. * Creates a ray that can be used to pick in the scene
  45714. * @param x defines the x coordinate of the origin (on-screen)
  45715. * @param y defines the y coordinate of the origin (on-screen)
  45716. * @param result defines the ray where to store the picking ray
  45717. * @param camera defines the camera to use for the picking
  45718. * @returns the current scene
  45719. */
  45720. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45721. /** Launch a ray to try to pick a mesh in the scene
  45722. * @param x position on screen
  45723. * @param y position on screen
  45724. * @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
  45725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45726. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45728. * @returns a PickingInfo
  45729. */
  45730. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45731. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45732. * @param x position on screen
  45733. * @param y position on screen
  45734. * @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
  45735. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45736. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45737. * @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)
  45738. */
  45739. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45740. /** Use the given ray to pick a mesh in the scene
  45741. * @param ray The ray to use to pick meshes
  45742. * @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
  45743. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45744. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45745. * @returns a PickingInfo
  45746. */
  45747. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45748. /**
  45749. * Launch a ray to try to pick a mesh in the scene
  45750. * @param x X position on screen
  45751. * @param y Y position on screen
  45752. * @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
  45753. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45754. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45755. * @returns an array of PickingInfo
  45756. */
  45757. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45758. /**
  45759. * Launch a ray to try to pick a mesh in the scene
  45760. * @param ray Ray to use
  45761. * @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
  45762. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45763. * @returns an array of PickingInfo
  45764. */
  45765. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45766. /**
  45767. * Force the value of meshUnderPointer
  45768. * @param mesh defines the mesh to use
  45769. * @param pointerId optional pointer id when using more than one pointer
  45770. */
  45771. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45772. /**
  45773. * Gets the mesh under the pointer
  45774. * @returns a Mesh or null if no mesh is under the pointer
  45775. */
  45776. getPointerOverMesh(): Nullable<AbstractMesh>;
  45777. /** @hidden */
  45778. _rebuildGeometries(): void;
  45779. /** @hidden */
  45780. _rebuildTextures(): void;
  45781. private _getByTags;
  45782. /**
  45783. * Get a list of meshes by tags
  45784. * @param tagsQuery defines the tags query to use
  45785. * @param forEach defines a predicate used to filter results
  45786. * @returns an array of Mesh
  45787. */
  45788. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45789. /**
  45790. * Get a list of cameras by tags
  45791. * @param tagsQuery defines the tags query to use
  45792. * @param forEach defines a predicate used to filter results
  45793. * @returns an array of Camera
  45794. */
  45795. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45796. /**
  45797. * Get a list of lights by tags
  45798. * @param tagsQuery defines the tags query to use
  45799. * @param forEach defines a predicate used to filter results
  45800. * @returns an array of Light
  45801. */
  45802. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45803. /**
  45804. * Get a list of materials by tags
  45805. * @param tagsQuery defines the tags query to use
  45806. * @param forEach defines a predicate used to filter results
  45807. * @returns an array of Material
  45808. */
  45809. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45810. /**
  45811. * Get a list of transform nodes by tags
  45812. * @param tagsQuery defines the tags query to use
  45813. * @param forEach defines a predicate used to filter results
  45814. * @returns an array of TransformNode
  45815. */
  45816. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45817. /**
  45818. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45819. * This allowed control for front to back rendering or reversly depending of the special needs.
  45820. *
  45821. * @param renderingGroupId The rendering group id corresponding to its index
  45822. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45823. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45824. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45825. */
  45826. 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;
  45827. /**
  45828. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45829. *
  45830. * @param renderingGroupId The rendering group id corresponding to its index
  45831. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45832. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45833. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45834. */
  45835. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45836. /**
  45837. * Gets the current auto clear configuration for one rendering group of the rendering
  45838. * manager.
  45839. * @param index the rendering group index to get the information for
  45840. * @returns The auto clear setup for the requested rendering group
  45841. */
  45842. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45843. private _blockMaterialDirtyMechanism;
  45844. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45845. get blockMaterialDirtyMechanism(): boolean;
  45846. set blockMaterialDirtyMechanism(value: boolean);
  45847. /**
  45848. * Will flag all materials as dirty to trigger new shader compilation
  45849. * @param flag defines the flag used to specify which material part must be marked as dirty
  45850. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45851. */
  45852. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45853. /** @hidden */
  45854. _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;
  45855. /** @hidden */
  45856. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45857. /** @hidden */
  45858. _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;
  45859. /** @hidden */
  45860. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45861. /** @hidden */
  45862. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45863. /** @hidden */
  45864. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45865. }
  45866. }
  45867. declare module "babylonjs/assetContainer" {
  45868. import { AbstractScene } from "babylonjs/abstractScene";
  45869. import { Scene } from "babylonjs/scene";
  45870. import { Mesh } from "babylonjs/Meshes/mesh";
  45871. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45872. import { Skeleton } from "babylonjs/Bones/skeleton";
  45873. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45874. import { Animatable } from "babylonjs/Animations/animatable";
  45875. import { Nullable } from "babylonjs/types";
  45876. import { Node } from "babylonjs/node";
  45877. /**
  45878. * Set of assets to keep when moving a scene into an asset container.
  45879. */
  45880. export class KeepAssets extends AbstractScene {
  45881. }
  45882. /**
  45883. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45884. */
  45885. export class InstantiatedEntries {
  45886. /**
  45887. * List of new root nodes (eg. nodes with no parent)
  45888. */
  45889. rootNodes: TransformNode[];
  45890. /**
  45891. * List of new skeletons
  45892. */
  45893. skeletons: Skeleton[];
  45894. /**
  45895. * List of new animation groups
  45896. */
  45897. animationGroups: AnimationGroup[];
  45898. }
  45899. /**
  45900. * Container with a set of assets that can be added or removed from a scene.
  45901. */
  45902. export class AssetContainer extends AbstractScene {
  45903. private _wasAddedToScene;
  45904. /**
  45905. * The scene the AssetContainer belongs to.
  45906. */
  45907. scene: Scene;
  45908. /**
  45909. * Instantiates an AssetContainer.
  45910. * @param scene The scene the AssetContainer belongs to.
  45911. */
  45912. constructor(scene: Scene);
  45913. /**
  45914. * Instantiate or clone all meshes and add the new ones to the scene.
  45915. * Skeletons and animation groups will all be cloned
  45916. * @param nameFunction defines an optional function used to get new names for clones
  45917. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45918. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45919. */
  45920. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45921. /**
  45922. * Adds all the assets from the container to the scene.
  45923. */
  45924. addAllToScene(): void;
  45925. /**
  45926. * Removes all the assets in the container from the scene
  45927. */
  45928. removeAllFromScene(): void;
  45929. /**
  45930. * Disposes all the assets in the container
  45931. */
  45932. dispose(): void;
  45933. private _moveAssets;
  45934. /**
  45935. * Removes all the assets contained in the scene and adds them to the container.
  45936. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45937. */
  45938. moveAllFromScene(keepAssets?: KeepAssets): void;
  45939. /**
  45940. * 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.
  45941. * @returns the root mesh
  45942. */
  45943. createRootMesh(): Mesh;
  45944. /**
  45945. * Merge animations (direct and animation groups) from this asset container into a scene
  45946. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45947. * @param animatables set of animatables to retarget to a node from the scene
  45948. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45949. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45950. */
  45951. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45952. }
  45953. }
  45954. declare module "babylonjs/abstractScene" {
  45955. import { Scene } from "babylonjs/scene";
  45956. import { Nullable } from "babylonjs/types";
  45957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45958. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45959. import { Geometry } from "babylonjs/Meshes/geometry";
  45960. import { Skeleton } from "babylonjs/Bones/skeleton";
  45961. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45962. import { AssetContainer } from "babylonjs/assetContainer";
  45963. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45964. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45966. import { Material } from "babylonjs/Materials/material";
  45967. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45968. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45969. import { Camera } from "babylonjs/Cameras/camera";
  45970. import { Light } from "babylonjs/Lights/light";
  45971. import { Node } from "babylonjs/node";
  45972. import { Animation } from "babylonjs/Animations/animation";
  45973. /**
  45974. * Defines how the parser contract is defined.
  45975. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45976. */
  45977. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45978. /**
  45979. * Defines how the individual parser contract is defined.
  45980. * These parser can parse an individual asset
  45981. */
  45982. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45983. /**
  45984. * Base class of the scene acting as a container for the different elements composing a scene.
  45985. * This class is dynamically extended by the different components of the scene increasing
  45986. * flexibility and reducing coupling
  45987. */
  45988. export abstract class AbstractScene {
  45989. /**
  45990. * Stores the list of available parsers in the application.
  45991. */
  45992. private static _BabylonFileParsers;
  45993. /**
  45994. * Stores the list of available individual parsers in the application.
  45995. */
  45996. private static _IndividualBabylonFileParsers;
  45997. /**
  45998. * Adds a parser in the list of available ones
  45999. * @param name Defines the name of the parser
  46000. * @param parser Defines the parser to add
  46001. */
  46002. static AddParser(name: string, parser: BabylonFileParser): void;
  46003. /**
  46004. * Gets a general parser from the list of avaialble ones
  46005. * @param name Defines the name of the parser
  46006. * @returns the requested parser or null
  46007. */
  46008. static GetParser(name: string): Nullable<BabylonFileParser>;
  46009. /**
  46010. * Adds n individual parser in the list of available ones
  46011. * @param name Defines the name of the parser
  46012. * @param parser Defines the parser to add
  46013. */
  46014. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46015. /**
  46016. * Gets an individual parser from the list of avaialble ones
  46017. * @param name Defines the name of the parser
  46018. * @returns the requested parser or null
  46019. */
  46020. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46021. /**
  46022. * Parser json data and populate both a scene and its associated container object
  46023. * @param jsonData Defines the data to parse
  46024. * @param scene Defines the scene to parse the data for
  46025. * @param container Defines the container attached to the parsing sequence
  46026. * @param rootUrl Defines the root url of the data
  46027. */
  46028. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46029. /**
  46030. * Gets the list of root nodes (ie. nodes with no parent)
  46031. */
  46032. rootNodes: Node[];
  46033. /** All of the cameras added to this scene
  46034. * @see https://doc.babylonjs.com/babylon101/cameras
  46035. */
  46036. cameras: Camera[];
  46037. /**
  46038. * All of the lights added to this scene
  46039. * @see https://doc.babylonjs.com/babylon101/lights
  46040. */
  46041. lights: Light[];
  46042. /**
  46043. * All of the (abstract) meshes added to this scene
  46044. */
  46045. meshes: AbstractMesh[];
  46046. /**
  46047. * The list of skeletons added to the scene
  46048. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46049. */
  46050. skeletons: Skeleton[];
  46051. /**
  46052. * All of the particle systems added to this scene
  46053. * @see https://doc.babylonjs.com/babylon101/particles
  46054. */
  46055. particleSystems: IParticleSystem[];
  46056. /**
  46057. * Gets a list of Animations associated with the scene
  46058. */
  46059. animations: Animation[];
  46060. /**
  46061. * All of the animation groups added to this scene
  46062. * @see https://doc.babylonjs.com/how_to/group
  46063. */
  46064. animationGroups: AnimationGroup[];
  46065. /**
  46066. * All of the multi-materials added to this scene
  46067. * @see https://doc.babylonjs.com/how_to/multi_materials
  46068. */
  46069. multiMaterials: MultiMaterial[];
  46070. /**
  46071. * All of the materials added to this scene
  46072. * In the context of a Scene, it is not supposed to be modified manually.
  46073. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46074. * Note also that the order of the Material within the array is not significant and might change.
  46075. * @see https://doc.babylonjs.com/babylon101/materials
  46076. */
  46077. materials: Material[];
  46078. /**
  46079. * The list of morph target managers added to the scene
  46080. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46081. */
  46082. morphTargetManagers: MorphTargetManager[];
  46083. /**
  46084. * The list of geometries used in the scene.
  46085. */
  46086. geometries: Geometry[];
  46087. /**
  46088. * All of the tranform nodes added to this scene
  46089. * In the context of a Scene, it is not supposed to be modified manually.
  46090. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46091. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46092. * @see https://doc.babylonjs.com/how_to/transformnode
  46093. */
  46094. transformNodes: TransformNode[];
  46095. /**
  46096. * ActionManagers available on the scene.
  46097. */
  46098. actionManagers: AbstractActionManager[];
  46099. /**
  46100. * Textures to keep.
  46101. */
  46102. textures: BaseTexture[];
  46103. /** @hidden */
  46104. protected _environmentTexture: Nullable<BaseTexture>;
  46105. /**
  46106. * Texture used in all pbr material as the reflection texture.
  46107. * As in the majority of the scene they are the same (exception for multi room and so on),
  46108. * this is easier to reference from here than from all the materials.
  46109. */
  46110. get environmentTexture(): Nullable<BaseTexture>;
  46111. set environmentTexture(value: Nullable<BaseTexture>);
  46112. /**
  46113. * The list of postprocesses added to the scene
  46114. */
  46115. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46116. /**
  46117. * @returns all meshes, lights, cameras, transformNodes and bones
  46118. */
  46119. getNodes(): Array<Node>;
  46120. }
  46121. }
  46122. declare module "babylonjs/Audio/sound" {
  46123. import { Observable } from "babylonjs/Misc/observable";
  46124. import { Vector3 } from "babylonjs/Maths/math.vector";
  46125. import { Nullable } from "babylonjs/types";
  46126. import { Scene } from "babylonjs/scene";
  46127. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46128. /**
  46129. * Interface used to define options for Sound class
  46130. */
  46131. export interface ISoundOptions {
  46132. /**
  46133. * Does the sound autoplay once loaded.
  46134. */
  46135. autoplay?: boolean;
  46136. /**
  46137. * Does the sound loop after it finishes playing once.
  46138. */
  46139. loop?: boolean;
  46140. /**
  46141. * Sound's volume
  46142. */
  46143. volume?: number;
  46144. /**
  46145. * Is it a spatial sound?
  46146. */
  46147. spatialSound?: boolean;
  46148. /**
  46149. * Maximum distance to hear that sound
  46150. */
  46151. maxDistance?: number;
  46152. /**
  46153. * Uses user defined attenuation function
  46154. */
  46155. useCustomAttenuation?: boolean;
  46156. /**
  46157. * Define the roll off factor of spatial sounds.
  46158. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46159. */
  46160. rolloffFactor?: number;
  46161. /**
  46162. * Define the reference distance the sound should be heard perfectly.
  46163. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46164. */
  46165. refDistance?: number;
  46166. /**
  46167. * Define the distance attenuation model the sound will follow.
  46168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46169. */
  46170. distanceModel?: string;
  46171. /**
  46172. * Defines the playback speed (1 by default)
  46173. */
  46174. playbackRate?: number;
  46175. /**
  46176. * Defines if the sound is from a streaming source
  46177. */
  46178. streaming?: boolean;
  46179. /**
  46180. * Defines an optional length (in seconds) inside the sound file
  46181. */
  46182. length?: number;
  46183. /**
  46184. * Defines an optional offset (in seconds) inside the sound file
  46185. */
  46186. offset?: number;
  46187. /**
  46188. * If true, URLs will not be required to state the audio file codec to use.
  46189. */
  46190. skipCodecCheck?: boolean;
  46191. }
  46192. /**
  46193. * Defines a sound that can be played in the application.
  46194. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46195. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46196. */
  46197. export class Sound {
  46198. /**
  46199. * The name of the sound in the scene.
  46200. */
  46201. name: string;
  46202. /**
  46203. * Does the sound autoplay once loaded.
  46204. */
  46205. autoplay: boolean;
  46206. /**
  46207. * Does the sound loop after it finishes playing once.
  46208. */
  46209. loop: boolean;
  46210. /**
  46211. * Does the sound use a custom attenuation curve to simulate the falloff
  46212. * happening when the source gets further away from the camera.
  46213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46214. */
  46215. useCustomAttenuation: boolean;
  46216. /**
  46217. * The sound track id this sound belongs to.
  46218. */
  46219. soundTrackId: number;
  46220. /**
  46221. * Is this sound currently played.
  46222. */
  46223. isPlaying: boolean;
  46224. /**
  46225. * Is this sound currently paused.
  46226. */
  46227. isPaused: boolean;
  46228. /**
  46229. * Does this sound enables spatial sound.
  46230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46231. */
  46232. spatialSound: boolean;
  46233. /**
  46234. * Define the reference distance the sound should be heard perfectly.
  46235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46236. */
  46237. refDistance: number;
  46238. /**
  46239. * Define the roll off factor of spatial sounds.
  46240. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46241. */
  46242. rolloffFactor: number;
  46243. /**
  46244. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46245. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46246. */
  46247. maxDistance: number;
  46248. /**
  46249. * Define the distance attenuation model the sound will follow.
  46250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46251. */
  46252. distanceModel: string;
  46253. /**
  46254. * @hidden
  46255. * Back Compat
  46256. **/
  46257. onended: () => any;
  46258. /**
  46259. * Gets or sets an object used to store user defined information for the sound.
  46260. */
  46261. metadata: any;
  46262. /**
  46263. * Observable event when the current playing sound finishes.
  46264. */
  46265. onEndedObservable: Observable<Sound>;
  46266. private _panningModel;
  46267. private _playbackRate;
  46268. private _streaming;
  46269. private _startTime;
  46270. private _startOffset;
  46271. private _position;
  46272. /** @hidden */
  46273. _positionInEmitterSpace: boolean;
  46274. private _localDirection;
  46275. private _volume;
  46276. private _isReadyToPlay;
  46277. private _isDirectional;
  46278. private _readyToPlayCallback;
  46279. private _audioBuffer;
  46280. private _soundSource;
  46281. private _streamingSource;
  46282. private _soundPanner;
  46283. private _soundGain;
  46284. private _inputAudioNode;
  46285. private _outputAudioNode;
  46286. private _coneInnerAngle;
  46287. private _coneOuterAngle;
  46288. private _coneOuterGain;
  46289. private _scene;
  46290. private _connectedTransformNode;
  46291. private _customAttenuationFunction;
  46292. private _registerFunc;
  46293. private _isOutputConnected;
  46294. private _htmlAudioElement;
  46295. private _urlType;
  46296. private _length?;
  46297. private _offset?;
  46298. /** @hidden */
  46299. static _SceneComponentInitialization: (scene: Scene) => void;
  46300. /**
  46301. * Create a sound and attach it to a scene
  46302. * @param name Name of your sound
  46303. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46304. * @param scene defines the scene the sound belongs to
  46305. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46306. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46307. */
  46308. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46309. /**
  46310. * Release the sound and its associated resources
  46311. */
  46312. dispose(): void;
  46313. /**
  46314. * Gets if the sounds is ready to be played or not.
  46315. * @returns true if ready, otherwise false
  46316. */
  46317. isReady(): boolean;
  46318. private _soundLoaded;
  46319. /**
  46320. * Sets the data of the sound from an audiobuffer
  46321. * @param audioBuffer The audioBuffer containing the data
  46322. */
  46323. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46324. /**
  46325. * Updates the current sounds options such as maxdistance, loop...
  46326. * @param options A JSON object containing values named as the object properties
  46327. */
  46328. updateOptions(options: ISoundOptions): void;
  46329. private _createSpatialParameters;
  46330. private _updateSpatialParameters;
  46331. /**
  46332. * Switch the panning model to HRTF:
  46333. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46335. */
  46336. switchPanningModelToHRTF(): void;
  46337. /**
  46338. * Switch the panning model to Equal Power:
  46339. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46341. */
  46342. switchPanningModelToEqualPower(): void;
  46343. private _switchPanningModel;
  46344. /**
  46345. * Connect this sound to a sound track audio node like gain...
  46346. * @param soundTrackAudioNode the sound track audio node to connect to
  46347. */
  46348. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46349. /**
  46350. * Transform this sound into a directional source
  46351. * @param coneInnerAngle Size of the inner cone in degree
  46352. * @param coneOuterAngle Size of the outer cone in degree
  46353. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46354. */
  46355. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46356. /**
  46357. * Gets or sets the inner angle for the directional cone.
  46358. */
  46359. get directionalConeInnerAngle(): number;
  46360. /**
  46361. * Gets or sets the inner angle for the directional cone.
  46362. */
  46363. set directionalConeInnerAngle(value: number);
  46364. /**
  46365. * Gets or sets the outer angle for the directional cone.
  46366. */
  46367. get directionalConeOuterAngle(): number;
  46368. /**
  46369. * Gets or sets the outer angle for the directional cone.
  46370. */
  46371. set directionalConeOuterAngle(value: number);
  46372. /**
  46373. * Sets the position of the emitter if spatial sound is enabled
  46374. * @param newPosition Defines the new posisiton
  46375. */
  46376. setPosition(newPosition: Vector3): void;
  46377. /**
  46378. * Sets the local direction of the emitter if spatial sound is enabled
  46379. * @param newLocalDirection Defines the new local direction
  46380. */
  46381. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46382. private _updateDirection;
  46383. /** @hidden */
  46384. updateDistanceFromListener(): void;
  46385. /**
  46386. * Sets a new custom attenuation function for the sound.
  46387. * @param callback Defines the function used for the attenuation
  46388. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46389. */
  46390. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46391. /**
  46392. * Play the sound
  46393. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46394. * @param offset (optional) Start the sound at a specific time in seconds
  46395. * @param length (optional) Sound duration (in seconds)
  46396. */
  46397. play(time?: number, offset?: number, length?: number): void;
  46398. private _onended;
  46399. /**
  46400. * Stop the sound
  46401. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46402. */
  46403. stop(time?: number): void;
  46404. /**
  46405. * Put the sound in pause
  46406. */
  46407. pause(): void;
  46408. /**
  46409. * Sets a dedicated volume for this sounds
  46410. * @param newVolume Define the new volume of the sound
  46411. * @param time Define time for gradual change to new volume
  46412. */
  46413. setVolume(newVolume: number, time?: number): void;
  46414. /**
  46415. * Set the sound play back rate
  46416. * @param newPlaybackRate Define the playback rate the sound should be played at
  46417. */
  46418. setPlaybackRate(newPlaybackRate: number): void;
  46419. /**
  46420. * Gets the volume of the sound.
  46421. * @returns the volume of the sound
  46422. */
  46423. getVolume(): number;
  46424. /**
  46425. * Attach the sound to a dedicated mesh
  46426. * @param transformNode The transform node to connect the sound with
  46427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46428. */
  46429. attachToMesh(transformNode: TransformNode): void;
  46430. /**
  46431. * Detach the sound from the previously attached mesh
  46432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46433. */
  46434. detachFromMesh(): void;
  46435. private _onRegisterAfterWorldMatrixUpdate;
  46436. /**
  46437. * Clone the current sound in the scene.
  46438. * @returns the new sound clone
  46439. */
  46440. clone(): Nullable<Sound>;
  46441. /**
  46442. * Gets the current underlying audio buffer containing the data
  46443. * @returns the audio buffer
  46444. */
  46445. getAudioBuffer(): Nullable<AudioBuffer>;
  46446. /**
  46447. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46448. * @returns the source node
  46449. */
  46450. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46451. /**
  46452. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46453. * @returns the gain node
  46454. */
  46455. getSoundGain(): Nullable<GainNode>;
  46456. /**
  46457. * Serializes the Sound in a JSON representation
  46458. * @returns the JSON representation of the sound
  46459. */
  46460. serialize(): any;
  46461. /**
  46462. * Parse a JSON representation of a sound to innstantiate in a given scene
  46463. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46464. * @param scene Define the scene the new parsed sound should be created in
  46465. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46466. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46467. * @returns the newly parsed sound
  46468. */
  46469. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46470. }
  46471. }
  46472. declare module "babylonjs/Actions/directAudioActions" {
  46473. import { Action } from "babylonjs/Actions/action";
  46474. import { Condition } from "babylonjs/Actions/condition";
  46475. import { Sound } from "babylonjs/Audio/sound";
  46476. /**
  46477. * This defines an action helpful to play a defined sound on a triggered action.
  46478. */
  46479. export class PlaySoundAction extends Action {
  46480. private _sound;
  46481. /**
  46482. * Instantiate the action
  46483. * @param triggerOptions defines the trigger options
  46484. * @param sound defines the sound to play
  46485. * @param condition defines the trigger related conditions
  46486. */
  46487. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46488. /** @hidden */
  46489. _prepare(): void;
  46490. /**
  46491. * Execute the action and play the sound.
  46492. */
  46493. execute(): void;
  46494. /**
  46495. * Serializes the actions and its related information.
  46496. * @param parent defines the object to serialize in
  46497. * @returns the serialized object
  46498. */
  46499. serialize(parent: any): any;
  46500. }
  46501. /**
  46502. * This defines an action helpful to stop a defined sound on a triggered action.
  46503. */
  46504. export class StopSoundAction extends Action {
  46505. private _sound;
  46506. /**
  46507. * Instantiate the action
  46508. * @param triggerOptions defines the trigger options
  46509. * @param sound defines the sound to stop
  46510. * @param condition defines the trigger related conditions
  46511. */
  46512. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46513. /** @hidden */
  46514. _prepare(): void;
  46515. /**
  46516. * Execute the action and stop the sound.
  46517. */
  46518. execute(): void;
  46519. /**
  46520. * Serializes the actions and its related information.
  46521. * @param parent defines the object to serialize in
  46522. * @returns the serialized object
  46523. */
  46524. serialize(parent: any): any;
  46525. }
  46526. }
  46527. declare module "babylonjs/Actions/interpolateValueAction" {
  46528. import { Action } from "babylonjs/Actions/action";
  46529. import { Condition } from "babylonjs/Actions/condition";
  46530. import { Observable } from "babylonjs/Misc/observable";
  46531. /**
  46532. * This defines an action responsible to change the value of a property
  46533. * by interpolating between its current value and the newly set one once triggered.
  46534. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46535. */
  46536. export class InterpolateValueAction extends Action {
  46537. /**
  46538. * Defines the path of the property where the value should be interpolated
  46539. */
  46540. propertyPath: string;
  46541. /**
  46542. * Defines the target value at the end of the interpolation.
  46543. */
  46544. value: any;
  46545. /**
  46546. * Defines the time it will take for the property to interpolate to the value.
  46547. */
  46548. duration: number;
  46549. /**
  46550. * Defines if the other scene animations should be stopped when the action has been triggered
  46551. */
  46552. stopOtherAnimations?: boolean;
  46553. /**
  46554. * Defines a callback raised once the interpolation animation has been done.
  46555. */
  46556. onInterpolationDone?: () => void;
  46557. /**
  46558. * Observable triggered once the interpolation animation has been done.
  46559. */
  46560. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46561. private _target;
  46562. private _effectiveTarget;
  46563. private _property;
  46564. /**
  46565. * Instantiate the action
  46566. * @param triggerOptions defines the trigger options
  46567. * @param target defines the object containing the value to interpolate
  46568. * @param propertyPath defines the path to the property in the target object
  46569. * @param value defines the target value at the end of the interpolation
  46570. * @param duration deines the time it will take for the property to interpolate to the value.
  46571. * @param condition defines the trigger related conditions
  46572. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46573. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46574. */
  46575. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46576. /** @hidden */
  46577. _prepare(): void;
  46578. /**
  46579. * Execute the action starts the value interpolation.
  46580. */
  46581. execute(): void;
  46582. /**
  46583. * Serializes the actions and its related information.
  46584. * @param parent defines the object to serialize in
  46585. * @returns the serialized object
  46586. */
  46587. serialize(parent: any): any;
  46588. }
  46589. }
  46590. declare module "babylonjs/Actions/index" {
  46591. export * from "babylonjs/Actions/abstractActionManager";
  46592. export * from "babylonjs/Actions/action";
  46593. export * from "babylonjs/Actions/actionEvent";
  46594. export * from "babylonjs/Actions/actionManager";
  46595. export * from "babylonjs/Actions/condition";
  46596. export * from "babylonjs/Actions/directActions";
  46597. export * from "babylonjs/Actions/directAudioActions";
  46598. export * from "babylonjs/Actions/interpolateValueAction";
  46599. }
  46600. declare module "babylonjs/Animations/index" {
  46601. export * from "babylonjs/Animations/animatable";
  46602. export * from "babylonjs/Animations/animation";
  46603. export * from "babylonjs/Animations/animationGroup";
  46604. export * from "babylonjs/Animations/animationPropertiesOverride";
  46605. export * from "babylonjs/Animations/easing";
  46606. export * from "babylonjs/Animations/runtimeAnimation";
  46607. export * from "babylonjs/Animations/animationEvent";
  46608. export * from "babylonjs/Animations/animationGroup";
  46609. export * from "babylonjs/Animations/animationKey";
  46610. export * from "babylonjs/Animations/animationRange";
  46611. export * from "babylonjs/Animations/animatable.interface";
  46612. }
  46613. declare module "babylonjs/Audio/soundTrack" {
  46614. import { Sound } from "babylonjs/Audio/sound";
  46615. import { Analyser } from "babylonjs/Audio/analyser";
  46616. import { Scene } from "babylonjs/scene";
  46617. /**
  46618. * Options allowed during the creation of a sound track.
  46619. */
  46620. export interface ISoundTrackOptions {
  46621. /**
  46622. * The volume the sound track should take during creation
  46623. */
  46624. volume?: number;
  46625. /**
  46626. * Define if the sound track is the main sound track of the scene
  46627. */
  46628. mainTrack?: boolean;
  46629. }
  46630. /**
  46631. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46632. * It will be also used in a future release to apply effects on a specific track.
  46633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46634. */
  46635. export class SoundTrack {
  46636. /**
  46637. * The unique identifier of the sound track in the scene.
  46638. */
  46639. id: number;
  46640. /**
  46641. * The list of sounds included in the sound track.
  46642. */
  46643. soundCollection: Array<Sound>;
  46644. private _outputAudioNode;
  46645. private _scene;
  46646. private _connectedAnalyser;
  46647. private _options;
  46648. private _isInitialized;
  46649. /**
  46650. * Creates a new sound track.
  46651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46652. * @param scene Define the scene the sound track belongs to
  46653. * @param options
  46654. */
  46655. constructor(scene: Scene, options?: ISoundTrackOptions);
  46656. private _initializeSoundTrackAudioGraph;
  46657. /**
  46658. * Release the sound track and its associated resources
  46659. */
  46660. dispose(): void;
  46661. /**
  46662. * Adds a sound to this sound track
  46663. * @param sound define the cound to add
  46664. * @ignoreNaming
  46665. */
  46666. AddSound(sound: Sound): void;
  46667. /**
  46668. * Removes a sound to this sound track
  46669. * @param sound define the cound to remove
  46670. * @ignoreNaming
  46671. */
  46672. RemoveSound(sound: Sound): void;
  46673. /**
  46674. * Set a global volume for the full sound track.
  46675. * @param newVolume Define the new volume of the sound track
  46676. */
  46677. setVolume(newVolume: number): void;
  46678. /**
  46679. * Switch the panning model to HRTF:
  46680. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46681. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46682. */
  46683. switchPanningModelToHRTF(): void;
  46684. /**
  46685. * Switch the panning model to Equal Power:
  46686. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46687. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46688. */
  46689. switchPanningModelToEqualPower(): void;
  46690. /**
  46691. * Connect the sound track to an audio analyser allowing some amazing
  46692. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46693. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46694. * @param analyser The analyser to connect to the engine
  46695. */
  46696. connectToAnalyser(analyser: Analyser): void;
  46697. }
  46698. }
  46699. declare module "babylonjs/Audio/audioSceneComponent" {
  46700. import { Sound } from "babylonjs/Audio/sound";
  46701. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46702. import { Nullable } from "babylonjs/types";
  46703. import { Vector3 } from "babylonjs/Maths/math.vector";
  46704. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46705. import { Scene } from "babylonjs/scene";
  46706. import { AbstractScene } from "babylonjs/abstractScene";
  46707. import "babylonjs/Audio/audioEngine";
  46708. module "babylonjs/abstractScene" {
  46709. interface AbstractScene {
  46710. /**
  46711. * The list of sounds used in the scene.
  46712. */
  46713. sounds: Nullable<Array<Sound>>;
  46714. }
  46715. }
  46716. module "babylonjs/scene" {
  46717. interface Scene {
  46718. /**
  46719. * @hidden
  46720. * Backing field
  46721. */
  46722. _mainSoundTrack: SoundTrack;
  46723. /**
  46724. * The main sound track played by the scene.
  46725. * It cotains your primary collection of sounds.
  46726. */
  46727. mainSoundTrack: SoundTrack;
  46728. /**
  46729. * The list of sound tracks added to the scene
  46730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46731. */
  46732. soundTracks: Nullable<Array<SoundTrack>>;
  46733. /**
  46734. * Gets a sound using a given name
  46735. * @param name defines the name to search for
  46736. * @return the found sound or null if not found at all.
  46737. */
  46738. getSoundByName(name: string): Nullable<Sound>;
  46739. /**
  46740. * Gets or sets if audio support is enabled
  46741. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46742. */
  46743. audioEnabled: boolean;
  46744. /**
  46745. * Gets or sets if audio will be output to headphones
  46746. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46747. */
  46748. headphone: boolean;
  46749. /**
  46750. * Gets or sets custom audio listener position provider
  46751. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46752. */
  46753. audioListenerPositionProvider: Nullable<() => Vector3>;
  46754. /**
  46755. * Gets or sets a refresh rate when using 3D audio positioning
  46756. */
  46757. audioPositioningRefreshRate: number;
  46758. }
  46759. }
  46760. /**
  46761. * Defines the sound scene component responsible to manage any sounds
  46762. * in a given scene.
  46763. */
  46764. export class AudioSceneComponent implements ISceneSerializableComponent {
  46765. private static _CameraDirectionLH;
  46766. private static _CameraDirectionRH;
  46767. /**
  46768. * The component name helpfull to identify the component in the list of scene components.
  46769. */
  46770. readonly name: string;
  46771. /**
  46772. * The scene the component belongs to.
  46773. */
  46774. scene: Scene;
  46775. private _audioEnabled;
  46776. /**
  46777. * Gets whether audio is enabled or not.
  46778. * Please use related enable/disable method to switch state.
  46779. */
  46780. get audioEnabled(): boolean;
  46781. private _headphone;
  46782. /**
  46783. * Gets whether audio is outputing to headphone or not.
  46784. * Please use the according Switch methods to change output.
  46785. */
  46786. get headphone(): boolean;
  46787. /**
  46788. * Gets or sets a refresh rate when using 3D audio positioning
  46789. */
  46790. audioPositioningRefreshRate: number;
  46791. private _audioListenerPositionProvider;
  46792. /**
  46793. * Gets the current audio listener position provider
  46794. */
  46795. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46796. /**
  46797. * Sets a custom listener position for all sounds in the scene
  46798. * By default, this is the position of the first active camera
  46799. */
  46800. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46801. /**
  46802. * Creates a new instance of the component for the given scene
  46803. * @param scene Defines the scene to register the component in
  46804. */
  46805. constructor(scene: Scene);
  46806. /**
  46807. * Registers the component in a given scene
  46808. */
  46809. register(): void;
  46810. /**
  46811. * Rebuilds the elements related to this component in case of
  46812. * context lost for instance.
  46813. */
  46814. rebuild(): void;
  46815. /**
  46816. * Serializes the component data to the specified json object
  46817. * @param serializationObject The object to serialize to
  46818. */
  46819. serialize(serializationObject: any): void;
  46820. /**
  46821. * Adds all the elements from the container to the scene
  46822. * @param container the container holding the elements
  46823. */
  46824. addFromContainer(container: AbstractScene): void;
  46825. /**
  46826. * Removes all the elements in the container from the scene
  46827. * @param container contains the elements to remove
  46828. * @param dispose if the removed element should be disposed (default: false)
  46829. */
  46830. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46831. /**
  46832. * Disposes the component and the associated ressources.
  46833. */
  46834. dispose(): void;
  46835. /**
  46836. * Disables audio in the associated scene.
  46837. */
  46838. disableAudio(): void;
  46839. /**
  46840. * Enables audio in the associated scene.
  46841. */
  46842. enableAudio(): void;
  46843. /**
  46844. * Switch audio to headphone output.
  46845. */
  46846. switchAudioModeForHeadphones(): void;
  46847. /**
  46848. * Switch audio to normal speakers.
  46849. */
  46850. switchAudioModeForNormalSpeakers(): void;
  46851. private _cachedCameraDirection;
  46852. private _cachedCameraPosition;
  46853. private _lastCheck;
  46854. private _afterRender;
  46855. }
  46856. }
  46857. declare module "babylonjs/Audio/weightedsound" {
  46858. import { Sound } from "babylonjs/Audio/sound";
  46859. /**
  46860. * Wraps one or more Sound objects and selects one with random weight for playback.
  46861. */
  46862. export class WeightedSound {
  46863. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46864. loop: boolean;
  46865. private _coneInnerAngle;
  46866. private _coneOuterAngle;
  46867. private _volume;
  46868. /** A Sound is currently playing. */
  46869. isPlaying: boolean;
  46870. /** A Sound is currently paused. */
  46871. isPaused: boolean;
  46872. private _sounds;
  46873. private _weights;
  46874. private _currentIndex?;
  46875. /**
  46876. * Creates a new WeightedSound from the list of sounds given.
  46877. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46878. * @param sounds Array of Sounds that will be selected from.
  46879. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46880. */
  46881. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46882. /**
  46883. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46884. */
  46885. get directionalConeInnerAngle(): number;
  46886. /**
  46887. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46888. */
  46889. set directionalConeInnerAngle(value: number);
  46890. /**
  46891. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46892. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46893. */
  46894. get directionalConeOuterAngle(): number;
  46895. /**
  46896. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46897. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46898. */
  46899. set directionalConeOuterAngle(value: number);
  46900. /**
  46901. * Playback volume.
  46902. */
  46903. get volume(): number;
  46904. /**
  46905. * Playback volume.
  46906. */
  46907. set volume(value: number);
  46908. private _onended;
  46909. /**
  46910. * Suspend playback
  46911. */
  46912. pause(): void;
  46913. /**
  46914. * Stop playback
  46915. */
  46916. stop(): void;
  46917. /**
  46918. * Start playback.
  46919. * @param startOffset Position the clip head at a specific time in seconds.
  46920. */
  46921. play(startOffset?: number): void;
  46922. }
  46923. }
  46924. declare module "babylonjs/Audio/index" {
  46925. export * from "babylonjs/Audio/analyser";
  46926. export * from "babylonjs/Audio/audioEngine";
  46927. export * from "babylonjs/Audio/audioSceneComponent";
  46928. export * from "babylonjs/Audio/sound";
  46929. export * from "babylonjs/Audio/soundTrack";
  46930. export * from "babylonjs/Audio/weightedsound";
  46931. }
  46932. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46933. import { Behavior } from "babylonjs/Behaviors/behavior";
  46934. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46935. import { BackEase } from "babylonjs/Animations/easing";
  46936. /**
  46937. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46938. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46939. */
  46940. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46941. /**
  46942. * Gets the name of the behavior.
  46943. */
  46944. get name(): string;
  46945. /**
  46946. * The easing function used by animations
  46947. */
  46948. static EasingFunction: BackEase;
  46949. /**
  46950. * The easing mode used by animations
  46951. */
  46952. static EasingMode: number;
  46953. /**
  46954. * The duration of the animation, in milliseconds
  46955. */
  46956. transitionDuration: number;
  46957. /**
  46958. * Length of the distance animated by the transition when lower radius is reached
  46959. */
  46960. lowerRadiusTransitionRange: number;
  46961. /**
  46962. * Length of the distance animated by the transition when upper radius is reached
  46963. */
  46964. upperRadiusTransitionRange: number;
  46965. private _autoTransitionRange;
  46966. /**
  46967. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46968. */
  46969. get autoTransitionRange(): boolean;
  46970. /**
  46971. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46972. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46973. */
  46974. set autoTransitionRange(value: boolean);
  46975. private _attachedCamera;
  46976. private _onAfterCheckInputsObserver;
  46977. private _onMeshTargetChangedObserver;
  46978. /**
  46979. * Initializes the behavior.
  46980. */
  46981. init(): void;
  46982. /**
  46983. * Attaches the behavior to its arc rotate camera.
  46984. * @param camera Defines the camera to attach the behavior to
  46985. */
  46986. attach(camera: ArcRotateCamera): void;
  46987. /**
  46988. * Detaches the behavior from its current arc rotate camera.
  46989. */
  46990. detach(): void;
  46991. private _radiusIsAnimating;
  46992. private _radiusBounceTransition;
  46993. private _animatables;
  46994. private _cachedWheelPrecision;
  46995. /**
  46996. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46997. * @param radiusLimit The limit to check against.
  46998. * @return Bool to indicate if at limit.
  46999. */
  47000. private _isRadiusAtLimit;
  47001. /**
  47002. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47003. * @param radiusDelta The delta by which to animate to. Can be negative.
  47004. */
  47005. private _applyBoundRadiusAnimation;
  47006. /**
  47007. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47008. */
  47009. protected _clearAnimationLocks(): void;
  47010. /**
  47011. * Stops and removes all animations that have been applied to the camera
  47012. */
  47013. stopAllAnimations(): void;
  47014. }
  47015. }
  47016. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47017. import { Behavior } from "babylonjs/Behaviors/behavior";
  47018. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47019. import { ExponentialEase } from "babylonjs/Animations/easing";
  47020. import { Nullable } from "babylonjs/types";
  47021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47022. import { Vector3 } from "babylonjs/Maths/math.vector";
  47023. /**
  47024. * 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.
  47025. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47026. */
  47027. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47028. /**
  47029. * Gets the name of the behavior.
  47030. */
  47031. get name(): string;
  47032. private _mode;
  47033. private _radiusScale;
  47034. private _positionScale;
  47035. private _defaultElevation;
  47036. private _elevationReturnTime;
  47037. private _elevationReturnWaitTime;
  47038. private _zoomStopsAnimation;
  47039. private _framingTime;
  47040. /**
  47041. * The easing function used by animations
  47042. */
  47043. static EasingFunction: ExponentialEase;
  47044. /**
  47045. * The easing mode used by animations
  47046. */
  47047. static EasingMode: number;
  47048. /**
  47049. * Sets the current mode used by the behavior
  47050. */
  47051. set mode(mode: number);
  47052. /**
  47053. * Gets current mode used by the behavior.
  47054. */
  47055. get mode(): number;
  47056. /**
  47057. * Sets the scale applied to the radius (1 by default)
  47058. */
  47059. set radiusScale(radius: number);
  47060. /**
  47061. * Gets the scale applied to the radius
  47062. */
  47063. get radiusScale(): number;
  47064. /**
  47065. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47066. */
  47067. set positionScale(scale: number);
  47068. /**
  47069. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47070. */
  47071. get positionScale(): number;
  47072. /**
  47073. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47074. * behaviour is triggered, in radians.
  47075. */
  47076. set defaultElevation(elevation: number);
  47077. /**
  47078. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47079. * behaviour is triggered, in radians.
  47080. */
  47081. get defaultElevation(): number;
  47082. /**
  47083. * Sets the time (in milliseconds) taken to return to the default beta position.
  47084. * Negative value indicates camera should not return to default.
  47085. */
  47086. set elevationReturnTime(speed: number);
  47087. /**
  47088. * Gets the time (in milliseconds) taken to return to the default beta position.
  47089. * Negative value indicates camera should not return to default.
  47090. */
  47091. get elevationReturnTime(): number;
  47092. /**
  47093. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47094. */
  47095. set elevationReturnWaitTime(time: number);
  47096. /**
  47097. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47098. */
  47099. get elevationReturnWaitTime(): number;
  47100. /**
  47101. * Sets the flag that indicates if user zooming should stop animation.
  47102. */
  47103. set zoomStopsAnimation(flag: boolean);
  47104. /**
  47105. * Gets the flag that indicates if user zooming should stop animation.
  47106. */
  47107. get zoomStopsAnimation(): boolean;
  47108. /**
  47109. * Sets the transition time when framing the mesh, in milliseconds
  47110. */
  47111. set framingTime(time: number);
  47112. /**
  47113. * Gets the transition time when framing the mesh, in milliseconds
  47114. */
  47115. get framingTime(): number;
  47116. /**
  47117. * Define if the behavior should automatically change the configured
  47118. * camera limits and sensibilities.
  47119. */
  47120. autoCorrectCameraLimitsAndSensibility: boolean;
  47121. private _onPrePointerObservableObserver;
  47122. private _onAfterCheckInputsObserver;
  47123. private _onMeshTargetChangedObserver;
  47124. private _attachedCamera;
  47125. private _isPointerDown;
  47126. private _lastInteractionTime;
  47127. /**
  47128. * Initializes the behavior.
  47129. */
  47130. init(): void;
  47131. /**
  47132. * Attaches the behavior to its arc rotate camera.
  47133. * @param camera Defines the camera to attach the behavior to
  47134. */
  47135. attach(camera: ArcRotateCamera): void;
  47136. /**
  47137. * Detaches the behavior from its current arc rotate camera.
  47138. */
  47139. detach(): void;
  47140. private _animatables;
  47141. private _betaIsAnimating;
  47142. private _betaTransition;
  47143. private _radiusTransition;
  47144. private _vectorTransition;
  47145. /**
  47146. * Targets the given mesh and updates zoom level accordingly.
  47147. * @param mesh The mesh to target.
  47148. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47149. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47150. */
  47151. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47152. /**
  47153. * Targets the given mesh with its children and updates zoom level accordingly.
  47154. * @param mesh The mesh to target.
  47155. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47156. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47157. */
  47158. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47159. /**
  47160. * Targets the given meshes with their children and updates zoom level accordingly.
  47161. * @param meshes The mesh to target.
  47162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47164. */
  47165. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47166. /**
  47167. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47168. * @param minimumWorld Determines the smaller position of the bounding box extend
  47169. * @param maximumWorld Determines the bigger position of the bounding box extend
  47170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47172. */
  47173. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47174. /**
  47175. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47176. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47177. * frustum width.
  47178. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47179. * to fully enclose the mesh in the viewing frustum.
  47180. */
  47181. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47182. /**
  47183. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47184. * is automatically returned to its default position (expected to be above ground plane).
  47185. */
  47186. private _maintainCameraAboveGround;
  47187. /**
  47188. * Returns the frustum slope based on the canvas ratio and camera FOV
  47189. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47190. */
  47191. private _getFrustumSlope;
  47192. /**
  47193. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47194. */
  47195. private _clearAnimationLocks;
  47196. /**
  47197. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47198. */
  47199. private _applyUserInteraction;
  47200. /**
  47201. * Stops and removes all animations that have been applied to the camera
  47202. */
  47203. stopAllAnimations(): void;
  47204. /**
  47205. * Gets a value indicating if the user is moving the camera
  47206. */
  47207. get isUserIsMoving(): boolean;
  47208. /**
  47209. * The camera can move all the way towards the mesh.
  47210. */
  47211. static IgnoreBoundsSizeMode: number;
  47212. /**
  47213. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47214. */
  47215. static FitFrustumSidesMode: number;
  47216. }
  47217. }
  47218. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47219. import { Nullable } from "babylonjs/types";
  47220. import { Camera } from "babylonjs/Cameras/camera";
  47221. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47222. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47223. /**
  47224. * Base class for Camera Pointer Inputs.
  47225. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47226. * for example usage.
  47227. */
  47228. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47229. /**
  47230. * Defines the camera the input is attached to.
  47231. */
  47232. abstract camera: Camera;
  47233. /**
  47234. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47235. */
  47236. protected _altKey: boolean;
  47237. protected _ctrlKey: boolean;
  47238. protected _metaKey: boolean;
  47239. protected _shiftKey: boolean;
  47240. /**
  47241. * Which mouse buttons were pressed at time of last mouse event.
  47242. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47243. */
  47244. protected _buttonsPressed: number;
  47245. /**
  47246. * Defines the buttons associated with the input to handle camera move.
  47247. */
  47248. buttons: number[];
  47249. /**
  47250. * Attach the input controls to a specific dom element to get the input from.
  47251. * @param element Defines the element the controls should be listened from
  47252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47253. */
  47254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47255. /**
  47256. * Detach the current controls from the specified dom element.
  47257. * @param element Defines the element to stop listening the inputs from
  47258. */
  47259. detachControl(element: Nullable<HTMLElement>): void;
  47260. /**
  47261. * Gets the class name of the current input.
  47262. * @returns the class name
  47263. */
  47264. getClassName(): string;
  47265. /**
  47266. * Get the friendly name associated with the input class.
  47267. * @returns the input friendly name
  47268. */
  47269. getSimpleName(): string;
  47270. /**
  47271. * Called on pointer POINTERDOUBLETAP event.
  47272. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47273. */
  47274. protected onDoubleTap(type: string): void;
  47275. /**
  47276. * Called on pointer POINTERMOVE event if only a single touch is active.
  47277. * Override this method to provide functionality.
  47278. */
  47279. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47280. /**
  47281. * Called on pointer POINTERMOVE event if multiple touches are active.
  47282. * Override this method to provide functionality.
  47283. */
  47284. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47285. /**
  47286. * Called on JS contextmenu event.
  47287. * Override this method to provide functionality.
  47288. */
  47289. protected onContextMenu(evt: PointerEvent): void;
  47290. /**
  47291. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47292. * press.
  47293. * Override this method to provide functionality.
  47294. */
  47295. protected onButtonDown(evt: PointerEvent): void;
  47296. /**
  47297. * Called each time a new POINTERUP event occurs. Ie, for each button
  47298. * release.
  47299. * Override this method to provide functionality.
  47300. */
  47301. protected onButtonUp(evt: PointerEvent): void;
  47302. /**
  47303. * Called when window becomes inactive.
  47304. * Override this method to provide functionality.
  47305. */
  47306. protected onLostFocus(): void;
  47307. private _pointerInput;
  47308. private _observer;
  47309. private _onLostFocus;
  47310. private pointA;
  47311. private pointB;
  47312. }
  47313. }
  47314. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47315. import { Nullable } from "babylonjs/types";
  47316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47317. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47318. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47319. /**
  47320. * Manage the pointers inputs to control an arc rotate camera.
  47321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47322. */
  47323. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47324. /**
  47325. * Defines the camera the input is attached to.
  47326. */
  47327. camera: ArcRotateCamera;
  47328. /**
  47329. * Gets the class name of the current input.
  47330. * @returns the class name
  47331. */
  47332. getClassName(): string;
  47333. /**
  47334. * Defines the buttons associated with the input to handle camera move.
  47335. */
  47336. buttons: number[];
  47337. /**
  47338. * Defines the pointer angular sensibility along the X axis or how fast is
  47339. * the camera rotating.
  47340. */
  47341. angularSensibilityX: number;
  47342. /**
  47343. * Defines the pointer angular sensibility along the Y axis or how fast is
  47344. * the camera rotating.
  47345. */
  47346. angularSensibilityY: number;
  47347. /**
  47348. * Defines the pointer pinch precision or how fast is the camera zooming.
  47349. */
  47350. pinchPrecision: number;
  47351. /**
  47352. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47353. * from 0.
  47354. * It defines the percentage of current camera.radius to use as delta when
  47355. * pinch zoom is used.
  47356. */
  47357. pinchDeltaPercentage: number;
  47358. /**
  47359. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47360. * that any object in the plane at the camera's target point will scale
  47361. * perfectly with finger motion.
  47362. * Overrides pinchDeltaPercentage and pinchPrecision.
  47363. */
  47364. useNaturalPinchZoom: boolean;
  47365. /**
  47366. * Defines the pointer panning sensibility or how fast is the camera moving.
  47367. */
  47368. panningSensibility: number;
  47369. /**
  47370. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47371. */
  47372. multiTouchPanning: boolean;
  47373. /**
  47374. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47375. * zoom (pinch) through multitouch.
  47376. */
  47377. multiTouchPanAndZoom: boolean;
  47378. /**
  47379. * Revers pinch action direction.
  47380. */
  47381. pinchInwards: boolean;
  47382. private _isPanClick;
  47383. private _twoFingerActivityCount;
  47384. private _isPinching;
  47385. /**
  47386. * Called on pointer POINTERMOVE event if only a single touch is active.
  47387. */
  47388. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47389. /**
  47390. * Called on pointer POINTERDOUBLETAP event.
  47391. */
  47392. protected onDoubleTap(type: string): void;
  47393. /**
  47394. * Called on pointer POINTERMOVE event if multiple touches are active.
  47395. */
  47396. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47397. /**
  47398. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47399. * press.
  47400. */
  47401. protected onButtonDown(evt: PointerEvent): void;
  47402. /**
  47403. * Called each time a new POINTERUP event occurs. Ie, for each button
  47404. * release.
  47405. */
  47406. protected onButtonUp(evt: PointerEvent): void;
  47407. /**
  47408. * Called when window becomes inactive.
  47409. */
  47410. protected onLostFocus(): void;
  47411. }
  47412. }
  47413. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47414. import { Nullable } from "babylonjs/types";
  47415. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47416. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47417. /**
  47418. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47419. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47420. */
  47421. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47422. /**
  47423. * Defines the camera the input is attached to.
  47424. */
  47425. camera: ArcRotateCamera;
  47426. /**
  47427. * Defines the list of key codes associated with the up action (increase alpha)
  47428. */
  47429. keysUp: number[];
  47430. /**
  47431. * Defines the list of key codes associated with the down action (decrease alpha)
  47432. */
  47433. keysDown: number[];
  47434. /**
  47435. * Defines the list of key codes associated with the left action (increase beta)
  47436. */
  47437. keysLeft: number[];
  47438. /**
  47439. * Defines the list of key codes associated with the right action (decrease beta)
  47440. */
  47441. keysRight: number[];
  47442. /**
  47443. * Defines the list of key codes associated with the reset action.
  47444. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47445. */
  47446. keysReset: number[];
  47447. /**
  47448. * Defines the panning sensibility of the inputs.
  47449. * (How fast is the camera panning)
  47450. */
  47451. panningSensibility: number;
  47452. /**
  47453. * Defines the zooming sensibility of the inputs.
  47454. * (How fast is the camera zooming)
  47455. */
  47456. zoomingSensibility: number;
  47457. /**
  47458. * Defines whether maintaining the alt key down switch the movement mode from
  47459. * orientation to zoom.
  47460. */
  47461. useAltToZoom: boolean;
  47462. /**
  47463. * Rotation speed of the camera
  47464. */
  47465. angularSpeed: number;
  47466. private _keys;
  47467. private _ctrlPressed;
  47468. private _altPressed;
  47469. private _onCanvasBlurObserver;
  47470. private _onKeyboardObserver;
  47471. private _engine;
  47472. private _scene;
  47473. /**
  47474. * Attach the input controls to a specific dom element to get the input from.
  47475. * @param element Defines the element the controls should be listened from
  47476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47477. */
  47478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47479. /**
  47480. * Detach the current controls from the specified dom element.
  47481. * @param element Defines the element to stop listening the inputs from
  47482. */
  47483. detachControl(element: Nullable<HTMLElement>): void;
  47484. /**
  47485. * Update the current camera state depending on the inputs that have been used this frame.
  47486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47487. */
  47488. checkInputs(): void;
  47489. /**
  47490. * Gets the class name of the current intput.
  47491. * @returns the class name
  47492. */
  47493. getClassName(): string;
  47494. /**
  47495. * Get the friendly name associated with the input class.
  47496. * @returns the input friendly name
  47497. */
  47498. getSimpleName(): string;
  47499. }
  47500. }
  47501. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47502. import { Nullable } from "babylonjs/types";
  47503. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47504. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47505. /**
  47506. * Manage the mouse wheel inputs to control an arc rotate camera.
  47507. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47508. */
  47509. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47510. /**
  47511. * Defines the camera the input is attached to.
  47512. */
  47513. camera: ArcRotateCamera;
  47514. /**
  47515. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47516. */
  47517. wheelPrecision: number;
  47518. /**
  47519. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47520. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47521. */
  47522. wheelDeltaPercentage: number;
  47523. private _wheel;
  47524. private _observer;
  47525. private computeDeltaFromMouseWheelLegacyEvent;
  47526. /**
  47527. * Attach the input controls to a specific dom element to get the input from.
  47528. * @param element Defines the element the controls should be listened from
  47529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47530. */
  47531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47532. /**
  47533. * Detach the current controls from the specified dom element.
  47534. * @param element Defines the element to stop listening the inputs from
  47535. */
  47536. detachControl(element: Nullable<HTMLElement>): void;
  47537. /**
  47538. * Gets the class name of the current intput.
  47539. * @returns the class name
  47540. */
  47541. getClassName(): string;
  47542. /**
  47543. * Get the friendly name associated with the input class.
  47544. * @returns the input friendly name
  47545. */
  47546. getSimpleName(): string;
  47547. }
  47548. }
  47549. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47550. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47551. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47552. /**
  47553. * Default Inputs manager for the ArcRotateCamera.
  47554. * It groups all the default supported inputs for ease of use.
  47555. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47556. */
  47557. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47558. /**
  47559. * Instantiates a new ArcRotateCameraInputsManager.
  47560. * @param camera Defines the camera the inputs belong to
  47561. */
  47562. constructor(camera: ArcRotateCamera);
  47563. /**
  47564. * Add mouse wheel input support to the input manager.
  47565. * @returns the current input manager
  47566. */
  47567. addMouseWheel(): ArcRotateCameraInputsManager;
  47568. /**
  47569. * Add pointers input support to the input manager.
  47570. * @returns the current input manager
  47571. */
  47572. addPointers(): ArcRotateCameraInputsManager;
  47573. /**
  47574. * Add keyboard input support to the input manager.
  47575. * @returns the current input manager
  47576. */
  47577. addKeyboard(): ArcRotateCameraInputsManager;
  47578. }
  47579. }
  47580. declare module "babylonjs/Cameras/arcRotateCamera" {
  47581. import { Observable } from "babylonjs/Misc/observable";
  47582. import { Nullable } from "babylonjs/types";
  47583. import { Scene } from "babylonjs/scene";
  47584. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47586. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47587. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47588. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47589. import { Camera } from "babylonjs/Cameras/camera";
  47590. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47591. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47592. import { Collider } from "babylonjs/Collisions/collider";
  47593. /**
  47594. * This represents an orbital type of camera.
  47595. *
  47596. * 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.
  47597. * 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.
  47598. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47599. */
  47600. export class ArcRotateCamera extends TargetCamera {
  47601. /**
  47602. * Defines the rotation angle of the camera along the longitudinal axis.
  47603. */
  47604. alpha: number;
  47605. /**
  47606. * Defines the rotation angle of the camera along the latitudinal axis.
  47607. */
  47608. beta: number;
  47609. /**
  47610. * Defines the radius of the camera from it s target point.
  47611. */
  47612. radius: number;
  47613. protected _target: Vector3;
  47614. protected _targetHost: Nullable<AbstractMesh>;
  47615. /**
  47616. * Defines the target point of the camera.
  47617. * The camera looks towards it form the radius distance.
  47618. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47619. */
  47620. get target(): Vector3;
  47621. set target(value: Vector3);
  47622. /**
  47623. * Define the current local position of the camera in the scene
  47624. */
  47625. get position(): Vector3;
  47626. set position(newPosition: Vector3);
  47627. protected _upToYMatrix: Matrix;
  47628. protected _YToUpMatrix: Matrix;
  47629. /**
  47630. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47631. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47632. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47633. */
  47634. set upVector(vec: Vector3);
  47635. get upVector(): Vector3;
  47636. /**
  47637. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47638. */
  47639. setMatUp(): void;
  47640. /**
  47641. * Current inertia value on the longitudinal axis.
  47642. * The bigger this number the longer it will take for the camera to stop.
  47643. */
  47644. inertialAlphaOffset: number;
  47645. /**
  47646. * Current inertia value on the latitudinal axis.
  47647. * The bigger this number the longer it will take for the camera to stop.
  47648. */
  47649. inertialBetaOffset: number;
  47650. /**
  47651. * Current inertia value on the radius axis.
  47652. * The bigger this number the longer it will take for the camera to stop.
  47653. */
  47654. inertialRadiusOffset: number;
  47655. /**
  47656. * Minimum allowed angle on the longitudinal axis.
  47657. * This can help limiting how the Camera is able to move in the scene.
  47658. */
  47659. lowerAlphaLimit: Nullable<number>;
  47660. /**
  47661. * Maximum allowed angle on the longitudinal axis.
  47662. * This can help limiting how the Camera is able to move in the scene.
  47663. */
  47664. upperAlphaLimit: Nullable<number>;
  47665. /**
  47666. * Minimum allowed angle on the latitudinal axis.
  47667. * This can help limiting how the Camera is able to move in the scene.
  47668. */
  47669. lowerBetaLimit: number;
  47670. /**
  47671. * Maximum allowed angle on the latitudinal axis.
  47672. * This can help limiting how the Camera is able to move in the scene.
  47673. */
  47674. upperBetaLimit: number;
  47675. /**
  47676. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47677. * This can help limiting how the Camera is able to move in the scene.
  47678. */
  47679. lowerRadiusLimit: Nullable<number>;
  47680. /**
  47681. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47682. * This can help limiting how the Camera is able to move in the scene.
  47683. */
  47684. upperRadiusLimit: Nullable<number>;
  47685. /**
  47686. * Defines the current inertia value used during panning of the camera along the X axis.
  47687. */
  47688. inertialPanningX: number;
  47689. /**
  47690. * Defines the current inertia value used during panning of the camera along the Y axis.
  47691. */
  47692. inertialPanningY: number;
  47693. /**
  47694. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47695. * Basically if your fingers moves away from more than this distance you will be considered
  47696. * in pinch mode.
  47697. */
  47698. pinchToPanMaxDistance: number;
  47699. /**
  47700. * Defines the maximum distance the camera can pan.
  47701. * This could help keeping the cammera always in your scene.
  47702. */
  47703. panningDistanceLimit: Nullable<number>;
  47704. /**
  47705. * Defines the target of the camera before paning.
  47706. */
  47707. panningOriginTarget: Vector3;
  47708. /**
  47709. * Defines the value of the inertia used during panning.
  47710. * 0 would mean stop inertia and one would mean no decelleration at all.
  47711. */
  47712. panningInertia: number;
  47713. /**
  47714. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47715. */
  47716. get angularSensibilityX(): number;
  47717. set angularSensibilityX(value: number);
  47718. /**
  47719. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47720. */
  47721. get angularSensibilityY(): number;
  47722. set angularSensibilityY(value: number);
  47723. /**
  47724. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47725. */
  47726. get pinchPrecision(): number;
  47727. set pinchPrecision(value: number);
  47728. /**
  47729. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47730. * It will be used instead of pinchDeltaPrecision if different from 0.
  47731. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47732. */
  47733. get pinchDeltaPercentage(): number;
  47734. set pinchDeltaPercentage(value: number);
  47735. /**
  47736. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47737. * and pinch delta percentage.
  47738. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47739. * that any object in the plane at the camera's target point will scale
  47740. * perfectly with finger motion.
  47741. */
  47742. get useNaturalPinchZoom(): boolean;
  47743. set useNaturalPinchZoom(value: boolean);
  47744. /**
  47745. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47746. */
  47747. get panningSensibility(): number;
  47748. set panningSensibility(value: number);
  47749. /**
  47750. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47751. */
  47752. get keysUp(): number[];
  47753. set keysUp(value: number[]);
  47754. /**
  47755. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47756. */
  47757. get keysDown(): number[];
  47758. set keysDown(value: number[]);
  47759. /**
  47760. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47761. */
  47762. get keysLeft(): number[];
  47763. set keysLeft(value: number[]);
  47764. /**
  47765. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47766. */
  47767. get keysRight(): number[];
  47768. set keysRight(value: number[]);
  47769. /**
  47770. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47771. */
  47772. get wheelPrecision(): number;
  47773. set wheelPrecision(value: number);
  47774. /**
  47775. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47776. * It will be used instead of pinchDeltaPrecision if different from 0.
  47777. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47778. */
  47779. get wheelDeltaPercentage(): number;
  47780. set wheelDeltaPercentage(value: number);
  47781. /**
  47782. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47783. */
  47784. zoomOnFactor: number;
  47785. /**
  47786. * Defines a screen offset for the camera position.
  47787. */
  47788. targetScreenOffset: Vector2;
  47789. /**
  47790. * Allows the camera to be completely reversed.
  47791. * If false the camera can not arrive upside down.
  47792. */
  47793. allowUpsideDown: boolean;
  47794. /**
  47795. * Define if double tap/click is used to restore the previously saved state of the camera.
  47796. */
  47797. useInputToRestoreState: boolean;
  47798. /** @hidden */
  47799. _viewMatrix: Matrix;
  47800. /** @hidden */
  47801. _useCtrlForPanning: boolean;
  47802. /** @hidden */
  47803. _panningMouseButton: number;
  47804. /**
  47805. * Defines the input associated to the camera.
  47806. */
  47807. inputs: ArcRotateCameraInputsManager;
  47808. /** @hidden */
  47809. _reset: () => void;
  47810. /**
  47811. * Defines the allowed panning axis.
  47812. */
  47813. panningAxis: Vector3;
  47814. protected _localDirection: Vector3;
  47815. protected _transformedDirection: Vector3;
  47816. private _bouncingBehavior;
  47817. /**
  47818. * Gets the bouncing behavior of the camera if it has been enabled.
  47819. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47820. */
  47821. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47822. /**
  47823. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47824. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47825. */
  47826. get useBouncingBehavior(): boolean;
  47827. set useBouncingBehavior(value: boolean);
  47828. private _framingBehavior;
  47829. /**
  47830. * Gets the framing behavior of the camera if it has been enabled.
  47831. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47832. */
  47833. get framingBehavior(): Nullable<FramingBehavior>;
  47834. /**
  47835. * Defines if the framing behavior of the camera is enabled on the camera.
  47836. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47837. */
  47838. get useFramingBehavior(): boolean;
  47839. set useFramingBehavior(value: boolean);
  47840. private _autoRotationBehavior;
  47841. /**
  47842. * Gets the auto rotation behavior of the camera if it has been enabled.
  47843. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47844. */
  47845. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47846. /**
  47847. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47848. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47849. */
  47850. get useAutoRotationBehavior(): boolean;
  47851. set useAutoRotationBehavior(value: boolean);
  47852. /**
  47853. * Observable triggered when the mesh target has been changed on the camera.
  47854. */
  47855. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47856. /**
  47857. * Event raised when the camera is colliding with a mesh.
  47858. */
  47859. onCollide: (collidedMesh: AbstractMesh) => void;
  47860. /**
  47861. * Defines whether the camera should check collision with the objects oh the scene.
  47862. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47863. */
  47864. checkCollisions: boolean;
  47865. /**
  47866. * Defines the collision radius of the camera.
  47867. * This simulates a sphere around the camera.
  47868. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47869. */
  47870. collisionRadius: Vector3;
  47871. protected _collider: Collider;
  47872. protected _previousPosition: Vector3;
  47873. protected _collisionVelocity: Vector3;
  47874. protected _newPosition: Vector3;
  47875. protected _previousAlpha: number;
  47876. protected _previousBeta: number;
  47877. protected _previousRadius: number;
  47878. protected _collisionTriggered: boolean;
  47879. protected _targetBoundingCenter: Nullable<Vector3>;
  47880. private _computationVector;
  47881. /**
  47882. * Instantiates a new ArcRotateCamera in a given scene
  47883. * @param name Defines the name of the camera
  47884. * @param alpha Defines the camera rotation along the logitudinal axis
  47885. * @param beta Defines the camera rotation along the latitudinal axis
  47886. * @param radius Defines the camera distance from its target
  47887. * @param target Defines the camera target
  47888. * @param scene Defines the scene the camera belongs to
  47889. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47890. */
  47891. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47892. /** @hidden */
  47893. _initCache(): void;
  47894. /** @hidden */
  47895. _updateCache(ignoreParentClass?: boolean): void;
  47896. protected _getTargetPosition(): Vector3;
  47897. private _storedAlpha;
  47898. private _storedBeta;
  47899. private _storedRadius;
  47900. private _storedTarget;
  47901. private _storedTargetScreenOffset;
  47902. /**
  47903. * Stores the current state of the camera (alpha, beta, radius and target)
  47904. * @returns the camera itself
  47905. */
  47906. storeState(): Camera;
  47907. /**
  47908. * @hidden
  47909. * Restored camera state. You must call storeState() first
  47910. */
  47911. _restoreStateValues(): boolean;
  47912. /** @hidden */
  47913. _isSynchronizedViewMatrix(): boolean;
  47914. /**
  47915. * Attached controls to the current camera.
  47916. * @param element Defines the element the controls should be listened from
  47917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47918. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47919. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47920. */
  47921. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47922. /**
  47923. * Detach the current controls from the camera.
  47924. * The camera will stop reacting to inputs.
  47925. * @param element Defines the element to stop listening the inputs from
  47926. */
  47927. detachControl(element: HTMLElement): void;
  47928. /** @hidden */
  47929. _checkInputs(): void;
  47930. protected _checkLimits(): void;
  47931. /**
  47932. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47933. */
  47934. rebuildAnglesAndRadius(): void;
  47935. /**
  47936. * Use a position to define the current camera related information like alpha, beta and radius
  47937. * @param position Defines the position to set the camera at
  47938. */
  47939. setPosition(position: Vector3): void;
  47940. /**
  47941. * Defines the target the camera should look at.
  47942. * This will automatically adapt alpha beta and radius to fit within the new target.
  47943. * @param target Defines the new target as a Vector or a mesh
  47944. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47945. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47946. */
  47947. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47948. /** @hidden */
  47949. _getViewMatrix(): Matrix;
  47950. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47951. /**
  47952. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47953. * @param meshes Defines the mesh to zoom on
  47954. * @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)
  47955. */
  47956. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47957. /**
  47958. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47959. * The target will be changed but the radius
  47960. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47961. * @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)
  47962. */
  47963. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47964. min: Vector3;
  47965. max: Vector3;
  47966. distance: number;
  47967. }, doNotUpdateMaxZ?: boolean): void;
  47968. /**
  47969. * @override
  47970. * Override Camera.createRigCamera
  47971. */
  47972. createRigCamera(name: string, cameraIndex: number): Camera;
  47973. /**
  47974. * @hidden
  47975. * @override
  47976. * Override Camera._updateRigCameras
  47977. */
  47978. _updateRigCameras(): void;
  47979. /**
  47980. * Destroy the camera and release the current resources hold by it.
  47981. */
  47982. dispose(): void;
  47983. /**
  47984. * Gets the current object class name.
  47985. * @return the class name
  47986. */
  47987. getClassName(): string;
  47988. }
  47989. }
  47990. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47991. import { Behavior } from "babylonjs/Behaviors/behavior";
  47992. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47993. /**
  47994. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47995. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47996. */
  47997. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47998. /**
  47999. * Gets the name of the behavior.
  48000. */
  48001. get name(): string;
  48002. private _zoomStopsAnimation;
  48003. private _idleRotationSpeed;
  48004. private _idleRotationWaitTime;
  48005. private _idleRotationSpinupTime;
  48006. /**
  48007. * Sets the flag that indicates if user zooming should stop animation.
  48008. */
  48009. set zoomStopsAnimation(flag: boolean);
  48010. /**
  48011. * Gets the flag that indicates if user zooming should stop animation.
  48012. */
  48013. get zoomStopsAnimation(): boolean;
  48014. /**
  48015. * Sets the default speed at which the camera rotates around the model.
  48016. */
  48017. set idleRotationSpeed(speed: number);
  48018. /**
  48019. * Gets the default speed at which the camera rotates around the model.
  48020. */
  48021. get idleRotationSpeed(): number;
  48022. /**
  48023. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48024. */
  48025. set idleRotationWaitTime(time: number);
  48026. /**
  48027. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48028. */
  48029. get idleRotationWaitTime(): number;
  48030. /**
  48031. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48032. */
  48033. set idleRotationSpinupTime(time: number);
  48034. /**
  48035. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48036. */
  48037. get idleRotationSpinupTime(): number;
  48038. /**
  48039. * Gets a value indicating if the camera is currently rotating because of this behavior
  48040. */
  48041. get rotationInProgress(): boolean;
  48042. private _onPrePointerObservableObserver;
  48043. private _onAfterCheckInputsObserver;
  48044. private _attachedCamera;
  48045. private _isPointerDown;
  48046. private _lastFrameTime;
  48047. private _lastInteractionTime;
  48048. private _cameraRotationSpeed;
  48049. /**
  48050. * Initializes the behavior.
  48051. */
  48052. init(): void;
  48053. /**
  48054. * Attaches the behavior to its arc rotate camera.
  48055. * @param camera Defines the camera to attach the behavior to
  48056. */
  48057. attach(camera: ArcRotateCamera): void;
  48058. /**
  48059. * Detaches the behavior from its current arc rotate camera.
  48060. */
  48061. detach(): void;
  48062. /**
  48063. * Returns true if user is scrolling.
  48064. * @return true if user is scrolling.
  48065. */
  48066. private _userIsZooming;
  48067. private _lastFrameRadius;
  48068. private _shouldAnimationStopForInteraction;
  48069. /**
  48070. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48071. */
  48072. private _applyUserInteraction;
  48073. private _userIsMoving;
  48074. }
  48075. }
  48076. declare module "babylonjs/Behaviors/Cameras/index" {
  48077. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48078. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48079. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48080. }
  48081. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48082. import { Mesh } from "babylonjs/Meshes/mesh";
  48083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48084. import { Behavior } from "babylonjs/Behaviors/behavior";
  48085. /**
  48086. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48087. */
  48088. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48089. private ui;
  48090. /**
  48091. * The name of the behavior
  48092. */
  48093. name: string;
  48094. /**
  48095. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48096. */
  48097. distanceAwayFromFace: number;
  48098. /**
  48099. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48100. */
  48101. distanceAwayFromBottomOfFace: number;
  48102. private _faceVectors;
  48103. private _target;
  48104. private _scene;
  48105. private _onRenderObserver;
  48106. private _tmpMatrix;
  48107. private _tmpVector;
  48108. /**
  48109. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48110. * @param ui The transform node that should be attched to the mesh
  48111. */
  48112. constructor(ui: TransformNode);
  48113. /**
  48114. * Initializes the behavior
  48115. */
  48116. init(): void;
  48117. private _closestFace;
  48118. private _zeroVector;
  48119. private _lookAtTmpMatrix;
  48120. private _lookAtToRef;
  48121. /**
  48122. * Attaches the AttachToBoxBehavior to the passed in mesh
  48123. * @param target The mesh that the specified node will be attached to
  48124. */
  48125. attach(target: Mesh): void;
  48126. /**
  48127. * Detaches the behavior from the mesh
  48128. */
  48129. detach(): void;
  48130. }
  48131. }
  48132. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48133. import { Behavior } from "babylonjs/Behaviors/behavior";
  48134. import { Mesh } from "babylonjs/Meshes/mesh";
  48135. /**
  48136. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48137. */
  48138. export class FadeInOutBehavior implements Behavior<Mesh> {
  48139. /**
  48140. * Time in milliseconds to delay before fading in (Default: 0)
  48141. */
  48142. delay: number;
  48143. /**
  48144. * Time in milliseconds for the mesh to fade in (Default: 300)
  48145. */
  48146. fadeInTime: number;
  48147. private _millisecondsPerFrame;
  48148. private _hovered;
  48149. private _hoverValue;
  48150. private _ownerNode;
  48151. /**
  48152. * Instatiates the FadeInOutBehavior
  48153. */
  48154. constructor();
  48155. /**
  48156. * The name of the behavior
  48157. */
  48158. get name(): string;
  48159. /**
  48160. * Initializes the behavior
  48161. */
  48162. init(): void;
  48163. /**
  48164. * Attaches the fade behavior on the passed in mesh
  48165. * @param ownerNode The mesh that will be faded in/out once attached
  48166. */
  48167. attach(ownerNode: Mesh): void;
  48168. /**
  48169. * Detaches the behavior from the mesh
  48170. */
  48171. detach(): void;
  48172. /**
  48173. * Triggers the mesh to begin fading in or out
  48174. * @param value if the object should fade in or out (true to fade in)
  48175. */
  48176. fadeIn(value: boolean): void;
  48177. private _update;
  48178. private _setAllVisibility;
  48179. }
  48180. }
  48181. declare module "babylonjs/Misc/pivotTools" {
  48182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48183. /**
  48184. * Class containing a set of static utilities functions for managing Pivots
  48185. * @hidden
  48186. */
  48187. export class PivotTools {
  48188. private static _PivotCached;
  48189. private static _OldPivotPoint;
  48190. private static _PivotTranslation;
  48191. private static _PivotTmpVector;
  48192. private static _PivotPostMultiplyPivotMatrix;
  48193. /** @hidden */
  48194. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48195. /** @hidden */
  48196. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48197. }
  48198. }
  48199. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48200. import { Scene } from "babylonjs/scene";
  48201. import { Vector4 } from "babylonjs/Maths/math.vector";
  48202. import { Mesh } from "babylonjs/Meshes/mesh";
  48203. import { Nullable } from "babylonjs/types";
  48204. import { Plane } from "babylonjs/Maths/math.plane";
  48205. /**
  48206. * Class containing static functions to help procedurally build meshes
  48207. */
  48208. export class PlaneBuilder {
  48209. /**
  48210. * Creates a plane mesh
  48211. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48212. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48213. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48217. * @param name defines the name of the mesh
  48218. * @param options defines the options used to create the mesh
  48219. * @param scene defines the hosting scene
  48220. * @returns the plane mesh
  48221. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48222. */
  48223. static CreatePlane(name: string, options: {
  48224. size?: number;
  48225. width?: number;
  48226. height?: number;
  48227. sideOrientation?: number;
  48228. frontUVs?: Vector4;
  48229. backUVs?: Vector4;
  48230. updatable?: boolean;
  48231. sourcePlane?: Plane;
  48232. }, scene?: Nullable<Scene>): Mesh;
  48233. }
  48234. }
  48235. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48236. import { Behavior } from "babylonjs/Behaviors/behavior";
  48237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48238. import { Observable } from "babylonjs/Misc/observable";
  48239. import { Vector3 } from "babylonjs/Maths/math.vector";
  48240. import { Ray } from "babylonjs/Culling/ray";
  48241. import "babylonjs/Meshes/Builders/planeBuilder";
  48242. /**
  48243. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48244. */
  48245. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48246. private static _AnyMouseID;
  48247. /**
  48248. * Abstract mesh the behavior is set on
  48249. */
  48250. attachedNode: AbstractMesh;
  48251. private _dragPlane;
  48252. private _scene;
  48253. private _pointerObserver;
  48254. private _beforeRenderObserver;
  48255. private static _planeScene;
  48256. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48257. /**
  48258. * 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)
  48259. */
  48260. maxDragAngle: number;
  48261. /**
  48262. * @hidden
  48263. */
  48264. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48265. /**
  48266. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48267. */
  48268. currentDraggingPointerID: number;
  48269. /**
  48270. * The last position where the pointer hit the drag plane in world space
  48271. */
  48272. lastDragPosition: Vector3;
  48273. /**
  48274. * If the behavior is currently in a dragging state
  48275. */
  48276. dragging: boolean;
  48277. /**
  48278. * 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)
  48279. */
  48280. dragDeltaRatio: number;
  48281. /**
  48282. * If the drag plane orientation should be updated during the dragging (Default: true)
  48283. */
  48284. updateDragPlane: boolean;
  48285. private _debugMode;
  48286. private _moving;
  48287. /**
  48288. * Fires each time the attached mesh is dragged with the pointer
  48289. * * delta between last drag position and current drag position in world space
  48290. * * dragDistance along the drag axis
  48291. * * dragPlaneNormal normal of the current drag plane used during the drag
  48292. * * dragPlanePoint in world space where the drag intersects the drag plane
  48293. */
  48294. onDragObservable: Observable<{
  48295. delta: Vector3;
  48296. dragPlanePoint: Vector3;
  48297. dragPlaneNormal: Vector3;
  48298. dragDistance: number;
  48299. pointerId: number;
  48300. }>;
  48301. /**
  48302. * Fires each time a drag begins (eg. mouse down on mesh)
  48303. */
  48304. onDragStartObservable: Observable<{
  48305. dragPlanePoint: Vector3;
  48306. pointerId: number;
  48307. }>;
  48308. /**
  48309. * Fires each time a drag ends (eg. mouse release after drag)
  48310. */
  48311. onDragEndObservable: Observable<{
  48312. dragPlanePoint: Vector3;
  48313. pointerId: number;
  48314. }>;
  48315. /**
  48316. * If the attached mesh should be moved when dragged
  48317. */
  48318. moveAttached: boolean;
  48319. /**
  48320. * If the drag behavior will react to drag events (Default: true)
  48321. */
  48322. enabled: boolean;
  48323. /**
  48324. * If pointer events should start and release the drag (Default: true)
  48325. */
  48326. startAndReleaseDragOnPointerEvents: boolean;
  48327. /**
  48328. * If camera controls should be detached during the drag
  48329. */
  48330. detachCameraControls: boolean;
  48331. /**
  48332. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48333. */
  48334. useObjectOrientationForDragging: boolean;
  48335. private _options;
  48336. /**
  48337. * Gets the options used by the behavior
  48338. */
  48339. get options(): {
  48340. dragAxis?: Vector3;
  48341. dragPlaneNormal?: Vector3;
  48342. };
  48343. /**
  48344. * Sets the options used by the behavior
  48345. */
  48346. set options(options: {
  48347. dragAxis?: Vector3;
  48348. dragPlaneNormal?: Vector3;
  48349. });
  48350. /**
  48351. * Creates a pointer drag behavior that can be attached to a mesh
  48352. * @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)
  48353. */
  48354. constructor(options?: {
  48355. dragAxis?: Vector3;
  48356. dragPlaneNormal?: Vector3;
  48357. });
  48358. /**
  48359. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48360. */
  48361. validateDrag: (targetPosition: Vector3) => boolean;
  48362. /**
  48363. * The name of the behavior
  48364. */
  48365. get name(): string;
  48366. /**
  48367. * Initializes the behavior
  48368. */
  48369. init(): void;
  48370. private _tmpVector;
  48371. private _alternatePickedPoint;
  48372. private _worldDragAxis;
  48373. private _targetPosition;
  48374. private _attachedElement;
  48375. /**
  48376. * Attaches the drag behavior the passed in mesh
  48377. * @param ownerNode The mesh that will be dragged around once attached
  48378. * @param predicate Predicate to use for pick filtering
  48379. */
  48380. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48381. /**
  48382. * Force relase the drag action by code.
  48383. */
  48384. releaseDrag(): void;
  48385. private _startDragRay;
  48386. private _lastPointerRay;
  48387. /**
  48388. * Simulates the start of a pointer drag event on the behavior
  48389. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48390. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48391. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48392. */
  48393. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48394. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48395. private _dragDelta;
  48396. protected _moveDrag(ray: Ray): void;
  48397. private _pickWithRayOnDragPlane;
  48398. private _pointA;
  48399. private _pointC;
  48400. private _localAxis;
  48401. private _lookAt;
  48402. private _updateDragPlanePosition;
  48403. /**
  48404. * Detaches the behavior from the mesh
  48405. */
  48406. detach(): void;
  48407. }
  48408. }
  48409. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48410. import { Mesh } from "babylonjs/Meshes/mesh";
  48411. import { Behavior } from "babylonjs/Behaviors/behavior";
  48412. /**
  48413. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48414. */
  48415. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48416. private _dragBehaviorA;
  48417. private _dragBehaviorB;
  48418. private _startDistance;
  48419. private _initialScale;
  48420. private _targetScale;
  48421. private _ownerNode;
  48422. private _sceneRenderObserver;
  48423. /**
  48424. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48425. */
  48426. constructor();
  48427. /**
  48428. * The name of the behavior
  48429. */
  48430. get name(): string;
  48431. /**
  48432. * Initializes the behavior
  48433. */
  48434. init(): void;
  48435. private _getCurrentDistance;
  48436. /**
  48437. * Attaches the scale behavior the passed in mesh
  48438. * @param ownerNode The mesh that will be scaled around once attached
  48439. */
  48440. attach(ownerNode: Mesh): void;
  48441. /**
  48442. * Detaches the behavior from the mesh
  48443. */
  48444. detach(): void;
  48445. }
  48446. }
  48447. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48448. import { Behavior } from "babylonjs/Behaviors/behavior";
  48449. import { Mesh } from "babylonjs/Meshes/mesh";
  48450. import { Observable } from "babylonjs/Misc/observable";
  48451. /**
  48452. * 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
  48453. */
  48454. export class SixDofDragBehavior implements Behavior<Mesh> {
  48455. private static _virtualScene;
  48456. private _ownerNode;
  48457. private _sceneRenderObserver;
  48458. private _scene;
  48459. private _targetPosition;
  48460. private _virtualOriginMesh;
  48461. private _virtualDragMesh;
  48462. private _pointerObserver;
  48463. private _moving;
  48464. private _startingOrientation;
  48465. private _attachedElement;
  48466. /**
  48467. * 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)
  48468. */
  48469. private zDragFactor;
  48470. /**
  48471. * If the object should rotate to face the drag origin
  48472. */
  48473. rotateDraggedObject: boolean;
  48474. /**
  48475. * If the behavior is currently in a dragging state
  48476. */
  48477. dragging: boolean;
  48478. /**
  48479. * 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)
  48480. */
  48481. dragDeltaRatio: number;
  48482. /**
  48483. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48484. */
  48485. currentDraggingPointerID: number;
  48486. /**
  48487. * If camera controls should be detached during the drag
  48488. */
  48489. detachCameraControls: boolean;
  48490. /**
  48491. * Fires each time a drag starts
  48492. */
  48493. onDragStartObservable: Observable<{}>;
  48494. /**
  48495. * Fires each time a drag ends (eg. mouse release after drag)
  48496. */
  48497. onDragEndObservable: Observable<{}>;
  48498. /**
  48499. * 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
  48500. */
  48501. constructor();
  48502. /**
  48503. * The name of the behavior
  48504. */
  48505. get name(): string;
  48506. /**
  48507. * Initializes the behavior
  48508. */
  48509. init(): void;
  48510. /**
  48511. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48512. */
  48513. private get _pointerCamera();
  48514. /**
  48515. * Attaches the scale behavior the passed in mesh
  48516. * @param ownerNode The mesh that will be scaled around once attached
  48517. */
  48518. attach(ownerNode: Mesh): void;
  48519. /**
  48520. * Detaches the behavior from the mesh
  48521. */
  48522. detach(): void;
  48523. }
  48524. }
  48525. declare module "babylonjs/Behaviors/Meshes/index" {
  48526. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48527. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48528. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48529. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48530. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48531. }
  48532. declare module "babylonjs/Behaviors/index" {
  48533. export * from "babylonjs/Behaviors/behavior";
  48534. export * from "babylonjs/Behaviors/Cameras/index";
  48535. export * from "babylonjs/Behaviors/Meshes/index";
  48536. }
  48537. declare module "babylonjs/Bones/boneIKController" {
  48538. import { Bone } from "babylonjs/Bones/bone";
  48539. import { Vector3 } from "babylonjs/Maths/math.vector";
  48540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48541. import { Nullable } from "babylonjs/types";
  48542. /**
  48543. * Class used to apply inverse kinematics to bones
  48544. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48545. */
  48546. export class BoneIKController {
  48547. private static _tmpVecs;
  48548. private static _tmpQuat;
  48549. private static _tmpMats;
  48550. /**
  48551. * Gets or sets the target mesh
  48552. */
  48553. targetMesh: AbstractMesh;
  48554. /** Gets or sets the mesh used as pole */
  48555. poleTargetMesh: AbstractMesh;
  48556. /**
  48557. * Gets or sets the bone used as pole
  48558. */
  48559. poleTargetBone: Nullable<Bone>;
  48560. /**
  48561. * Gets or sets the target position
  48562. */
  48563. targetPosition: Vector3;
  48564. /**
  48565. * Gets or sets the pole target position
  48566. */
  48567. poleTargetPosition: Vector3;
  48568. /**
  48569. * Gets or sets the pole target local offset
  48570. */
  48571. poleTargetLocalOffset: Vector3;
  48572. /**
  48573. * Gets or sets the pole angle
  48574. */
  48575. poleAngle: number;
  48576. /**
  48577. * Gets or sets the mesh associated with the controller
  48578. */
  48579. mesh: AbstractMesh;
  48580. /**
  48581. * 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)
  48582. */
  48583. slerpAmount: number;
  48584. private _bone1Quat;
  48585. private _bone1Mat;
  48586. private _bone2Ang;
  48587. private _bone1;
  48588. private _bone2;
  48589. private _bone1Length;
  48590. private _bone2Length;
  48591. private _maxAngle;
  48592. private _maxReach;
  48593. private _rightHandedSystem;
  48594. private _bendAxis;
  48595. private _slerping;
  48596. private _adjustRoll;
  48597. /**
  48598. * Gets or sets maximum allowed angle
  48599. */
  48600. get maxAngle(): number;
  48601. set maxAngle(value: number);
  48602. /**
  48603. * Creates a new BoneIKController
  48604. * @param mesh defines the mesh to control
  48605. * @param bone defines the bone to control
  48606. * @param options defines options to set up the controller
  48607. */
  48608. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48609. targetMesh?: AbstractMesh;
  48610. poleTargetMesh?: AbstractMesh;
  48611. poleTargetBone?: Bone;
  48612. poleTargetLocalOffset?: Vector3;
  48613. poleAngle?: number;
  48614. bendAxis?: Vector3;
  48615. maxAngle?: number;
  48616. slerpAmount?: number;
  48617. });
  48618. private _setMaxAngle;
  48619. /**
  48620. * Force the controller to update the bones
  48621. */
  48622. update(): void;
  48623. }
  48624. }
  48625. declare module "babylonjs/Bones/boneLookController" {
  48626. import { Vector3 } from "babylonjs/Maths/math.vector";
  48627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48628. import { Bone } from "babylonjs/Bones/bone";
  48629. import { Space } from "babylonjs/Maths/math.axis";
  48630. /**
  48631. * Class used to make a bone look toward a point in space
  48632. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48633. */
  48634. export class BoneLookController {
  48635. private static _tmpVecs;
  48636. private static _tmpQuat;
  48637. private static _tmpMats;
  48638. /**
  48639. * The target Vector3 that the bone will look at
  48640. */
  48641. target: Vector3;
  48642. /**
  48643. * The mesh that the bone is attached to
  48644. */
  48645. mesh: AbstractMesh;
  48646. /**
  48647. * The bone that will be looking to the target
  48648. */
  48649. bone: Bone;
  48650. /**
  48651. * The up axis of the coordinate system that is used when the bone is rotated
  48652. */
  48653. upAxis: Vector3;
  48654. /**
  48655. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48656. */
  48657. upAxisSpace: Space;
  48658. /**
  48659. * Used to make an adjustment to the yaw of the bone
  48660. */
  48661. adjustYaw: number;
  48662. /**
  48663. * Used to make an adjustment to the pitch of the bone
  48664. */
  48665. adjustPitch: number;
  48666. /**
  48667. * Used to make an adjustment to the roll of the bone
  48668. */
  48669. adjustRoll: number;
  48670. /**
  48671. * 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)
  48672. */
  48673. slerpAmount: number;
  48674. private _minYaw;
  48675. private _maxYaw;
  48676. private _minPitch;
  48677. private _maxPitch;
  48678. private _minYawSin;
  48679. private _minYawCos;
  48680. private _maxYawSin;
  48681. private _maxYawCos;
  48682. private _midYawConstraint;
  48683. private _minPitchTan;
  48684. private _maxPitchTan;
  48685. private _boneQuat;
  48686. private _slerping;
  48687. private _transformYawPitch;
  48688. private _transformYawPitchInv;
  48689. private _firstFrameSkipped;
  48690. private _yawRange;
  48691. private _fowardAxis;
  48692. /**
  48693. * Gets or sets the minimum yaw angle that the bone can look to
  48694. */
  48695. get minYaw(): number;
  48696. set minYaw(value: number);
  48697. /**
  48698. * Gets or sets the maximum yaw angle that the bone can look to
  48699. */
  48700. get maxYaw(): number;
  48701. set maxYaw(value: number);
  48702. /**
  48703. * Gets or sets the minimum pitch angle that the bone can look to
  48704. */
  48705. get minPitch(): number;
  48706. set minPitch(value: number);
  48707. /**
  48708. * Gets or sets the maximum pitch angle that the bone can look to
  48709. */
  48710. get maxPitch(): number;
  48711. set maxPitch(value: number);
  48712. /**
  48713. * Create a BoneLookController
  48714. * @param mesh the mesh that the bone belongs to
  48715. * @param bone the bone that will be looking to the target
  48716. * @param target the target Vector3 to look at
  48717. * @param options optional settings:
  48718. * * maxYaw: the maximum angle the bone will yaw to
  48719. * * minYaw: the minimum angle the bone will yaw to
  48720. * * maxPitch: the maximum angle the bone will pitch to
  48721. * * minPitch: the minimum angle the bone will yaw to
  48722. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48723. * * upAxis: the up axis of the coordinate system
  48724. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48725. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48726. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48727. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48728. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48729. * * adjustRoll: used to make an adjustment to the roll of the bone
  48730. **/
  48731. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48732. maxYaw?: number;
  48733. minYaw?: number;
  48734. maxPitch?: number;
  48735. minPitch?: number;
  48736. slerpAmount?: number;
  48737. upAxis?: Vector3;
  48738. upAxisSpace?: Space;
  48739. yawAxis?: Vector3;
  48740. pitchAxis?: Vector3;
  48741. adjustYaw?: number;
  48742. adjustPitch?: number;
  48743. adjustRoll?: number;
  48744. });
  48745. /**
  48746. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48747. */
  48748. update(): void;
  48749. private _getAngleDiff;
  48750. private _getAngleBetween;
  48751. private _isAngleBetween;
  48752. }
  48753. }
  48754. declare module "babylonjs/Bones/index" {
  48755. export * from "babylonjs/Bones/bone";
  48756. export * from "babylonjs/Bones/boneIKController";
  48757. export * from "babylonjs/Bones/boneLookController";
  48758. export * from "babylonjs/Bones/skeleton";
  48759. }
  48760. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48761. import { Nullable } from "babylonjs/types";
  48762. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48763. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48764. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48765. /**
  48766. * Manage the gamepad inputs to control an arc rotate camera.
  48767. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48768. */
  48769. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48770. /**
  48771. * Defines the camera the input is attached to.
  48772. */
  48773. camera: ArcRotateCamera;
  48774. /**
  48775. * Defines the gamepad the input is gathering event from.
  48776. */
  48777. gamepad: Nullable<Gamepad>;
  48778. /**
  48779. * Defines the gamepad rotation sensiblity.
  48780. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48781. */
  48782. gamepadRotationSensibility: number;
  48783. /**
  48784. * Defines the gamepad move sensiblity.
  48785. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48786. */
  48787. gamepadMoveSensibility: number;
  48788. private _yAxisScale;
  48789. /**
  48790. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48791. */
  48792. get invertYAxis(): boolean;
  48793. set invertYAxis(value: boolean);
  48794. private _onGamepadConnectedObserver;
  48795. private _onGamepadDisconnectedObserver;
  48796. /**
  48797. * Attach the input controls to a specific dom element to get the input from.
  48798. * @param element Defines the element the controls should be listened from
  48799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48800. */
  48801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48802. /**
  48803. * Detach the current controls from the specified dom element.
  48804. * @param element Defines the element to stop listening the inputs from
  48805. */
  48806. detachControl(element: Nullable<HTMLElement>): void;
  48807. /**
  48808. * Update the current camera state depending on the inputs that have been used this frame.
  48809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48810. */
  48811. checkInputs(): void;
  48812. /**
  48813. * Gets the class name of the current intput.
  48814. * @returns the class name
  48815. */
  48816. getClassName(): string;
  48817. /**
  48818. * Get the friendly name associated with the input class.
  48819. * @returns the input friendly name
  48820. */
  48821. getSimpleName(): string;
  48822. }
  48823. }
  48824. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48825. import { Nullable } from "babylonjs/types";
  48826. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48827. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48828. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48829. interface ArcRotateCameraInputsManager {
  48830. /**
  48831. * Add orientation input support to the input manager.
  48832. * @returns the current input manager
  48833. */
  48834. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48835. }
  48836. }
  48837. /**
  48838. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48839. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48840. */
  48841. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48842. /**
  48843. * Defines the camera the input is attached to.
  48844. */
  48845. camera: ArcRotateCamera;
  48846. /**
  48847. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48848. */
  48849. alphaCorrection: number;
  48850. /**
  48851. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48852. */
  48853. gammaCorrection: number;
  48854. private _alpha;
  48855. private _gamma;
  48856. private _dirty;
  48857. private _deviceOrientationHandler;
  48858. /**
  48859. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48860. */
  48861. constructor();
  48862. /**
  48863. * Attach the input controls to a specific dom element to get the input from.
  48864. * @param element Defines the element the controls should be listened from
  48865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48866. */
  48867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48868. /** @hidden */
  48869. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48870. /**
  48871. * Update the current camera state depending on the inputs that have been used this frame.
  48872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48873. */
  48874. checkInputs(): void;
  48875. /**
  48876. * Detach the current controls from the specified dom element.
  48877. * @param element Defines the element to stop listening the inputs from
  48878. */
  48879. detachControl(element: Nullable<HTMLElement>): void;
  48880. /**
  48881. * Gets the class name of the current intput.
  48882. * @returns the class name
  48883. */
  48884. getClassName(): string;
  48885. /**
  48886. * Get the friendly name associated with the input class.
  48887. * @returns the input friendly name
  48888. */
  48889. getSimpleName(): string;
  48890. }
  48891. }
  48892. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48893. import { Nullable } from "babylonjs/types";
  48894. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48895. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48896. /**
  48897. * Listen to mouse events to control the camera.
  48898. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48899. */
  48900. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48901. /**
  48902. * Defines the camera the input is attached to.
  48903. */
  48904. camera: FlyCamera;
  48905. /**
  48906. * Defines if touch is enabled. (Default is true.)
  48907. */
  48908. touchEnabled: boolean;
  48909. /**
  48910. * Defines the buttons associated with the input to handle camera rotation.
  48911. */
  48912. buttons: number[];
  48913. /**
  48914. * Assign buttons for Yaw control.
  48915. */
  48916. buttonsYaw: number[];
  48917. /**
  48918. * Assign buttons for Pitch control.
  48919. */
  48920. buttonsPitch: number[];
  48921. /**
  48922. * Assign buttons for Roll control.
  48923. */
  48924. buttonsRoll: number[];
  48925. /**
  48926. * Detect if any button is being pressed while mouse is moved.
  48927. * -1 = Mouse locked.
  48928. * 0 = Left button.
  48929. * 1 = Middle Button.
  48930. * 2 = Right Button.
  48931. */
  48932. activeButton: number;
  48933. /**
  48934. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48935. * Higher values reduce its sensitivity.
  48936. */
  48937. angularSensibility: number;
  48938. private _observer;
  48939. private _rollObserver;
  48940. private previousPosition;
  48941. private noPreventDefault;
  48942. private element;
  48943. /**
  48944. * Listen to mouse events to control the camera.
  48945. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48946. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48947. */
  48948. constructor(touchEnabled?: boolean);
  48949. /**
  48950. * Attach the mouse control to the HTML DOM element.
  48951. * @param element Defines the element that listens to the input events.
  48952. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48953. */
  48954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48955. /**
  48956. * Detach the current controls from the specified dom element.
  48957. * @param element Defines the element to stop listening the inputs from
  48958. */
  48959. detachControl(element: Nullable<HTMLElement>): void;
  48960. /**
  48961. * Gets the class name of the current input.
  48962. * @returns the class name.
  48963. */
  48964. getClassName(): string;
  48965. /**
  48966. * Get the friendly name associated with the input class.
  48967. * @returns the input's friendly name.
  48968. */
  48969. getSimpleName(): string;
  48970. private _pointerInput;
  48971. private _onMouseMove;
  48972. /**
  48973. * Rotate camera by mouse offset.
  48974. */
  48975. private rotateCamera;
  48976. }
  48977. }
  48978. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48979. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48980. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48981. /**
  48982. * Default Inputs manager for the FlyCamera.
  48983. * It groups all the default supported inputs for ease of use.
  48984. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48985. */
  48986. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48987. /**
  48988. * Instantiates a new FlyCameraInputsManager.
  48989. * @param camera Defines the camera the inputs belong to.
  48990. */
  48991. constructor(camera: FlyCamera);
  48992. /**
  48993. * Add keyboard input support to the input manager.
  48994. * @returns the new FlyCameraKeyboardMoveInput().
  48995. */
  48996. addKeyboard(): FlyCameraInputsManager;
  48997. /**
  48998. * Add mouse input support to the input manager.
  48999. * @param touchEnabled Enable touch screen support.
  49000. * @returns the new FlyCameraMouseInput().
  49001. */
  49002. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49003. }
  49004. }
  49005. declare module "babylonjs/Cameras/flyCamera" {
  49006. import { Scene } from "babylonjs/scene";
  49007. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49009. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49010. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49011. /**
  49012. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49013. * such as in a 3D Space Shooter or a Flight Simulator.
  49014. */
  49015. export class FlyCamera extends TargetCamera {
  49016. /**
  49017. * Define the collision ellipsoid of the camera.
  49018. * This is helpful for simulating a camera body, like a player's body.
  49019. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49020. */
  49021. ellipsoid: Vector3;
  49022. /**
  49023. * Define an offset for the position of the ellipsoid around the camera.
  49024. * This can be helpful if the camera is attached away from the player's body center,
  49025. * such as at its head.
  49026. */
  49027. ellipsoidOffset: Vector3;
  49028. /**
  49029. * Enable or disable collisions of the camera with the rest of the scene objects.
  49030. */
  49031. checkCollisions: boolean;
  49032. /**
  49033. * Enable or disable gravity on the camera.
  49034. */
  49035. applyGravity: boolean;
  49036. /**
  49037. * Define the current direction the camera is moving to.
  49038. */
  49039. cameraDirection: Vector3;
  49040. /**
  49041. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49042. * This overrides and empties cameraRotation.
  49043. */
  49044. rotationQuaternion: Quaternion;
  49045. /**
  49046. * Track Roll to maintain the wanted Rolling when looking around.
  49047. */
  49048. _trackRoll: number;
  49049. /**
  49050. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49051. */
  49052. rollCorrect: number;
  49053. /**
  49054. * Mimic a banked turn, Rolling the camera when Yawing.
  49055. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49056. */
  49057. bankedTurn: boolean;
  49058. /**
  49059. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49060. */
  49061. bankedTurnLimit: number;
  49062. /**
  49063. * Value of 0 disables the banked Roll.
  49064. * Value of 1 is equal to the Yaw angle in radians.
  49065. */
  49066. bankedTurnMultiplier: number;
  49067. /**
  49068. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49069. */
  49070. inputs: FlyCameraInputsManager;
  49071. /**
  49072. * Gets the input sensibility for mouse input.
  49073. * Higher values reduce sensitivity.
  49074. */
  49075. get angularSensibility(): number;
  49076. /**
  49077. * Sets the input sensibility for a mouse input.
  49078. * Higher values reduce sensitivity.
  49079. */
  49080. set angularSensibility(value: number);
  49081. /**
  49082. * Get the keys for camera movement forward.
  49083. */
  49084. get keysForward(): number[];
  49085. /**
  49086. * Set the keys for camera movement forward.
  49087. */
  49088. set keysForward(value: number[]);
  49089. /**
  49090. * Get the keys for camera movement backward.
  49091. */
  49092. get keysBackward(): number[];
  49093. set keysBackward(value: number[]);
  49094. /**
  49095. * Get the keys for camera movement up.
  49096. */
  49097. get keysUp(): number[];
  49098. /**
  49099. * Set the keys for camera movement up.
  49100. */
  49101. set keysUp(value: number[]);
  49102. /**
  49103. * Get the keys for camera movement down.
  49104. */
  49105. get keysDown(): number[];
  49106. /**
  49107. * Set the keys for camera movement down.
  49108. */
  49109. set keysDown(value: number[]);
  49110. /**
  49111. * Get the keys for camera movement left.
  49112. */
  49113. get keysLeft(): number[];
  49114. /**
  49115. * Set the keys for camera movement left.
  49116. */
  49117. set keysLeft(value: number[]);
  49118. /**
  49119. * Set the keys for camera movement right.
  49120. */
  49121. get keysRight(): number[];
  49122. /**
  49123. * Set the keys for camera movement right.
  49124. */
  49125. set keysRight(value: number[]);
  49126. /**
  49127. * Event raised when the camera collides with a mesh in the scene.
  49128. */
  49129. onCollide: (collidedMesh: AbstractMesh) => void;
  49130. private _collider;
  49131. private _needMoveForGravity;
  49132. private _oldPosition;
  49133. private _diffPosition;
  49134. private _newPosition;
  49135. /** @hidden */
  49136. _localDirection: Vector3;
  49137. /** @hidden */
  49138. _transformedDirection: Vector3;
  49139. /**
  49140. * Instantiates a FlyCamera.
  49141. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49142. * such as in a 3D Space Shooter or a Flight Simulator.
  49143. * @param name Define the name of the camera in the scene.
  49144. * @param position Define the starting position of the camera in the scene.
  49145. * @param scene Define the scene the camera belongs to.
  49146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49147. */
  49148. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49149. /**
  49150. * Attach a control to the HTML DOM element.
  49151. * @param element Defines the element that listens to the input events.
  49152. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49153. */
  49154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49155. /**
  49156. * Detach a control from the HTML DOM element.
  49157. * The camera will stop reacting to that input.
  49158. * @param element Defines the element that listens to the input events.
  49159. */
  49160. detachControl(element: HTMLElement): void;
  49161. private _collisionMask;
  49162. /**
  49163. * Get the mask that the camera ignores in collision events.
  49164. */
  49165. get collisionMask(): number;
  49166. /**
  49167. * Set the mask that the camera ignores in collision events.
  49168. */
  49169. set collisionMask(mask: number);
  49170. /** @hidden */
  49171. _collideWithWorld(displacement: Vector3): void;
  49172. /** @hidden */
  49173. private _onCollisionPositionChange;
  49174. /** @hidden */
  49175. _checkInputs(): void;
  49176. /** @hidden */
  49177. _decideIfNeedsToMove(): boolean;
  49178. /** @hidden */
  49179. _updatePosition(): void;
  49180. /**
  49181. * Restore the Roll to its target value at the rate specified.
  49182. * @param rate - Higher means slower restoring.
  49183. * @hidden
  49184. */
  49185. restoreRoll(rate: number): void;
  49186. /**
  49187. * Destroy the camera and release the current resources held by it.
  49188. */
  49189. dispose(): void;
  49190. /**
  49191. * Get the current object class name.
  49192. * @returns the class name.
  49193. */
  49194. getClassName(): string;
  49195. }
  49196. }
  49197. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49198. import { Nullable } from "babylonjs/types";
  49199. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49200. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49201. /**
  49202. * Listen to keyboard events to control the camera.
  49203. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49204. */
  49205. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49206. /**
  49207. * Defines the camera the input is attached to.
  49208. */
  49209. camera: FlyCamera;
  49210. /**
  49211. * The list of keyboard keys used to control the forward move of the camera.
  49212. */
  49213. keysForward: number[];
  49214. /**
  49215. * The list of keyboard keys used to control the backward move of the camera.
  49216. */
  49217. keysBackward: number[];
  49218. /**
  49219. * The list of keyboard keys used to control the forward move of the camera.
  49220. */
  49221. keysUp: number[];
  49222. /**
  49223. * The list of keyboard keys used to control the backward move of the camera.
  49224. */
  49225. keysDown: number[];
  49226. /**
  49227. * The list of keyboard keys used to control the right strafe move of the camera.
  49228. */
  49229. keysRight: number[];
  49230. /**
  49231. * The list of keyboard keys used to control the left strafe move of the camera.
  49232. */
  49233. keysLeft: number[];
  49234. private _keys;
  49235. private _onCanvasBlurObserver;
  49236. private _onKeyboardObserver;
  49237. private _engine;
  49238. private _scene;
  49239. /**
  49240. * Attach the input controls to a specific dom element to get the input from.
  49241. * @param element Defines the element the controls should be listened from
  49242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49243. */
  49244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49245. /**
  49246. * Detach the current controls from the specified dom element.
  49247. * @param element Defines the element to stop listening the inputs from
  49248. */
  49249. detachControl(element: Nullable<HTMLElement>): void;
  49250. /**
  49251. * Gets the class name of the current intput.
  49252. * @returns the class name
  49253. */
  49254. getClassName(): string;
  49255. /** @hidden */
  49256. _onLostFocus(e: FocusEvent): void;
  49257. /**
  49258. * Get the friendly name associated with the input class.
  49259. * @returns the input friendly name
  49260. */
  49261. getSimpleName(): string;
  49262. /**
  49263. * Update the current camera state depending on the inputs that have been used this frame.
  49264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49265. */
  49266. checkInputs(): void;
  49267. }
  49268. }
  49269. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49270. import { Nullable } from "babylonjs/types";
  49271. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49273. /**
  49274. * Manage the mouse wheel inputs to control a follow camera.
  49275. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49276. */
  49277. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49278. /**
  49279. * Defines the camera the input is attached to.
  49280. */
  49281. camera: FollowCamera;
  49282. /**
  49283. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49284. */
  49285. axisControlRadius: boolean;
  49286. /**
  49287. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49288. */
  49289. axisControlHeight: boolean;
  49290. /**
  49291. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49292. */
  49293. axisControlRotation: boolean;
  49294. /**
  49295. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49296. * relation to mouseWheel events.
  49297. */
  49298. wheelPrecision: number;
  49299. /**
  49300. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49301. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49302. */
  49303. wheelDeltaPercentage: number;
  49304. private _wheel;
  49305. private _observer;
  49306. /**
  49307. * Attach the input controls to a specific dom element to get the input from.
  49308. * @param element Defines the element the controls should be listened from
  49309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49310. */
  49311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49312. /**
  49313. * Detach the current controls from the specified dom element.
  49314. * @param element Defines the element to stop listening the inputs from
  49315. */
  49316. detachControl(element: Nullable<HTMLElement>): void;
  49317. /**
  49318. * Gets the class name of the current intput.
  49319. * @returns the class name
  49320. */
  49321. getClassName(): string;
  49322. /**
  49323. * Get the friendly name associated with the input class.
  49324. * @returns the input friendly name
  49325. */
  49326. getSimpleName(): string;
  49327. }
  49328. }
  49329. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49330. import { Nullable } from "babylonjs/types";
  49331. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49332. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49333. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49334. /**
  49335. * Manage the pointers inputs to control an follow camera.
  49336. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49337. */
  49338. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49339. /**
  49340. * Defines the camera the input is attached to.
  49341. */
  49342. camera: FollowCamera;
  49343. /**
  49344. * Gets the class name of the current input.
  49345. * @returns the class name
  49346. */
  49347. getClassName(): string;
  49348. /**
  49349. * Defines the pointer angular sensibility along the X axis or how fast is
  49350. * the camera rotating.
  49351. * A negative number will reverse the axis direction.
  49352. */
  49353. angularSensibilityX: number;
  49354. /**
  49355. * Defines the pointer angular sensibility along the Y axis or how fast is
  49356. * the camera rotating.
  49357. * A negative number will reverse the axis direction.
  49358. */
  49359. angularSensibilityY: number;
  49360. /**
  49361. * Defines the pointer pinch precision or how fast is the camera zooming.
  49362. * A negative number will reverse the axis direction.
  49363. */
  49364. pinchPrecision: number;
  49365. /**
  49366. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49367. * from 0.
  49368. * It defines the percentage of current camera.radius to use as delta when
  49369. * pinch zoom is used.
  49370. */
  49371. pinchDeltaPercentage: number;
  49372. /**
  49373. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49374. */
  49375. axisXControlRadius: boolean;
  49376. /**
  49377. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49378. */
  49379. axisXControlHeight: boolean;
  49380. /**
  49381. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49382. */
  49383. axisXControlRotation: boolean;
  49384. /**
  49385. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49386. */
  49387. axisYControlRadius: boolean;
  49388. /**
  49389. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49390. */
  49391. axisYControlHeight: boolean;
  49392. /**
  49393. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49394. */
  49395. axisYControlRotation: boolean;
  49396. /**
  49397. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49398. */
  49399. axisPinchControlRadius: boolean;
  49400. /**
  49401. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49402. */
  49403. axisPinchControlHeight: boolean;
  49404. /**
  49405. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49406. */
  49407. axisPinchControlRotation: boolean;
  49408. /**
  49409. * Log error messages if basic misconfiguration has occurred.
  49410. */
  49411. warningEnable: boolean;
  49412. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49413. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49414. private _warningCounter;
  49415. private _warning;
  49416. }
  49417. }
  49418. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49419. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49420. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49421. /**
  49422. * Default Inputs manager for the FollowCamera.
  49423. * It groups all the default supported inputs for ease of use.
  49424. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49425. */
  49426. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49427. /**
  49428. * Instantiates a new FollowCameraInputsManager.
  49429. * @param camera Defines the camera the inputs belong to
  49430. */
  49431. constructor(camera: FollowCamera);
  49432. /**
  49433. * Add keyboard input support to the input manager.
  49434. * @returns the current input manager
  49435. */
  49436. addKeyboard(): FollowCameraInputsManager;
  49437. /**
  49438. * Add mouse wheel input support to the input manager.
  49439. * @returns the current input manager
  49440. */
  49441. addMouseWheel(): FollowCameraInputsManager;
  49442. /**
  49443. * Add pointers input support to the input manager.
  49444. * @returns the current input manager
  49445. */
  49446. addPointers(): FollowCameraInputsManager;
  49447. /**
  49448. * Add orientation input support to the input manager.
  49449. * @returns the current input manager
  49450. */
  49451. addVRDeviceOrientation(): FollowCameraInputsManager;
  49452. }
  49453. }
  49454. declare module "babylonjs/Cameras/followCamera" {
  49455. import { Nullable } from "babylonjs/types";
  49456. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49457. import { Scene } from "babylonjs/scene";
  49458. import { Vector3 } from "babylonjs/Maths/math.vector";
  49459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49460. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49461. /**
  49462. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49463. * an arc rotate version arcFollowCamera are available.
  49464. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49465. */
  49466. export class FollowCamera extends TargetCamera {
  49467. /**
  49468. * Distance the follow camera should follow an object at
  49469. */
  49470. radius: number;
  49471. /**
  49472. * Minimum allowed distance of the camera to the axis of rotation
  49473. * (The camera can not get closer).
  49474. * This can help limiting how the Camera is able to move in the scene.
  49475. */
  49476. lowerRadiusLimit: Nullable<number>;
  49477. /**
  49478. * Maximum allowed distance of the camera to the axis of rotation
  49479. * (The camera can not get further).
  49480. * This can help limiting how the Camera is able to move in the scene.
  49481. */
  49482. upperRadiusLimit: Nullable<number>;
  49483. /**
  49484. * Define a rotation offset between the camera and the object it follows
  49485. */
  49486. rotationOffset: number;
  49487. /**
  49488. * Minimum allowed angle to camera position relative to target object.
  49489. * This can help limiting how the Camera is able to move in the scene.
  49490. */
  49491. lowerRotationOffsetLimit: Nullable<number>;
  49492. /**
  49493. * Maximum allowed angle to camera position relative to target object.
  49494. * This can help limiting how the Camera is able to move in the scene.
  49495. */
  49496. upperRotationOffsetLimit: Nullable<number>;
  49497. /**
  49498. * Define a height offset between the camera and the object it follows.
  49499. * It can help following an object from the top (like a car chaing a plane)
  49500. */
  49501. heightOffset: number;
  49502. /**
  49503. * Minimum allowed height of camera position relative to target object.
  49504. * This can help limiting how the Camera is able to move in the scene.
  49505. */
  49506. lowerHeightOffsetLimit: Nullable<number>;
  49507. /**
  49508. * Maximum allowed height of camera position relative to target object.
  49509. * This can help limiting how the Camera is able to move in the scene.
  49510. */
  49511. upperHeightOffsetLimit: Nullable<number>;
  49512. /**
  49513. * Define how fast the camera can accelerate to follow it s target.
  49514. */
  49515. cameraAcceleration: number;
  49516. /**
  49517. * Define the speed limit of the camera following an object.
  49518. */
  49519. maxCameraSpeed: number;
  49520. /**
  49521. * Define the target of the camera.
  49522. */
  49523. lockedTarget: Nullable<AbstractMesh>;
  49524. /**
  49525. * Defines the input associated with the camera.
  49526. */
  49527. inputs: FollowCameraInputsManager;
  49528. /**
  49529. * Instantiates the follow camera.
  49530. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49531. * @param name Define the name of the camera in the scene
  49532. * @param position Define the position of the camera
  49533. * @param scene Define the scene the camera belong to
  49534. * @param lockedTarget Define the target of the camera
  49535. */
  49536. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49537. private _follow;
  49538. /**
  49539. * Attached controls to the current camera.
  49540. * @param element Defines the element the controls should be listened from
  49541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49542. */
  49543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49544. /**
  49545. * Detach the current controls from the camera.
  49546. * The camera will stop reacting to inputs.
  49547. * @param element Defines the element to stop listening the inputs from
  49548. */
  49549. detachControl(element: HTMLElement): void;
  49550. /** @hidden */
  49551. _checkInputs(): void;
  49552. private _checkLimits;
  49553. /**
  49554. * Gets the camera class name.
  49555. * @returns the class name
  49556. */
  49557. getClassName(): string;
  49558. }
  49559. /**
  49560. * Arc Rotate version of the follow camera.
  49561. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49562. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49563. */
  49564. export class ArcFollowCamera extends TargetCamera {
  49565. /** The longitudinal angle of the camera */
  49566. alpha: number;
  49567. /** The latitudinal angle of the camera */
  49568. beta: number;
  49569. /** The radius of the camera from its target */
  49570. radius: number;
  49571. private _cartesianCoordinates;
  49572. /** Define the camera target (the mesh it should follow) */
  49573. private _meshTarget;
  49574. /**
  49575. * Instantiates a new ArcFollowCamera
  49576. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49577. * @param name Define the name of the camera
  49578. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49579. * @param beta Define the rotation angle of the camera around the elevation axis
  49580. * @param radius Define the radius of the camera from its target point
  49581. * @param target Define the target of the camera
  49582. * @param scene Define the scene the camera belongs to
  49583. */
  49584. constructor(name: string,
  49585. /** The longitudinal angle of the camera */
  49586. alpha: number,
  49587. /** The latitudinal angle of the camera */
  49588. beta: number,
  49589. /** The radius of the camera from its target */
  49590. radius: number,
  49591. /** Define the camera target (the mesh it should follow) */
  49592. target: Nullable<AbstractMesh>, scene: Scene);
  49593. private _follow;
  49594. /** @hidden */
  49595. _checkInputs(): void;
  49596. /**
  49597. * Returns the class name of the object.
  49598. * It is mostly used internally for serialization purposes.
  49599. */
  49600. getClassName(): string;
  49601. }
  49602. }
  49603. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49604. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49605. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49606. import { Nullable } from "babylonjs/types";
  49607. /**
  49608. * Manage the keyboard inputs to control the movement of a follow camera.
  49609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49610. */
  49611. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49612. /**
  49613. * Defines the camera the input is attached to.
  49614. */
  49615. camera: FollowCamera;
  49616. /**
  49617. * Defines the list of key codes associated with the up action (increase heightOffset)
  49618. */
  49619. keysHeightOffsetIncr: number[];
  49620. /**
  49621. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49622. */
  49623. keysHeightOffsetDecr: number[];
  49624. /**
  49625. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49626. */
  49627. keysHeightOffsetModifierAlt: boolean;
  49628. /**
  49629. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49630. */
  49631. keysHeightOffsetModifierCtrl: boolean;
  49632. /**
  49633. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49634. */
  49635. keysHeightOffsetModifierShift: boolean;
  49636. /**
  49637. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49638. */
  49639. keysRotationOffsetIncr: number[];
  49640. /**
  49641. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49642. */
  49643. keysRotationOffsetDecr: number[];
  49644. /**
  49645. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49646. */
  49647. keysRotationOffsetModifierAlt: boolean;
  49648. /**
  49649. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49650. */
  49651. keysRotationOffsetModifierCtrl: boolean;
  49652. /**
  49653. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49654. */
  49655. keysRotationOffsetModifierShift: boolean;
  49656. /**
  49657. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49658. */
  49659. keysRadiusIncr: number[];
  49660. /**
  49661. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49662. */
  49663. keysRadiusDecr: number[];
  49664. /**
  49665. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49666. */
  49667. keysRadiusModifierAlt: boolean;
  49668. /**
  49669. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49670. */
  49671. keysRadiusModifierCtrl: boolean;
  49672. /**
  49673. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49674. */
  49675. keysRadiusModifierShift: boolean;
  49676. /**
  49677. * Defines the rate of change of heightOffset.
  49678. */
  49679. heightSensibility: number;
  49680. /**
  49681. * Defines the rate of change of rotationOffset.
  49682. */
  49683. rotationSensibility: number;
  49684. /**
  49685. * Defines the rate of change of radius.
  49686. */
  49687. radiusSensibility: number;
  49688. private _keys;
  49689. private _ctrlPressed;
  49690. private _altPressed;
  49691. private _shiftPressed;
  49692. private _onCanvasBlurObserver;
  49693. private _onKeyboardObserver;
  49694. private _engine;
  49695. private _scene;
  49696. /**
  49697. * Attach the input controls to a specific dom element to get the input from.
  49698. * @param element Defines the element the controls should be listened from
  49699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49700. */
  49701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49702. /**
  49703. * Detach the current controls from the specified dom element.
  49704. * @param element Defines the element to stop listening the inputs from
  49705. */
  49706. detachControl(element: Nullable<HTMLElement>): void;
  49707. /**
  49708. * Update the current camera state depending on the inputs that have been used this frame.
  49709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49710. */
  49711. checkInputs(): void;
  49712. /**
  49713. * Gets the class name of the current input.
  49714. * @returns the class name
  49715. */
  49716. getClassName(): string;
  49717. /**
  49718. * Get the friendly name associated with the input class.
  49719. * @returns the input friendly name
  49720. */
  49721. getSimpleName(): string;
  49722. /**
  49723. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49724. * allow modification of the heightOffset value.
  49725. */
  49726. private _modifierHeightOffset;
  49727. /**
  49728. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49729. * allow modification of the rotationOffset value.
  49730. */
  49731. private _modifierRotationOffset;
  49732. /**
  49733. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49734. * allow modification of the radius value.
  49735. */
  49736. private _modifierRadius;
  49737. }
  49738. }
  49739. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49740. import { Nullable } from "babylonjs/types";
  49741. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49742. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49743. import { Observable } from "babylonjs/Misc/observable";
  49744. module "babylonjs/Cameras/freeCameraInputsManager" {
  49745. interface FreeCameraInputsManager {
  49746. /**
  49747. * @hidden
  49748. */
  49749. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49750. /**
  49751. * Add orientation input support to the input manager.
  49752. * @returns the current input manager
  49753. */
  49754. addDeviceOrientation(): FreeCameraInputsManager;
  49755. }
  49756. }
  49757. /**
  49758. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49759. * Screen rotation is taken into account.
  49760. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49761. */
  49762. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49763. private _camera;
  49764. private _screenOrientationAngle;
  49765. private _constantTranform;
  49766. private _screenQuaternion;
  49767. private _alpha;
  49768. private _beta;
  49769. private _gamma;
  49770. /**
  49771. * Can be used to detect if a device orientation sensor is available on a device
  49772. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49773. * @returns a promise that will resolve on orientation change
  49774. */
  49775. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49776. /**
  49777. * @hidden
  49778. */
  49779. _onDeviceOrientationChangedObservable: Observable<void>;
  49780. /**
  49781. * Instantiates a new input
  49782. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49783. */
  49784. constructor();
  49785. /**
  49786. * Define the camera controlled by the input.
  49787. */
  49788. get camera(): FreeCamera;
  49789. set camera(camera: FreeCamera);
  49790. /**
  49791. * Attach the input controls to a specific dom element to get the input from.
  49792. * @param element Defines the element the controls should be listened from
  49793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49794. */
  49795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49796. private _orientationChanged;
  49797. private _deviceOrientation;
  49798. /**
  49799. * Detach the current controls from the specified dom element.
  49800. * @param element Defines the element to stop listening the inputs from
  49801. */
  49802. detachControl(element: Nullable<HTMLElement>): void;
  49803. /**
  49804. * Update the current camera state depending on the inputs that have been used this frame.
  49805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49806. */
  49807. checkInputs(): void;
  49808. /**
  49809. * Gets the class name of the current intput.
  49810. * @returns the class name
  49811. */
  49812. getClassName(): string;
  49813. /**
  49814. * Get the friendly name associated with the input class.
  49815. * @returns the input friendly name
  49816. */
  49817. getSimpleName(): string;
  49818. }
  49819. }
  49820. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49821. import { Nullable } from "babylonjs/types";
  49822. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49824. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49825. /**
  49826. * Manage the gamepad inputs to control a free camera.
  49827. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49828. */
  49829. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49830. /**
  49831. * Define the camera the input is attached to.
  49832. */
  49833. camera: FreeCamera;
  49834. /**
  49835. * Define the Gamepad controlling the input
  49836. */
  49837. gamepad: Nullable<Gamepad>;
  49838. /**
  49839. * Defines the gamepad rotation sensiblity.
  49840. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49841. */
  49842. gamepadAngularSensibility: number;
  49843. /**
  49844. * Defines the gamepad move sensiblity.
  49845. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49846. */
  49847. gamepadMoveSensibility: number;
  49848. private _yAxisScale;
  49849. /**
  49850. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49851. */
  49852. get invertYAxis(): boolean;
  49853. set invertYAxis(value: boolean);
  49854. private _onGamepadConnectedObserver;
  49855. private _onGamepadDisconnectedObserver;
  49856. private _cameraTransform;
  49857. private _deltaTransform;
  49858. private _vector3;
  49859. private _vector2;
  49860. /**
  49861. * Attach the input controls to a specific dom element to get the input from.
  49862. * @param element Defines the element the controls should be listened from
  49863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49864. */
  49865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49866. /**
  49867. * Detach the current controls from the specified dom element.
  49868. * @param element Defines the element to stop listening the inputs from
  49869. */
  49870. detachControl(element: Nullable<HTMLElement>): void;
  49871. /**
  49872. * Update the current camera state depending on the inputs that have been used this frame.
  49873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49874. */
  49875. checkInputs(): void;
  49876. /**
  49877. * Gets the class name of the current intput.
  49878. * @returns the class name
  49879. */
  49880. getClassName(): string;
  49881. /**
  49882. * Get the friendly name associated with the input class.
  49883. * @returns the input friendly name
  49884. */
  49885. getSimpleName(): string;
  49886. }
  49887. }
  49888. declare module "babylonjs/Misc/virtualJoystick" {
  49889. import { Nullable } from "babylonjs/types";
  49890. import { Vector3 } from "babylonjs/Maths/math.vector";
  49891. /**
  49892. * Defines the potential axis of a Joystick
  49893. */
  49894. export enum JoystickAxis {
  49895. /** X axis */
  49896. X = 0,
  49897. /** Y axis */
  49898. Y = 1,
  49899. /** Z axis */
  49900. Z = 2
  49901. }
  49902. /**
  49903. * Represents the different customization options available
  49904. * for VirtualJoystick
  49905. */
  49906. interface VirtualJoystickCustomizations {
  49907. /**
  49908. * Size of the joystick's puck
  49909. */
  49910. puckSize: number;
  49911. /**
  49912. * Size of the joystick's container
  49913. */
  49914. containerSize: number;
  49915. /**
  49916. * Color of the joystick && puck
  49917. */
  49918. color: string;
  49919. /**
  49920. * Image URL for the joystick's puck
  49921. */
  49922. puckImage?: string;
  49923. /**
  49924. * Image URL for the joystick's container
  49925. */
  49926. containerImage?: string;
  49927. /**
  49928. * Defines the unmoving position of the joystick container
  49929. */
  49930. position?: {
  49931. x: number;
  49932. y: number;
  49933. };
  49934. /**
  49935. * Defines whether or not the joystick container is always visible
  49936. */
  49937. alwaysVisible: boolean;
  49938. /**
  49939. * Defines whether or not to limit the movement of the puck to the joystick's container
  49940. */
  49941. limitToContainer: boolean;
  49942. }
  49943. /**
  49944. * Class used to define virtual joystick (used in touch mode)
  49945. */
  49946. export class VirtualJoystick {
  49947. /**
  49948. * Gets or sets a boolean indicating that left and right values must be inverted
  49949. */
  49950. reverseLeftRight: boolean;
  49951. /**
  49952. * Gets or sets a boolean indicating that up and down values must be inverted
  49953. */
  49954. reverseUpDown: boolean;
  49955. /**
  49956. * Gets the offset value for the position (ie. the change of the position value)
  49957. */
  49958. deltaPosition: Vector3;
  49959. /**
  49960. * Gets a boolean indicating if the virtual joystick was pressed
  49961. */
  49962. pressed: boolean;
  49963. /**
  49964. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49965. */
  49966. static Canvas: Nullable<HTMLCanvasElement>;
  49967. /**
  49968. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49969. */
  49970. limitToContainer: boolean;
  49971. private static _globalJoystickIndex;
  49972. private static _alwaysVisibleSticks;
  49973. private static vjCanvasContext;
  49974. private static vjCanvasWidth;
  49975. private static vjCanvasHeight;
  49976. private static halfWidth;
  49977. private static _GetDefaultOptions;
  49978. private _action;
  49979. private _axisTargetedByLeftAndRight;
  49980. private _axisTargetedByUpAndDown;
  49981. private _joystickSensibility;
  49982. private _inversedSensibility;
  49983. private _joystickPointerID;
  49984. private _joystickColor;
  49985. private _joystickPointerPos;
  49986. private _joystickPreviousPointerPos;
  49987. private _joystickPointerStartPos;
  49988. private _deltaJoystickVector;
  49989. private _leftJoystick;
  49990. private _touches;
  49991. private _joystickPosition;
  49992. private _alwaysVisible;
  49993. private _puckImage;
  49994. private _containerImage;
  49995. private _joystickPuckSize;
  49996. private _joystickContainerSize;
  49997. private _clearPuckSize;
  49998. private _clearContainerSize;
  49999. private _clearPuckSizeOffset;
  50000. private _clearContainerSizeOffset;
  50001. private _onPointerDownHandlerRef;
  50002. private _onPointerMoveHandlerRef;
  50003. private _onPointerUpHandlerRef;
  50004. private _onResize;
  50005. /**
  50006. * Creates a new virtual joystick
  50007. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50008. * @param customizations Defines the options we want to customize the VirtualJoystick
  50009. */
  50010. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50011. /**
  50012. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50013. * @param newJoystickSensibility defines the new sensibility
  50014. */
  50015. setJoystickSensibility(newJoystickSensibility: number): void;
  50016. private _onPointerDown;
  50017. private _onPointerMove;
  50018. private _onPointerUp;
  50019. /**
  50020. * Change the color of the virtual joystick
  50021. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50022. */
  50023. setJoystickColor(newColor: string): void;
  50024. /**
  50025. * Size of the joystick's container
  50026. */
  50027. set containerSize(newSize: number);
  50028. get containerSize(): number;
  50029. /**
  50030. * Size of the joystick's puck
  50031. */
  50032. set puckSize(newSize: number);
  50033. get puckSize(): number;
  50034. /**
  50035. * Clears the set position of the joystick
  50036. */
  50037. clearPosition(): void;
  50038. /**
  50039. * Defines whether or not the joystick container is always visible
  50040. */
  50041. set alwaysVisible(value: boolean);
  50042. get alwaysVisible(): boolean;
  50043. /**
  50044. * Sets the constant position of the Joystick container
  50045. * @param x X axis coordinate
  50046. * @param y Y axis coordinate
  50047. */
  50048. setPosition(x: number, y: number): void;
  50049. /**
  50050. * Defines a callback to call when the joystick is touched
  50051. * @param action defines the callback
  50052. */
  50053. setActionOnTouch(action: () => any): void;
  50054. /**
  50055. * Defines which axis you'd like to control for left & right
  50056. * @param axis defines the axis to use
  50057. */
  50058. setAxisForLeftRight(axis: JoystickAxis): void;
  50059. /**
  50060. * Defines which axis you'd like to control for up & down
  50061. * @param axis defines the axis to use
  50062. */
  50063. setAxisForUpDown(axis: JoystickAxis): void;
  50064. /**
  50065. * Clears the canvas from the previous puck / container draw
  50066. */
  50067. private _clearPreviousDraw;
  50068. /**
  50069. * Loads `urlPath` to be used for the container's image
  50070. * @param urlPath defines the urlPath of an image to use
  50071. */
  50072. setContainerImage(urlPath: string): void;
  50073. /**
  50074. * Loads `urlPath` to be used for the puck's image
  50075. * @param urlPath defines the urlPath of an image to use
  50076. */
  50077. setPuckImage(urlPath: string): void;
  50078. /**
  50079. * Draws the Virtual Joystick's container
  50080. */
  50081. private _drawContainer;
  50082. /**
  50083. * Draws the Virtual Joystick's puck
  50084. */
  50085. private _drawPuck;
  50086. private _drawVirtualJoystick;
  50087. /**
  50088. * Release internal HTML canvas
  50089. */
  50090. releaseCanvas(): void;
  50091. }
  50092. }
  50093. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50094. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50095. import { Nullable } from "babylonjs/types";
  50096. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50098. module "babylonjs/Cameras/freeCameraInputsManager" {
  50099. interface FreeCameraInputsManager {
  50100. /**
  50101. * Add virtual joystick input support to the input manager.
  50102. * @returns the current input manager
  50103. */
  50104. addVirtualJoystick(): FreeCameraInputsManager;
  50105. }
  50106. }
  50107. /**
  50108. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50109. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50110. */
  50111. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50112. /**
  50113. * Defines the camera the input is attached to.
  50114. */
  50115. camera: FreeCamera;
  50116. private _leftjoystick;
  50117. private _rightjoystick;
  50118. /**
  50119. * Gets the left stick of the virtual joystick.
  50120. * @returns The virtual Joystick
  50121. */
  50122. getLeftJoystick(): VirtualJoystick;
  50123. /**
  50124. * Gets the right stick of the virtual joystick.
  50125. * @returns The virtual Joystick
  50126. */
  50127. getRightJoystick(): VirtualJoystick;
  50128. /**
  50129. * Update the current camera state depending on the inputs that have been used this frame.
  50130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50131. */
  50132. checkInputs(): void;
  50133. /**
  50134. * Attach the input controls to a specific dom element to get the input from.
  50135. * @param element Defines the element the controls should be listened from
  50136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50137. */
  50138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50139. /**
  50140. * Detach the current controls from the specified dom element.
  50141. * @param element Defines the element to stop listening the inputs from
  50142. */
  50143. detachControl(element: Nullable<HTMLElement>): void;
  50144. /**
  50145. * Gets the class name of the current intput.
  50146. * @returns the class name
  50147. */
  50148. getClassName(): string;
  50149. /**
  50150. * Get the friendly name associated with the input class.
  50151. * @returns the input friendly name
  50152. */
  50153. getSimpleName(): string;
  50154. }
  50155. }
  50156. declare module "babylonjs/Cameras/Inputs/index" {
  50157. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50158. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50159. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50160. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50161. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50162. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50163. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50164. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50165. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50166. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50167. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50168. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50169. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50170. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50171. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50172. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50173. }
  50174. declare module "babylonjs/Cameras/touchCamera" {
  50175. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50176. import { Scene } from "babylonjs/scene";
  50177. import { Vector3 } from "babylonjs/Maths/math.vector";
  50178. /**
  50179. * This represents a FPS type of camera controlled by touch.
  50180. * This is like a universal camera minus the Gamepad controls.
  50181. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50182. */
  50183. export class TouchCamera extends FreeCamera {
  50184. /**
  50185. * Defines the touch sensibility for rotation.
  50186. * The higher the faster.
  50187. */
  50188. get touchAngularSensibility(): number;
  50189. set touchAngularSensibility(value: number);
  50190. /**
  50191. * Defines the touch sensibility for move.
  50192. * The higher the faster.
  50193. */
  50194. get touchMoveSensibility(): number;
  50195. set touchMoveSensibility(value: number);
  50196. /**
  50197. * Instantiates a new touch camera.
  50198. * This represents a FPS type of camera controlled by touch.
  50199. * This is like a universal camera minus the Gamepad controls.
  50200. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50201. * @param name Define the name of the camera in the scene
  50202. * @param position Define the start position of the camera in the scene
  50203. * @param scene Define the scene the camera belongs to
  50204. */
  50205. constructor(name: string, position: Vector3, scene: Scene);
  50206. /**
  50207. * Gets the current object class name.
  50208. * @return the class name
  50209. */
  50210. getClassName(): string;
  50211. /** @hidden */
  50212. _setupInputs(): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50216. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50217. import { Scene } from "babylonjs/scene";
  50218. import { Vector3 } from "babylonjs/Maths/math.vector";
  50219. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50220. import { Axis } from "babylonjs/Maths/math.axis";
  50221. /**
  50222. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50223. * being tilted forward or back and left or right.
  50224. */
  50225. export class DeviceOrientationCamera extends FreeCamera {
  50226. private _initialQuaternion;
  50227. private _quaternionCache;
  50228. private _tmpDragQuaternion;
  50229. private _disablePointerInputWhenUsingDeviceOrientation;
  50230. /**
  50231. * Creates a new device orientation camera
  50232. * @param name The name of the camera
  50233. * @param position The start position camera
  50234. * @param scene The scene the camera belongs to
  50235. */
  50236. constructor(name: string, position: Vector3, scene: Scene);
  50237. /**
  50238. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50239. */
  50240. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50241. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50242. private _dragFactor;
  50243. /**
  50244. * Enabled turning on the y axis when the orientation sensor is active
  50245. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50246. */
  50247. enableHorizontalDragging(dragFactor?: number): void;
  50248. /**
  50249. * Gets the current instance class name ("DeviceOrientationCamera").
  50250. * This helps avoiding instanceof at run time.
  50251. * @returns the class name
  50252. */
  50253. getClassName(): string;
  50254. /**
  50255. * @hidden
  50256. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50257. */
  50258. _checkInputs(): void;
  50259. /**
  50260. * Reset the camera to its default orientation on the specified axis only.
  50261. * @param axis The axis to reset
  50262. */
  50263. resetToCurrentRotation(axis?: Axis): void;
  50264. }
  50265. }
  50266. declare module "babylonjs/Gamepads/xboxGamepad" {
  50267. import { Observable } from "babylonjs/Misc/observable";
  50268. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50269. /**
  50270. * Defines supported buttons for XBox360 compatible gamepads
  50271. */
  50272. export enum Xbox360Button {
  50273. /** A */
  50274. A = 0,
  50275. /** B */
  50276. B = 1,
  50277. /** X */
  50278. X = 2,
  50279. /** Y */
  50280. Y = 3,
  50281. /** Left button */
  50282. LB = 4,
  50283. /** Right button */
  50284. RB = 5,
  50285. /** Back */
  50286. Back = 8,
  50287. /** Start */
  50288. Start = 9,
  50289. /** Left stick */
  50290. LeftStick = 10,
  50291. /** Right stick */
  50292. RightStick = 11
  50293. }
  50294. /** Defines values for XBox360 DPad */
  50295. export enum Xbox360Dpad {
  50296. /** Up */
  50297. Up = 12,
  50298. /** Down */
  50299. Down = 13,
  50300. /** Left */
  50301. Left = 14,
  50302. /** Right */
  50303. Right = 15
  50304. }
  50305. /**
  50306. * Defines a XBox360 gamepad
  50307. */
  50308. export class Xbox360Pad extends Gamepad {
  50309. private _leftTrigger;
  50310. private _rightTrigger;
  50311. private _onlefttriggerchanged;
  50312. private _onrighttriggerchanged;
  50313. private _onbuttondown;
  50314. private _onbuttonup;
  50315. private _ondpaddown;
  50316. private _ondpadup;
  50317. /** Observable raised when a button is pressed */
  50318. onButtonDownObservable: Observable<Xbox360Button>;
  50319. /** Observable raised when a button is released */
  50320. onButtonUpObservable: Observable<Xbox360Button>;
  50321. /** Observable raised when a pad is pressed */
  50322. onPadDownObservable: Observable<Xbox360Dpad>;
  50323. /** Observable raised when a pad is released */
  50324. onPadUpObservable: Observable<Xbox360Dpad>;
  50325. private _buttonA;
  50326. private _buttonB;
  50327. private _buttonX;
  50328. private _buttonY;
  50329. private _buttonBack;
  50330. private _buttonStart;
  50331. private _buttonLB;
  50332. private _buttonRB;
  50333. private _buttonLeftStick;
  50334. private _buttonRightStick;
  50335. private _dPadUp;
  50336. private _dPadDown;
  50337. private _dPadLeft;
  50338. private _dPadRight;
  50339. private _isXboxOnePad;
  50340. /**
  50341. * Creates a new XBox360 gamepad object
  50342. * @param id defines the id of this gamepad
  50343. * @param index defines its index
  50344. * @param gamepad defines the internal HTML gamepad object
  50345. * @param xboxOne defines if it is a XBox One gamepad
  50346. */
  50347. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50348. /**
  50349. * Defines the callback to call when left trigger is pressed
  50350. * @param callback defines the callback to use
  50351. */
  50352. onlefttriggerchanged(callback: (value: number) => void): void;
  50353. /**
  50354. * Defines the callback to call when right trigger is pressed
  50355. * @param callback defines the callback to use
  50356. */
  50357. onrighttriggerchanged(callback: (value: number) => void): void;
  50358. /**
  50359. * Gets the left trigger value
  50360. */
  50361. get leftTrigger(): number;
  50362. /**
  50363. * Sets the left trigger value
  50364. */
  50365. set leftTrigger(newValue: number);
  50366. /**
  50367. * Gets the right trigger value
  50368. */
  50369. get rightTrigger(): number;
  50370. /**
  50371. * Sets the right trigger value
  50372. */
  50373. set rightTrigger(newValue: number);
  50374. /**
  50375. * Defines the callback to call when a button is pressed
  50376. * @param callback defines the callback to use
  50377. */
  50378. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50379. /**
  50380. * Defines the callback to call when a button is released
  50381. * @param callback defines the callback to use
  50382. */
  50383. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50384. /**
  50385. * Defines the callback to call when a pad is pressed
  50386. * @param callback defines the callback to use
  50387. */
  50388. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50389. /**
  50390. * Defines the callback to call when a pad is released
  50391. * @param callback defines the callback to use
  50392. */
  50393. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50394. private _setButtonValue;
  50395. private _setDPadValue;
  50396. /**
  50397. * Gets the value of the `A` button
  50398. */
  50399. get buttonA(): number;
  50400. /**
  50401. * Sets the value of the `A` button
  50402. */
  50403. set buttonA(value: number);
  50404. /**
  50405. * Gets the value of the `B` button
  50406. */
  50407. get buttonB(): number;
  50408. /**
  50409. * Sets the value of the `B` button
  50410. */
  50411. set buttonB(value: number);
  50412. /**
  50413. * Gets the value of the `X` button
  50414. */
  50415. get buttonX(): number;
  50416. /**
  50417. * Sets the value of the `X` button
  50418. */
  50419. set buttonX(value: number);
  50420. /**
  50421. * Gets the value of the `Y` button
  50422. */
  50423. get buttonY(): number;
  50424. /**
  50425. * Sets the value of the `Y` button
  50426. */
  50427. set buttonY(value: number);
  50428. /**
  50429. * Gets the value of the `Start` button
  50430. */
  50431. get buttonStart(): number;
  50432. /**
  50433. * Sets the value of the `Start` button
  50434. */
  50435. set buttonStart(value: number);
  50436. /**
  50437. * Gets the value of the `Back` button
  50438. */
  50439. get buttonBack(): number;
  50440. /**
  50441. * Sets the value of the `Back` button
  50442. */
  50443. set buttonBack(value: number);
  50444. /**
  50445. * Gets the value of the `Left` button
  50446. */
  50447. get buttonLB(): number;
  50448. /**
  50449. * Sets the value of the `Left` button
  50450. */
  50451. set buttonLB(value: number);
  50452. /**
  50453. * Gets the value of the `Right` button
  50454. */
  50455. get buttonRB(): number;
  50456. /**
  50457. * Sets the value of the `Right` button
  50458. */
  50459. set buttonRB(value: number);
  50460. /**
  50461. * Gets the value of the Left joystick
  50462. */
  50463. get buttonLeftStick(): number;
  50464. /**
  50465. * Sets the value of the Left joystick
  50466. */
  50467. set buttonLeftStick(value: number);
  50468. /**
  50469. * Gets the value of the Right joystick
  50470. */
  50471. get buttonRightStick(): number;
  50472. /**
  50473. * Sets the value of the Right joystick
  50474. */
  50475. set buttonRightStick(value: number);
  50476. /**
  50477. * Gets the value of D-pad up
  50478. */
  50479. get dPadUp(): number;
  50480. /**
  50481. * Sets the value of D-pad up
  50482. */
  50483. set dPadUp(value: number);
  50484. /**
  50485. * Gets the value of D-pad down
  50486. */
  50487. get dPadDown(): number;
  50488. /**
  50489. * Sets the value of D-pad down
  50490. */
  50491. set dPadDown(value: number);
  50492. /**
  50493. * Gets the value of D-pad left
  50494. */
  50495. get dPadLeft(): number;
  50496. /**
  50497. * Sets the value of D-pad left
  50498. */
  50499. set dPadLeft(value: number);
  50500. /**
  50501. * Gets the value of D-pad right
  50502. */
  50503. get dPadRight(): number;
  50504. /**
  50505. * Sets the value of D-pad right
  50506. */
  50507. set dPadRight(value: number);
  50508. /**
  50509. * Force the gamepad to synchronize with device values
  50510. */
  50511. update(): void;
  50512. /**
  50513. * Disposes the gamepad
  50514. */
  50515. dispose(): void;
  50516. }
  50517. }
  50518. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50519. import { Observable } from "babylonjs/Misc/observable";
  50520. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50521. /**
  50522. * Defines supported buttons for DualShock compatible gamepads
  50523. */
  50524. export enum DualShockButton {
  50525. /** Cross */
  50526. Cross = 0,
  50527. /** Circle */
  50528. Circle = 1,
  50529. /** Square */
  50530. Square = 2,
  50531. /** Triangle */
  50532. Triangle = 3,
  50533. /** L1 */
  50534. L1 = 4,
  50535. /** R1 */
  50536. R1 = 5,
  50537. /** Share */
  50538. Share = 8,
  50539. /** Options */
  50540. Options = 9,
  50541. /** Left stick */
  50542. LeftStick = 10,
  50543. /** Right stick */
  50544. RightStick = 11
  50545. }
  50546. /** Defines values for DualShock DPad */
  50547. export enum DualShockDpad {
  50548. /** Up */
  50549. Up = 12,
  50550. /** Down */
  50551. Down = 13,
  50552. /** Left */
  50553. Left = 14,
  50554. /** Right */
  50555. Right = 15
  50556. }
  50557. /**
  50558. * Defines a DualShock gamepad
  50559. */
  50560. export class DualShockPad extends Gamepad {
  50561. private _leftTrigger;
  50562. private _rightTrigger;
  50563. private _onlefttriggerchanged;
  50564. private _onrighttriggerchanged;
  50565. private _onbuttondown;
  50566. private _onbuttonup;
  50567. private _ondpaddown;
  50568. private _ondpadup;
  50569. /** Observable raised when a button is pressed */
  50570. onButtonDownObservable: Observable<DualShockButton>;
  50571. /** Observable raised when a button is released */
  50572. onButtonUpObservable: Observable<DualShockButton>;
  50573. /** Observable raised when a pad is pressed */
  50574. onPadDownObservable: Observable<DualShockDpad>;
  50575. /** Observable raised when a pad is released */
  50576. onPadUpObservable: Observable<DualShockDpad>;
  50577. private _buttonCross;
  50578. private _buttonCircle;
  50579. private _buttonSquare;
  50580. private _buttonTriangle;
  50581. private _buttonShare;
  50582. private _buttonOptions;
  50583. private _buttonL1;
  50584. private _buttonR1;
  50585. private _buttonLeftStick;
  50586. private _buttonRightStick;
  50587. private _dPadUp;
  50588. private _dPadDown;
  50589. private _dPadLeft;
  50590. private _dPadRight;
  50591. /**
  50592. * Creates a new DualShock gamepad object
  50593. * @param id defines the id of this gamepad
  50594. * @param index defines its index
  50595. * @param gamepad defines the internal HTML gamepad object
  50596. */
  50597. constructor(id: string, index: number, gamepad: any);
  50598. /**
  50599. * Defines the callback to call when left trigger is pressed
  50600. * @param callback defines the callback to use
  50601. */
  50602. onlefttriggerchanged(callback: (value: number) => void): void;
  50603. /**
  50604. * Defines the callback to call when right trigger is pressed
  50605. * @param callback defines the callback to use
  50606. */
  50607. onrighttriggerchanged(callback: (value: number) => void): void;
  50608. /**
  50609. * Gets the left trigger value
  50610. */
  50611. get leftTrigger(): number;
  50612. /**
  50613. * Sets the left trigger value
  50614. */
  50615. set leftTrigger(newValue: number);
  50616. /**
  50617. * Gets the right trigger value
  50618. */
  50619. get rightTrigger(): number;
  50620. /**
  50621. * Sets the right trigger value
  50622. */
  50623. set rightTrigger(newValue: number);
  50624. /**
  50625. * Defines the callback to call when a button is pressed
  50626. * @param callback defines the callback to use
  50627. */
  50628. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50629. /**
  50630. * Defines the callback to call when a button is released
  50631. * @param callback defines the callback to use
  50632. */
  50633. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50634. /**
  50635. * Defines the callback to call when a pad is pressed
  50636. * @param callback defines the callback to use
  50637. */
  50638. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50639. /**
  50640. * Defines the callback to call when a pad is released
  50641. * @param callback defines the callback to use
  50642. */
  50643. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50644. private _setButtonValue;
  50645. private _setDPadValue;
  50646. /**
  50647. * Gets the value of the `Cross` button
  50648. */
  50649. get buttonCross(): number;
  50650. /**
  50651. * Sets the value of the `Cross` button
  50652. */
  50653. set buttonCross(value: number);
  50654. /**
  50655. * Gets the value of the `Circle` button
  50656. */
  50657. get buttonCircle(): number;
  50658. /**
  50659. * Sets the value of the `Circle` button
  50660. */
  50661. set buttonCircle(value: number);
  50662. /**
  50663. * Gets the value of the `Square` button
  50664. */
  50665. get buttonSquare(): number;
  50666. /**
  50667. * Sets the value of the `Square` button
  50668. */
  50669. set buttonSquare(value: number);
  50670. /**
  50671. * Gets the value of the `Triangle` button
  50672. */
  50673. get buttonTriangle(): number;
  50674. /**
  50675. * Sets the value of the `Triangle` button
  50676. */
  50677. set buttonTriangle(value: number);
  50678. /**
  50679. * Gets the value of the `Options` button
  50680. */
  50681. get buttonOptions(): number;
  50682. /**
  50683. * Sets the value of the `Options` button
  50684. */
  50685. set buttonOptions(value: number);
  50686. /**
  50687. * Gets the value of the `Share` button
  50688. */
  50689. get buttonShare(): number;
  50690. /**
  50691. * Sets the value of the `Share` button
  50692. */
  50693. set buttonShare(value: number);
  50694. /**
  50695. * Gets the value of the `L1` button
  50696. */
  50697. get buttonL1(): number;
  50698. /**
  50699. * Sets the value of the `L1` button
  50700. */
  50701. set buttonL1(value: number);
  50702. /**
  50703. * Gets the value of the `R1` button
  50704. */
  50705. get buttonR1(): number;
  50706. /**
  50707. * Sets the value of the `R1` button
  50708. */
  50709. set buttonR1(value: number);
  50710. /**
  50711. * Gets the value of the Left joystick
  50712. */
  50713. get buttonLeftStick(): number;
  50714. /**
  50715. * Sets the value of the Left joystick
  50716. */
  50717. set buttonLeftStick(value: number);
  50718. /**
  50719. * Gets the value of the Right joystick
  50720. */
  50721. get buttonRightStick(): number;
  50722. /**
  50723. * Sets the value of the Right joystick
  50724. */
  50725. set buttonRightStick(value: number);
  50726. /**
  50727. * Gets the value of D-pad up
  50728. */
  50729. get dPadUp(): number;
  50730. /**
  50731. * Sets the value of D-pad up
  50732. */
  50733. set dPadUp(value: number);
  50734. /**
  50735. * Gets the value of D-pad down
  50736. */
  50737. get dPadDown(): number;
  50738. /**
  50739. * Sets the value of D-pad down
  50740. */
  50741. set dPadDown(value: number);
  50742. /**
  50743. * Gets the value of D-pad left
  50744. */
  50745. get dPadLeft(): number;
  50746. /**
  50747. * Sets the value of D-pad left
  50748. */
  50749. set dPadLeft(value: number);
  50750. /**
  50751. * Gets the value of D-pad right
  50752. */
  50753. get dPadRight(): number;
  50754. /**
  50755. * Sets the value of D-pad right
  50756. */
  50757. set dPadRight(value: number);
  50758. /**
  50759. * Force the gamepad to synchronize with device values
  50760. */
  50761. update(): void;
  50762. /**
  50763. * Disposes the gamepad
  50764. */
  50765. dispose(): void;
  50766. }
  50767. }
  50768. declare module "babylonjs/Gamepads/gamepadManager" {
  50769. import { Observable } from "babylonjs/Misc/observable";
  50770. import { Nullable } from "babylonjs/types";
  50771. import { Scene } from "babylonjs/scene";
  50772. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50773. /**
  50774. * Manager for handling gamepads
  50775. */
  50776. export class GamepadManager {
  50777. private _scene?;
  50778. private _babylonGamepads;
  50779. private _oneGamepadConnected;
  50780. /** @hidden */
  50781. _isMonitoring: boolean;
  50782. private _gamepadEventSupported;
  50783. private _gamepadSupport?;
  50784. /**
  50785. * observable to be triggered when the gamepad controller has been connected
  50786. */
  50787. onGamepadConnectedObservable: Observable<Gamepad>;
  50788. /**
  50789. * observable to be triggered when the gamepad controller has been disconnected
  50790. */
  50791. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50792. private _onGamepadConnectedEvent;
  50793. private _onGamepadDisconnectedEvent;
  50794. /**
  50795. * Initializes the gamepad manager
  50796. * @param _scene BabylonJS scene
  50797. */
  50798. constructor(_scene?: Scene | undefined);
  50799. /**
  50800. * The gamepads in the game pad manager
  50801. */
  50802. get gamepads(): Gamepad[];
  50803. /**
  50804. * Get the gamepad controllers based on type
  50805. * @param type The type of gamepad controller
  50806. * @returns Nullable gamepad
  50807. */
  50808. getGamepadByType(type?: number): Nullable<Gamepad>;
  50809. /**
  50810. * Disposes the gamepad manager
  50811. */
  50812. dispose(): void;
  50813. private _addNewGamepad;
  50814. private _startMonitoringGamepads;
  50815. private _stopMonitoringGamepads;
  50816. /** @hidden */
  50817. _checkGamepadsStatus(): void;
  50818. private _updateGamepadObjects;
  50819. }
  50820. }
  50821. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50822. import { Nullable } from "babylonjs/types";
  50823. import { Scene } from "babylonjs/scene";
  50824. import { ISceneComponent } from "babylonjs/sceneComponent";
  50825. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50826. module "babylonjs/scene" {
  50827. interface Scene {
  50828. /** @hidden */
  50829. _gamepadManager: Nullable<GamepadManager>;
  50830. /**
  50831. * Gets the gamepad manager associated with the scene
  50832. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50833. */
  50834. gamepadManager: GamepadManager;
  50835. }
  50836. }
  50837. module "babylonjs/Cameras/freeCameraInputsManager" {
  50838. /**
  50839. * Interface representing a free camera inputs manager
  50840. */
  50841. interface FreeCameraInputsManager {
  50842. /**
  50843. * Adds gamepad input support to the FreeCameraInputsManager.
  50844. * @returns the FreeCameraInputsManager
  50845. */
  50846. addGamepad(): FreeCameraInputsManager;
  50847. }
  50848. }
  50849. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50850. /**
  50851. * Interface representing an arc rotate camera inputs manager
  50852. */
  50853. interface ArcRotateCameraInputsManager {
  50854. /**
  50855. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50856. * @returns the camera inputs manager
  50857. */
  50858. addGamepad(): ArcRotateCameraInputsManager;
  50859. }
  50860. }
  50861. /**
  50862. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50863. */
  50864. export class GamepadSystemSceneComponent implements ISceneComponent {
  50865. /**
  50866. * The component name helpfull to identify the component in the list of scene components.
  50867. */
  50868. readonly name: string;
  50869. /**
  50870. * The scene the component belongs to.
  50871. */
  50872. scene: Scene;
  50873. /**
  50874. * Creates a new instance of the component for the given scene
  50875. * @param scene Defines the scene to register the component in
  50876. */
  50877. constructor(scene: Scene);
  50878. /**
  50879. * Registers the component in a given scene
  50880. */
  50881. register(): void;
  50882. /**
  50883. * Rebuilds the elements related to this component in case of
  50884. * context lost for instance.
  50885. */
  50886. rebuild(): void;
  50887. /**
  50888. * Disposes the component and the associated ressources
  50889. */
  50890. dispose(): void;
  50891. private _beforeCameraUpdate;
  50892. }
  50893. }
  50894. declare module "babylonjs/Cameras/universalCamera" {
  50895. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50896. import { Scene } from "babylonjs/scene";
  50897. import { Vector3 } from "babylonjs/Maths/math.vector";
  50898. import "babylonjs/Gamepads/gamepadSceneComponent";
  50899. /**
  50900. * 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,
  50901. * which still works and will still be found in many Playgrounds.
  50902. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50903. */
  50904. export class UniversalCamera extends TouchCamera {
  50905. /**
  50906. * Defines the gamepad rotation sensiblity.
  50907. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50908. */
  50909. get gamepadAngularSensibility(): number;
  50910. set gamepadAngularSensibility(value: number);
  50911. /**
  50912. * Defines the gamepad move sensiblity.
  50913. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50914. */
  50915. get gamepadMoveSensibility(): number;
  50916. set gamepadMoveSensibility(value: number);
  50917. /**
  50918. * 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,
  50919. * which still works and will still be found in many Playgrounds.
  50920. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50921. * @param name Define the name of the camera in the scene
  50922. * @param position Define the start position of the camera in the scene
  50923. * @param scene Define the scene the camera belongs to
  50924. */
  50925. constructor(name: string, position: Vector3, scene: Scene);
  50926. /**
  50927. * Gets the current object class name.
  50928. * @return the class name
  50929. */
  50930. getClassName(): string;
  50931. }
  50932. }
  50933. declare module "babylonjs/Cameras/gamepadCamera" {
  50934. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50935. import { Scene } from "babylonjs/scene";
  50936. import { Vector3 } from "babylonjs/Maths/math.vector";
  50937. /**
  50938. * This represents a FPS type of camera. This is only here for back compat purpose.
  50939. * Please use the UniversalCamera instead as both are identical.
  50940. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50941. */
  50942. export class GamepadCamera extends UniversalCamera {
  50943. /**
  50944. * Instantiates a new Gamepad Camera
  50945. * This represents a FPS type of camera. This is only here for back compat purpose.
  50946. * Please use the UniversalCamera instead as both are identical.
  50947. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50948. * @param name Define the name of the camera in the scene
  50949. * @param position Define the start position of the camera in the scene
  50950. * @param scene Define the scene the camera belongs to
  50951. */
  50952. constructor(name: string, position: Vector3, scene: Scene);
  50953. /**
  50954. * Gets the current object class name.
  50955. * @return the class name
  50956. */
  50957. getClassName(): string;
  50958. }
  50959. }
  50960. declare module "babylonjs/Shaders/pass.fragment" {
  50961. /** @hidden */
  50962. export var passPixelShader: {
  50963. name: string;
  50964. shader: string;
  50965. };
  50966. }
  50967. declare module "babylonjs/Shaders/passCube.fragment" {
  50968. /** @hidden */
  50969. export var passCubePixelShader: {
  50970. name: string;
  50971. shader: string;
  50972. };
  50973. }
  50974. declare module "babylonjs/PostProcesses/passPostProcess" {
  50975. import { Nullable } from "babylonjs/types";
  50976. import { Camera } from "babylonjs/Cameras/camera";
  50977. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50978. import { Engine } from "babylonjs/Engines/engine";
  50979. import "babylonjs/Shaders/pass.fragment";
  50980. import "babylonjs/Shaders/passCube.fragment";
  50981. import { Scene } from "babylonjs/scene";
  50982. /**
  50983. * PassPostProcess which produces an output the same as it's input
  50984. */
  50985. export class PassPostProcess extends PostProcess {
  50986. /**
  50987. * Gets a string identifying the name of the class
  50988. * @returns "PassPostProcess" string
  50989. */
  50990. getClassName(): string;
  50991. /**
  50992. * Creates the PassPostProcess
  50993. * @param name The name of the effect.
  50994. * @param options The required width/height ratio to downsize to before computing the render pass.
  50995. * @param camera The camera to apply the render pass to.
  50996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50997. * @param engine The engine which the post process will be applied. (default: current engine)
  50998. * @param reusable If the post process can be reused on the same frame. (default: false)
  50999. * @param textureType The type of texture to be used when performing the post processing.
  51000. * @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)
  51001. */
  51002. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51003. /** @hidden */
  51004. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51005. }
  51006. /**
  51007. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51008. */
  51009. export class PassCubePostProcess extends PostProcess {
  51010. private _face;
  51011. /**
  51012. * Gets or sets the cube face to display.
  51013. * * 0 is +X
  51014. * * 1 is -X
  51015. * * 2 is +Y
  51016. * * 3 is -Y
  51017. * * 4 is +Z
  51018. * * 5 is -Z
  51019. */
  51020. get face(): number;
  51021. set face(value: number);
  51022. /**
  51023. * Gets a string identifying the name of the class
  51024. * @returns "PassCubePostProcess" string
  51025. */
  51026. getClassName(): string;
  51027. /**
  51028. * Creates the PassCubePostProcess
  51029. * @param name The name of the effect.
  51030. * @param options The required width/height ratio to downsize to before computing the render pass.
  51031. * @param camera The camera to apply the render pass to.
  51032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51033. * @param engine The engine which the post process will be applied. (default: current engine)
  51034. * @param reusable If the post process can be reused on the same frame. (default: false)
  51035. * @param textureType The type of texture to be used when performing the post processing.
  51036. * @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)
  51037. */
  51038. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51039. /** @hidden */
  51040. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51041. }
  51042. }
  51043. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51044. /** @hidden */
  51045. export var anaglyphPixelShader: {
  51046. name: string;
  51047. shader: string;
  51048. };
  51049. }
  51050. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51051. import { Engine } from "babylonjs/Engines/engine";
  51052. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51053. import { Camera } from "babylonjs/Cameras/camera";
  51054. import "babylonjs/Shaders/anaglyph.fragment";
  51055. /**
  51056. * Postprocess used to generate anaglyphic rendering
  51057. */
  51058. export class AnaglyphPostProcess extends PostProcess {
  51059. private _passedProcess;
  51060. /**
  51061. * Gets a string identifying the name of the class
  51062. * @returns "AnaglyphPostProcess" string
  51063. */
  51064. getClassName(): string;
  51065. /**
  51066. * Creates a new AnaglyphPostProcess
  51067. * @param name defines postprocess name
  51068. * @param options defines creation options or target ratio scale
  51069. * @param rigCameras defines cameras using this postprocess
  51070. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51071. * @param engine defines hosting engine
  51072. * @param reusable defines if the postprocess will be reused multiple times per frame
  51073. */
  51074. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51075. }
  51076. }
  51077. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51078. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51079. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51080. import { Scene } from "babylonjs/scene";
  51081. import { Vector3 } from "babylonjs/Maths/math.vector";
  51082. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51083. /**
  51084. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51085. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51086. */
  51087. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51088. /**
  51089. * Creates a new AnaglyphArcRotateCamera
  51090. * @param name defines camera name
  51091. * @param alpha defines alpha angle (in radians)
  51092. * @param beta defines beta angle (in radians)
  51093. * @param radius defines radius
  51094. * @param target defines camera target
  51095. * @param interaxialDistance defines distance between each color axis
  51096. * @param scene defines the hosting scene
  51097. */
  51098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51099. /**
  51100. * Gets camera class name
  51101. * @returns AnaglyphArcRotateCamera
  51102. */
  51103. getClassName(): string;
  51104. }
  51105. }
  51106. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51107. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51108. import { Scene } from "babylonjs/scene";
  51109. import { Vector3 } from "babylonjs/Maths/math.vector";
  51110. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51111. /**
  51112. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51113. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51114. */
  51115. export class AnaglyphFreeCamera extends FreeCamera {
  51116. /**
  51117. * Creates a new AnaglyphFreeCamera
  51118. * @param name defines camera name
  51119. * @param position defines initial position
  51120. * @param interaxialDistance defines distance between each color axis
  51121. * @param scene defines the hosting scene
  51122. */
  51123. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51124. /**
  51125. * Gets camera class name
  51126. * @returns AnaglyphFreeCamera
  51127. */
  51128. getClassName(): string;
  51129. }
  51130. }
  51131. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51132. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51133. import { Scene } from "babylonjs/scene";
  51134. import { Vector3 } from "babylonjs/Maths/math.vector";
  51135. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51136. /**
  51137. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51138. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51139. */
  51140. export class AnaglyphGamepadCamera extends GamepadCamera {
  51141. /**
  51142. * Creates a new AnaglyphGamepadCamera
  51143. * @param name defines camera name
  51144. * @param position defines initial position
  51145. * @param interaxialDistance defines distance between each color axis
  51146. * @param scene defines the hosting scene
  51147. */
  51148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51149. /**
  51150. * Gets camera class name
  51151. * @returns AnaglyphGamepadCamera
  51152. */
  51153. getClassName(): string;
  51154. }
  51155. }
  51156. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51157. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51158. import { Scene } from "babylonjs/scene";
  51159. import { Vector3 } from "babylonjs/Maths/math.vector";
  51160. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51161. /**
  51162. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51163. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51164. */
  51165. export class AnaglyphUniversalCamera extends UniversalCamera {
  51166. /**
  51167. * Creates a new AnaglyphUniversalCamera
  51168. * @param name defines camera name
  51169. * @param position defines initial position
  51170. * @param interaxialDistance defines distance between each color axis
  51171. * @param scene defines the hosting scene
  51172. */
  51173. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51174. /**
  51175. * Gets camera class name
  51176. * @returns AnaglyphUniversalCamera
  51177. */
  51178. getClassName(): string;
  51179. }
  51180. }
  51181. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51182. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51183. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51184. import { Scene } from "babylonjs/scene";
  51185. import { Vector3 } from "babylonjs/Maths/math.vector";
  51186. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51187. /**
  51188. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51189. * @see https://doc.babylonjs.com/features/cameras
  51190. */
  51191. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51192. /**
  51193. * Creates a new StereoscopicArcRotateCamera
  51194. * @param name defines camera name
  51195. * @param alpha defines alpha angle (in radians)
  51196. * @param beta defines beta angle (in radians)
  51197. * @param radius defines radius
  51198. * @param target defines camera target
  51199. * @param interaxialDistance defines distance between each color axis
  51200. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51201. * @param scene defines the hosting scene
  51202. */
  51203. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51204. /**
  51205. * Gets camera class name
  51206. * @returns StereoscopicArcRotateCamera
  51207. */
  51208. getClassName(): string;
  51209. }
  51210. }
  51211. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51212. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51213. import { Scene } from "babylonjs/scene";
  51214. import { Vector3 } from "babylonjs/Maths/math.vector";
  51215. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51216. /**
  51217. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51218. * @see https://doc.babylonjs.com/features/cameras
  51219. */
  51220. export class StereoscopicFreeCamera extends FreeCamera {
  51221. /**
  51222. * Creates a new StereoscopicFreeCamera
  51223. * @param name defines camera name
  51224. * @param position defines initial position
  51225. * @param interaxialDistance defines distance between each color axis
  51226. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51227. * @param scene defines the hosting scene
  51228. */
  51229. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51230. /**
  51231. * Gets camera class name
  51232. * @returns StereoscopicFreeCamera
  51233. */
  51234. getClassName(): string;
  51235. }
  51236. }
  51237. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51238. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51239. import { Scene } from "babylonjs/scene";
  51240. import { Vector3 } from "babylonjs/Maths/math.vector";
  51241. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51242. /**
  51243. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51244. * @see https://doc.babylonjs.com/features/cameras
  51245. */
  51246. export class StereoscopicGamepadCamera extends GamepadCamera {
  51247. /**
  51248. * Creates a new StereoscopicGamepadCamera
  51249. * @param name defines camera name
  51250. * @param position defines initial position
  51251. * @param interaxialDistance defines distance between each color axis
  51252. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51253. * @param scene defines the hosting scene
  51254. */
  51255. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51256. /**
  51257. * Gets camera class name
  51258. * @returns StereoscopicGamepadCamera
  51259. */
  51260. getClassName(): string;
  51261. }
  51262. }
  51263. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51264. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51265. import { Scene } from "babylonjs/scene";
  51266. import { Vector3 } from "babylonjs/Maths/math.vector";
  51267. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51268. /**
  51269. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51270. * @see https://doc.babylonjs.com/features/cameras
  51271. */
  51272. export class StereoscopicUniversalCamera extends UniversalCamera {
  51273. /**
  51274. * Creates a new StereoscopicUniversalCamera
  51275. * @param name defines camera name
  51276. * @param position defines initial position
  51277. * @param interaxialDistance defines distance between each color axis
  51278. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51279. * @param scene defines the hosting scene
  51280. */
  51281. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51282. /**
  51283. * Gets camera class name
  51284. * @returns StereoscopicUniversalCamera
  51285. */
  51286. getClassName(): string;
  51287. }
  51288. }
  51289. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51290. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51291. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51292. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51293. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51294. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51295. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51296. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51297. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51298. }
  51299. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51300. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51301. import { Scene } from "babylonjs/scene";
  51302. import { Vector3 } from "babylonjs/Maths/math.vector";
  51303. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51304. /**
  51305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51306. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51307. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51308. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51309. */
  51310. export class VirtualJoysticksCamera extends FreeCamera {
  51311. /**
  51312. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51313. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51314. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51315. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51316. * @param name Define the name of the camera in the scene
  51317. * @param position Define the start position of the camera in the scene
  51318. * @param scene Define the scene the camera belongs to
  51319. */
  51320. constructor(name: string, position: Vector3, scene: Scene);
  51321. /**
  51322. * Gets the current object class name.
  51323. * @return the class name
  51324. */
  51325. getClassName(): string;
  51326. }
  51327. }
  51328. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51329. import { Matrix } from "babylonjs/Maths/math.vector";
  51330. /**
  51331. * This represents all the required metrics to create a VR camera.
  51332. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51333. */
  51334. export class VRCameraMetrics {
  51335. /**
  51336. * Define the horizontal resolution off the screen.
  51337. */
  51338. hResolution: number;
  51339. /**
  51340. * Define the vertical resolution off the screen.
  51341. */
  51342. vResolution: number;
  51343. /**
  51344. * Define the horizontal screen size.
  51345. */
  51346. hScreenSize: number;
  51347. /**
  51348. * Define the vertical screen size.
  51349. */
  51350. vScreenSize: number;
  51351. /**
  51352. * Define the vertical screen center position.
  51353. */
  51354. vScreenCenter: number;
  51355. /**
  51356. * Define the distance of the eyes to the screen.
  51357. */
  51358. eyeToScreenDistance: number;
  51359. /**
  51360. * Define the distance between both lenses
  51361. */
  51362. lensSeparationDistance: number;
  51363. /**
  51364. * Define the distance between both viewer's eyes.
  51365. */
  51366. interpupillaryDistance: number;
  51367. /**
  51368. * Define the distortion factor of the VR postprocess.
  51369. * Please, touch with care.
  51370. */
  51371. distortionK: number[];
  51372. /**
  51373. * Define the chromatic aberration correction factors for the VR post process.
  51374. */
  51375. chromaAbCorrection: number[];
  51376. /**
  51377. * Define the scale factor of the post process.
  51378. * The smaller the better but the slower.
  51379. */
  51380. postProcessScaleFactor: number;
  51381. /**
  51382. * Define an offset for the lens center.
  51383. */
  51384. lensCenterOffset: number;
  51385. /**
  51386. * Define if the current vr camera should compensate the distortion of the lense or not.
  51387. */
  51388. compensateDistortion: boolean;
  51389. /**
  51390. * Defines if multiview should be enabled when rendering (Default: false)
  51391. */
  51392. multiviewEnabled: boolean;
  51393. /**
  51394. * Gets the rendering aspect ratio based on the provided resolutions.
  51395. */
  51396. get aspectRatio(): number;
  51397. /**
  51398. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51399. */
  51400. get aspectRatioFov(): number;
  51401. /**
  51402. * @hidden
  51403. */
  51404. get leftHMatrix(): Matrix;
  51405. /**
  51406. * @hidden
  51407. */
  51408. get rightHMatrix(): Matrix;
  51409. /**
  51410. * @hidden
  51411. */
  51412. get leftPreViewMatrix(): Matrix;
  51413. /**
  51414. * @hidden
  51415. */
  51416. get rightPreViewMatrix(): Matrix;
  51417. /**
  51418. * Get the default VRMetrics based on the most generic setup.
  51419. * @returns the default vr metrics
  51420. */
  51421. static GetDefault(): VRCameraMetrics;
  51422. }
  51423. }
  51424. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51425. /** @hidden */
  51426. export var vrDistortionCorrectionPixelShader: {
  51427. name: string;
  51428. shader: string;
  51429. };
  51430. }
  51431. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51432. import { Camera } from "babylonjs/Cameras/camera";
  51433. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51435. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51436. /**
  51437. * VRDistortionCorrectionPostProcess used for mobile VR
  51438. */
  51439. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51440. private _isRightEye;
  51441. private _distortionFactors;
  51442. private _postProcessScaleFactor;
  51443. private _lensCenterOffset;
  51444. private _scaleIn;
  51445. private _scaleFactor;
  51446. private _lensCenter;
  51447. /**
  51448. * Gets a string identifying the name of the class
  51449. * @returns "VRDistortionCorrectionPostProcess" string
  51450. */
  51451. getClassName(): string;
  51452. /**
  51453. * Initializes the VRDistortionCorrectionPostProcess
  51454. * @param name The name of the effect.
  51455. * @param camera The camera to apply the render pass to.
  51456. * @param isRightEye If this is for the right eye distortion
  51457. * @param vrMetrics All the required metrics for the VR camera
  51458. */
  51459. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51460. }
  51461. }
  51462. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51463. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51465. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51466. import { Scene } from "babylonjs/scene";
  51467. import { Vector3 } from "babylonjs/Maths/math.vector";
  51468. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51469. import "babylonjs/Cameras/RigModes/vrRigMode";
  51470. /**
  51471. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51472. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51473. */
  51474. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51475. /**
  51476. * Creates a new VRDeviceOrientationArcRotateCamera
  51477. * @param name defines camera name
  51478. * @param alpha defines the camera rotation along the logitudinal axis
  51479. * @param beta defines the camera rotation along the latitudinal axis
  51480. * @param radius defines the camera distance from its target
  51481. * @param target defines the camera target
  51482. * @param scene defines the scene the camera belongs to
  51483. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51484. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51485. */
  51486. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51487. /**
  51488. * Gets camera class name
  51489. * @returns VRDeviceOrientationArcRotateCamera
  51490. */
  51491. getClassName(): string;
  51492. }
  51493. }
  51494. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51495. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51496. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51497. import { Scene } from "babylonjs/scene";
  51498. import { Vector3 } from "babylonjs/Maths/math.vector";
  51499. import "babylonjs/Cameras/RigModes/vrRigMode";
  51500. /**
  51501. * Camera used to simulate VR rendering (based on FreeCamera)
  51502. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51503. */
  51504. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51505. /**
  51506. * Creates a new VRDeviceOrientationFreeCamera
  51507. * @param name defines camera name
  51508. * @param position defines the start position of the camera
  51509. * @param scene defines the scene the camera belongs to
  51510. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51511. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51512. */
  51513. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51514. /**
  51515. * Gets camera class name
  51516. * @returns VRDeviceOrientationFreeCamera
  51517. */
  51518. getClassName(): string;
  51519. }
  51520. }
  51521. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51522. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51523. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51524. import { Scene } from "babylonjs/scene";
  51525. import { Vector3 } from "babylonjs/Maths/math.vector";
  51526. import "babylonjs/Gamepads/gamepadSceneComponent";
  51527. /**
  51528. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51529. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51530. */
  51531. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51532. /**
  51533. * Creates a new VRDeviceOrientationGamepadCamera
  51534. * @param name defines camera name
  51535. * @param position defines the start position of the camera
  51536. * @param scene defines the scene the camera belongs to
  51537. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51538. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51539. */
  51540. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51541. /**
  51542. * Gets camera class name
  51543. * @returns VRDeviceOrientationGamepadCamera
  51544. */
  51545. getClassName(): string;
  51546. }
  51547. }
  51548. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51549. import { Scene } from "babylonjs/scene";
  51550. import { Texture } from "babylonjs/Materials/Textures/texture";
  51551. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51552. /**
  51553. * A class extending Texture allowing drawing on a texture
  51554. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51555. */
  51556. export class DynamicTexture extends Texture {
  51557. private _generateMipMaps;
  51558. private _canvas;
  51559. private _context;
  51560. /**
  51561. * Creates a DynamicTexture
  51562. * @param name defines the name of the texture
  51563. * @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
  51564. * @param scene defines the scene where you want the texture
  51565. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51566. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51567. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51568. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51569. */
  51570. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51571. /**
  51572. * Get the current class name of the texture useful for serialization or dynamic coding.
  51573. * @returns "DynamicTexture"
  51574. */
  51575. getClassName(): string;
  51576. /**
  51577. * Gets the current state of canRescale
  51578. */
  51579. get canRescale(): boolean;
  51580. private _recreate;
  51581. /**
  51582. * Scales the texture
  51583. * @param ratio the scale factor to apply to both width and height
  51584. */
  51585. scale(ratio: number): void;
  51586. /**
  51587. * Resizes the texture
  51588. * @param width the new width
  51589. * @param height the new height
  51590. */
  51591. scaleTo(width: number, height: number): void;
  51592. /**
  51593. * Gets the context of the canvas used by the texture
  51594. * @returns the canvas context of the dynamic texture
  51595. */
  51596. getContext(): CanvasRenderingContext2D;
  51597. /**
  51598. * Clears the texture
  51599. */
  51600. clear(): void;
  51601. /**
  51602. * Updates the texture
  51603. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51604. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51605. */
  51606. update(invertY?: boolean, premulAlpha?: boolean): void;
  51607. /**
  51608. * Draws text onto the texture
  51609. * @param text defines the text to be drawn
  51610. * @param x defines the placement of the text from the left
  51611. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51612. * @param font defines the font to be used with font-style, font-size, font-name
  51613. * @param color defines the color used for the text
  51614. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51615. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51616. * @param update defines whether texture is immediately update (default is true)
  51617. */
  51618. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51619. /**
  51620. * Clones the texture
  51621. * @returns the clone of the texture.
  51622. */
  51623. clone(): DynamicTexture;
  51624. /**
  51625. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51626. * @returns a serialized dynamic texture object
  51627. */
  51628. serialize(): any;
  51629. private _IsCanvasElement;
  51630. /** @hidden */
  51631. _rebuild(): void;
  51632. }
  51633. }
  51634. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51635. import { Scene } from "babylonjs/scene";
  51636. import { Color3 } from "babylonjs/Maths/math.color";
  51637. import { Mesh } from "babylonjs/Meshes/mesh";
  51638. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51639. import { Nullable } from "babylonjs/types";
  51640. /**
  51641. * Class containing static functions to help procedurally build meshes
  51642. */
  51643. export class GroundBuilder {
  51644. /**
  51645. * Creates a ground mesh
  51646. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51647. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51649. * @param name defines the name of the mesh
  51650. * @param options defines the options used to create the mesh
  51651. * @param scene defines the hosting scene
  51652. * @returns the ground mesh
  51653. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51654. */
  51655. static CreateGround(name: string, options: {
  51656. width?: number;
  51657. height?: number;
  51658. subdivisions?: number;
  51659. subdivisionsX?: number;
  51660. subdivisionsY?: number;
  51661. updatable?: boolean;
  51662. }, scene: any): Mesh;
  51663. /**
  51664. * Creates a tiled ground mesh
  51665. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51666. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51667. * * 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
  51668. * * 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
  51669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51670. * @param name defines the name of the mesh
  51671. * @param options defines the options used to create the mesh
  51672. * @param scene defines the hosting scene
  51673. * @returns the tiled ground mesh
  51674. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51675. */
  51676. static CreateTiledGround(name: string, options: {
  51677. xmin: number;
  51678. zmin: number;
  51679. xmax: number;
  51680. zmax: number;
  51681. subdivisions?: {
  51682. w: number;
  51683. h: number;
  51684. };
  51685. precision?: {
  51686. w: number;
  51687. h: number;
  51688. };
  51689. updatable?: boolean;
  51690. }, scene?: Nullable<Scene>): Mesh;
  51691. /**
  51692. * Creates a ground mesh from a height map
  51693. * * The parameter `url` sets the URL of the height map image resource.
  51694. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51695. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51696. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51697. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51698. * * 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.
  51699. * * 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).
  51700. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51702. * @param name defines the name of the mesh
  51703. * @param url defines the url to the height map
  51704. * @param options defines the options used to create the mesh
  51705. * @param scene defines the hosting scene
  51706. * @returns the ground mesh
  51707. * @see https://doc.babylonjs.com/babylon101/height_map
  51708. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51709. */
  51710. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51711. width?: number;
  51712. height?: number;
  51713. subdivisions?: number;
  51714. minHeight?: number;
  51715. maxHeight?: number;
  51716. colorFilter?: Color3;
  51717. alphaFilter?: number;
  51718. updatable?: boolean;
  51719. onReady?: (mesh: GroundMesh) => void;
  51720. }, scene?: Nullable<Scene>): GroundMesh;
  51721. }
  51722. }
  51723. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51724. import { Vector4 } from "babylonjs/Maths/math.vector";
  51725. import { Mesh } from "babylonjs/Meshes/mesh";
  51726. /**
  51727. * Class containing static functions to help procedurally build meshes
  51728. */
  51729. export class TorusBuilder {
  51730. /**
  51731. * Creates a torus mesh
  51732. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51733. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51734. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51738. * @param name defines the name of the mesh
  51739. * @param options defines the options used to create the mesh
  51740. * @param scene defines the hosting scene
  51741. * @returns the torus mesh
  51742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51743. */
  51744. static CreateTorus(name: string, options: {
  51745. diameter?: number;
  51746. thickness?: number;
  51747. tessellation?: number;
  51748. updatable?: boolean;
  51749. sideOrientation?: number;
  51750. frontUVs?: Vector4;
  51751. backUVs?: Vector4;
  51752. }, scene: any): Mesh;
  51753. }
  51754. }
  51755. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51756. import { Vector4 } from "babylonjs/Maths/math.vector";
  51757. import { Color4 } from "babylonjs/Maths/math.color";
  51758. import { Mesh } from "babylonjs/Meshes/mesh";
  51759. /**
  51760. * Class containing static functions to help procedurally build meshes
  51761. */
  51762. export class CylinderBuilder {
  51763. /**
  51764. * Creates a cylinder or a cone mesh
  51765. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51766. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51767. * * 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.
  51768. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51769. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51770. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51771. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51772. * * 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).
  51773. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51774. * * 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).
  51775. * * 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
  51776. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51777. * * 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
  51778. * * 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.
  51779. * * If `enclose` is false, a ring surface is one element.
  51780. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51781. * * 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
  51782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51785. * @param name defines the name of the mesh
  51786. * @param options defines the options used to create the mesh
  51787. * @param scene defines the hosting scene
  51788. * @returns the cylinder mesh
  51789. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51790. */
  51791. static CreateCylinder(name: string, options: {
  51792. height?: number;
  51793. diameterTop?: number;
  51794. diameterBottom?: number;
  51795. diameter?: number;
  51796. tessellation?: number;
  51797. subdivisions?: number;
  51798. arc?: number;
  51799. faceColors?: Color4[];
  51800. faceUV?: Vector4[];
  51801. updatable?: boolean;
  51802. hasRings?: boolean;
  51803. enclose?: boolean;
  51804. cap?: number;
  51805. sideOrientation?: number;
  51806. frontUVs?: Vector4;
  51807. backUVs?: Vector4;
  51808. }, scene: any): Mesh;
  51809. }
  51810. }
  51811. declare module "babylonjs/XR/webXRTypes" {
  51812. import { Nullable } from "babylonjs/types";
  51813. import { IDisposable } from "babylonjs/scene";
  51814. /**
  51815. * States of the webXR experience
  51816. */
  51817. export enum WebXRState {
  51818. /**
  51819. * Transitioning to being in XR mode
  51820. */
  51821. ENTERING_XR = 0,
  51822. /**
  51823. * Transitioning to non XR mode
  51824. */
  51825. EXITING_XR = 1,
  51826. /**
  51827. * In XR mode and presenting
  51828. */
  51829. IN_XR = 2,
  51830. /**
  51831. * Not entered XR mode
  51832. */
  51833. NOT_IN_XR = 3
  51834. }
  51835. /**
  51836. * The state of the XR camera's tracking
  51837. */
  51838. export enum WebXRTrackingState {
  51839. /**
  51840. * No transformation received, device is not being tracked
  51841. */
  51842. NOT_TRACKING = 0,
  51843. /**
  51844. * Tracking lost - using emulated position
  51845. */
  51846. TRACKING_LOST = 1,
  51847. /**
  51848. * Transformation tracking works normally
  51849. */
  51850. TRACKING = 2
  51851. }
  51852. /**
  51853. * Abstraction of the XR render target
  51854. */
  51855. export interface WebXRRenderTarget extends IDisposable {
  51856. /**
  51857. * xrpresent context of the canvas which can be used to display/mirror xr content
  51858. */
  51859. canvasContext: WebGLRenderingContext;
  51860. /**
  51861. * xr layer for the canvas
  51862. */
  51863. xrLayer: Nullable<XRWebGLLayer>;
  51864. /**
  51865. * Initializes the xr layer for the session
  51866. * @param xrSession xr session
  51867. * @returns a promise that will resolve once the XR Layer has been created
  51868. */
  51869. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51870. }
  51871. }
  51872. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51873. import { Nullable } from "babylonjs/types";
  51874. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51875. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51876. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51877. import { Observable } from "babylonjs/Misc/observable";
  51878. /**
  51879. * COnfiguration object for WebXR output canvas
  51880. */
  51881. export class WebXRManagedOutputCanvasOptions {
  51882. /**
  51883. * An optional canvas in case you wish to create it yourself and provide it here.
  51884. * If not provided, a new canvas will be created
  51885. */
  51886. canvasElement?: HTMLCanvasElement;
  51887. /**
  51888. * Options for this XR Layer output
  51889. */
  51890. canvasOptions?: XRWebGLLayerOptions;
  51891. /**
  51892. * CSS styling for a newly created canvas (if not provided)
  51893. */
  51894. newCanvasCssStyle?: string;
  51895. /**
  51896. * Get the default values of the configuration object
  51897. * @param engine defines the engine to use (can be null)
  51898. * @returns default values of this configuration object
  51899. */
  51900. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51901. }
  51902. /**
  51903. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51904. */
  51905. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51906. private _options;
  51907. private _canvas;
  51908. private _engine;
  51909. private _originalCanvasSize;
  51910. /**
  51911. * Rendering context of the canvas which can be used to display/mirror xr content
  51912. */
  51913. canvasContext: WebGLRenderingContext;
  51914. /**
  51915. * xr layer for the canvas
  51916. */
  51917. xrLayer: Nullable<XRWebGLLayer>;
  51918. /**
  51919. * Obseervers registered here will be triggered when the xr layer was initialized
  51920. */
  51921. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51922. /**
  51923. * Initializes the canvas to be added/removed upon entering/exiting xr
  51924. * @param _xrSessionManager The XR Session manager
  51925. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51926. */
  51927. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51928. /**
  51929. * Disposes of the object
  51930. */
  51931. dispose(): void;
  51932. /**
  51933. * Initializes the xr layer for the session
  51934. * @param xrSession xr session
  51935. * @returns a promise that will resolve once the XR Layer has been created
  51936. */
  51937. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51938. private _addCanvas;
  51939. private _removeCanvas;
  51940. private _setCanvasSize;
  51941. private _setManagedOutputCanvas;
  51942. }
  51943. }
  51944. declare module "babylonjs/XR/webXRSessionManager" {
  51945. import { Observable } from "babylonjs/Misc/observable";
  51946. import { Nullable } from "babylonjs/types";
  51947. import { IDisposable, Scene } from "babylonjs/scene";
  51948. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51949. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51950. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51951. /**
  51952. * Manages an XRSession to work with Babylon's engine
  51953. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51954. */
  51955. export class WebXRSessionManager implements IDisposable {
  51956. /** The scene which the session should be created for */
  51957. scene: Scene;
  51958. private _referenceSpace;
  51959. private _rttProvider;
  51960. private _sessionEnded;
  51961. private _xrNavigator;
  51962. private baseLayer;
  51963. /**
  51964. * The base reference space from which the session started. good if you want to reset your
  51965. * reference space
  51966. */
  51967. baseReferenceSpace: XRReferenceSpace;
  51968. /**
  51969. * Current XR frame
  51970. */
  51971. currentFrame: Nullable<XRFrame>;
  51972. /** WebXR timestamp updated every frame */
  51973. currentTimestamp: number;
  51974. /**
  51975. * Used just in case of a failure to initialize an immersive session.
  51976. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51977. */
  51978. defaultHeightCompensation: number;
  51979. /**
  51980. * Fires every time a new xrFrame arrives which can be used to update the camera
  51981. */
  51982. onXRFrameObservable: Observable<XRFrame>;
  51983. /**
  51984. * Fires when the reference space changed
  51985. */
  51986. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51987. /**
  51988. * Fires when the xr session is ended either by the device or manually done
  51989. */
  51990. onXRSessionEnded: Observable<any>;
  51991. /**
  51992. * Fires when the xr session is ended either by the device or manually done
  51993. */
  51994. onXRSessionInit: Observable<XRSession>;
  51995. /**
  51996. * Underlying xr session
  51997. */
  51998. session: XRSession;
  51999. /**
  52000. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52001. * or get the offset the player is currently at.
  52002. */
  52003. viewerReferenceSpace: XRReferenceSpace;
  52004. /**
  52005. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52006. * @param scene The scene which the session should be created for
  52007. */
  52008. constructor(
  52009. /** The scene which the session should be created for */
  52010. scene: Scene);
  52011. /**
  52012. * The current reference space used in this session. This reference space can constantly change!
  52013. * It is mainly used to offset the camera's position.
  52014. */
  52015. get referenceSpace(): XRReferenceSpace;
  52016. /**
  52017. * Set a new reference space and triggers the observable
  52018. */
  52019. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52020. /**
  52021. * Disposes of the session manager
  52022. */
  52023. dispose(): void;
  52024. /**
  52025. * Stops the xrSession and restores the render loop
  52026. * @returns Promise which resolves after it exits XR
  52027. */
  52028. exitXRAsync(): Promise<void>;
  52029. /**
  52030. * Gets the correct render target texture to be rendered this frame for this eye
  52031. * @param eye the eye for which to get the render target
  52032. * @returns the render target for the specified eye
  52033. */
  52034. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52035. /**
  52036. * Creates a WebXRRenderTarget object for the XR session
  52037. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52038. * @param options optional options to provide when creating a new render target
  52039. * @returns a WebXR render target to which the session can render
  52040. */
  52041. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52042. /**
  52043. * Initializes the manager
  52044. * After initialization enterXR can be called to start an XR session
  52045. * @returns Promise which resolves after it is initialized
  52046. */
  52047. initializeAsync(): Promise<void>;
  52048. /**
  52049. * Initializes an xr session
  52050. * @param xrSessionMode mode to initialize
  52051. * @param xrSessionInit defines optional and required values to pass to the session builder
  52052. * @returns a promise which will resolve once the session has been initialized
  52053. */
  52054. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52055. /**
  52056. * Checks if a session would be supported for the creation options specified
  52057. * @param sessionMode session mode to check if supported eg. immersive-vr
  52058. * @returns A Promise that resolves to true if supported and false if not
  52059. */
  52060. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52061. /**
  52062. * Resets the reference space to the one started the session
  52063. */
  52064. resetReferenceSpace(): void;
  52065. /**
  52066. * Starts rendering to the xr layer
  52067. */
  52068. runXRRenderLoop(): void;
  52069. /**
  52070. * Sets the reference space on the xr session
  52071. * @param referenceSpaceType space to set
  52072. * @returns a promise that will resolve once the reference space has been set
  52073. */
  52074. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52075. /**
  52076. * Updates the render state of the session
  52077. * @param state state to set
  52078. * @returns a promise that resolves once the render state has been updated
  52079. */
  52080. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52081. /**
  52082. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52083. * @param sessionMode defines the session to test
  52084. * @returns a promise with boolean as final value
  52085. */
  52086. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52087. private _createRenderTargetTexture;
  52088. }
  52089. }
  52090. declare module "babylonjs/XR/webXRCamera" {
  52091. import { Vector3 } from "babylonjs/Maths/math.vector";
  52092. import { Scene } from "babylonjs/scene";
  52093. import { Camera } from "babylonjs/Cameras/camera";
  52094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52095. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52096. import { Observable } from "babylonjs/Misc/observable";
  52097. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52098. /**
  52099. * WebXR Camera which holds the views for the xrSession
  52100. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52101. */
  52102. export class WebXRCamera extends FreeCamera {
  52103. private _xrSessionManager;
  52104. private _firstFrame;
  52105. private _referenceQuaternion;
  52106. private _referencedPosition;
  52107. private _xrInvPositionCache;
  52108. private _xrInvQuaternionCache;
  52109. private _trackingState;
  52110. /**
  52111. * Observable raised before camera teleportation
  52112. */
  52113. onBeforeCameraTeleport: Observable<Vector3>;
  52114. /**
  52115. * Observable raised after camera teleportation
  52116. */
  52117. onAfterCameraTeleport: Observable<Vector3>;
  52118. /**
  52119. * Notifies when the camera's tracking state has changed.
  52120. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52121. */
  52122. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52123. /**
  52124. * Should position compensation execute on first frame.
  52125. * This is used when copying the position from a native (non XR) camera
  52126. */
  52127. compensateOnFirstFrame: boolean;
  52128. /**
  52129. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52130. * @param name the name of the camera
  52131. * @param scene the scene to add the camera to
  52132. * @param _xrSessionManager a constructed xr session manager
  52133. */
  52134. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52135. /**
  52136. * Get the current XR tracking state of the camera
  52137. */
  52138. get trackingState(): WebXRTrackingState;
  52139. private _setTrackingState;
  52140. /**
  52141. * Return the user's height, unrelated to the current ground.
  52142. * This will be the y position of this camera, when ground level is 0.
  52143. */
  52144. get realWorldHeight(): number;
  52145. /** @hidden */
  52146. _updateForDualEyeDebugging(): void;
  52147. /**
  52148. * Sets this camera's transformation based on a non-vr camera
  52149. * @param otherCamera the non-vr camera to copy the transformation from
  52150. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52151. */
  52152. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52153. /**
  52154. * Gets the current instance class name ("WebXRCamera").
  52155. * @returns the class name
  52156. */
  52157. getClassName(): string;
  52158. private _rotate180;
  52159. private _updateFromXRSession;
  52160. private _updateNumberOfRigCameras;
  52161. private _updateReferenceSpace;
  52162. private _updateReferenceSpaceOffset;
  52163. }
  52164. }
  52165. declare module "babylonjs/XR/webXRFeaturesManager" {
  52166. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52167. import { IDisposable } from "babylonjs/scene";
  52168. /**
  52169. * Defining the interface required for a (webxr) feature
  52170. */
  52171. export interface IWebXRFeature extends IDisposable {
  52172. /**
  52173. * Is this feature attached
  52174. */
  52175. attached: boolean;
  52176. /**
  52177. * Should auto-attach be disabled?
  52178. */
  52179. disableAutoAttach: boolean;
  52180. /**
  52181. * Attach the feature to the session
  52182. * Will usually be called by the features manager
  52183. *
  52184. * @param force should attachment be forced (even when already attached)
  52185. * @returns true if successful.
  52186. */
  52187. attach(force?: boolean): boolean;
  52188. /**
  52189. * Detach the feature from the session
  52190. * Will usually be called by the features manager
  52191. *
  52192. * @returns true if successful.
  52193. */
  52194. detach(): boolean;
  52195. /**
  52196. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52197. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52198. *
  52199. * @returns whether or not the feature is compatible in this environment
  52200. */
  52201. isCompatible(): boolean;
  52202. /**
  52203. * Was this feature disposed;
  52204. */
  52205. isDisposed: boolean;
  52206. /**
  52207. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52208. */
  52209. xrNativeFeatureName?: string;
  52210. /**
  52211. * A list of (Babylon WebXR) features this feature depends on
  52212. */
  52213. dependsOn?: string[];
  52214. }
  52215. /**
  52216. * A list of the currently available features without referencing them
  52217. */
  52218. export class WebXRFeatureName {
  52219. /**
  52220. * The name of the anchor system feature
  52221. */
  52222. static readonly ANCHOR_SYSTEM: string;
  52223. /**
  52224. * The name of the background remover feature
  52225. */
  52226. static readonly BACKGROUND_REMOVER: string;
  52227. /**
  52228. * The name of the hit test feature
  52229. */
  52230. static readonly HIT_TEST: string;
  52231. /**
  52232. * physics impostors for xr controllers feature
  52233. */
  52234. static readonly PHYSICS_CONTROLLERS: string;
  52235. /**
  52236. * The name of the plane detection feature
  52237. */
  52238. static readonly PLANE_DETECTION: string;
  52239. /**
  52240. * The name of the pointer selection feature
  52241. */
  52242. static readonly POINTER_SELECTION: string;
  52243. /**
  52244. * The name of the teleportation feature
  52245. */
  52246. static readonly TELEPORTATION: string;
  52247. /**
  52248. * The name of the feature points feature.
  52249. */
  52250. static readonly FEATURE_POINTS: string;
  52251. /**
  52252. * The name of the hand tracking feature.
  52253. */
  52254. static readonly HAND_TRACKING: string;
  52255. }
  52256. /**
  52257. * Defining the constructor of a feature. Used to register the modules.
  52258. */
  52259. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52260. /**
  52261. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52262. * It is mainly used in AR sessions.
  52263. *
  52264. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52265. */
  52266. export class WebXRFeaturesManager implements IDisposable {
  52267. private _xrSessionManager;
  52268. private static readonly _AvailableFeatures;
  52269. private _features;
  52270. /**
  52271. * constructs a new features manages.
  52272. *
  52273. * @param _xrSessionManager an instance of WebXRSessionManager
  52274. */
  52275. constructor(_xrSessionManager: WebXRSessionManager);
  52276. /**
  52277. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52278. * Mainly used internally.
  52279. *
  52280. * @param featureName the name of the feature to register
  52281. * @param constructorFunction the function used to construct the module
  52282. * @param version the (babylon) version of the module
  52283. * @param stable is that a stable version of this module
  52284. */
  52285. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52286. /**
  52287. * Returns a constructor of a specific feature.
  52288. *
  52289. * @param featureName the name of the feature to construct
  52290. * @param version the version of the feature to load
  52291. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52292. * @param options optional options provided to the module.
  52293. * @returns a function that, when called, will return a new instance of this feature
  52294. */
  52295. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52296. /**
  52297. * Can be used to return the list of features currently registered
  52298. *
  52299. * @returns an Array of available features
  52300. */
  52301. static GetAvailableFeatures(): string[];
  52302. /**
  52303. * Gets the versions available for a specific feature
  52304. * @param featureName the name of the feature
  52305. * @returns an array with the available versions
  52306. */
  52307. static GetAvailableVersions(featureName: string): string[];
  52308. /**
  52309. * Return the latest unstable version of this feature
  52310. * @param featureName the name of the feature to search
  52311. * @returns the version number. if not found will return -1
  52312. */
  52313. static GetLatestVersionOfFeature(featureName: string): number;
  52314. /**
  52315. * Return the latest stable version of this feature
  52316. * @param featureName the name of the feature to search
  52317. * @returns the version number. if not found will return -1
  52318. */
  52319. static GetStableVersionOfFeature(featureName: string): number;
  52320. /**
  52321. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52322. * Can be used during a session to start a feature
  52323. * @param featureName the name of feature to attach
  52324. */
  52325. attachFeature(featureName: string): void;
  52326. /**
  52327. * Can be used inside a session or when the session ends to detach a specific feature
  52328. * @param featureName the name of the feature to detach
  52329. */
  52330. detachFeature(featureName: string): void;
  52331. /**
  52332. * Used to disable an already-enabled feature
  52333. * The feature will be disposed and will be recreated once enabled.
  52334. * @param featureName the feature to disable
  52335. * @returns true if disable was successful
  52336. */
  52337. disableFeature(featureName: string | {
  52338. Name: string;
  52339. }): boolean;
  52340. /**
  52341. * dispose this features manager
  52342. */
  52343. dispose(): void;
  52344. /**
  52345. * 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.
  52346. * 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.
  52347. *
  52348. * @param featureName the name of the feature to load or the class of the feature
  52349. * @param version optional version to load. if not provided the latest version will be enabled
  52350. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52351. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52352. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52353. * @returns a new constructed feature or throws an error if feature not found.
  52354. */
  52355. enableFeature(featureName: string | {
  52356. Name: string;
  52357. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52358. /**
  52359. * get the implementation of an enabled feature.
  52360. * @param featureName the name of the feature to load
  52361. * @returns the feature class, if found
  52362. */
  52363. getEnabledFeature(featureName: string): IWebXRFeature;
  52364. /**
  52365. * Get the list of enabled features
  52366. * @returns an array of enabled features
  52367. */
  52368. getEnabledFeatures(): string[];
  52369. /**
  52370. * This function will exten the session creation configuration object with enabled features.
  52371. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52372. * according to the defined "required" variable, provided during enableFeature call
  52373. * @param xrSessionInit the xr Session init object to extend
  52374. *
  52375. * @returns an extended XRSessionInit object
  52376. */
  52377. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52378. }
  52379. }
  52380. declare module "babylonjs/XR/webXRExperienceHelper" {
  52381. import { Observable } from "babylonjs/Misc/observable";
  52382. import { IDisposable, Scene } from "babylonjs/scene";
  52383. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52384. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52385. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52386. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52387. /**
  52388. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52389. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52390. */
  52391. export class WebXRExperienceHelper implements IDisposable {
  52392. private scene;
  52393. private _nonVRCamera;
  52394. private _originalSceneAutoClear;
  52395. private _supported;
  52396. /**
  52397. * Camera used to render xr content
  52398. */
  52399. camera: WebXRCamera;
  52400. /** A features manager for this xr session */
  52401. featuresManager: WebXRFeaturesManager;
  52402. /**
  52403. * Observers registered here will be triggered after the camera's initial transformation is set
  52404. * This can be used to set a different ground level or an extra rotation.
  52405. *
  52406. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52407. * to the position set after this observable is done executing.
  52408. */
  52409. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52410. /**
  52411. * Fires when the state of the experience helper has changed
  52412. */
  52413. onStateChangedObservable: Observable<WebXRState>;
  52414. /** Session manager used to keep track of xr session */
  52415. sessionManager: WebXRSessionManager;
  52416. /**
  52417. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52418. */
  52419. state: WebXRState;
  52420. /**
  52421. * Creates a WebXRExperienceHelper
  52422. * @param scene The scene the helper should be created in
  52423. */
  52424. private constructor();
  52425. /**
  52426. * Creates the experience helper
  52427. * @param scene the scene to attach the experience helper to
  52428. * @returns a promise for the experience helper
  52429. */
  52430. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52431. /**
  52432. * Disposes of the experience helper
  52433. */
  52434. dispose(): void;
  52435. /**
  52436. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52437. * @param sessionMode options for the XR session
  52438. * @param referenceSpaceType frame of reference of the XR session
  52439. * @param renderTarget the output canvas that will be used to enter XR mode
  52440. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52441. * @returns promise that resolves after xr mode has entered
  52442. */
  52443. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52444. /**
  52445. * Exits XR mode and returns the scene to its original state
  52446. * @returns promise that resolves after xr mode has exited
  52447. */
  52448. exitXRAsync(): Promise<void>;
  52449. private _nonXRToXRCamera;
  52450. private _setState;
  52451. }
  52452. }
  52453. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52454. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52455. import { Observable } from "babylonjs/Misc/observable";
  52456. import { IDisposable } from "babylonjs/scene";
  52457. /**
  52458. * X-Y values for axes in WebXR
  52459. */
  52460. export interface IWebXRMotionControllerAxesValue {
  52461. /**
  52462. * The value of the x axis
  52463. */
  52464. x: number;
  52465. /**
  52466. * The value of the y-axis
  52467. */
  52468. y: number;
  52469. }
  52470. /**
  52471. * changed / previous values for the values of this component
  52472. */
  52473. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52474. /**
  52475. * current (this frame) value
  52476. */
  52477. current: T;
  52478. /**
  52479. * previous (last change) value
  52480. */
  52481. previous: T;
  52482. }
  52483. /**
  52484. * Represents changes in the component between current frame and last values recorded
  52485. */
  52486. export interface IWebXRMotionControllerComponentChanges {
  52487. /**
  52488. * will be populated with previous and current values if axes changed
  52489. */
  52490. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52491. /**
  52492. * will be populated with previous and current values if pressed changed
  52493. */
  52494. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52495. /**
  52496. * will be populated with previous and current values if touched changed
  52497. */
  52498. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52499. /**
  52500. * will be populated with previous and current values if value changed
  52501. */
  52502. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52503. }
  52504. /**
  52505. * This class represents a single component (for example button or thumbstick) of a motion controller
  52506. */
  52507. export class WebXRControllerComponent implements IDisposable {
  52508. /**
  52509. * the id of this component
  52510. */
  52511. id: string;
  52512. /**
  52513. * the type of the component
  52514. */
  52515. type: MotionControllerComponentType;
  52516. private _buttonIndex;
  52517. private _axesIndices;
  52518. private _axes;
  52519. private _changes;
  52520. private _currentValue;
  52521. private _hasChanges;
  52522. private _pressed;
  52523. private _touched;
  52524. /**
  52525. * button component type
  52526. */
  52527. static BUTTON_TYPE: MotionControllerComponentType;
  52528. /**
  52529. * squeeze component type
  52530. */
  52531. static SQUEEZE_TYPE: MotionControllerComponentType;
  52532. /**
  52533. * Thumbstick component type
  52534. */
  52535. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52536. /**
  52537. * Touchpad component type
  52538. */
  52539. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52540. /**
  52541. * trigger component type
  52542. */
  52543. static TRIGGER_TYPE: MotionControllerComponentType;
  52544. /**
  52545. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52546. * the axes data changes
  52547. */
  52548. onAxisValueChangedObservable: Observable<{
  52549. x: number;
  52550. y: number;
  52551. }>;
  52552. /**
  52553. * Observers registered here will be triggered when the state of a button changes
  52554. * State change is either pressed / touched / value
  52555. */
  52556. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52557. /**
  52558. * Creates a new component for a motion controller.
  52559. * It is created by the motion controller itself
  52560. *
  52561. * @param id the id of this component
  52562. * @param type the type of the component
  52563. * @param _buttonIndex index in the buttons array of the gamepad
  52564. * @param _axesIndices indices of the values in the axes array of the gamepad
  52565. */
  52566. constructor(
  52567. /**
  52568. * the id of this component
  52569. */
  52570. id: string,
  52571. /**
  52572. * the type of the component
  52573. */
  52574. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52575. /**
  52576. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52577. */
  52578. get axes(): IWebXRMotionControllerAxesValue;
  52579. /**
  52580. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52581. */
  52582. get changes(): IWebXRMotionControllerComponentChanges;
  52583. /**
  52584. * Return whether or not the component changed the last frame
  52585. */
  52586. get hasChanges(): boolean;
  52587. /**
  52588. * is the button currently pressed
  52589. */
  52590. get pressed(): boolean;
  52591. /**
  52592. * is the button currently touched
  52593. */
  52594. get touched(): boolean;
  52595. /**
  52596. * Get the current value of this component
  52597. */
  52598. get value(): number;
  52599. /**
  52600. * Dispose this component
  52601. */
  52602. dispose(): void;
  52603. /**
  52604. * Are there axes correlating to this component
  52605. * @return true is axes data is available
  52606. */
  52607. isAxes(): boolean;
  52608. /**
  52609. * Is this component a button (hence - pressable)
  52610. * @returns true if can be pressed
  52611. */
  52612. isButton(): boolean;
  52613. /**
  52614. * update this component using the gamepad object it is in. Called on every frame
  52615. * @param nativeController the native gamepad controller object
  52616. */
  52617. update(nativeController: IMinimalMotionControllerObject): void;
  52618. }
  52619. }
  52620. declare module "babylonjs/Loading/sceneLoader" {
  52621. import { Observable } from "babylonjs/Misc/observable";
  52622. import { Nullable } from "babylonjs/types";
  52623. import { Scene } from "babylonjs/scene";
  52624. import { Engine } from "babylonjs/Engines/engine";
  52625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52626. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52627. import { AssetContainer } from "babylonjs/assetContainer";
  52628. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52629. import { Skeleton } from "babylonjs/Bones/skeleton";
  52630. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52631. import { WebRequest } from "babylonjs/Misc/webRequest";
  52632. /**
  52633. * Interface used to represent data loading progression
  52634. */
  52635. export interface ISceneLoaderProgressEvent {
  52636. /**
  52637. * Defines if data length to load can be evaluated
  52638. */
  52639. readonly lengthComputable: boolean;
  52640. /**
  52641. * Defines the loaded data length
  52642. */
  52643. readonly loaded: number;
  52644. /**
  52645. * Defines the data length to load
  52646. */
  52647. readonly total: number;
  52648. }
  52649. /**
  52650. * Interface used by SceneLoader plugins to define supported file extensions
  52651. */
  52652. export interface ISceneLoaderPluginExtensions {
  52653. /**
  52654. * Defines the list of supported extensions
  52655. */
  52656. [extension: string]: {
  52657. isBinary: boolean;
  52658. };
  52659. }
  52660. /**
  52661. * Interface used by SceneLoader plugin factory
  52662. */
  52663. export interface ISceneLoaderPluginFactory {
  52664. /**
  52665. * Defines the name of the factory
  52666. */
  52667. name: string;
  52668. /**
  52669. * Function called to create a new plugin
  52670. * @return the new plugin
  52671. */
  52672. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52673. /**
  52674. * The callback that returns true if the data can be directly loaded.
  52675. * @param data string containing the file data
  52676. * @returns if the data can be loaded directly
  52677. */
  52678. canDirectLoad?(data: string): boolean;
  52679. }
  52680. /**
  52681. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52682. */
  52683. export interface ISceneLoaderPluginBase {
  52684. /**
  52685. * The friendly name of this plugin.
  52686. */
  52687. name: string;
  52688. /**
  52689. * The file extensions supported by this plugin.
  52690. */
  52691. extensions: string | ISceneLoaderPluginExtensions;
  52692. /**
  52693. * The callback called when loading from a url.
  52694. * @param scene scene loading this url
  52695. * @param url url to load
  52696. * @param onSuccess callback called when the file successfully loads
  52697. * @param onProgress callback called while file is loading (if the server supports this mode)
  52698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52699. * @param onError callback called when the file fails to load
  52700. * @returns a file request object
  52701. */
  52702. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52703. /**
  52704. * The callback called when loading from a file object.
  52705. * @param scene scene loading this file
  52706. * @param file defines the file to load
  52707. * @param onSuccess defines the callback to call when data is loaded
  52708. * @param onProgress defines the callback to call during loading process
  52709. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52710. * @param onError defines the callback to call when an error occurs
  52711. * @returns a file request object
  52712. */
  52713. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52714. /**
  52715. * The callback that returns true if the data can be directly loaded.
  52716. * @param data string containing the file data
  52717. * @returns if the data can be loaded directly
  52718. */
  52719. canDirectLoad?(data: string): boolean;
  52720. /**
  52721. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52722. * @param scene scene loading this data
  52723. * @param data string containing the data
  52724. * @returns data to pass to the plugin
  52725. */
  52726. directLoad?(scene: Scene, data: string): any;
  52727. /**
  52728. * The callback that allows custom handling of the root url based on the response url.
  52729. * @param rootUrl the original root url
  52730. * @param responseURL the response url if available
  52731. * @returns the new root url
  52732. */
  52733. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52734. }
  52735. /**
  52736. * Interface used to define a SceneLoader plugin
  52737. */
  52738. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52739. /**
  52740. * Import meshes into a scene.
  52741. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52742. * @param scene The scene to import into
  52743. * @param data The data to import
  52744. * @param rootUrl The root url for scene and resources
  52745. * @param meshes The meshes array to import into
  52746. * @param particleSystems The particle systems array to import into
  52747. * @param skeletons The skeletons array to import into
  52748. * @param onError The callback when import fails
  52749. * @returns True if successful or false otherwise
  52750. */
  52751. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52752. /**
  52753. * Load into a scene.
  52754. * @param scene The scene to load into
  52755. * @param data The data to import
  52756. * @param rootUrl The root url for scene and resources
  52757. * @param onError The callback when import fails
  52758. * @returns True if successful or false otherwise
  52759. */
  52760. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52761. /**
  52762. * Load into an asset container.
  52763. * @param scene The scene to load into
  52764. * @param data The data to import
  52765. * @param rootUrl The root url for scene and resources
  52766. * @param onError The callback when import fails
  52767. * @returns The loaded asset container
  52768. */
  52769. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52770. }
  52771. /**
  52772. * Interface used to define an async SceneLoader plugin
  52773. */
  52774. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52775. /**
  52776. * Import meshes into a scene.
  52777. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52778. * @param scene The scene to import into
  52779. * @param data The data to import
  52780. * @param rootUrl The root url for scene and resources
  52781. * @param onProgress The callback when the load progresses
  52782. * @param fileName Defines the name of the file to load
  52783. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52784. */
  52785. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52786. meshes: AbstractMesh[];
  52787. particleSystems: IParticleSystem[];
  52788. skeletons: Skeleton[];
  52789. animationGroups: AnimationGroup[];
  52790. }>;
  52791. /**
  52792. * Load into a scene.
  52793. * @param scene The scene to load into
  52794. * @param data The data to import
  52795. * @param rootUrl The root url for scene and resources
  52796. * @param onProgress The callback when the load progresses
  52797. * @param fileName Defines the name of the file to load
  52798. * @returns Nothing
  52799. */
  52800. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52801. /**
  52802. * Load into an asset container.
  52803. * @param scene The scene to load into
  52804. * @param data The data to import
  52805. * @param rootUrl The root url for scene and resources
  52806. * @param onProgress The callback when the load progresses
  52807. * @param fileName Defines the name of the file to load
  52808. * @returns The loaded asset container
  52809. */
  52810. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52811. }
  52812. /**
  52813. * Mode that determines how to handle old animation groups before loading new ones.
  52814. */
  52815. export enum SceneLoaderAnimationGroupLoadingMode {
  52816. /**
  52817. * Reset all old animations to initial state then dispose them.
  52818. */
  52819. Clean = 0,
  52820. /**
  52821. * Stop all old animations.
  52822. */
  52823. Stop = 1,
  52824. /**
  52825. * Restart old animations from first frame.
  52826. */
  52827. Sync = 2,
  52828. /**
  52829. * Old animations remains untouched.
  52830. */
  52831. NoSync = 3
  52832. }
  52833. /**
  52834. * Defines a plugin registered by the SceneLoader
  52835. */
  52836. interface IRegisteredPlugin {
  52837. /**
  52838. * Defines the plugin to use
  52839. */
  52840. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52841. /**
  52842. * Defines if the plugin supports binary data
  52843. */
  52844. isBinary: boolean;
  52845. }
  52846. /**
  52847. * Class used to load scene from various file formats using registered plugins
  52848. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52849. */
  52850. export class SceneLoader {
  52851. /**
  52852. * No logging while loading
  52853. */
  52854. static readonly NO_LOGGING: number;
  52855. /**
  52856. * Minimal logging while loading
  52857. */
  52858. static readonly MINIMAL_LOGGING: number;
  52859. /**
  52860. * Summary logging while loading
  52861. */
  52862. static readonly SUMMARY_LOGGING: number;
  52863. /**
  52864. * Detailled logging while loading
  52865. */
  52866. static readonly DETAILED_LOGGING: number;
  52867. /**
  52868. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52869. */
  52870. static get ForceFullSceneLoadingForIncremental(): boolean;
  52871. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52872. /**
  52873. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52874. */
  52875. static get ShowLoadingScreen(): boolean;
  52876. static set ShowLoadingScreen(value: boolean);
  52877. /**
  52878. * Defines the current logging level (while loading the scene)
  52879. * @ignorenaming
  52880. */
  52881. static get loggingLevel(): number;
  52882. static set loggingLevel(value: number);
  52883. /**
  52884. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52885. */
  52886. static get CleanBoneMatrixWeights(): boolean;
  52887. static set CleanBoneMatrixWeights(value: boolean);
  52888. /**
  52889. * Event raised when a plugin is used to load a scene
  52890. */
  52891. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52892. private static _registeredPlugins;
  52893. private static _showingLoadingScreen;
  52894. /**
  52895. * Gets the default plugin (used to load Babylon files)
  52896. * @returns the .babylon plugin
  52897. */
  52898. static GetDefaultPlugin(): IRegisteredPlugin;
  52899. private static _GetPluginForExtension;
  52900. private static _GetPluginForDirectLoad;
  52901. private static _GetPluginForFilename;
  52902. private static _GetDirectLoad;
  52903. private static _LoadData;
  52904. private static _GetFileInfo;
  52905. /**
  52906. * Gets a plugin that can load the given extension
  52907. * @param extension defines the extension to load
  52908. * @returns a plugin or null if none works
  52909. */
  52910. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52911. /**
  52912. * Gets a boolean indicating that the given extension can be loaded
  52913. * @param extension defines the extension to load
  52914. * @returns true if the extension is supported
  52915. */
  52916. static IsPluginForExtensionAvailable(extension: string): boolean;
  52917. /**
  52918. * Adds a new plugin to the list of registered plugins
  52919. * @param plugin defines the plugin to add
  52920. */
  52921. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52922. /**
  52923. * Import meshes into a scene
  52924. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52925. * @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)
  52926. * @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)
  52927. * @param scene the instance of BABYLON.Scene to append to
  52928. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52929. * @param onProgress a callback with a progress event for each file being loaded
  52930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52931. * @param pluginExtension the extension used to determine the plugin
  52932. * @returns The loaded plugin
  52933. */
  52934. 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>;
  52935. /**
  52936. * Import meshes into a scene
  52937. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52938. * @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)
  52939. * @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)
  52940. * @param scene the instance of BABYLON.Scene to append to
  52941. * @param onProgress a callback with a progress event for each file being loaded
  52942. * @param pluginExtension the extension used to determine the plugin
  52943. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52944. */
  52945. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52946. meshes: AbstractMesh[];
  52947. particleSystems: IParticleSystem[];
  52948. skeletons: Skeleton[];
  52949. animationGroups: AnimationGroup[];
  52950. }>;
  52951. /**
  52952. * Load a scene
  52953. * @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)
  52954. * @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)
  52955. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52956. * @param onSuccess a callback with the scene when import succeeds
  52957. * @param onProgress a callback with a progress event for each file being loaded
  52958. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52959. * @param pluginExtension the extension used to determine the plugin
  52960. * @returns The loaded plugin
  52961. */
  52962. 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>;
  52963. /**
  52964. * Load a scene
  52965. * @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)
  52966. * @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)
  52967. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52968. * @param onProgress a callback with a progress event for each file being loaded
  52969. * @param pluginExtension the extension used to determine the plugin
  52970. * @returns The loaded scene
  52971. */
  52972. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52973. /**
  52974. * Append a scene
  52975. * @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)
  52976. * @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)
  52977. * @param scene is the instance of BABYLON.Scene to append to
  52978. * @param onSuccess a callback with the scene when import succeeds
  52979. * @param onProgress a callback with a progress event for each file being loaded
  52980. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52981. * @param pluginExtension the extension used to determine the plugin
  52982. * @returns The loaded plugin
  52983. */
  52984. 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>;
  52985. /**
  52986. * Append a scene
  52987. * @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)
  52988. * @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)
  52989. * @param scene is the instance of BABYLON.Scene to append to
  52990. * @param onProgress a callback with a progress event for each file being loaded
  52991. * @param pluginExtension the extension used to determine the plugin
  52992. * @returns The given scene
  52993. */
  52994. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52995. /**
  52996. * Load a scene into an asset container
  52997. * @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)
  52998. * @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)
  52999. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53000. * @param onSuccess a callback with the scene when import succeeds
  53001. * @param onProgress a callback with a progress event for each file being loaded
  53002. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53003. * @param pluginExtension the extension used to determine the plugin
  53004. * @returns The loaded plugin
  53005. */
  53006. 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>;
  53007. /**
  53008. * Load a scene into an asset container
  53009. * @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)
  53010. * @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)
  53011. * @param scene is the instance of Scene to append to
  53012. * @param onProgress a callback with a progress event for each file being loaded
  53013. * @param pluginExtension the extension used to determine the plugin
  53014. * @returns The loaded asset container
  53015. */
  53016. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53017. /**
  53018. * Import animations from a file into a scene
  53019. * @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)
  53020. * @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)
  53021. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53022. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53023. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53024. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53025. * @param onSuccess a callback with the scene when import succeeds
  53026. * @param onProgress a callback with a progress event for each file being loaded
  53027. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53028. * @param pluginExtension the extension used to determine the plugin
  53029. */
  53030. 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;
  53031. /**
  53032. * Import animations from a file into a scene
  53033. * @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)
  53034. * @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)
  53035. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53036. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53037. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53038. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53039. * @param onSuccess a callback with the scene when import succeeds
  53040. * @param onProgress a callback with a progress event for each file being loaded
  53041. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53042. * @param pluginExtension the extension used to determine the plugin
  53043. * @returns the updated scene with imported animations
  53044. */
  53045. 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>;
  53046. }
  53047. }
  53048. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53049. import { IDisposable, Scene } from "babylonjs/scene";
  53050. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53051. import { Observable } from "babylonjs/Misc/observable";
  53052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53053. import { Nullable } from "babylonjs/types";
  53054. /**
  53055. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53056. */
  53057. export type MotionControllerHandedness = "none" | "left" | "right";
  53058. /**
  53059. * The type of components available in motion controllers.
  53060. * This is not the name of the component.
  53061. */
  53062. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53063. /**
  53064. * The state of a controller component
  53065. */
  53066. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53067. /**
  53068. * The schema of motion controller layout.
  53069. * No object will be initialized using this interface
  53070. * This is used just to define the profile.
  53071. */
  53072. export interface IMotionControllerLayout {
  53073. /**
  53074. * Path to load the assets. Usually relative to the base path
  53075. */
  53076. assetPath: string;
  53077. /**
  53078. * Available components (unsorted)
  53079. */
  53080. components: {
  53081. /**
  53082. * A map of component Ids
  53083. */
  53084. [componentId: string]: {
  53085. /**
  53086. * The type of input the component outputs
  53087. */
  53088. type: MotionControllerComponentType;
  53089. /**
  53090. * The indices of this component in the gamepad object
  53091. */
  53092. gamepadIndices: {
  53093. /**
  53094. * Index of button
  53095. */
  53096. button?: number;
  53097. /**
  53098. * If available, index of x-axis
  53099. */
  53100. xAxis?: number;
  53101. /**
  53102. * If available, index of y-axis
  53103. */
  53104. yAxis?: number;
  53105. };
  53106. /**
  53107. * The mesh's root node name
  53108. */
  53109. rootNodeName: string;
  53110. /**
  53111. * Animation definitions for this model
  53112. */
  53113. visualResponses: {
  53114. [stateKey: string]: {
  53115. /**
  53116. * What property will be animated
  53117. */
  53118. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53119. /**
  53120. * What states influence this visual response
  53121. */
  53122. states: MotionControllerComponentStateType[];
  53123. /**
  53124. * Type of animation - movement or visibility
  53125. */
  53126. valueNodeProperty: "transform" | "visibility";
  53127. /**
  53128. * Base node name to move. Its position will be calculated according to the min and max nodes
  53129. */
  53130. valueNodeName?: string;
  53131. /**
  53132. * Minimum movement node
  53133. */
  53134. minNodeName?: string;
  53135. /**
  53136. * Max movement node
  53137. */
  53138. maxNodeName?: string;
  53139. };
  53140. };
  53141. /**
  53142. * If touch enabled, what is the name of node to display user feedback
  53143. */
  53144. touchPointNodeName?: string;
  53145. };
  53146. };
  53147. /**
  53148. * Is it xr standard mapping or not
  53149. */
  53150. gamepadMapping: "" | "xr-standard";
  53151. /**
  53152. * Base root node of this entire model
  53153. */
  53154. rootNodeName: string;
  53155. /**
  53156. * Defines the main button component id
  53157. */
  53158. selectComponentId: string;
  53159. }
  53160. /**
  53161. * A definition for the layout map in the input profile
  53162. */
  53163. export interface IMotionControllerLayoutMap {
  53164. /**
  53165. * Layouts with handedness type as a key
  53166. */
  53167. [handedness: string]: IMotionControllerLayout;
  53168. }
  53169. /**
  53170. * The XR Input profile schema
  53171. * Profiles can be found here:
  53172. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53173. */
  53174. export interface IMotionControllerProfile {
  53175. /**
  53176. * fallback profiles for this profileId
  53177. */
  53178. fallbackProfileIds: string[];
  53179. /**
  53180. * The layout map, with handedness as key
  53181. */
  53182. layouts: IMotionControllerLayoutMap;
  53183. /**
  53184. * The id of this profile
  53185. * correlates to the profile(s) in the xrInput.profiles array
  53186. */
  53187. profileId: string;
  53188. }
  53189. /**
  53190. * A helper-interface for the 3 meshes needed for controller button animation
  53191. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53192. */
  53193. export interface IMotionControllerButtonMeshMap {
  53194. /**
  53195. * the mesh that defines the pressed value mesh position.
  53196. * This is used to find the max-position of this button
  53197. */
  53198. pressedMesh: AbstractMesh;
  53199. /**
  53200. * the mesh that defines the unpressed value mesh position.
  53201. * This is used to find the min (or initial) position of this button
  53202. */
  53203. unpressedMesh: AbstractMesh;
  53204. /**
  53205. * The mesh that will be changed when value changes
  53206. */
  53207. valueMesh: AbstractMesh;
  53208. }
  53209. /**
  53210. * A helper-interface for the 3 meshes needed for controller axis animation.
  53211. * This will be expanded when touchpad animations are fully supported
  53212. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53213. */
  53214. export interface IMotionControllerMeshMap {
  53215. /**
  53216. * the mesh that defines the maximum value mesh position.
  53217. */
  53218. maxMesh?: AbstractMesh;
  53219. /**
  53220. * the mesh that defines the minimum value mesh position.
  53221. */
  53222. minMesh?: AbstractMesh;
  53223. /**
  53224. * The mesh that will be changed when axis value changes
  53225. */
  53226. valueMesh?: AbstractMesh;
  53227. }
  53228. /**
  53229. * The elements needed for change-detection of the gamepad objects in motion controllers
  53230. */
  53231. export interface IMinimalMotionControllerObject {
  53232. /**
  53233. * Available axes of this controller
  53234. */
  53235. axes: number[];
  53236. /**
  53237. * An array of available buttons
  53238. */
  53239. buttons: Array<{
  53240. /**
  53241. * Value of the button/trigger
  53242. */
  53243. value: number;
  53244. /**
  53245. * If the button/trigger is currently touched
  53246. */
  53247. touched: boolean;
  53248. /**
  53249. * If the button/trigger is currently pressed
  53250. */
  53251. pressed: boolean;
  53252. }>;
  53253. /**
  53254. * EXPERIMENTAL haptic support.
  53255. */
  53256. hapticActuators?: Array<{
  53257. pulse: (value: number, duration: number) => Promise<boolean>;
  53258. }>;
  53259. }
  53260. /**
  53261. * An Abstract Motion controller
  53262. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53263. * Each component has an observable to check for changes in value and state
  53264. */
  53265. export abstract class WebXRAbstractMotionController implements IDisposable {
  53266. protected scene: Scene;
  53267. protected layout: IMotionControllerLayout;
  53268. /**
  53269. * The gamepad object correlating to this controller
  53270. */
  53271. gamepadObject: IMinimalMotionControllerObject;
  53272. /**
  53273. * handedness (left/right/none) of this controller
  53274. */
  53275. handedness: MotionControllerHandedness;
  53276. private _initComponent;
  53277. private _modelReady;
  53278. /**
  53279. * A map of components (WebXRControllerComponent) in this motion controller
  53280. * Components have a ComponentType and can also have both button and axis definitions
  53281. */
  53282. readonly components: {
  53283. [id: string]: WebXRControllerComponent;
  53284. };
  53285. /**
  53286. * Disable the model's animation. Can be set at any time.
  53287. */
  53288. disableAnimation: boolean;
  53289. /**
  53290. * Observers registered here will be triggered when the model of this controller is done loading
  53291. */
  53292. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53293. /**
  53294. * The profile id of this motion controller
  53295. */
  53296. abstract profileId: string;
  53297. /**
  53298. * The root mesh of the model. It is null if the model was not yet initialized
  53299. */
  53300. rootMesh: Nullable<AbstractMesh>;
  53301. /**
  53302. * constructs a new abstract motion controller
  53303. * @param scene the scene to which the model of the controller will be added
  53304. * @param layout The profile layout to load
  53305. * @param gamepadObject The gamepad object correlating to this controller
  53306. * @param handedness handedness (left/right/none) of this controller
  53307. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53308. */
  53309. constructor(scene: Scene, layout: IMotionControllerLayout,
  53310. /**
  53311. * The gamepad object correlating to this controller
  53312. */
  53313. gamepadObject: IMinimalMotionControllerObject,
  53314. /**
  53315. * handedness (left/right/none) of this controller
  53316. */
  53317. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53318. /**
  53319. * Dispose this controller, the model mesh and all its components
  53320. */
  53321. dispose(): void;
  53322. /**
  53323. * Returns all components of specific type
  53324. * @param type the type to search for
  53325. * @return an array of components with this type
  53326. */
  53327. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53328. /**
  53329. * get a component based an its component id as defined in layout.components
  53330. * @param id the id of the component
  53331. * @returns the component correlates to the id or undefined if not found
  53332. */
  53333. getComponent(id: string): WebXRControllerComponent;
  53334. /**
  53335. * Get the list of components available in this motion controller
  53336. * @returns an array of strings correlating to available components
  53337. */
  53338. getComponentIds(): string[];
  53339. /**
  53340. * Get the first component of specific type
  53341. * @param type type of component to find
  53342. * @return a controller component or null if not found
  53343. */
  53344. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53345. /**
  53346. * Get the main (Select) component of this controller as defined in the layout
  53347. * @returns the main component of this controller
  53348. */
  53349. getMainComponent(): WebXRControllerComponent;
  53350. /**
  53351. * Loads the model correlating to this controller
  53352. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53353. * @returns A promise fulfilled with the result of the model loading
  53354. */
  53355. loadModel(): Promise<boolean>;
  53356. /**
  53357. * Update this model using the current XRFrame
  53358. * @param xrFrame the current xr frame to use and update the model
  53359. */
  53360. updateFromXRFrame(xrFrame: XRFrame): void;
  53361. /**
  53362. * Backwards compatibility due to a deeply-integrated typo
  53363. */
  53364. get handness(): XREye;
  53365. /**
  53366. * Pulse (vibrate) this controller
  53367. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53368. * Consecutive calls to this function will cancel the last pulse call
  53369. *
  53370. * @param value the strength of the pulse in 0.0...1.0 range
  53371. * @param duration Duration of the pulse in milliseconds
  53372. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53373. * @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
  53374. */
  53375. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53376. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53377. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53378. /**
  53379. * Moves the axis on the controller mesh based on its current state
  53380. * @param axis the index of the axis
  53381. * @param axisValue the value of the axis which determines the meshes new position
  53382. * @hidden
  53383. */
  53384. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53385. /**
  53386. * Update the model itself with the current frame data
  53387. * @param xrFrame the frame to use for updating the model mesh
  53388. */
  53389. protected updateModel(xrFrame: XRFrame): void;
  53390. /**
  53391. * Get the filename and path for this controller's model
  53392. * @returns a map of filename and path
  53393. */
  53394. protected abstract _getFilenameAndPath(): {
  53395. filename: string;
  53396. path: string;
  53397. };
  53398. /**
  53399. * This function is called before the mesh is loaded. It checks for loading constraints.
  53400. * For example, this function can check if the GLB loader is available
  53401. * If this function returns false, the generic controller will be loaded instead
  53402. * @returns Is the client ready to load the mesh
  53403. */
  53404. protected abstract _getModelLoadingConstraints(): boolean;
  53405. /**
  53406. * This function will be called after the model was successfully loaded and can be used
  53407. * for mesh transformations before it is available for the user
  53408. * @param meshes the loaded meshes
  53409. */
  53410. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53411. /**
  53412. * Set the root mesh for this controller. Important for the WebXR controller class
  53413. * @param meshes the loaded meshes
  53414. */
  53415. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53416. /**
  53417. * A function executed each frame that updates the mesh (if needed)
  53418. * @param xrFrame the current xrFrame
  53419. */
  53420. protected abstract _updateModel(xrFrame: XRFrame): void;
  53421. private _getGenericFilenameAndPath;
  53422. private _getGenericParentMesh;
  53423. }
  53424. }
  53425. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53426. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53428. import { Scene } from "babylonjs/scene";
  53429. /**
  53430. * A generic trigger-only motion controller for WebXR
  53431. */
  53432. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53433. /**
  53434. * Static version of the profile id of this controller
  53435. */
  53436. static ProfileId: string;
  53437. profileId: string;
  53438. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53439. protected _getFilenameAndPath(): {
  53440. filename: string;
  53441. path: string;
  53442. };
  53443. protected _getModelLoadingConstraints(): boolean;
  53444. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53445. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53446. protected _updateModel(): void;
  53447. }
  53448. }
  53449. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53450. import { Vector4 } from "babylonjs/Maths/math.vector";
  53451. import { Mesh } from "babylonjs/Meshes/mesh";
  53452. import { Scene } from "babylonjs/scene";
  53453. import { Nullable } from "babylonjs/types";
  53454. /**
  53455. * Class containing static functions to help procedurally build meshes
  53456. */
  53457. export class SphereBuilder {
  53458. /**
  53459. * Creates a sphere mesh
  53460. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53461. * * 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`)
  53462. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53463. * * 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
  53464. * * 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)
  53465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53468. * @param name defines the name of the mesh
  53469. * @param options defines the options used to create the mesh
  53470. * @param scene defines the hosting scene
  53471. * @returns the sphere mesh
  53472. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53473. */
  53474. static CreateSphere(name: string, options: {
  53475. segments?: number;
  53476. diameter?: number;
  53477. diameterX?: number;
  53478. diameterY?: number;
  53479. diameterZ?: number;
  53480. arc?: number;
  53481. slice?: number;
  53482. sideOrientation?: number;
  53483. frontUVs?: Vector4;
  53484. backUVs?: Vector4;
  53485. updatable?: boolean;
  53486. }, scene?: Nullable<Scene>): Mesh;
  53487. }
  53488. }
  53489. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53491. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53492. import { Scene } from "babylonjs/scene";
  53493. /**
  53494. * A profiled motion controller has its profile loaded from an online repository.
  53495. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53496. */
  53497. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53498. private _repositoryUrl;
  53499. private _buttonMeshMapping;
  53500. private _touchDots;
  53501. /**
  53502. * The profile ID of this controller. Will be populated when the controller initializes.
  53503. */
  53504. profileId: string;
  53505. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53506. dispose(): void;
  53507. protected _getFilenameAndPath(): {
  53508. filename: string;
  53509. path: string;
  53510. };
  53511. protected _getModelLoadingConstraints(): boolean;
  53512. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53513. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53514. protected _updateModel(_xrFrame: XRFrame): void;
  53515. }
  53516. }
  53517. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53518. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53519. import { Scene } from "babylonjs/scene";
  53520. /**
  53521. * A construction function type to create a new controller based on an xrInput object
  53522. */
  53523. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53524. /**
  53525. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53526. *
  53527. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53528. * it should be replaced with auto-loaded controllers.
  53529. *
  53530. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53531. */
  53532. export class WebXRMotionControllerManager {
  53533. private static _AvailableControllers;
  53534. private static _Fallbacks;
  53535. private static _ProfileLoadingPromises;
  53536. private static _ProfilesList;
  53537. /**
  53538. * The base URL of the online controller repository. Can be changed at any time.
  53539. */
  53540. static BaseRepositoryUrl: string;
  53541. /**
  53542. * Which repository gets priority - local or online
  53543. */
  53544. static PrioritizeOnlineRepository: boolean;
  53545. /**
  53546. * Use the online repository, or use only locally-defined controllers
  53547. */
  53548. static UseOnlineRepository: boolean;
  53549. /**
  53550. * Clear the cache used for profile loading and reload when requested again
  53551. */
  53552. static ClearProfilesCache(): void;
  53553. /**
  53554. * Register the default fallbacks.
  53555. * This function is called automatically when this file is imported.
  53556. */
  53557. static DefaultFallbacks(): void;
  53558. /**
  53559. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53560. * @param profileId the profile to which a fallback needs to be found
  53561. * @return an array with corresponding fallback profiles
  53562. */
  53563. static FindFallbackWithProfileId(profileId: string): string[];
  53564. /**
  53565. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53566. * The order of search:
  53567. *
  53568. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53569. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53570. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53571. * 4) return the generic trigger controller if none were found
  53572. *
  53573. * @param xrInput the xrInput to which a new controller is initialized
  53574. * @param scene the scene to which the model will be added
  53575. * @param forceProfile force a certain profile for this controller
  53576. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53577. */
  53578. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53579. /**
  53580. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53581. *
  53582. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53583. *
  53584. * @param type the profile type to register
  53585. * @param constructFunction the function to be called when loading this profile
  53586. */
  53587. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53588. /**
  53589. * Register a fallback to a specific profile.
  53590. * @param profileId the profileId that will receive the fallbacks
  53591. * @param fallbacks A list of fallback profiles
  53592. */
  53593. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53594. /**
  53595. * Will update the list of profiles available in the repository
  53596. * @return a promise that resolves to a map of profiles available online
  53597. */
  53598. static UpdateProfilesList(): Promise<{
  53599. [profile: string]: string;
  53600. }>;
  53601. private static _LoadProfileFromRepository;
  53602. private static _LoadProfilesFromAvailableControllers;
  53603. }
  53604. }
  53605. declare module "babylonjs/XR/webXRInputSource" {
  53606. import { Observable } from "babylonjs/Misc/observable";
  53607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53608. import { Ray } from "babylonjs/Culling/ray";
  53609. import { Scene } from "babylonjs/scene";
  53610. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53611. /**
  53612. * Configuration options for the WebXR controller creation
  53613. */
  53614. export interface IWebXRControllerOptions {
  53615. /**
  53616. * Should the controller mesh be animated when a user interacts with it
  53617. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53618. */
  53619. disableMotionControllerAnimation?: boolean;
  53620. /**
  53621. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53622. */
  53623. doNotLoadControllerMesh?: boolean;
  53624. /**
  53625. * Force a specific controller type for this controller.
  53626. * This can be used when creating your own profile or when testing different controllers
  53627. */
  53628. forceControllerProfile?: string;
  53629. /**
  53630. * Defines a rendering group ID for meshes that will be loaded.
  53631. * This is for the default controllers only.
  53632. */
  53633. renderingGroupId?: number;
  53634. }
  53635. /**
  53636. * Represents an XR controller
  53637. */
  53638. export class WebXRInputSource {
  53639. private _scene;
  53640. /** The underlying input source for the controller */
  53641. inputSource: XRInputSource;
  53642. private _options;
  53643. private _tmpVector;
  53644. private _uniqueId;
  53645. private _disposed;
  53646. /**
  53647. * 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
  53648. */
  53649. grip?: AbstractMesh;
  53650. /**
  53651. * If available, this is the gamepad object related to this controller.
  53652. * Using this object it is possible to get click events and trackpad changes of the
  53653. * webxr controller that is currently being used.
  53654. */
  53655. motionController?: WebXRAbstractMotionController;
  53656. /**
  53657. * Event that fires when the controller is removed/disposed.
  53658. * The object provided as event data is this controller, after associated assets were disposed.
  53659. * uniqueId is still available.
  53660. */
  53661. onDisposeObservable: Observable<WebXRInputSource>;
  53662. /**
  53663. * Will be triggered when the mesh associated with the motion controller is done loading.
  53664. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53665. * A shortened version of controller -> motion controller -> on mesh loaded.
  53666. */
  53667. onMeshLoadedObservable: Observable<AbstractMesh>;
  53668. /**
  53669. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53670. */
  53671. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53672. /**
  53673. * Pointer which can be used to select objects or attach a visible laser to
  53674. */
  53675. pointer: AbstractMesh;
  53676. /**
  53677. * Creates the input source object
  53678. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53679. * @param _scene the scene which the controller should be associated to
  53680. * @param inputSource the underlying input source for the controller
  53681. * @param _options options for this controller creation
  53682. */
  53683. constructor(_scene: Scene,
  53684. /** The underlying input source for the controller */
  53685. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53686. /**
  53687. * Get this controllers unique id
  53688. */
  53689. get uniqueId(): string;
  53690. /**
  53691. * Disposes of the object
  53692. */
  53693. dispose(): void;
  53694. /**
  53695. * Gets a world space ray coming from the pointer or grip
  53696. * @param result the resulting ray
  53697. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53698. */
  53699. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53700. /**
  53701. * Updates the controller pose based on the given XRFrame
  53702. * @param xrFrame xr frame to update the pose with
  53703. * @param referenceSpace reference space to use
  53704. */
  53705. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53706. }
  53707. }
  53708. declare module "babylonjs/XR/webXRInput" {
  53709. import { Observable } from "babylonjs/Misc/observable";
  53710. import { IDisposable } from "babylonjs/scene";
  53711. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53712. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53713. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53714. /**
  53715. * The schema for initialization options of the XR Input class
  53716. */
  53717. export interface IWebXRInputOptions {
  53718. /**
  53719. * If set to true no model will be automatically loaded
  53720. */
  53721. doNotLoadControllerMeshes?: boolean;
  53722. /**
  53723. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53724. * If not found, the xr input profile data will be used.
  53725. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53726. */
  53727. forceInputProfile?: string;
  53728. /**
  53729. * Do not send a request to the controller repository to load the profile.
  53730. *
  53731. * Instead, use the controllers available in babylon itself.
  53732. */
  53733. disableOnlineControllerRepository?: boolean;
  53734. /**
  53735. * A custom URL for the controllers repository
  53736. */
  53737. customControllersRepositoryURL?: string;
  53738. /**
  53739. * Should the controller model's components not move according to the user input
  53740. */
  53741. disableControllerAnimation?: boolean;
  53742. /**
  53743. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53744. */
  53745. controllerOptions?: IWebXRControllerOptions;
  53746. }
  53747. /**
  53748. * XR input used to track XR inputs such as controllers/rays
  53749. */
  53750. export class WebXRInput implements IDisposable {
  53751. /**
  53752. * the xr session manager for this session
  53753. */
  53754. xrSessionManager: WebXRSessionManager;
  53755. /**
  53756. * the WebXR camera for this session. Mainly used for teleportation
  53757. */
  53758. xrCamera: WebXRCamera;
  53759. private readonly options;
  53760. /**
  53761. * XR controllers being tracked
  53762. */
  53763. controllers: Array<WebXRInputSource>;
  53764. private _frameObserver;
  53765. private _sessionEndedObserver;
  53766. private _sessionInitObserver;
  53767. /**
  53768. * Event when a controller has been connected/added
  53769. */
  53770. onControllerAddedObservable: Observable<WebXRInputSource>;
  53771. /**
  53772. * Event when a controller has been removed/disconnected
  53773. */
  53774. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53775. /**
  53776. * Initializes the WebXRInput
  53777. * @param xrSessionManager the xr session manager for this session
  53778. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53779. * @param options = initialization options for this xr input
  53780. */
  53781. constructor(
  53782. /**
  53783. * the xr session manager for this session
  53784. */
  53785. xrSessionManager: WebXRSessionManager,
  53786. /**
  53787. * the WebXR camera for this session. Mainly used for teleportation
  53788. */
  53789. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53790. private _onInputSourcesChange;
  53791. private _addAndRemoveControllers;
  53792. /**
  53793. * Disposes of the object
  53794. */
  53795. dispose(): void;
  53796. }
  53797. }
  53798. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53799. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53800. import { Observable, EventState } from "babylonjs/Misc/observable";
  53801. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53802. /**
  53803. * This is the base class for all WebXR features.
  53804. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53805. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53806. */
  53807. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53808. protected _xrSessionManager: WebXRSessionManager;
  53809. private _attached;
  53810. private _removeOnDetach;
  53811. /**
  53812. * Is this feature disposed?
  53813. */
  53814. isDisposed: boolean;
  53815. /**
  53816. * Should auto-attach be disabled?
  53817. */
  53818. disableAutoAttach: boolean;
  53819. /**
  53820. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53821. */
  53822. xrNativeFeatureName: string;
  53823. /**
  53824. * Construct a new (abstract) WebXR feature
  53825. * @param _xrSessionManager the xr session manager for this feature
  53826. */
  53827. constructor(_xrSessionManager: WebXRSessionManager);
  53828. /**
  53829. * Is this feature attached
  53830. */
  53831. get attached(): boolean;
  53832. /**
  53833. * attach this feature
  53834. *
  53835. * @param force should attachment be forced (even when already attached)
  53836. * @returns true if successful, false is failed or already attached
  53837. */
  53838. attach(force?: boolean): boolean;
  53839. /**
  53840. * detach this feature.
  53841. *
  53842. * @returns true if successful, false if failed or already detached
  53843. */
  53844. detach(): boolean;
  53845. /**
  53846. * Dispose this feature and all of the resources attached
  53847. */
  53848. dispose(): void;
  53849. /**
  53850. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53851. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53852. *
  53853. * @returns whether or not the feature is compatible in this environment
  53854. */
  53855. isCompatible(): boolean;
  53856. /**
  53857. * This is used to register callbacks that will automatically be removed when detach is called.
  53858. * @param observable the observable to which the observer will be attached
  53859. * @param callback the callback to register
  53860. */
  53861. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53862. /**
  53863. * Code in this function will be executed on each xrFrame received from the browser.
  53864. * This function will not execute after the feature is detached.
  53865. * @param _xrFrame the current frame
  53866. */
  53867. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53868. }
  53869. }
  53870. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53871. import { IDisposable, Scene } from "babylonjs/scene";
  53872. import { Nullable } from "babylonjs/types";
  53873. import { Observable } from "babylonjs/Misc/observable";
  53874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53875. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53876. import { Camera } from "babylonjs/Cameras/camera";
  53877. /**
  53878. * Renders a layer on top of an existing scene
  53879. */
  53880. export class UtilityLayerRenderer implements IDisposable {
  53881. /** the original scene that will be rendered on top of */
  53882. originalScene: Scene;
  53883. private _pointerCaptures;
  53884. private _lastPointerEvents;
  53885. private static _DefaultUtilityLayer;
  53886. private static _DefaultKeepDepthUtilityLayer;
  53887. private _sharedGizmoLight;
  53888. private _renderCamera;
  53889. /**
  53890. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53891. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53892. * @returns the camera that is used when rendering the utility layer
  53893. */
  53894. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53895. /**
  53896. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53897. * @param cam the camera that should be used when rendering the utility layer
  53898. */
  53899. setRenderCamera(cam: Nullable<Camera>): void;
  53900. /**
  53901. * @hidden
  53902. * Light which used by gizmos to get light shading
  53903. */
  53904. _getSharedGizmoLight(): HemisphericLight;
  53905. /**
  53906. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53907. */
  53908. pickUtilitySceneFirst: boolean;
  53909. /**
  53910. * 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)
  53911. */
  53912. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53913. /**
  53914. * 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)
  53915. */
  53916. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53917. /**
  53918. * The scene that is rendered on top of the original scene
  53919. */
  53920. utilityLayerScene: Scene;
  53921. /**
  53922. * If the utility layer should automatically be rendered on top of existing scene
  53923. */
  53924. shouldRender: boolean;
  53925. /**
  53926. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53927. */
  53928. onlyCheckPointerDownEvents: boolean;
  53929. /**
  53930. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53931. */
  53932. processAllEvents: boolean;
  53933. /**
  53934. * Observable raised when the pointer move from the utility layer scene to the main scene
  53935. */
  53936. onPointerOutObservable: Observable<number>;
  53937. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53938. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53939. private _afterRenderObserver;
  53940. private _sceneDisposeObserver;
  53941. private _originalPointerObserver;
  53942. /**
  53943. * Instantiates a UtilityLayerRenderer
  53944. * @param originalScene the original scene that will be rendered on top of
  53945. * @param handleEvents boolean indicating if the utility layer should handle events
  53946. */
  53947. constructor(
  53948. /** the original scene that will be rendered on top of */
  53949. originalScene: Scene, handleEvents?: boolean);
  53950. private _notifyObservers;
  53951. /**
  53952. * Renders the utility layers scene on top of the original scene
  53953. */
  53954. render(): void;
  53955. /**
  53956. * Disposes of the renderer
  53957. */
  53958. dispose(): void;
  53959. private _updateCamera;
  53960. }
  53961. }
  53962. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53963. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53965. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53966. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53967. import { Scene } from "babylonjs/scene";
  53968. import { Nullable } from "babylonjs/types";
  53969. import { Color3 } from "babylonjs/Maths/math.color";
  53970. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53971. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53972. /**
  53973. * Options interface for the pointer selection module
  53974. */
  53975. export interface IWebXRControllerPointerSelectionOptions {
  53976. /**
  53977. * if provided, this scene will be used to render meshes.
  53978. */
  53979. customUtilityLayerScene?: Scene;
  53980. /**
  53981. * 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)
  53982. * If not disabled, the last picked point will be used to execute a pointer up event
  53983. * If disabled, pointer up event will be triggered right after the pointer down event.
  53984. * Used in screen and gaze target ray mode only
  53985. */
  53986. disablePointerUpOnTouchOut: boolean;
  53987. /**
  53988. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53989. */
  53990. forceGazeMode: boolean;
  53991. /**
  53992. * 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
  53993. * to start a new countdown to the pointer down event.
  53994. * Defaults to 1.
  53995. */
  53996. gazeModePointerMovedFactor?: number;
  53997. /**
  53998. * Different button type to use instead of the main component
  53999. */
  54000. overrideButtonId?: string;
  54001. /**
  54002. * use this rendering group id for the meshes (optional)
  54003. */
  54004. renderingGroupId?: number;
  54005. /**
  54006. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54007. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54008. * 3000 means 3 seconds between pointing at something and selecting it
  54009. */
  54010. timeToSelect?: number;
  54011. /**
  54012. * Should meshes created here be added to a utility layer or the main scene
  54013. */
  54014. useUtilityLayer?: boolean;
  54015. /**
  54016. * Optional WebXR camera to be used for gaze selection
  54017. */
  54018. gazeCamera?: WebXRCamera;
  54019. /**
  54020. * the xr input to use with this pointer selection
  54021. */
  54022. xrInput: WebXRInput;
  54023. /**
  54024. * Should the scene pointerX and pointerY update be disabled
  54025. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54026. * Disable in VR, if not needed.
  54027. * The first rig camera (left eye) will be used to calculate the projection
  54028. */
  54029. disableScenePointerVectorUpdate: boolean;
  54030. /**
  54031. * Enable pointer selection on all controllers instead of switching between them
  54032. */
  54033. enablePointerSelectionOnAllControllers?: boolean;
  54034. /**
  54035. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54036. * If switch is enabled, it will still allow the user to switch between the different controllers
  54037. */
  54038. preferredHandedness?: XRHandedness;
  54039. /**
  54040. * Disable switching the pointer selection from one controller to the other.
  54041. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  54042. */
  54043. disableSwitchOnClick?: boolean;
  54044. /**
  54045. * The maximum distance of the pointer selection feature. Defaults to 100.
  54046. */
  54047. maxPointerDistance?: number;
  54048. }
  54049. /**
  54050. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54051. */
  54052. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54053. private readonly _options;
  54054. private static _idCounter;
  54055. private _attachController;
  54056. private _controllers;
  54057. private _scene;
  54058. private _tmpVectorForPickCompare;
  54059. private _attachedController;
  54060. /**
  54061. * The module's name
  54062. */
  54063. static readonly Name: string;
  54064. /**
  54065. * The (Babylon) version of this module.
  54066. * This is an integer representing the implementation version.
  54067. * This number does not correspond to the WebXR specs version
  54068. */
  54069. static readonly Version: number;
  54070. /**
  54071. * Disable lighting on the laser pointer (so it will always be visible)
  54072. */
  54073. disablePointerLighting: boolean;
  54074. /**
  54075. * Disable lighting on the selection mesh (so it will always be visible)
  54076. */
  54077. disableSelectionMeshLighting: boolean;
  54078. /**
  54079. * Should the laser pointer be displayed
  54080. */
  54081. displayLaserPointer: boolean;
  54082. /**
  54083. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54084. */
  54085. displaySelectionMesh: boolean;
  54086. /**
  54087. * This color will be set to the laser pointer when selection is triggered
  54088. */
  54089. laserPointerPickedColor: Color3;
  54090. /**
  54091. * Default color of the laser pointer
  54092. */
  54093. laserPointerDefaultColor: Color3;
  54094. /**
  54095. * default color of the selection ring
  54096. */
  54097. selectionMeshDefaultColor: Color3;
  54098. /**
  54099. * This color will be applied to the selection ring when selection is triggered
  54100. */
  54101. selectionMeshPickedColor: Color3;
  54102. /**
  54103. * Optional filter to be used for ray selection. This predicate shares behavior with
  54104. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54105. */
  54106. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54107. /**
  54108. * constructs a new background remover module
  54109. * @param _xrSessionManager the session manager for this module
  54110. * @param _options read-only options to be used in this module
  54111. */
  54112. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54113. /**
  54114. * attach this feature
  54115. * Will usually be called by the features manager
  54116. *
  54117. * @returns true if successful.
  54118. */
  54119. attach(): boolean;
  54120. /**
  54121. * detach this feature.
  54122. * Will usually be called by the features manager
  54123. *
  54124. * @returns true if successful.
  54125. */
  54126. detach(): boolean;
  54127. /**
  54128. * Will get the mesh under a specific pointer.
  54129. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54130. * @param controllerId the controllerId to check
  54131. * @returns The mesh under pointer or null if no mesh is under the pointer
  54132. */
  54133. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54134. /**
  54135. * Get the xr controller that correlates to the pointer id in the pointer event
  54136. *
  54137. * @param id the pointer id to search for
  54138. * @returns the controller that correlates to this id or null if not found
  54139. */
  54140. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54141. private _identityMatrix;
  54142. private _screenCoordinatesRef;
  54143. private _viewportRef;
  54144. protected _onXRFrame(_xrFrame: XRFrame): void;
  54145. private _attachGazeMode;
  54146. private _attachScreenRayMode;
  54147. private _attachTrackedPointerRayMode;
  54148. private _convertNormalToDirectionOfRay;
  54149. private _detachController;
  54150. private _generateNewMeshPair;
  54151. private _pickingMoved;
  54152. private _updatePointerDistance;
  54153. /** @hidden */
  54154. get lasterPointerDefaultColor(): Color3;
  54155. }
  54156. }
  54157. declare module "babylonjs/XR/webXREnterExitUI" {
  54158. import { Nullable } from "babylonjs/types";
  54159. import { Observable } from "babylonjs/Misc/observable";
  54160. import { IDisposable, Scene } from "babylonjs/scene";
  54161. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54162. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54163. /**
  54164. * Button which can be used to enter a different mode of XR
  54165. */
  54166. export class WebXREnterExitUIButton {
  54167. /** button element */
  54168. element: HTMLElement;
  54169. /** XR initialization options for the button */
  54170. sessionMode: XRSessionMode;
  54171. /** Reference space type */
  54172. referenceSpaceType: XRReferenceSpaceType;
  54173. /**
  54174. * Creates a WebXREnterExitUIButton
  54175. * @param element button element
  54176. * @param sessionMode XR initialization session mode
  54177. * @param referenceSpaceType the type of reference space to be used
  54178. */
  54179. constructor(
  54180. /** button element */
  54181. element: HTMLElement,
  54182. /** XR initialization options for the button */
  54183. sessionMode: XRSessionMode,
  54184. /** Reference space type */
  54185. referenceSpaceType: XRReferenceSpaceType);
  54186. /**
  54187. * Extendable function which can be used to update the button's visuals when the state changes
  54188. * @param activeButton the current active button in the UI
  54189. */
  54190. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54191. }
  54192. /**
  54193. * Options to create the webXR UI
  54194. */
  54195. export class WebXREnterExitUIOptions {
  54196. /**
  54197. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54198. */
  54199. customButtons?: Array<WebXREnterExitUIButton>;
  54200. /**
  54201. * A reference space type to use when creating the default button.
  54202. * Default is local-floor
  54203. */
  54204. referenceSpaceType?: XRReferenceSpaceType;
  54205. /**
  54206. * Context to enter xr with
  54207. */
  54208. renderTarget?: Nullable<WebXRRenderTarget>;
  54209. /**
  54210. * A session mode to use when creating the default button.
  54211. * Default is immersive-vr
  54212. */
  54213. sessionMode?: XRSessionMode;
  54214. /**
  54215. * A list of optional features to init the session with
  54216. */
  54217. optionalFeatures?: string[];
  54218. /**
  54219. * A list of optional features to init the session with
  54220. */
  54221. requiredFeatures?: string[];
  54222. }
  54223. /**
  54224. * UI to allow the user to enter/exit XR mode
  54225. */
  54226. export class WebXREnterExitUI implements IDisposable {
  54227. private scene;
  54228. /** version of the options passed to this UI */
  54229. options: WebXREnterExitUIOptions;
  54230. private _activeButton;
  54231. private _buttons;
  54232. /**
  54233. * The HTML Div Element to which buttons are added.
  54234. */
  54235. readonly overlay: HTMLDivElement;
  54236. /**
  54237. * Fired every time the active button is changed.
  54238. *
  54239. * When xr is entered via a button that launches xr that button will be the callback parameter
  54240. *
  54241. * When exiting xr the callback parameter will be null)
  54242. */
  54243. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54244. /**
  54245. *
  54246. * @param scene babylon scene object to use
  54247. * @param options (read-only) version of the options passed to this UI
  54248. */
  54249. private constructor();
  54250. /**
  54251. * Creates UI to allow the user to enter/exit XR mode
  54252. * @param scene the scene to add the ui to
  54253. * @param helper the xr experience helper to enter/exit xr with
  54254. * @param options options to configure the UI
  54255. * @returns the created ui
  54256. */
  54257. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54258. /**
  54259. * Disposes of the XR UI component
  54260. */
  54261. dispose(): void;
  54262. private _updateButtons;
  54263. }
  54264. }
  54265. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54266. import { Vector3 } from "babylonjs/Maths/math.vector";
  54267. import { Color4 } from "babylonjs/Maths/math.color";
  54268. import { Nullable } from "babylonjs/types";
  54269. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54270. import { Scene } from "babylonjs/scene";
  54271. /**
  54272. * Class containing static functions to help procedurally build meshes
  54273. */
  54274. export class LinesBuilder {
  54275. /**
  54276. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54277. * * 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
  54278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54279. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54280. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54281. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54282. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54283. * * 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
  54284. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54287. * @param name defines the name of the new line system
  54288. * @param options defines the options used to create the line system
  54289. * @param scene defines the hosting scene
  54290. * @returns a new line system mesh
  54291. */
  54292. static CreateLineSystem(name: string, options: {
  54293. lines: Vector3[][];
  54294. updatable?: boolean;
  54295. instance?: Nullable<LinesMesh>;
  54296. colors?: Nullable<Color4[][]>;
  54297. useVertexAlpha?: boolean;
  54298. }, scene: Nullable<Scene>): LinesMesh;
  54299. /**
  54300. * Creates a line mesh
  54301. * 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
  54302. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54303. * * The parameter `points` is an array successive Vector3
  54304. * * 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
  54305. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54306. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54307. * * When updating an instance, remember that only point positions can change, not the number of points
  54308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54310. * @param name defines the name of the new line system
  54311. * @param options defines the options used to create the line system
  54312. * @param scene defines the hosting scene
  54313. * @returns a new line mesh
  54314. */
  54315. static CreateLines(name: string, options: {
  54316. points: Vector3[];
  54317. updatable?: boolean;
  54318. instance?: Nullable<LinesMesh>;
  54319. colors?: Color4[];
  54320. useVertexAlpha?: boolean;
  54321. }, scene?: Nullable<Scene>): LinesMesh;
  54322. /**
  54323. * Creates a dashed line mesh
  54324. * * 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
  54325. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54326. * * The parameter `points` is an array successive Vector3
  54327. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54328. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54329. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54330. * * 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
  54331. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54332. * * When updating an instance, remember that only point positions can change, not the number of points
  54333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54334. * @param name defines the name of the mesh
  54335. * @param options defines the options used to create the mesh
  54336. * @param scene defines the hosting scene
  54337. * @returns the dashed line mesh
  54338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54339. */
  54340. static CreateDashedLines(name: string, options: {
  54341. points: Vector3[];
  54342. dashSize?: number;
  54343. gapSize?: number;
  54344. dashNb?: number;
  54345. updatable?: boolean;
  54346. instance?: LinesMesh;
  54347. useVertexAlpha?: boolean;
  54348. }, scene?: Nullable<Scene>): LinesMesh;
  54349. }
  54350. }
  54351. declare module "babylonjs/Misc/timer" {
  54352. import { Observable, Observer } from "babylonjs/Misc/observable";
  54353. import { Nullable } from "babylonjs/types";
  54354. import { IDisposable } from "babylonjs/scene";
  54355. /**
  54356. * Construction options for a timer
  54357. */
  54358. export interface ITimerOptions<T> {
  54359. /**
  54360. * Time-to-end
  54361. */
  54362. timeout: number;
  54363. /**
  54364. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54365. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54366. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54367. */
  54368. contextObservable: Observable<T>;
  54369. /**
  54370. * Optional parameters when adding an observer to the observable
  54371. */
  54372. observableParameters?: {
  54373. mask?: number;
  54374. insertFirst?: boolean;
  54375. scope?: any;
  54376. };
  54377. /**
  54378. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54379. */
  54380. breakCondition?: (data?: ITimerData<T>) => boolean;
  54381. /**
  54382. * Will be triggered when the time condition has met
  54383. */
  54384. onEnded?: (data: ITimerData<any>) => void;
  54385. /**
  54386. * Will be triggered when the break condition has met (prematurely ended)
  54387. */
  54388. onAborted?: (data: ITimerData<any>) => void;
  54389. /**
  54390. * Optional function to execute on each tick (or count)
  54391. */
  54392. onTick?: (data: ITimerData<any>) => void;
  54393. }
  54394. /**
  54395. * An interface defining the data sent by the timer
  54396. */
  54397. export interface ITimerData<T> {
  54398. /**
  54399. * When did it start
  54400. */
  54401. startTime: number;
  54402. /**
  54403. * Time now
  54404. */
  54405. currentTime: number;
  54406. /**
  54407. * Time passed since started
  54408. */
  54409. deltaTime: number;
  54410. /**
  54411. * How much is completed, in [0.0...1.0].
  54412. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54413. */
  54414. completeRate: number;
  54415. /**
  54416. * What the registered observable sent in the last count
  54417. */
  54418. payload: T;
  54419. }
  54420. /**
  54421. * The current state of the timer
  54422. */
  54423. export enum TimerState {
  54424. /**
  54425. * Timer initialized, not yet started
  54426. */
  54427. INIT = 0,
  54428. /**
  54429. * Timer started and counting
  54430. */
  54431. STARTED = 1,
  54432. /**
  54433. * Timer ended (whether aborted or time reached)
  54434. */
  54435. ENDED = 2
  54436. }
  54437. /**
  54438. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54439. *
  54440. * @param options options with which to initialize this timer
  54441. */
  54442. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54443. /**
  54444. * An advanced implementation of a timer class
  54445. */
  54446. export class AdvancedTimer<T = any> implements IDisposable {
  54447. /**
  54448. * Will notify each time the timer calculates the remaining time
  54449. */
  54450. onEachCountObservable: Observable<ITimerData<T>>;
  54451. /**
  54452. * Will trigger when the timer was aborted due to the break condition
  54453. */
  54454. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54455. /**
  54456. * Will trigger when the timer ended successfully
  54457. */
  54458. onTimerEndedObservable: Observable<ITimerData<T>>;
  54459. /**
  54460. * Will trigger when the timer state has changed
  54461. */
  54462. onStateChangedObservable: Observable<TimerState>;
  54463. private _observer;
  54464. private _contextObservable;
  54465. private _observableParameters;
  54466. private _startTime;
  54467. private _timer;
  54468. private _state;
  54469. private _breakCondition;
  54470. private _timeToEnd;
  54471. private _breakOnNextTick;
  54472. /**
  54473. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54474. * @param options construction options for this advanced timer
  54475. */
  54476. constructor(options: ITimerOptions<T>);
  54477. /**
  54478. * set a breaking condition for this timer. Default is to never break during count
  54479. * @param predicate the new break condition. Returns true to break, false otherwise
  54480. */
  54481. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54482. /**
  54483. * Reset ALL associated observables in this advanced timer
  54484. */
  54485. clearObservables(): void;
  54486. /**
  54487. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54488. *
  54489. * @param timeToEnd how much time to measure until timer ended
  54490. */
  54491. start(timeToEnd?: number): void;
  54492. /**
  54493. * Will force a stop on the next tick.
  54494. */
  54495. stop(): void;
  54496. /**
  54497. * Dispose this timer, clearing all resources
  54498. */
  54499. dispose(): void;
  54500. private _setState;
  54501. private _tick;
  54502. private _stop;
  54503. }
  54504. }
  54505. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54506. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54507. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54508. import { Nullable } from "babylonjs/types";
  54509. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54511. import { Vector3 } from "babylonjs/Maths/math.vector";
  54512. import { Material } from "babylonjs/Materials/material";
  54513. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54514. import { Scene } from "babylonjs/scene";
  54515. /**
  54516. * The options container for the teleportation module
  54517. */
  54518. export interface IWebXRTeleportationOptions {
  54519. /**
  54520. * if provided, this scene will be used to render meshes.
  54521. */
  54522. customUtilityLayerScene?: Scene;
  54523. /**
  54524. * Values to configure the default target mesh
  54525. */
  54526. defaultTargetMeshOptions?: {
  54527. /**
  54528. * Fill color of the teleportation area
  54529. */
  54530. teleportationFillColor?: string;
  54531. /**
  54532. * Border color for the teleportation area
  54533. */
  54534. teleportationBorderColor?: string;
  54535. /**
  54536. * Disable the mesh's animation sequence
  54537. */
  54538. disableAnimation?: boolean;
  54539. /**
  54540. * Disable lighting on the material or the ring and arrow
  54541. */
  54542. disableLighting?: boolean;
  54543. /**
  54544. * Override the default material of the torus and arrow
  54545. */
  54546. torusArrowMaterial?: Material;
  54547. };
  54548. /**
  54549. * A list of meshes to use as floor meshes.
  54550. * Meshes can be added and removed after initializing the feature using the
  54551. * addFloorMesh and removeFloorMesh functions
  54552. * If empty, rotation will still work
  54553. */
  54554. floorMeshes?: AbstractMesh[];
  54555. /**
  54556. * use this rendering group id for the meshes (optional)
  54557. */
  54558. renderingGroupId?: number;
  54559. /**
  54560. * Should teleportation move only to snap points
  54561. */
  54562. snapPointsOnly?: boolean;
  54563. /**
  54564. * An array of points to which the teleportation will snap to.
  54565. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54566. */
  54567. snapPositions?: Vector3[];
  54568. /**
  54569. * How close should the teleportation ray be in order to snap to position.
  54570. * Default to 0.8 units (meters)
  54571. */
  54572. snapToPositionRadius?: number;
  54573. /**
  54574. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54575. * If you want to support rotation, make sure your mesh has a direction indicator.
  54576. *
  54577. * When left untouched, the default mesh will be initialized.
  54578. */
  54579. teleportationTargetMesh?: AbstractMesh;
  54580. /**
  54581. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54582. */
  54583. timeToTeleport?: number;
  54584. /**
  54585. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54586. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54587. */
  54588. useMainComponentOnly?: boolean;
  54589. /**
  54590. * Should meshes created here be added to a utility layer or the main scene
  54591. */
  54592. useUtilityLayer?: boolean;
  54593. /**
  54594. * Babylon XR Input class for controller
  54595. */
  54596. xrInput: WebXRInput;
  54597. /**
  54598. * Meshes that the teleportation ray cannot go through
  54599. */
  54600. pickBlockerMeshes?: AbstractMesh[];
  54601. }
  54602. /**
  54603. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54604. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54605. * the input of the attached controllers.
  54606. */
  54607. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54608. private _options;
  54609. private _controllers;
  54610. private _currentTeleportationControllerId;
  54611. private _floorMeshes;
  54612. private _quadraticBezierCurve;
  54613. private _selectionFeature;
  54614. private _snapToPositions;
  54615. private _snappedToPoint;
  54616. private _teleportationRingMaterial?;
  54617. private _tmpRay;
  54618. private _tmpVector;
  54619. private _tmpQuaternion;
  54620. /**
  54621. * The module's name
  54622. */
  54623. static readonly Name: string;
  54624. /**
  54625. * The (Babylon) version of this module.
  54626. * This is an integer representing the implementation version.
  54627. * This number does not correspond to the webxr specs version
  54628. */
  54629. static readonly Version: number;
  54630. /**
  54631. * Is movement backwards enabled
  54632. */
  54633. backwardsMovementEnabled: boolean;
  54634. /**
  54635. * Distance to travel when moving backwards
  54636. */
  54637. backwardsTeleportationDistance: number;
  54638. /**
  54639. * The distance from the user to the inspection point in the direction of the controller
  54640. * A higher number will allow the user to move further
  54641. * defaults to 5 (meters, in xr units)
  54642. */
  54643. parabolicCheckRadius: number;
  54644. /**
  54645. * Should the module support parabolic ray on top of direct ray
  54646. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54647. * Very helpful when moving between floors / different heights
  54648. */
  54649. parabolicRayEnabled: boolean;
  54650. /**
  54651. * How much rotation should be applied when rotating right and left
  54652. */
  54653. rotationAngle: number;
  54654. /**
  54655. * Is rotation enabled when moving forward?
  54656. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54657. */
  54658. rotationEnabled: boolean;
  54659. /**
  54660. * constructs a new anchor system
  54661. * @param _xrSessionManager an instance of WebXRSessionManager
  54662. * @param _options configuration object for this feature
  54663. */
  54664. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54665. /**
  54666. * Get the snapPointsOnly flag
  54667. */
  54668. get snapPointsOnly(): boolean;
  54669. /**
  54670. * Sets the snapPointsOnly flag
  54671. * @param snapToPoints should teleportation be exclusively to snap points
  54672. */
  54673. set snapPointsOnly(snapToPoints: boolean);
  54674. /**
  54675. * Add a new mesh to the floor meshes array
  54676. * @param mesh the mesh to use as floor mesh
  54677. */
  54678. addFloorMesh(mesh: AbstractMesh): void;
  54679. /**
  54680. * Add a new snap-to point to fix teleportation to this position
  54681. * @param newSnapPoint The new Snap-To point
  54682. */
  54683. addSnapPoint(newSnapPoint: Vector3): void;
  54684. attach(): boolean;
  54685. detach(): boolean;
  54686. dispose(): void;
  54687. /**
  54688. * Remove a mesh from the floor meshes array
  54689. * @param mesh the mesh to remove
  54690. */
  54691. removeFloorMesh(mesh: AbstractMesh): void;
  54692. /**
  54693. * Remove a mesh from the floor meshes array using its name
  54694. * @param name the mesh name to remove
  54695. */
  54696. removeFloorMeshByName(name: string): void;
  54697. /**
  54698. * 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
  54699. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54700. * @returns was the point found and removed or not
  54701. */
  54702. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54703. /**
  54704. * This function sets a selection feature that will be disabled when
  54705. * the forward ray is shown and will be reattached when hidden.
  54706. * This is used to remove the selection rays when moving.
  54707. * @param selectionFeature the feature to disable when forward movement is enabled
  54708. */
  54709. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54710. protected _onXRFrame(_xrFrame: XRFrame): void;
  54711. private _attachController;
  54712. private _createDefaultTargetMesh;
  54713. private _detachController;
  54714. private _findClosestSnapPointWithRadius;
  54715. private _setTargetMeshPosition;
  54716. private _setTargetMeshVisibility;
  54717. private _showParabolicPath;
  54718. private _teleportForward;
  54719. }
  54720. }
  54721. declare module "babylonjs/XR/webXRDefaultExperience" {
  54722. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54723. import { Scene } from "babylonjs/scene";
  54724. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54725. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54726. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54727. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54729. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54730. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54731. /**
  54732. * Options for the default xr helper
  54733. */
  54734. export class WebXRDefaultExperienceOptions {
  54735. /**
  54736. * Enable or disable default UI to enter XR
  54737. */
  54738. disableDefaultUI?: boolean;
  54739. /**
  54740. * Should teleportation not initialize. defaults to false.
  54741. */
  54742. disableTeleportation?: boolean;
  54743. /**
  54744. * Floor meshes that will be used for teleport
  54745. */
  54746. floorMeshes?: Array<AbstractMesh>;
  54747. /**
  54748. * If set to true, the first frame will not be used to reset position
  54749. * The first frame is mainly used when copying transformation from the old camera
  54750. * Mainly used in AR
  54751. */
  54752. ignoreNativeCameraTransformation?: boolean;
  54753. /**
  54754. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54755. */
  54756. inputOptions?: IWebXRInputOptions;
  54757. /**
  54758. * optional configuration for the output canvas
  54759. */
  54760. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54761. /**
  54762. * optional UI options. This can be used among other to change session mode and reference space type
  54763. */
  54764. uiOptions?: WebXREnterExitUIOptions;
  54765. /**
  54766. * When loading teleportation and pointer select, use stable versions instead of latest.
  54767. */
  54768. useStablePlugins?: boolean;
  54769. /**
  54770. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54771. */
  54772. renderingGroupId?: number;
  54773. /**
  54774. * A list of optional features to init the session with
  54775. * If set to true, all features we support will be added
  54776. */
  54777. optionalFeatures?: boolean | string[];
  54778. }
  54779. /**
  54780. * Default experience which provides a similar setup to the previous webVRExperience
  54781. */
  54782. export class WebXRDefaultExperience {
  54783. /**
  54784. * Base experience
  54785. */
  54786. baseExperience: WebXRExperienceHelper;
  54787. /**
  54788. * Enables ui for entering/exiting xr
  54789. */
  54790. enterExitUI: WebXREnterExitUI;
  54791. /**
  54792. * Input experience extension
  54793. */
  54794. input: WebXRInput;
  54795. /**
  54796. * Enables laser pointer and selection
  54797. */
  54798. pointerSelection: WebXRControllerPointerSelection;
  54799. /**
  54800. * Default target xr should render to
  54801. */
  54802. renderTarget: WebXRRenderTarget;
  54803. /**
  54804. * Enables teleportation
  54805. */
  54806. teleportation: WebXRMotionControllerTeleportation;
  54807. private constructor();
  54808. /**
  54809. * Creates the default xr experience
  54810. * @param scene scene
  54811. * @param options options for basic configuration
  54812. * @returns resulting WebXRDefaultExperience
  54813. */
  54814. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54815. /**
  54816. * DIsposes of the experience helper
  54817. */
  54818. dispose(): void;
  54819. }
  54820. }
  54821. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54822. import { Observable } from "babylonjs/Misc/observable";
  54823. import { Nullable } from "babylonjs/types";
  54824. import { Camera } from "babylonjs/Cameras/camera";
  54825. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54826. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54827. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54828. import { Scene } from "babylonjs/scene";
  54829. import { Vector3 } from "babylonjs/Maths/math.vector";
  54830. import { Color3 } from "babylonjs/Maths/math.color";
  54831. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54833. import { Mesh } from "babylonjs/Meshes/mesh";
  54834. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54835. import { EasingFunction } from "babylonjs/Animations/easing";
  54836. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54837. import "babylonjs/Meshes/Builders/groundBuilder";
  54838. import "babylonjs/Meshes/Builders/torusBuilder";
  54839. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54840. import "babylonjs/Gamepads/gamepadSceneComponent";
  54841. import "babylonjs/Animations/animatable";
  54842. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54843. /**
  54844. * Options to modify the vr teleportation behavior.
  54845. */
  54846. export interface VRTeleportationOptions {
  54847. /**
  54848. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54849. */
  54850. floorMeshName?: string;
  54851. /**
  54852. * A list of meshes to be used as the teleportation floor. (default: empty)
  54853. */
  54854. floorMeshes?: Mesh[];
  54855. /**
  54856. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54857. */
  54858. teleportationMode?: number;
  54859. /**
  54860. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54861. */
  54862. teleportationTime?: number;
  54863. /**
  54864. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54865. */
  54866. teleportationSpeed?: number;
  54867. /**
  54868. * The easing function used in the animation or null for Linear. (default CircleEase)
  54869. */
  54870. easingFunction?: EasingFunction;
  54871. }
  54872. /**
  54873. * Options to modify the vr experience helper's behavior.
  54874. */
  54875. export interface VRExperienceHelperOptions extends WebVROptions {
  54876. /**
  54877. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54878. */
  54879. createDeviceOrientationCamera?: boolean;
  54880. /**
  54881. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54882. */
  54883. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54884. /**
  54885. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54886. */
  54887. laserToggle?: boolean;
  54888. /**
  54889. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54890. */
  54891. floorMeshes?: Mesh[];
  54892. /**
  54893. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54894. */
  54895. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54896. /**
  54897. * Defines if WebXR should be used instead of WebVR (if available)
  54898. */
  54899. useXR?: boolean;
  54900. }
  54901. /**
  54902. * Event containing information after VR has been entered
  54903. */
  54904. export class OnAfterEnteringVRObservableEvent {
  54905. /**
  54906. * If entering vr was successful
  54907. */
  54908. success: boolean;
  54909. }
  54910. /**
  54911. * Helps to quickly add VR support to an existing scene.
  54912. * See https://doc.babylonjs.com/how_to/webvr_helper
  54913. */
  54914. export class VRExperienceHelper {
  54915. /** Options to modify the vr experience helper's behavior. */
  54916. webVROptions: VRExperienceHelperOptions;
  54917. private _scene;
  54918. private _position;
  54919. private _btnVR;
  54920. private _btnVRDisplayed;
  54921. private _webVRsupported;
  54922. private _webVRready;
  54923. private _webVRrequesting;
  54924. private _webVRpresenting;
  54925. private _hasEnteredVR;
  54926. private _fullscreenVRpresenting;
  54927. private _inputElement;
  54928. private _webVRCamera;
  54929. private _vrDeviceOrientationCamera;
  54930. private _deviceOrientationCamera;
  54931. private _existingCamera;
  54932. private _onKeyDown;
  54933. private _onVrDisplayPresentChange;
  54934. private _onVRDisplayChanged;
  54935. private _onVRRequestPresentStart;
  54936. private _onVRRequestPresentComplete;
  54937. /**
  54938. * 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)
  54939. */
  54940. enableGazeEvenWhenNoPointerLock: boolean;
  54941. /**
  54942. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54943. */
  54944. exitVROnDoubleTap: boolean;
  54945. /**
  54946. * Observable raised right before entering VR.
  54947. */
  54948. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54949. /**
  54950. * Observable raised when entering VR has completed.
  54951. */
  54952. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54953. /**
  54954. * Observable raised when exiting VR.
  54955. */
  54956. onExitingVRObservable: Observable<VRExperienceHelper>;
  54957. /**
  54958. * Observable raised when controller mesh is loaded.
  54959. */
  54960. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54961. /** Return this.onEnteringVRObservable
  54962. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54963. */
  54964. get onEnteringVR(): Observable<VRExperienceHelper>;
  54965. /** Return this.onExitingVRObservable
  54966. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54967. */
  54968. get onExitingVR(): Observable<VRExperienceHelper>;
  54969. /** Return this.onControllerMeshLoadedObservable
  54970. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54971. */
  54972. get onControllerMeshLoaded(): Observable<WebVRController>;
  54973. private _rayLength;
  54974. private _useCustomVRButton;
  54975. private _teleportationRequested;
  54976. private _teleportActive;
  54977. private _floorMeshName;
  54978. private _floorMeshesCollection;
  54979. private _teleportationMode;
  54980. private _teleportationTime;
  54981. private _teleportationSpeed;
  54982. private _teleportationEasing;
  54983. private _rotationAllowed;
  54984. private _teleportBackwardsVector;
  54985. private _teleportationTarget;
  54986. private _isDefaultTeleportationTarget;
  54987. private _postProcessMove;
  54988. private _teleportationFillColor;
  54989. private _teleportationBorderColor;
  54990. private _rotationAngle;
  54991. private _haloCenter;
  54992. private _cameraGazer;
  54993. private _padSensibilityUp;
  54994. private _padSensibilityDown;
  54995. private _leftController;
  54996. private _rightController;
  54997. private _gazeColor;
  54998. private _laserColor;
  54999. private _pickedLaserColor;
  55000. private _pickedGazeColor;
  55001. /**
  55002. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55003. */
  55004. onNewMeshSelected: Observable<AbstractMesh>;
  55005. /**
  55006. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55007. * This observable will provide the mesh and the controller used to select the mesh
  55008. */
  55009. onMeshSelectedWithController: Observable<{
  55010. mesh: AbstractMesh;
  55011. controller: WebVRController;
  55012. }>;
  55013. /**
  55014. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55015. */
  55016. onNewMeshPicked: Observable<PickingInfo>;
  55017. private _circleEase;
  55018. /**
  55019. * Observable raised before camera teleportation
  55020. */
  55021. onBeforeCameraTeleport: Observable<Vector3>;
  55022. /**
  55023. * Observable raised after camera teleportation
  55024. */
  55025. onAfterCameraTeleport: Observable<Vector3>;
  55026. /**
  55027. * Observable raised when current selected mesh gets unselected
  55028. */
  55029. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55030. private _raySelectionPredicate;
  55031. /**
  55032. * To be optionaly changed by user to define custom ray selection
  55033. */
  55034. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55035. /**
  55036. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55037. */
  55038. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55039. /**
  55040. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55041. */
  55042. teleportationEnabled: boolean;
  55043. private _defaultHeight;
  55044. private _teleportationInitialized;
  55045. private _interactionsEnabled;
  55046. private _interactionsRequested;
  55047. private _displayGaze;
  55048. private _displayLaserPointer;
  55049. /**
  55050. * The mesh used to display where the user is going to teleport.
  55051. */
  55052. get teleportationTarget(): Mesh;
  55053. /**
  55054. * Sets the mesh to be used to display where the user is going to teleport.
  55055. */
  55056. set teleportationTarget(value: Mesh);
  55057. /**
  55058. * 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
  55059. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55060. * See https://doc.babylonjs.com/resources/baking_transformations
  55061. */
  55062. get gazeTrackerMesh(): Mesh;
  55063. set gazeTrackerMesh(value: Mesh);
  55064. /**
  55065. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55066. */
  55067. updateGazeTrackerScale: boolean;
  55068. /**
  55069. * If the gaze trackers color should be updated when selecting meshes
  55070. */
  55071. updateGazeTrackerColor: boolean;
  55072. /**
  55073. * If the controller laser color should be updated when selecting meshes
  55074. */
  55075. updateControllerLaserColor: boolean;
  55076. /**
  55077. * The gaze tracking mesh corresponding to the left controller
  55078. */
  55079. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55080. /**
  55081. * The gaze tracking mesh corresponding to the right controller
  55082. */
  55083. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55084. /**
  55085. * If the ray of the gaze should be displayed.
  55086. */
  55087. get displayGaze(): boolean;
  55088. /**
  55089. * Sets if the ray of the gaze should be displayed.
  55090. */
  55091. set displayGaze(value: boolean);
  55092. /**
  55093. * If the ray of the LaserPointer should be displayed.
  55094. */
  55095. get displayLaserPointer(): boolean;
  55096. /**
  55097. * Sets if the ray of the LaserPointer should be displayed.
  55098. */
  55099. set displayLaserPointer(value: boolean);
  55100. /**
  55101. * The deviceOrientationCamera used as the camera when not in VR.
  55102. */
  55103. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55104. /**
  55105. * Based on the current WebVR support, returns the current VR camera used.
  55106. */
  55107. get currentVRCamera(): Nullable<Camera>;
  55108. /**
  55109. * The webVRCamera which is used when in VR.
  55110. */
  55111. get webVRCamera(): WebVRFreeCamera;
  55112. /**
  55113. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55114. */
  55115. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55116. /**
  55117. * The html button that is used to trigger entering into VR.
  55118. */
  55119. get vrButton(): Nullable<HTMLButtonElement>;
  55120. private get _teleportationRequestInitiated();
  55121. /**
  55122. * Defines whether or not Pointer lock should be requested when switching to
  55123. * full screen.
  55124. */
  55125. requestPointerLockOnFullScreen: boolean;
  55126. /**
  55127. * If asking to force XR, this will be populated with the default xr experience
  55128. */
  55129. xr: WebXRDefaultExperience;
  55130. /**
  55131. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55132. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55133. */
  55134. xrTestDone: boolean;
  55135. /**
  55136. * Instantiates a VRExperienceHelper.
  55137. * Helps to quickly add VR support to an existing scene.
  55138. * @param scene The scene the VRExperienceHelper belongs to.
  55139. * @param webVROptions Options to modify the vr experience helper's behavior.
  55140. */
  55141. constructor(scene: Scene,
  55142. /** Options to modify the vr experience helper's behavior. */
  55143. webVROptions?: VRExperienceHelperOptions);
  55144. private completeVRInit;
  55145. private _onDefaultMeshLoaded;
  55146. private _onResize;
  55147. private _onFullscreenChange;
  55148. /**
  55149. * Gets a value indicating if we are currently in VR mode.
  55150. */
  55151. get isInVRMode(): boolean;
  55152. private onVrDisplayPresentChange;
  55153. private onVRDisplayChanged;
  55154. private moveButtonToBottomRight;
  55155. private displayVRButton;
  55156. private updateButtonVisibility;
  55157. private _cachedAngularSensibility;
  55158. /**
  55159. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55160. * Otherwise, will use the fullscreen API.
  55161. */
  55162. enterVR(): void;
  55163. /**
  55164. * Attempt to exit VR, or fullscreen.
  55165. */
  55166. exitVR(): void;
  55167. /**
  55168. * The position of the vr experience helper.
  55169. */
  55170. get position(): Vector3;
  55171. /**
  55172. * Sets the position of the vr experience helper.
  55173. */
  55174. set position(value: Vector3);
  55175. /**
  55176. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55177. */
  55178. enableInteractions(): void;
  55179. private get _noControllerIsActive();
  55180. private beforeRender;
  55181. private _isTeleportationFloor;
  55182. /**
  55183. * Adds a floor mesh to be used for teleportation.
  55184. * @param floorMesh the mesh to be used for teleportation.
  55185. */
  55186. addFloorMesh(floorMesh: Mesh): void;
  55187. /**
  55188. * Removes a floor mesh from being used for teleportation.
  55189. * @param floorMesh the mesh to be removed.
  55190. */
  55191. removeFloorMesh(floorMesh: Mesh): void;
  55192. /**
  55193. * Enables interactions and teleportation using the VR controllers and gaze.
  55194. * @param vrTeleportationOptions options to modify teleportation behavior.
  55195. */
  55196. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55197. private _onNewGamepadConnected;
  55198. private _tryEnableInteractionOnController;
  55199. private _onNewGamepadDisconnected;
  55200. private _enableInteractionOnController;
  55201. private _checkTeleportWithRay;
  55202. private _checkRotate;
  55203. private _checkTeleportBackwards;
  55204. private _enableTeleportationOnController;
  55205. private _createTeleportationCircles;
  55206. private _displayTeleportationTarget;
  55207. private _hideTeleportationTarget;
  55208. private _rotateCamera;
  55209. private _moveTeleportationSelectorTo;
  55210. private _workingVector;
  55211. private _workingQuaternion;
  55212. private _workingMatrix;
  55213. /**
  55214. * Time Constant Teleportation Mode
  55215. */
  55216. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55217. /**
  55218. * Speed Constant Teleportation Mode
  55219. */
  55220. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55221. /**
  55222. * Teleports the users feet to the desired location
  55223. * @param location The location where the user's feet should be placed
  55224. */
  55225. teleportCamera(location: Vector3): void;
  55226. private _convertNormalToDirectionOfRay;
  55227. private _castRayAndSelectObject;
  55228. private _notifySelectedMeshUnselected;
  55229. /**
  55230. * Permanently set new colors for the laser pointer
  55231. * @param color the new laser color
  55232. * @param pickedColor the new laser color when picked mesh detected
  55233. */
  55234. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55235. /**
  55236. * Set lighting enabled / disabled on the laser pointer of both controllers
  55237. * @param enabled should the lighting be enabled on the laser pointer
  55238. */
  55239. setLaserLightingState(enabled?: boolean): void;
  55240. /**
  55241. * Permanently set new colors for the gaze pointer
  55242. * @param color the new gaze color
  55243. * @param pickedColor the new gaze color when picked mesh detected
  55244. */
  55245. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55246. /**
  55247. * Sets the color of the laser ray from the vr controllers.
  55248. * @param color new color for the ray.
  55249. */
  55250. changeLaserColor(color: Color3): void;
  55251. /**
  55252. * Sets the color of the ray from the vr headsets gaze.
  55253. * @param color new color for the ray.
  55254. */
  55255. changeGazeColor(color: Color3): void;
  55256. /**
  55257. * Exits VR and disposes of the vr experience helper
  55258. */
  55259. dispose(): void;
  55260. /**
  55261. * Gets the name of the VRExperienceHelper class
  55262. * @returns "VRExperienceHelper"
  55263. */
  55264. getClassName(): string;
  55265. }
  55266. }
  55267. declare module "babylonjs/Cameras/VR/index" {
  55268. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55269. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55270. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55271. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55272. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55273. export * from "babylonjs/Cameras/VR/webVRCamera";
  55274. }
  55275. declare module "babylonjs/Cameras/RigModes/index" {
  55276. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55277. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55278. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55279. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55280. }
  55281. declare module "babylonjs/Cameras/index" {
  55282. export * from "babylonjs/Cameras/Inputs/index";
  55283. export * from "babylonjs/Cameras/cameraInputsManager";
  55284. export * from "babylonjs/Cameras/camera";
  55285. export * from "babylonjs/Cameras/targetCamera";
  55286. export * from "babylonjs/Cameras/freeCamera";
  55287. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55288. export * from "babylonjs/Cameras/touchCamera";
  55289. export * from "babylonjs/Cameras/arcRotateCamera";
  55290. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55291. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55292. export * from "babylonjs/Cameras/flyCamera";
  55293. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55294. export * from "babylonjs/Cameras/followCamera";
  55295. export * from "babylonjs/Cameras/followCameraInputsManager";
  55296. export * from "babylonjs/Cameras/gamepadCamera";
  55297. export * from "babylonjs/Cameras/Stereoscopic/index";
  55298. export * from "babylonjs/Cameras/universalCamera";
  55299. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55300. export * from "babylonjs/Cameras/VR/index";
  55301. export * from "babylonjs/Cameras/RigModes/index";
  55302. }
  55303. declare module "babylonjs/Collisions/index" {
  55304. export * from "babylonjs/Collisions/collider";
  55305. export * from "babylonjs/Collisions/collisionCoordinator";
  55306. export * from "babylonjs/Collisions/pickingInfo";
  55307. export * from "babylonjs/Collisions/intersectionInfo";
  55308. export * from "babylonjs/Collisions/meshCollisionData";
  55309. }
  55310. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55311. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55312. import { Vector3 } from "babylonjs/Maths/math.vector";
  55313. import { Ray } from "babylonjs/Culling/ray";
  55314. import { Plane } from "babylonjs/Maths/math.plane";
  55315. /**
  55316. * Contains an array of blocks representing the octree
  55317. */
  55318. export interface IOctreeContainer<T> {
  55319. /**
  55320. * Blocks within the octree
  55321. */
  55322. blocks: Array<OctreeBlock<T>>;
  55323. }
  55324. /**
  55325. * Class used to store a cell in an octree
  55326. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55327. */
  55328. export class OctreeBlock<T> {
  55329. /**
  55330. * Gets the content of the current block
  55331. */
  55332. entries: T[];
  55333. /**
  55334. * Gets the list of block children
  55335. */
  55336. blocks: Array<OctreeBlock<T>>;
  55337. private _depth;
  55338. private _maxDepth;
  55339. private _capacity;
  55340. private _minPoint;
  55341. private _maxPoint;
  55342. private _boundingVectors;
  55343. private _creationFunc;
  55344. /**
  55345. * Creates a new block
  55346. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55347. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55348. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55349. * @param depth defines the current depth of this block in the octree
  55350. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55351. * @param creationFunc defines a callback to call when an element is added to the block
  55352. */
  55353. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55354. /**
  55355. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55356. */
  55357. get capacity(): number;
  55358. /**
  55359. * Gets the minimum vector (in world space) of the block's bounding box
  55360. */
  55361. get minPoint(): Vector3;
  55362. /**
  55363. * Gets the maximum vector (in world space) of the block's bounding box
  55364. */
  55365. get maxPoint(): Vector3;
  55366. /**
  55367. * Add a new element to this block
  55368. * @param entry defines the element to add
  55369. */
  55370. addEntry(entry: T): void;
  55371. /**
  55372. * Remove an element from this block
  55373. * @param entry defines the element to remove
  55374. */
  55375. removeEntry(entry: T): void;
  55376. /**
  55377. * Add an array of elements to this block
  55378. * @param entries defines the array of elements to add
  55379. */
  55380. addEntries(entries: T[]): void;
  55381. /**
  55382. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55383. * @param frustumPlanes defines the frustum planes to test
  55384. * @param selection defines the array to store current content if selection is positive
  55385. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55386. */
  55387. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55388. /**
  55389. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55390. * @param sphereCenter defines the bounding sphere center
  55391. * @param sphereRadius defines the bounding sphere radius
  55392. * @param selection defines the array to store current content if selection is positive
  55393. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55394. */
  55395. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55396. /**
  55397. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55398. * @param ray defines the ray to test with
  55399. * @param selection defines the array to store current content if selection is positive
  55400. */
  55401. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55402. /**
  55403. * Subdivide the content into child blocks (this block will then be empty)
  55404. */
  55405. createInnerBlocks(): void;
  55406. /**
  55407. * @hidden
  55408. */
  55409. 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;
  55410. }
  55411. }
  55412. declare module "babylonjs/Culling/Octrees/octree" {
  55413. import { SmartArray } from "babylonjs/Misc/smartArray";
  55414. import { Vector3 } from "babylonjs/Maths/math.vector";
  55415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55417. import { Ray } from "babylonjs/Culling/ray";
  55418. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55419. import { Plane } from "babylonjs/Maths/math.plane";
  55420. /**
  55421. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55422. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55423. */
  55424. export class Octree<T> {
  55425. /** 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.) */
  55426. maxDepth: number;
  55427. /**
  55428. * Blocks within the octree containing objects
  55429. */
  55430. blocks: Array<OctreeBlock<T>>;
  55431. /**
  55432. * Content stored in the octree
  55433. */
  55434. dynamicContent: T[];
  55435. private _maxBlockCapacity;
  55436. private _selectionContent;
  55437. private _creationFunc;
  55438. /**
  55439. * Creates a octree
  55440. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55441. * @param creationFunc function to be used to instatiate the octree
  55442. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55443. * @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.)
  55444. */
  55445. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55446. /** 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.) */
  55447. maxDepth?: number);
  55448. /**
  55449. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55450. * @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);
  55451. * @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);
  55452. * @param entries meshes to be added to the octree blocks
  55453. */
  55454. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55455. /**
  55456. * Adds a mesh to the octree
  55457. * @param entry Mesh to add to the octree
  55458. */
  55459. addMesh(entry: T): void;
  55460. /**
  55461. * Remove an element from the octree
  55462. * @param entry defines the element to remove
  55463. */
  55464. removeMesh(entry: T): void;
  55465. /**
  55466. * Selects an array of meshes within the frustum
  55467. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55468. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55469. * @returns array of meshes within the frustum
  55470. */
  55471. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55472. /**
  55473. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55474. * @param sphereCenter defines the bounding sphere center
  55475. * @param sphereRadius defines the bounding sphere radius
  55476. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55477. * @returns an array of objects that intersect the sphere
  55478. */
  55479. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55480. /**
  55481. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55482. * @param ray defines the ray to test with
  55483. * @returns array of intersected objects
  55484. */
  55485. intersectsRay(ray: Ray): SmartArray<T>;
  55486. /**
  55487. * Adds a mesh into the octree block if it intersects the block
  55488. */
  55489. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55490. /**
  55491. * Adds a submesh into the octree block if it intersects the block
  55492. */
  55493. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55494. }
  55495. }
  55496. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55497. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55498. import { Scene } from "babylonjs/scene";
  55499. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55501. import { Ray } from "babylonjs/Culling/ray";
  55502. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55503. import { Collider } from "babylonjs/Collisions/collider";
  55504. module "babylonjs/scene" {
  55505. interface Scene {
  55506. /**
  55507. * @hidden
  55508. * Backing Filed
  55509. */
  55510. _selectionOctree: Octree<AbstractMesh>;
  55511. /**
  55512. * Gets the octree used to boost mesh selection (picking)
  55513. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55514. */
  55515. selectionOctree: Octree<AbstractMesh>;
  55516. /**
  55517. * Creates or updates the octree used to boost selection (picking)
  55518. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55519. * @param maxCapacity defines the maximum capacity per leaf
  55520. * @param maxDepth defines the maximum depth of the octree
  55521. * @returns an octree of AbstractMesh
  55522. */
  55523. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55524. }
  55525. }
  55526. module "babylonjs/Meshes/abstractMesh" {
  55527. interface AbstractMesh {
  55528. /**
  55529. * @hidden
  55530. * Backing Field
  55531. */
  55532. _submeshesOctree: Octree<SubMesh>;
  55533. /**
  55534. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55535. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55536. * @param maxCapacity defines the maximum size of each block (64 by default)
  55537. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55538. * @returns the new octree
  55539. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55540. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55541. */
  55542. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55543. }
  55544. }
  55545. /**
  55546. * Defines the octree scene component responsible to manage any octrees
  55547. * in a given scene.
  55548. */
  55549. export class OctreeSceneComponent {
  55550. /**
  55551. * The component name help to identify the component in the list of scene components.
  55552. */
  55553. readonly name: string;
  55554. /**
  55555. * The scene the component belongs to.
  55556. */
  55557. scene: Scene;
  55558. /**
  55559. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55560. */
  55561. readonly checksIsEnabled: boolean;
  55562. /**
  55563. * Creates a new instance of the component for the given scene
  55564. * @param scene Defines the scene to register the component in
  55565. */
  55566. constructor(scene: Scene);
  55567. /**
  55568. * Registers the component in a given scene
  55569. */
  55570. register(): void;
  55571. /**
  55572. * Return the list of active meshes
  55573. * @returns the list of active meshes
  55574. */
  55575. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55576. /**
  55577. * Return the list of active sub meshes
  55578. * @param mesh The mesh to get the candidates sub meshes from
  55579. * @returns the list of active sub meshes
  55580. */
  55581. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55582. private _tempRay;
  55583. /**
  55584. * Return the list of sub meshes intersecting with a given local ray
  55585. * @param mesh defines the mesh to find the submesh for
  55586. * @param localRay defines the ray in local space
  55587. * @returns the list of intersecting sub meshes
  55588. */
  55589. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55590. /**
  55591. * Return the list of sub meshes colliding with a collider
  55592. * @param mesh defines the mesh to find the submesh for
  55593. * @param collider defines the collider to evaluate the collision against
  55594. * @returns the list of colliding sub meshes
  55595. */
  55596. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55597. /**
  55598. * Rebuilds the elements related to this component in case of
  55599. * context lost for instance.
  55600. */
  55601. rebuild(): void;
  55602. /**
  55603. * Disposes the component and the associated ressources.
  55604. */
  55605. dispose(): void;
  55606. }
  55607. }
  55608. declare module "babylonjs/Culling/Octrees/index" {
  55609. export * from "babylonjs/Culling/Octrees/octree";
  55610. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55611. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55612. }
  55613. declare module "babylonjs/Culling/index" {
  55614. export * from "babylonjs/Culling/boundingBox";
  55615. export * from "babylonjs/Culling/boundingInfo";
  55616. export * from "babylonjs/Culling/boundingSphere";
  55617. export * from "babylonjs/Culling/Octrees/index";
  55618. export * from "babylonjs/Culling/ray";
  55619. }
  55620. declare module "babylonjs/Gizmos/gizmo" {
  55621. import { Nullable } from "babylonjs/types";
  55622. import { IDisposable } from "babylonjs/scene";
  55623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55624. import { Mesh } from "babylonjs/Meshes/mesh";
  55625. import { Node } from "babylonjs/node";
  55626. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55627. /**
  55628. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55629. */
  55630. export class Gizmo implements IDisposable {
  55631. /** The utility layer the gizmo will be added to */
  55632. gizmoLayer: UtilityLayerRenderer;
  55633. /**
  55634. * The root mesh of the gizmo
  55635. */
  55636. _rootMesh: Mesh;
  55637. private _attachedMesh;
  55638. private _attachedNode;
  55639. /**
  55640. * Ratio for the scale of the gizmo (Default: 1)
  55641. */
  55642. protected _scaleRatio: number;
  55643. /**
  55644. * boolean updated by pointermove when a gizmo mesh is hovered
  55645. */
  55646. protected _isHovered: boolean;
  55647. /**
  55648. * Ratio for the scale of the gizmo (Default: 1)
  55649. */
  55650. set scaleRatio(value: number);
  55651. get scaleRatio(): number;
  55652. /**
  55653. * True when the mouse pointer is hovered a gizmo mesh
  55654. */
  55655. get isHovered(): boolean;
  55656. /**
  55657. * If a custom mesh has been set (Default: false)
  55658. */
  55659. protected _customMeshSet: boolean;
  55660. /**
  55661. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55662. * * When set, interactions will be enabled
  55663. */
  55664. get attachedMesh(): Nullable<AbstractMesh>;
  55665. set attachedMesh(value: Nullable<AbstractMesh>);
  55666. /**
  55667. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55668. * * When set, interactions will be enabled
  55669. */
  55670. get attachedNode(): Nullable<Node>;
  55671. set attachedNode(value: Nullable<Node>);
  55672. /**
  55673. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55674. * @param mesh The mesh to replace the default mesh of the gizmo
  55675. */
  55676. setCustomMesh(mesh: Mesh): void;
  55677. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55678. /**
  55679. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55680. */
  55681. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55682. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55683. /**
  55684. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55685. */
  55686. updateGizmoPositionToMatchAttachedMesh: boolean;
  55687. /**
  55688. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55689. */
  55690. updateScale: boolean;
  55691. protected _interactionsEnabled: boolean;
  55692. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55693. private _beforeRenderObserver;
  55694. private _tempQuaternion;
  55695. private _tempVector;
  55696. private _tempVector2;
  55697. private _tempMatrix1;
  55698. private _tempMatrix2;
  55699. private _rightHandtoLeftHandMatrix;
  55700. /**
  55701. * Creates a gizmo
  55702. * @param gizmoLayer The utility layer the gizmo will be added to
  55703. */
  55704. constructor(
  55705. /** The utility layer the gizmo will be added to */
  55706. gizmoLayer?: UtilityLayerRenderer);
  55707. /**
  55708. * Updates the gizmo to match the attached mesh's position/rotation
  55709. */
  55710. protected _update(): void;
  55711. /**
  55712. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55713. * @param value Node, TransformNode or mesh
  55714. */
  55715. protected _matrixChanged(): void;
  55716. /**
  55717. * Disposes of the gizmo
  55718. */
  55719. dispose(): void;
  55720. }
  55721. }
  55722. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55723. import { Observable } from "babylonjs/Misc/observable";
  55724. import { Nullable } from "babylonjs/types";
  55725. import { Vector3 } from "babylonjs/Maths/math.vector";
  55726. import { Color3 } from "babylonjs/Maths/math.color";
  55727. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55728. import { Node } from "babylonjs/node";
  55729. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55730. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55731. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55732. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55733. import { Scene } from "babylonjs/scene";
  55734. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55735. /**
  55736. * Single plane drag gizmo
  55737. */
  55738. export class PlaneDragGizmo extends Gizmo {
  55739. /**
  55740. * Drag behavior responsible for the gizmos dragging interactions
  55741. */
  55742. dragBehavior: PointerDragBehavior;
  55743. private _pointerObserver;
  55744. /**
  55745. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55746. */
  55747. snapDistance: number;
  55748. /**
  55749. * Event that fires each time the gizmo snaps to a new location.
  55750. * * snapDistance is the the change in distance
  55751. */
  55752. onSnapObservable: Observable<{
  55753. snapDistance: number;
  55754. }>;
  55755. private _plane;
  55756. private _coloredMaterial;
  55757. private _hoverMaterial;
  55758. private _isEnabled;
  55759. private _parent;
  55760. /** @hidden */
  55761. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55762. /** @hidden */
  55763. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55764. /**
  55765. * Creates a PlaneDragGizmo
  55766. * @param gizmoLayer The utility layer the gizmo will be added to
  55767. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55768. * @param color The color of the gizmo
  55769. */
  55770. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55771. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55772. /**
  55773. * If the gizmo is enabled
  55774. */
  55775. set isEnabled(value: boolean);
  55776. get isEnabled(): boolean;
  55777. /**
  55778. * Disposes of the gizmo
  55779. */
  55780. dispose(): void;
  55781. }
  55782. }
  55783. declare module "babylonjs/Gizmos/positionGizmo" {
  55784. import { Observable } from "babylonjs/Misc/observable";
  55785. import { Nullable } from "babylonjs/types";
  55786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55787. import { Node } from "babylonjs/node";
  55788. import { Mesh } from "babylonjs/Meshes/mesh";
  55789. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55790. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55791. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55792. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55793. /**
  55794. * Gizmo that enables dragging a mesh along 3 axis
  55795. */
  55796. export class PositionGizmo extends Gizmo {
  55797. /**
  55798. * Internal gizmo used for interactions on the x axis
  55799. */
  55800. xGizmo: AxisDragGizmo;
  55801. /**
  55802. * Internal gizmo used for interactions on the y axis
  55803. */
  55804. yGizmo: AxisDragGizmo;
  55805. /**
  55806. * Internal gizmo used for interactions on the z axis
  55807. */
  55808. zGizmo: AxisDragGizmo;
  55809. /**
  55810. * Internal gizmo used for interactions on the yz plane
  55811. */
  55812. xPlaneGizmo: PlaneDragGizmo;
  55813. /**
  55814. * Internal gizmo used for interactions on the xz plane
  55815. */
  55816. yPlaneGizmo: PlaneDragGizmo;
  55817. /**
  55818. * Internal gizmo used for interactions on the xy plane
  55819. */
  55820. zPlaneGizmo: PlaneDragGizmo;
  55821. /**
  55822. * private variables
  55823. */
  55824. private _meshAttached;
  55825. private _nodeAttached;
  55826. private _snapDistance;
  55827. /** Fires an event when any of it's sub gizmos are dragged */
  55828. onDragStartObservable: Observable<unknown>;
  55829. /** Fires an event when any of it's sub gizmos are released from dragging */
  55830. onDragEndObservable: Observable<unknown>;
  55831. /**
  55832. * If set to true, planar drag is enabled
  55833. */
  55834. private _planarGizmoEnabled;
  55835. get attachedMesh(): Nullable<AbstractMesh>;
  55836. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55837. get attachedNode(): Nullable<Node>;
  55838. set attachedNode(node: Nullable<Node>);
  55839. /**
  55840. * True when the mouse pointer is hovering a gizmo mesh
  55841. */
  55842. get isHovered(): boolean;
  55843. /**
  55844. * Creates a PositionGizmo
  55845. * @param gizmoLayer The utility layer the gizmo will be added to
  55846. @param thickness display gizmo axis thickness
  55847. */
  55848. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55849. /**
  55850. * If the planar drag gizmo is enabled
  55851. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55852. */
  55853. set planarGizmoEnabled(value: boolean);
  55854. get planarGizmoEnabled(): boolean;
  55855. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55856. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55857. /**
  55858. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55859. */
  55860. set snapDistance(value: number);
  55861. get snapDistance(): number;
  55862. /**
  55863. * Ratio for the scale of the gizmo (Default: 1)
  55864. */
  55865. set scaleRatio(value: number);
  55866. get scaleRatio(): number;
  55867. /**
  55868. * Disposes of the gizmo
  55869. */
  55870. dispose(): void;
  55871. /**
  55872. * CustomMeshes are not supported by this gizmo
  55873. * @param mesh The mesh to replace the default mesh of the gizmo
  55874. */
  55875. setCustomMesh(mesh: Mesh): void;
  55876. }
  55877. }
  55878. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55879. import { Observable } from "babylonjs/Misc/observable";
  55880. import { Nullable } from "babylonjs/types";
  55881. import { Vector3 } from "babylonjs/Maths/math.vector";
  55882. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55883. import { Node } from "babylonjs/node";
  55884. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55885. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55886. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55887. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55888. import { Scene } from "babylonjs/scene";
  55889. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55890. import { Color3 } from "babylonjs/Maths/math.color";
  55891. /**
  55892. * Single axis drag gizmo
  55893. */
  55894. export class AxisDragGizmo extends Gizmo {
  55895. /**
  55896. * Drag behavior responsible for the gizmos dragging interactions
  55897. */
  55898. dragBehavior: PointerDragBehavior;
  55899. private _pointerObserver;
  55900. /**
  55901. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55902. */
  55903. snapDistance: number;
  55904. /**
  55905. * Event that fires each time the gizmo snaps to a new location.
  55906. * * snapDistance is the the change in distance
  55907. */
  55908. onSnapObservable: Observable<{
  55909. snapDistance: number;
  55910. }>;
  55911. private _isEnabled;
  55912. private _parent;
  55913. private _arrow;
  55914. private _coloredMaterial;
  55915. private _hoverMaterial;
  55916. /** @hidden */
  55917. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55918. /** @hidden */
  55919. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55920. /**
  55921. * Creates an AxisDragGizmo
  55922. * @param gizmoLayer The utility layer the gizmo will be added to
  55923. * @param dragAxis The axis which the gizmo will be able to drag on
  55924. * @param color The color of the gizmo
  55925. * @param thickness display gizmo axis thickness
  55926. */
  55927. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55928. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55929. /**
  55930. * If the gizmo is enabled
  55931. */
  55932. set isEnabled(value: boolean);
  55933. get isEnabled(): boolean;
  55934. /**
  55935. * Disposes of the gizmo
  55936. */
  55937. dispose(): void;
  55938. }
  55939. }
  55940. declare module "babylonjs/Debug/axesViewer" {
  55941. import { Vector3 } from "babylonjs/Maths/math.vector";
  55942. import { Nullable } from "babylonjs/types";
  55943. import { Scene } from "babylonjs/scene";
  55944. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55945. /**
  55946. * The Axes viewer will show 3 axes in a specific point in space
  55947. */
  55948. export class AxesViewer {
  55949. private _xAxis;
  55950. private _yAxis;
  55951. private _zAxis;
  55952. private _scaleLinesFactor;
  55953. private _instanced;
  55954. /**
  55955. * Gets the hosting scene
  55956. */
  55957. scene: Nullable<Scene>;
  55958. /**
  55959. * Gets or sets a number used to scale line length
  55960. */
  55961. scaleLines: number;
  55962. /** Gets the node hierarchy used to render x-axis */
  55963. get xAxis(): TransformNode;
  55964. /** Gets the node hierarchy used to render y-axis */
  55965. get yAxis(): TransformNode;
  55966. /** Gets the node hierarchy used to render z-axis */
  55967. get zAxis(): TransformNode;
  55968. /**
  55969. * Creates a new AxesViewer
  55970. * @param scene defines the hosting scene
  55971. * @param scaleLines defines a number used to scale line length (1 by default)
  55972. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55973. * @param xAxis defines the node hierarchy used to render the x-axis
  55974. * @param yAxis defines the node hierarchy used to render the y-axis
  55975. * @param zAxis defines the node hierarchy used to render the z-axis
  55976. */
  55977. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55978. /**
  55979. * Force the viewer to update
  55980. * @param position defines the position of the viewer
  55981. * @param xaxis defines the x axis of the viewer
  55982. * @param yaxis defines the y axis of the viewer
  55983. * @param zaxis defines the z axis of the viewer
  55984. */
  55985. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55986. /**
  55987. * Creates an instance of this axes viewer.
  55988. * @returns a new axes viewer with instanced meshes
  55989. */
  55990. createInstance(): AxesViewer;
  55991. /** Releases resources */
  55992. dispose(): void;
  55993. private static _SetRenderingGroupId;
  55994. }
  55995. }
  55996. declare module "babylonjs/Debug/boneAxesViewer" {
  55997. import { Nullable } from "babylonjs/types";
  55998. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55999. import { Vector3 } from "babylonjs/Maths/math.vector";
  56000. import { Mesh } from "babylonjs/Meshes/mesh";
  56001. import { Bone } from "babylonjs/Bones/bone";
  56002. import { Scene } from "babylonjs/scene";
  56003. /**
  56004. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  56005. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  56006. */
  56007. export class BoneAxesViewer extends AxesViewer {
  56008. /**
  56009. * Gets or sets the target mesh where to display the axes viewer
  56010. */
  56011. mesh: Nullable<Mesh>;
  56012. /**
  56013. * Gets or sets the target bone where to display the axes viewer
  56014. */
  56015. bone: Nullable<Bone>;
  56016. /** Gets current position */
  56017. pos: Vector3;
  56018. /** Gets direction of X axis */
  56019. xaxis: Vector3;
  56020. /** Gets direction of Y axis */
  56021. yaxis: Vector3;
  56022. /** Gets direction of Z axis */
  56023. zaxis: Vector3;
  56024. /**
  56025. * Creates a new BoneAxesViewer
  56026. * @param scene defines the hosting scene
  56027. * @param bone defines the target bone
  56028. * @param mesh defines the target mesh
  56029. * @param scaleLines defines a scaling factor for line length (1 by default)
  56030. */
  56031. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56032. /**
  56033. * Force the viewer to update
  56034. */
  56035. update(): void;
  56036. /** Releases resources */
  56037. dispose(): void;
  56038. }
  56039. }
  56040. declare module "babylonjs/Debug/debugLayer" {
  56041. import { Scene } from "babylonjs/scene";
  56042. /**
  56043. * Interface used to define scene explorer extensibility option
  56044. */
  56045. export interface IExplorerExtensibilityOption {
  56046. /**
  56047. * Define the option label
  56048. */
  56049. label: string;
  56050. /**
  56051. * Defines the action to execute on click
  56052. */
  56053. action: (entity: any) => void;
  56054. }
  56055. /**
  56056. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56057. */
  56058. export interface IExplorerExtensibilityGroup {
  56059. /**
  56060. * Defines a predicate to test if a given type mut be extended
  56061. */
  56062. predicate: (entity: any) => boolean;
  56063. /**
  56064. * Gets the list of options added to a type
  56065. */
  56066. entries: IExplorerExtensibilityOption[];
  56067. }
  56068. /**
  56069. * Interface used to define the options to use to create the Inspector
  56070. */
  56071. export interface IInspectorOptions {
  56072. /**
  56073. * Display in overlay mode (default: false)
  56074. */
  56075. overlay?: boolean;
  56076. /**
  56077. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56078. */
  56079. globalRoot?: HTMLElement;
  56080. /**
  56081. * Display the Scene explorer
  56082. */
  56083. showExplorer?: boolean;
  56084. /**
  56085. * Display the property inspector
  56086. */
  56087. showInspector?: boolean;
  56088. /**
  56089. * Display in embed mode (both panes on the right)
  56090. */
  56091. embedMode?: boolean;
  56092. /**
  56093. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56094. */
  56095. handleResize?: boolean;
  56096. /**
  56097. * Allow the panes to popup (default: true)
  56098. */
  56099. enablePopup?: boolean;
  56100. /**
  56101. * Allow the panes to be closed by users (default: true)
  56102. */
  56103. enableClose?: boolean;
  56104. /**
  56105. * Optional list of extensibility entries
  56106. */
  56107. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56108. /**
  56109. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56110. */
  56111. inspectorURL?: string;
  56112. /**
  56113. * Optional initial tab (default to DebugLayerTab.Properties)
  56114. */
  56115. initialTab?: DebugLayerTab;
  56116. }
  56117. module "babylonjs/scene" {
  56118. interface Scene {
  56119. /**
  56120. * @hidden
  56121. * Backing field
  56122. */
  56123. _debugLayer: DebugLayer;
  56124. /**
  56125. * Gets the debug layer (aka Inspector) associated with the scene
  56126. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56127. */
  56128. debugLayer: DebugLayer;
  56129. }
  56130. }
  56131. /**
  56132. * Enum of inspector action tab
  56133. */
  56134. export enum DebugLayerTab {
  56135. /**
  56136. * Properties tag (default)
  56137. */
  56138. Properties = 0,
  56139. /**
  56140. * Debug tab
  56141. */
  56142. Debug = 1,
  56143. /**
  56144. * Statistics tab
  56145. */
  56146. Statistics = 2,
  56147. /**
  56148. * Tools tab
  56149. */
  56150. Tools = 3,
  56151. /**
  56152. * Settings tab
  56153. */
  56154. Settings = 4
  56155. }
  56156. /**
  56157. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56158. * what is happening in your scene
  56159. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56160. */
  56161. export class DebugLayer {
  56162. /**
  56163. * Define the url to get the inspector script from.
  56164. * By default it uses the babylonjs CDN.
  56165. * @ignoreNaming
  56166. */
  56167. static InspectorURL: string;
  56168. private _scene;
  56169. private BJSINSPECTOR;
  56170. private _onPropertyChangedObservable?;
  56171. /**
  56172. * Observable triggered when a property is changed through the inspector.
  56173. */
  56174. get onPropertyChangedObservable(): any;
  56175. /**
  56176. * Instantiates a new debug layer.
  56177. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56178. * what is happening in your scene
  56179. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56180. * @param scene Defines the scene to inspect
  56181. */
  56182. constructor(scene: Scene);
  56183. /** Creates the inspector window. */
  56184. private _createInspector;
  56185. /**
  56186. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56187. * @param entity defines the entity to select
  56188. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56189. */
  56190. select(entity: any, lineContainerTitles?: string | string[]): void;
  56191. /** Get the inspector from bundle or global */
  56192. private _getGlobalInspector;
  56193. /**
  56194. * Get if the inspector is visible or not.
  56195. * @returns true if visible otherwise, false
  56196. */
  56197. isVisible(): boolean;
  56198. /**
  56199. * Hide the inspector and close its window.
  56200. */
  56201. hide(): void;
  56202. /**
  56203. * Update the scene in the inspector
  56204. */
  56205. setAsActiveScene(): void;
  56206. /**
  56207. * Launch the debugLayer.
  56208. * @param config Define the configuration of the inspector
  56209. * @return a promise fulfilled when the debug layer is visible
  56210. */
  56211. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56212. }
  56213. }
  56214. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56215. import { Nullable } from "babylonjs/types";
  56216. import { Scene } from "babylonjs/scene";
  56217. import { Vector4 } from "babylonjs/Maths/math.vector";
  56218. import { Color4 } from "babylonjs/Maths/math.color";
  56219. import { Mesh } from "babylonjs/Meshes/mesh";
  56220. /**
  56221. * Class containing static functions to help procedurally build meshes
  56222. */
  56223. export class BoxBuilder {
  56224. /**
  56225. * Creates a box mesh
  56226. * * The parameter `size` sets the size (float) of each box side (default 1)
  56227. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56228. * * 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)
  56229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56233. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56234. * @param name defines the name of the mesh
  56235. * @param options defines the options used to create the mesh
  56236. * @param scene defines the hosting scene
  56237. * @returns the box mesh
  56238. */
  56239. static CreateBox(name: string, options: {
  56240. size?: number;
  56241. width?: number;
  56242. height?: number;
  56243. depth?: number;
  56244. faceUV?: Vector4[];
  56245. faceColors?: Color4[];
  56246. sideOrientation?: number;
  56247. frontUVs?: Vector4;
  56248. backUVs?: Vector4;
  56249. wrap?: boolean;
  56250. topBaseAt?: number;
  56251. bottomBaseAt?: number;
  56252. updatable?: boolean;
  56253. }, scene?: Nullable<Scene>): Mesh;
  56254. }
  56255. }
  56256. declare module "babylonjs/Debug/physicsViewer" {
  56257. import { Nullable } from "babylonjs/types";
  56258. import { Scene } from "babylonjs/scene";
  56259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56260. import { Mesh } from "babylonjs/Meshes/mesh";
  56261. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56262. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56263. /**
  56264. * Used to show the physics impostor around the specific mesh
  56265. */
  56266. export class PhysicsViewer {
  56267. /** @hidden */
  56268. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56269. /** @hidden */
  56270. protected _meshes: Array<Nullable<AbstractMesh>>;
  56271. /** @hidden */
  56272. protected _scene: Nullable<Scene>;
  56273. /** @hidden */
  56274. protected _numMeshes: number;
  56275. /** @hidden */
  56276. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56277. private _renderFunction;
  56278. private _utilityLayer;
  56279. private _debugBoxMesh;
  56280. private _debugSphereMesh;
  56281. private _debugCylinderMesh;
  56282. private _debugMaterial;
  56283. private _debugMeshMeshes;
  56284. /**
  56285. * Creates a new PhysicsViewer
  56286. * @param scene defines the hosting scene
  56287. */
  56288. constructor(scene: Scene);
  56289. /** @hidden */
  56290. protected _updateDebugMeshes(): void;
  56291. /**
  56292. * Renders a specified physic impostor
  56293. * @param impostor defines the impostor to render
  56294. * @param targetMesh defines the mesh represented by the impostor
  56295. * @returns the new debug mesh used to render the impostor
  56296. */
  56297. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56298. /**
  56299. * Hides a specified physic impostor
  56300. * @param impostor defines the impostor to hide
  56301. */
  56302. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56303. private _getDebugMaterial;
  56304. private _getDebugBoxMesh;
  56305. private _getDebugSphereMesh;
  56306. private _getDebugCylinderMesh;
  56307. private _getDebugMeshMesh;
  56308. private _getDebugMesh;
  56309. /** Releases all resources */
  56310. dispose(): void;
  56311. }
  56312. }
  56313. declare module "babylonjs/Debug/rayHelper" {
  56314. import { Nullable } from "babylonjs/types";
  56315. import { Ray } from "babylonjs/Culling/ray";
  56316. import { Vector3 } from "babylonjs/Maths/math.vector";
  56317. import { Color3 } from "babylonjs/Maths/math.color";
  56318. import { Scene } from "babylonjs/scene";
  56319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56320. import "babylonjs/Meshes/Builders/linesBuilder";
  56321. /**
  56322. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56323. * in order to better appreciate the issue one might have.
  56324. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56325. */
  56326. export class RayHelper {
  56327. /**
  56328. * Defines the ray we are currently tryin to visualize.
  56329. */
  56330. ray: Nullable<Ray>;
  56331. private _renderPoints;
  56332. private _renderLine;
  56333. private _renderFunction;
  56334. private _scene;
  56335. private _onAfterRenderObserver;
  56336. private _onAfterStepObserver;
  56337. private _attachedToMesh;
  56338. private _meshSpaceDirection;
  56339. private _meshSpaceOrigin;
  56340. /**
  56341. * Helper function to create a colored helper in a scene in one line.
  56342. * @param ray Defines the ray we are currently tryin to visualize
  56343. * @param scene Defines the scene the ray is used in
  56344. * @param color Defines the color we want to see the ray in
  56345. * @returns The newly created ray helper.
  56346. */
  56347. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56348. /**
  56349. * Instantiate a new ray helper.
  56350. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56351. * in order to better appreciate the issue one might have.
  56352. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56353. * @param ray Defines the ray we are currently tryin to visualize
  56354. */
  56355. constructor(ray: Ray);
  56356. /**
  56357. * Shows the ray we are willing to debug.
  56358. * @param scene Defines the scene the ray needs to be rendered in
  56359. * @param color Defines the color the ray needs to be rendered in
  56360. */
  56361. show(scene: Scene, color?: Color3): void;
  56362. /**
  56363. * Hides the ray we are debugging.
  56364. */
  56365. hide(): void;
  56366. private _render;
  56367. /**
  56368. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56369. * @param mesh Defines the mesh we want the helper attached to
  56370. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56371. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56372. * @param length Defines the length of the ray
  56373. */
  56374. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56375. /**
  56376. * Detach the ray helper from the mesh it has previously been attached to.
  56377. */
  56378. detachFromMesh(): void;
  56379. private _updateToMesh;
  56380. /**
  56381. * Dispose the helper and release its associated resources.
  56382. */
  56383. dispose(): void;
  56384. }
  56385. }
  56386. declare module "babylonjs/Debug/ISkeletonViewer" {
  56387. import { Skeleton } from "babylonjs/Bones/skeleton";
  56388. import { Color3 } from "babylonjs/Maths/math.color";
  56389. /**
  56390. * Defines the options associated with the creation of a SkeletonViewer.
  56391. */
  56392. export interface ISkeletonViewerOptions {
  56393. /** Should the system pause animations before building the Viewer? */
  56394. pauseAnimations: boolean;
  56395. /** Should the system return the skeleton to rest before building? */
  56396. returnToRest: boolean;
  56397. /** public Display Mode of the Viewer */
  56398. displayMode: number;
  56399. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56400. displayOptions: ISkeletonViewerDisplayOptions;
  56401. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56402. computeBonesUsingShaders: boolean;
  56403. /** Flag ignore non weighted bones */
  56404. useAllBones: boolean;
  56405. }
  56406. /**
  56407. * Defines how to display the various bone meshes for the viewer.
  56408. */
  56409. export interface ISkeletonViewerDisplayOptions {
  56410. /** How far down to start tapering the bone spurs */
  56411. midStep?: number;
  56412. /** How big is the midStep? */
  56413. midStepFactor?: number;
  56414. /** Base for the Sphere Size */
  56415. sphereBaseSize?: number;
  56416. /** The ratio of the sphere to the longest bone in units */
  56417. sphereScaleUnit?: number;
  56418. /** Ratio for the Sphere Size */
  56419. sphereFactor?: number;
  56420. /** Whether a spur should attach its far end to the child bone position */
  56421. spurFollowsChild?: boolean;
  56422. /** Whether to show local axes or not */
  56423. showLocalAxes?: boolean;
  56424. /** Length of each local axis */
  56425. localAxesSize?: number;
  56426. }
  56427. /**
  56428. * Defines the constructor options for the BoneWeight Shader.
  56429. */
  56430. export interface IBoneWeightShaderOptions {
  56431. /** Skeleton to Map */
  56432. skeleton: Skeleton;
  56433. /** Colors for Uninfluenced bones */
  56434. colorBase?: Color3;
  56435. /** Colors for 0.0-0.25 Weight bones */
  56436. colorZero?: Color3;
  56437. /** Color for 0.25-0.5 Weight Influence */
  56438. colorQuarter?: Color3;
  56439. /** Color for 0.5-0.75 Weight Influence */
  56440. colorHalf?: Color3;
  56441. /** Color for 0.75-1 Weight Influence */
  56442. colorFull?: Color3;
  56443. /** Color for Zero Weight Influence */
  56444. targetBoneIndex?: number;
  56445. }
  56446. /**
  56447. * Simple structure of the gradient steps for the Color Map.
  56448. */
  56449. export interface ISkeletonMapShaderColorMapKnot {
  56450. /** Color of the Knot */
  56451. color: Color3;
  56452. /** Location of the Knot */
  56453. location: number;
  56454. }
  56455. /**
  56456. * Defines the constructor options for the SkeletonMap Shader.
  56457. */
  56458. export interface ISkeletonMapShaderOptions {
  56459. /** Skeleton to Map */
  56460. skeleton: Skeleton;
  56461. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56462. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56463. }
  56464. }
  56465. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56466. import { Nullable } from "babylonjs/types";
  56467. import { Scene } from "babylonjs/scene";
  56468. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56469. import { Color4 } from "babylonjs/Maths/math.color";
  56470. import { Mesh } from "babylonjs/Meshes/mesh";
  56471. /**
  56472. * Class containing static functions to help procedurally build meshes
  56473. */
  56474. export class RibbonBuilder {
  56475. /**
  56476. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56477. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56478. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56479. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56480. * * 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
  56481. * * 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
  56482. * * 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
  56483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56486. * * 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
  56487. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56488. * * 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
  56489. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56491. * @param name defines the name of the mesh
  56492. * @param options defines the options used to create the mesh
  56493. * @param scene defines the hosting scene
  56494. * @returns the ribbon mesh
  56495. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56497. */
  56498. static CreateRibbon(name: string, options: {
  56499. pathArray: Vector3[][];
  56500. closeArray?: boolean;
  56501. closePath?: boolean;
  56502. offset?: number;
  56503. updatable?: boolean;
  56504. sideOrientation?: number;
  56505. frontUVs?: Vector4;
  56506. backUVs?: Vector4;
  56507. instance?: Mesh;
  56508. invertUV?: boolean;
  56509. uvs?: Vector2[];
  56510. colors?: Color4[];
  56511. }, scene?: Nullable<Scene>): Mesh;
  56512. }
  56513. }
  56514. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56515. import { Nullable } from "babylonjs/types";
  56516. import { Scene } from "babylonjs/scene";
  56517. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56518. import { Mesh } from "babylonjs/Meshes/mesh";
  56519. /**
  56520. * Class containing static functions to help procedurally build meshes
  56521. */
  56522. export class ShapeBuilder {
  56523. /**
  56524. * 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.
  56525. * * 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.
  56526. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56527. * * 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.
  56528. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56529. * * 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
  56530. * * 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
  56531. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56534. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56536. * @param name defines the name of the mesh
  56537. * @param options defines the options used to create the mesh
  56538. * @param scene defines the hosting scene
  56539. * @returns the extruded shape mesh
  56540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56542. */
  56543. static ExtrudeShape(name: string, options: {
  56544. shape: Vector3[];
  56545. path: Vector3[];
  56546. scale?: number;
  56547. rotation?: number;
  56548. cap?: number;
  56549. updatable?: boolean;
  56550. sideOrientation?: number;
  56551. frontUVs?: Vector4;
  56552. backUVs?: Vector4;
  56553. instance?: Mesh;
  56554. invertUV?: boolean;
  56555. }, scene?: Nullable<Scene>): Mesh;
  56556. /**
  56557. * Creates an custom extruded shape mesh.
  56558. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56559. * * 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.
  56560. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56561. * * 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
  56562. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56563. * * 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
  56564. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56565. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56566. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56567. * * 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
  56568. * * 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
  56569. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56572. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56574. * @param name defines the name of the mesh
  56575. * @param options defines the options used to create the mesh
  56576. * @param scene defines the hosting scene
  56577. * @returns the custom extruded shape mesh
  56578. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56581. */
  56582. static ExtrudeShapeCustom(name: string, options: {
  56583. shape: Vector3[];
  56584. path: Vector3[];
  56585. scaleFunction?: any;
  56586. rotationFunction?: any;
  56587. ribbonCloseArray?: boolean;
  56588. ribbonClosePath?: boolean;
  56589. cap?: number;
  56590. updatable?: boolean;
  56591. sideOrientation?: number;
  56592. frontUVs?: Vector4;
  56593. backUVs?: Vector4;
  56594. instance?: Mesh;
  56595. invertUV?: boolean;
  56596. }, scene?: Nullable<Scene>): Mesh;
  56597. private static _ExtrudeShapeGeneric;
  56598. }
  56599. }
  56600. declare module "babylonjs/Debug/skeletonViewer" {
  56601. import { Color3 } from "babylonjs/Maths/math.color";
  56602. import { Scene } from "babylonjs/scene";
  56603. import { Nullable } from "babylonjs/types";
  56604. import { Skeleton } from "babylonjs/Bones/skeleton";
  56605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56606. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56607. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56608. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56609. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56610. /**
  56611. * Class used to render a debug view of a given skeleton
  56612. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56613. */
  56614. export class SkeletonViewer {
  56615. /** defines the skeleton to render */
  56616. skeleton: Skeleton;
  56617. /** defines the mesh attached to the skeleton */
  56618. mesh: AbstractMesh;
  56619. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56620. autoUpdateBonesMatrices: boolean;
  56621. /** defines the rendering group id to use with the viewer */
  56622. renderingGroupId: number;
  56623. /** is the options for the viewer */
  56624. options: Partial<ISkeletonViewerOptions>;
  56625. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56626. static readonly DISPLAY_LINES: number;
  56627. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56628. static readonly DISPLAY_SPHERES: number;
  56629. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56630. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56631. /** public static method to create a BoneWeight Shader
  56632. * @param options The constructor options
  56633. * @param scene The scene that the shader is scoped to
  56634. * @returns The created ShaderMaterial
  56635. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56636. */
  56637. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56638. /** public static method to create a BoneWeight Shader
  56639. * @param options The constructor options
  56640. * @param scene The scene that the shader is scoped to
  56641. * @returns The created ShaderMaterial
  56642. */
  56643. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56644. /** private static method to create a BoneWeight Shader
  56645. * @param size The size of the buffer to create (usually the bone count)
  56646. * @param colorMap The gradient data to generate
  56647. * @param scene The scene that the shader is scoped to
  56648. * @returns an Array of floats from the color gradient values
  56649. */
  56650. private static _CreateBoneMapColorBuffer;
  56651. /** If SkeletonViewer scene scope. */
  56652. private _scene;
  56653. /** Gets or sets the color used to render the skeleton */
  56654. color: Color3;
  56655. /** Array of the points of the skeleton fo the line view. */
  56656. private _debugLines;
  56657. /** The SkeletonViewers Mesh. */
  56658. private _debugMesh;
  56659. /** The local axes Meshes. */
  56660. private _localAxes;
  56661. /** If SkeletonViewer is enabled. */
  56662. private _isEnabled;
  56663. /** If SkeletonViewer is ready. */
  56664. private _ready;
  56665. /** SkeletonViewer render observable. */
  56666. private _obs;
  56667. /** The Utility Layer to render the gizmos in. */
  56668. private _utilityLayer;
  56669. private _boneIndices;
  56670. /** Gets the Scene. */
  56671. get scene(): Scene;
  56672. /** Gets the utilityLayer. */
  56673. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56674. /** Checks Ready Status. */
  56675. get isReady(): Boolean;
  56676. /** Sets Ready Status. */
  56677. set ready(value: boolean);
  56678. /** Gets the debugMesh */
  56679. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56680. /** Sets the debugMesh */
  56681. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56682. /** Gets the displayMode */
  56683. get displayMode(): number;
  56684. /** Sets the displayMode */
  56685. set displayMode(value: number);
  56686. /**
  56687. * Creates a new SkeletonViewer
  56688. * @param skeleton defines the skeleton to render
  56689. * @param mesh defines the mesh attached to the skeleton
  56690. * @param scene defines the hosting scene
  56691. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56692. * @param renderingGroupId defines the rendering group id to use with the viewer
  56693. * @param options All of the extra constructor options for the SkeletonViewer
  56694. */
  56695. constructor(
  56696. /** defines the skeleton to render */
  56697. skeleton: Skeleton,
  56698. /** defines the mesh attached to the skeleton */
  56699. mesh: AbstractMesh,
  56700. /** The Scene scope*/
  56701. scene: Scene,
  56702. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56703. autoUpdateBonesMatrices?: boolean,
  56704. /** defines the rendering group id to use with the viewer */
  56705. renderingGroupId?: number,
  56706. /** is the options for the viewer */
  56707. options?: Partial<ISkeletonViewerOptions>);
  56708. /** The Dynamic bindings for the update functions */
  56709. private _bindObs;
  56710. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56711. update(): void;
  56712. /** Gets or sets a boolean indicating if the viewer is enabled */
  56713. set isEnabled(value: boolean);
  56714. get isEnabled(): boolean;
  56715. private _getBonePosition;
  56716. private _getLinesForBonesWithLength;
  56717. private _getLinesForBonesNoLength;
  56718. /** function to revert the mesh and scene back to the initial state. */
  56719. private _revert;
  56720. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56721. private _getAbsoluteBindPoseToRef;
  56722. /** function to build and bind sphere joint points and spur bone representations. */
  56723. private _buildSpheresAndSpurs;
  56724. private _buildLocalAxes;
  56725. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56726. private _displayLinesUpdate;
  56727. /** Changes the displayMode of the skeleton viewer
  56728. * @param mode The displayMode numerical value
  56729. */
  56730. changeDisplayMode(mode: number): void;
  56731. /** Sets a display option of the skeleton viewer
  56732. *
  56733. * | Option | Type | Default | Description |
  56734. * | ---------------- | ------- | ------- | ----------- |
  56735. * | 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`. |
  56736. * | 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`. |
  56737. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56738. * | 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`. |
  56739. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56740. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56741. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56742. *
  56743. * @param option String of the option name
  56744. * @param value The numerical option value
  56745. */
  56746. changeDisplayOptions(option: string, value: number): void;
  56747. /** Release associated resources */
  56748. dispose(): void;
  56749. }
  56750. }
  56751. declare module "babylonjs/Debug/index" {
  56752. export * from "babylonjs/Debug/axesViewer";
  56753. export * from "babylonjs/Debug/boneAxesViewer";
  56754. export * from "babylonjs/Debug/debugLayer";
  56755. export * from "babylonjs/Debug/physicsViewer";
  56756. export * from "babylonjs/Debug/rayHelper";
  56757. export * from "babylonjs/Debug/skeletonViewer";
  56758. export * from "babylonjs/Debug/ISkeletonViewer";
  56759. }
  56760. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56761. /**
  56762. * Enum for Device Types
  56763. */
  56764. export enum DeviceType {
  56765. /** Generic */
  56766. Generic = 0,
  56767. /** Keyboard */
  56768. Keyboard = 1,
  56769. /** Mouse */
  56770. Mouse = 2,
  56771. /** Touch Pointers */
  56772. Touch = 3,
  56773. /** PS4 Dual Shock */
  56774. DualShock = 4,
  56775. /** Xbox */
  56776. Xbox = 5,
  56777. /** Switch Controller */
  56778. Switch = 6
  56779. }
  56780. /**
  56781. * Enum for All Pointers (Touch/Mouse)
  56782. */
  56783. export enum PointerInput {
  56784. /** Horizontal Axis */
  56785. Horizontal = 0,
  56786. /** Vertical Axis */
  56787. Vertical = 1,
  56788. /** Left Click or Touch */
  56789. LeftClick = 2,
  56790. /** Middle Click */
  56791. MiddleClick = 3,
  56792. /** Right Click */
  56793. RightClick = 4,
  56794. /** Browser Back */
  56795. BrowserBack = 5,
  56796. /** Browser Forward */
  56797. BrowserForward = 6
  56798. }
  56799. /**
  56800. * Enum for Dual Shock Gamepad
  56801. */
  56802. export enum DualShockInput {
  56803. /** Cross */
  56804. Cross = 0,
  56805. /** Circle */
  56806. Circle = 1,
  56807. /** Square */
  56808. Square = 2,
  56809. /** Triangle */
  56810. Triangle = 3,
  56811. /** L1 */
  56812. L1 = 4,
  56813. /** R1 */
  56814. R1 = 5,
  56815. /** L2 */
  56816. L2 = 6,
  56817. /** R2 */
  56818. R2 = 7,
  56819. /** Share */
  56820. Share = 8,
  56821. /** Options */
  56822. Options = 9,
  56823. /** L3 */
  56824. L3 = 10,
  56825. /** R3 */
  56826. R3 = 11,
  56827. /** DPadUp */
  56828. DPadUp = 12,
  56829. /** DPadDown */
  56830. DPadDown = 13,
  56831. /** DPadLeft */
  56832. DPadLeft = 14,
  56833. /** DRight */
  56834. DPadRight = 15,
  56835. /** Home */
  56836. Home = 16,
  56837. /** TouchPad */
  56838. TouchPad = 17,
  56839. /** LStickXAxis */
  56840. LStickXAxis = 18,
  56841. /** LStickYAxis */
  56842. LStickYAxis = 19,
  56843. /** RStickXAxis */
  56844. RStickXAxis = 20,
  56845. /** RStickYAxis */
  56846. RStickYAxis = 21
  56847. }
  56848. /**
  56849. * Enum for Xbox Gamepad
  56850. */
  56851. export enum XboxInput {
  56852. /** A */
  56853. A = 0,
  56854. /** B */
  56855. B = 1,
  56856. /** X */
  56857. X = 2,
  56858. /** Y */
  56859. Y = 3,
  56860. /** LB */
  56861. LB = 4,
  56862. /** RB */
  56863. RB = 5,
  56864. /** LT */
  56865. LT = 6,
  56866. /** RT */
  56867. RT = 7,
  56868. /** Back */
  56869. Back = 8,
  56870. /** Start */
  56871. Start = 9,
  56872. /** LS */
  56873. LS = 10,
  56874. /** RS */
  56875. RS = 11,
  56876. /** DPadUp */
  56877. DPadUp = 12,
  56878. /** DPadDown */
  56879. DPadDown = 13,
  56880. /** DPadLeft */
  56881. DPadLeft = 14,
  56882. /** DRight */
  56883. DPadRight = 15,
  56884. /** Home */
  56885. Home = 16,
  56886. /** LStickXAxis */
  56887. LStickXAxis = 17,
  56888. /** LStickYAxis */
  56889. LStickYAxis = 18,
  56890. /** RStickXAxis */
  56891. RStickXAxis = 19,
  56892. /** RStickYAxis */
  56893. RStickYAxis = 20
  56894. }
  56895. /**
  56896. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56897. */
  56898. export enum SwitchInput {
  56899. /** B */
  56900. B = 0,
  56901. /** A */
  56902. A = 1,
  56903. /** Y */
  56904. Y = 2,
  56905. /** X */
  56906. X = 3,
  56907. /** L */
  56908. L = 4,
  56909. /** R */
  56910. R = 5,
  56911. /** ZL */
  56912. ZL = 6,
  56913. /** ZR */
  56914. ZR = 7,
  56915. /** Minus */
  56916. Minus = 8,
  56917. /** Plus */
  56918. Plus = 9,
  56919. /** LS */
  56920. LS = 10,
  56921. /** RS */
  56922. RS = 11,
  56923. /** DPadUp */
  56924. DPadUp = 12,
  56925. /** DPadDown */
  56926. DPadDown = 13,
  56927. /** DPadLeft */
  56928. DPadLeft = 14,
  56929. /** DRight */
  56930. DPadRight = 15,
  56931. /** Home */
  56932. Home = 16,
  56933. /** Capture */
  56934. Capture = 17,
  56935. /** LStickXAxis */
  56936. LStickXAxis = 18,
  56937. /** LStickYAxis */
  56938. LStickYAxis = 19,
  56939. /** RStickXAxis */
  56940. RStickXAxis = 20,
  56941. /** RStickYAxis */
  56942. RStickYAxis = 21
  56943. }
  56944. }
  56945. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56946. import { Engine } from "babylonjs/Engines/engine";
  56947. import { IDisposable } from "babylonjs/scene";
  56948. import { Nullable } from "babylonjs/types";
  56949. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56950. /**
  56951. * This class will take all inputs from Keyboard, Pointer, and
  56952. * any Gamepads and provide a polling system that all devices
  56953. * will use. This class assumes that there will only be one
  56954. * pointer device and one keyboard.
  56955. */
  56956. export class DeviceInputSystem implements IDisposable {
  56957. /**
  56958. * Callback to be triggered when a device is connected
  56959. */
  56960. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56961. /**
  56962. * Callback to be triggered when a device is disconnected
  56963. */
  56964. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56965. /**
  56966. * Callback to be triggered when event driven input is updated
  56967. */
  56968. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56969. private _inputs;
  56970. private _gamepads;
  56971. private _keyboardActive;
  56972. private _pointerActive;
  56973. private _elementToAttachTo;
  56974. private _keyboardDownEvent;
  56975. private _keyboardUpEvent;
  56976. private _pointerMoveEvent;
  56977. private _pointerDownEvent;
  56978. private _pointerUpEvent;
  56979. private _gamepadConnectedEvent;
  56980. private _gamepadDisconnectedEvent;
  56981. private static _MAX_KEYCODES;
  56982. private static _MAX_POINTER_INPUTS;
  56983. private constructor();
  56984. /**
  56985. * Creates a new DeviceInputSystem instance
  56986. * @param engine Engine to pull input element from
  56987. * @returns The new instance
  56988. */
  56989. static Create(engine: Engine): DeviceInputSystem;
  56990. /**
  56991. * Checks for current device input value, given an id and input index
  56992. * @param deviceName Id of connected device
  56993. * @param inputIndex Index of device input
  56994. * @returns Current value of input
  56995. */
  56996. /**
  56997. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56998. * @param deviceType Enum specifiying device type
  56999. * @param deviceSlot "Slot" or index that device is referenced in
  57000. * @param inputIndex Id of input to be checked
  57001. * @returns Current value of input
  57002. */
  57003. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  57004. /**
  57005. * Dispose of all the eventlisteners
  57006. */
  57007. dispose(): void;
  57008. /**
  57009. * Add device and inputs to device array
  57010. * @param deviceType Enum specifiying device type
  57011. * @param deviceSlot "Slot" or index that device is referenced in
  57012. * @param numberOfInputs Number of input entries to create for given device
  57013. */
  57014. private _registerDevice;
  57015. /**
  57016. * Given a specific device name, remove that device from the device map
  57017. * @param deviceType Enum specifiying device type
  57018. * @param deviceSlot "Slot" or index that device is referenced in
  57019. */
  57020. private _unregisterDevice;
  57021. /**
  57022. * Handle all actions that come from keyboard interaction
  57023. */
  57024. private _handleKeyActions;
  57025. /**
  57026. * Handle all actions that come from pointer interaction
  57027. */
  57028. private _handlePointerActions;
  57029. /**
  57030. * Handle all actions that come from gamepad interaction
  57031. */
  57032. private _handleGamepadActions;
  57033. /**
  57034. * Update all non-event based devices with each frame
  57035. * @param deviceType Enum specifiying device type
  57036. * @param deviceSlot "Slot" or index that device is referenced in
  57037. * @param inputIndex Id of input to be checked
  57038. */
  57039. private _updateDevice;
  57040. /**
  57041. * Gets DeviceType from the device name
  57042. * @param deviceName Name of Device from DeviceInputSystem
  57043. * @returns DeviceType enum value
  57044. */
  57045. private _getGamepadDeviceType;
  57046. }
  57047. }
  57048. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57049. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57050. /**
  57051. * Type to handle enforcement of inputs
  57052. */
  57053. 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;
  57054. }
  57055. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57056. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57057. import { Engine } from "babylonjs/Engines/engine";
  57058. import { IDisposable } from "babylonjs/scene";
  57059. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57060. import { Nullable } from "babylonjs/types";
  57061. import { Observable } from "babylonjs/Misc/observable";
  57062. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57063. /**
  57064. * Class that handles all input for a specific device
  57065. */
  57066. export class DeviceSource<T extends DeviceType> {
  57067. /** Type of device */
  57068. readonly deviceType: DeviceType;
  57069. /** "Slot" or index that device is referenced in */
  57070. readonly deviceSlot: number;
  57071. /**
  57072. * Observable to handle device input changes per device
  57073. */
  57074. readonly onInputChangedObservable: Observable<{
  57075. inputIndex: DeviceInput<T>;
  57076. previousState: Nullable<number>;
  57077. currentState: Nullable<number>;
  57078. }>;
  57079. private readonly _deviceInputSystem;
  57080. /**
  57081. * Default Constructor
  57082. * @param deviceInputSystem Reference to DeviceInputSystem
  57083. * @param deviceType Type of device
  57084. * @param deviceSlot "Slot" or index that device is referenced in
  57085. */
  57086. constructor(deviceInputSystem: DeviceInputSystem,
  57087. /** Type of device */
  57088. deviceType: DeviceType,
  57089. /** "Slot" or index that device is referenced in */
  57090. deviceSlot?: number);
  57091. /**
  57092. * Get input for specific input
  57093. * @param inputIndex index of specific input on device
  57094. * @returns Input value from DeviceInputSystem
  57095. */
  57096. getInput(inputIndex: DeviceInput<T>): number;
  57097. }
  57098. /**
  57099. * Class to keep track of devices
  57100. */
  57101. export class DeviceSourceManager implements IDisposable {
  57102. /**
  57103. * Observable to be triggered when before a device is connected
  57104. */
  57105. readonly onBeforeDeviceConnectedObservable: Observable<{
  57106. deviceType: DeviceType;
  57107. deviceSlot: number;
  57108. }>;
  57109. /**
  57110. * Observable to be triggered when before a device is disconnected
  57111. */
  57112. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  57113. deviceType: DeviceType;
  57114. deviceSlot: number;
  57115. }>;
  57116. /**
  57117. * Observable to be triggered when after a device is connected
  57118. */
  57119. readonly onAfterDeviceConnectedObservable: Observable<{
  57120. deviceType: DeviceType;
  57121. deviceSlot: number;
  57122. }>;
  57123. /**
  57124. * Observable to be triggered when after a device is disconnected
  57125. */
  57126. readonly onAfterDeviceDisconnectedObservable: Observable<{
  57127. deviceType: DeviceType;
  57128. deviceSlot: number;
  57129. }>;
  57130. private readonly _devices;
  57131. private readonly _firstDevice;
  57132. private readonly _deviceInputSystem;
  57133. /**
  57134. * Default Constructor
  57135. * @param engine engine to pull input element from
  57136. */
  57137. constructor(engine: Engine);
  57138. /**
  57139. * Gets a DeviceSource, given a type and slot
  57140. * @param deviceType Enum specifying device type
  57141. * @param deviceSlot "Slot" or index that device is referenced in
  57142. * @returns DeviceSource object
  57143. */
  57144. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57145. /**
  57146. * Gets an array of DeviceSource objects for a given device type
  57147. * @param deviceType Enum specifying device type
  57148. * @returns Array of DeviceSource objects
  57149. */
  57150. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57151. /**
  57152. * Dispose of DeviceInputSystem and other parts
  57153. */
  57154. dispose(): void;
  57155. /**
  57156. * Function to add device name to device list
  57157. * @param deviceType Enum specifying device type
  57158. * @param deviceSlot "Slot" or index that device is referenced in
  57159. */
  57160. private _addDevice;
  57161. /**
  57162. * Function to remove device name to device list
  57163. * @param deviceType Enum specifying device type
  57164. * @param deviceSlot "Slot" or index that device is referenced in
  57165. */
  57166. private _removeDevice;
  57167. /**
  57168. * Updates array storing first connected device of each type
  57169. * @param type Type of Device
  57170. */
  57171. private _updateFirstDevices;
  57172. }
  57173. }
  57174. declare module "babylonjs/DeviceInput/index" {
  57175. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57176. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57177. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57178. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57179. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57180. }
  57181. declare module "babylonjs/Engines/nullEngine" {
  57182. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57183. import { Engine } from "babylonjs/Engines/engine";
  57184. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57185. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57186. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57187. import { Effect } from "babylonjs/Materials/effect";
  57188. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57189. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57190. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57191. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57192. /**
  57193. * Options to create the null engine
  57194. */
  57195. export class NullEngineOptions {
  57196. /**
  57197. * Render width (Default: 512)
  57198. */
  57199. renderWidth: number;
  57200. /**
  57201. * Render height (Default: 256)
  57202. */
  57203. renderHeight: number;
  57204. /**
  57205. * Texture size (Default: 512)
  57206. */
  57207. textureSize: number;
  57208. /**
  57209. * If delta time between frames should be constant
  57210. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57211. */
  57212. deterministicLockstep: boolean;
  57213. /**
  57214. * Maximum about of steps between frames (Default: 4)
  57215. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57216. */
  57217. lockstepMaxSteps: number;
  57218. /**
  57219. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57220. */
  57221. useHighPrecisionMatrix?: boolean;
  57222. }
  57223. /**
  57224. * The null engine class provides support for headless version of babylon.js.
  57225. * This can be used in server side scenario or for testing purposes
  57226. */
  57227. export class NullEngine extends Engine {
  57228. private _options;
  57229. /**
  57230. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57231. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57232. * @returns true if engine is in deterministic lock step mode
  57233. */
  57234. isDeterministicLockStep(): boolean;
  57235. /**
  57236. * Gets the max steps when engine is running in deterministic lock step
  57237. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57238. * @returns the max steps
  57239. */
  57240. getLockstepMaxSteps(): number;
  57241. /**
  57242. * Gets the current hardware scaling level.
  57243. * By default the hardware scaling level is computed from the window device ratio.
  57244. * 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.
  57245. * @returns a number indicating the current hardware scaling level
  57246. */
  57247. getHardwareScalingLevel(): number;
  57248. constructor(options?: NullEngineOptions);
  57249. /**
  57250. * Creates a vertex buffer
  57251. * @param vertices the data for the vertex buffer
  57252. * @returns the new WebGL static buffer
  57253. */
  57254. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57255. /**
  57256. * Creates a new index buffer
  57257. * @param indices defines the content of the index buffer
  57258. * @param updatable defines if the index buffer must be updatable
  57259. * @returns a new webGL buffer
  57260. */
  57261. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57262. /**
  57263. * Clear the current render buffer or the current render target (if any is set up)
  57264. * @param color defines the color to use
  57265. * @param backBuffer defines if the back buffer must be cleared
  57266. * @param depth defines if the depth buffer must be cleared
  57267. * @param stencil defines if the stencil buffer must be cleared
  57268. */
  57269. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57270. /**
  57271. * Gets the current render width
  57272. * @param useScreen defines if screen size must be used (or the current render target if any)
  57273. * @returns a number defining the current render width
  57274. */
  57275. getRenderWidth(useScreen?: boolean): number;
  57276. /**
  57277. * Gets the current render height
  57278. * @param useScreen defines if screen size must be used (or the current render target if any)
  57279. * @returns a number defining the current render height
  57280. */
  57281. getRenderHeight(useScreen?: boolean): number;
  57282. /**
  57283. * Set the WebGL's viewport
  57284. * @param viewport defines the viewport element to be used
  57285. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57286. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57287. */
  57288. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57289. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57290. /**
  57291. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57292. * @param pipelineContext defines the pipeline context to use
  57293. * @param uniformsNames defines the list of uniform names
  57294. * @returns an array of webGL uniform locations
  57295. */
  57296. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57297. /**
  57298. * Gets the lsit of active attributes for a given webGL program
  57299. * @param pipelineContext defines the pipeline context to use
  57300. * @param attributesNames defines the list of attribute names to get
  57301. * @returns an array of indices indicating the offset of each attribute
  57302. */
  57303. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57304. /**
  57305. * Binds an effect to the webGL context
  57306. * @param effect defines the effect to bind
  57307. */
  57308. bindSamplers(effect: Effect): void;
  57309. /**
  57310. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57311. * @param effect defines the effect to activate
  57312. */
  57313. enableEffect(effect: Effect): void;
  57314. /**
  57315. * Set various states to the webGL context
  57316. * @param culling defines backface culling state
  57317. * @param zOffset defines the value to apply to zOffset (0 by default)
  57318. * @param force defines if states must be applied even if cache is up to date
  57319. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57320. */
  57321. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57322. /**
  57323. * Set the value of an uniform to an array of int32
  57324. * @param uniform defines the webGL uniform location where to store the value
  57325. * @param array defines the array of int32 to store
  57326. * @returns true if value was set
  57327. */
  57328. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57329. /**
  57330. * Set the value of an uniform to an array of int32 (stored as vec2)
  57331. * @param uniform defines the webGL uniform location where to store the value
  57332. * @param array defines the array of int32 to store
  57333. * @returns true if value was set
  57334. */
  57335. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57336. /**
  57337. * Set the value of an uniform to an array of int32 (stored as vec3)
  57338. * @param uniform defines the webGL uniform location where to store the value
  57339. * @param array defines the array of int32 to store
  57340. * @returns true if value was set
  57341. */
  57342. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57343. /**
  57344. * Set the value of an uniform to an array of int32 (stored as vec4)
  57345. * @param uniform defines the webGL uniform location where to store the value
  57346. * @param array defines the array of int32 to store
  57347. * @returns true if value was set
  57348. */
  57349. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57350. /**
  57351. * Set the value of an uniform to an array of float32
  57352. * @param uniform defines the webGL uniform location where to store the value
  57353. * @param array defines the array of float32 to store
  57354. * @returns true if value was set
  57355. */
  57356. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57357. /**
  57358. * Set the value of an uniform to an array of float32 (stored as vec2)
  57359. * @param uniform defines the webGL uniform location where to store the value
  57360. * @param array defines the array of float32 to store
  57361. * @returns true if value was set
  57362. */
  57363. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57364. /**
  57365. * Set the value of an uniform to an array of float32 (stored as vec3)
  57366. * @param uniform defines the webGL uniform location where to store the value
  57367. * @param array defines the array of float32 to store
  57368. * @returns true if value was set
  57369. */
  57370. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57371. /**
  57372. * Set the value of an uniform to an array of float32 (stored as vec4)
  57373. * @param uniform defines the webGL uniform location where to store the value
  57374. * @param array defines the array of float32 to store
  57375. * @returns true if value was set
  57376. */
  57377. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57378. /**
  57379. * Set the value of an uniform to an array of number
  57380. * @param uniform defines the webGL uniform location where to store the value
  57381. * @param array defines the array of number to store
  57382. * @returns true if value was set
  57383. */
  57384. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57385. /**
  57386. * Set the value of an uniform to an array of number (stored as vec2)
  57387. * @param uniform defines the webGL uniform location where to store the value
  57388. * @param array defines the array of number to store
  57389. * @returns true if value was set
  57390. */
  57391. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57392. /**
  57393. * Set the value of an uniform to an array of number (stored as vec3)
  57394. * @param uniform defines the webGL uniform location where to store the value
  57395. * @param array defines the array of number to store
  57396. * @returns true if value was set
  57397. */
  57398. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57399. /**
  57400. * Set the value of an uniform to an array of number (stored as vec4)
  57401. * @param uniform defines the webGL uniform location where to store the value
  57402. * @param array defines the array of number to store
  57403. * @returns true if value was set
  57404. */
  57405. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57406. /**
  57407. * Set the value of an uniform to an array of float32 (stored as matrices)
  57408. * @param uniform defines the webGL uniform location where to store the value
  57409. * @param matrices defines the array of float32 to store
  57410. * @returns true if value was set
  57411. */
  57412. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57413. /**
  57414. * Set the value of an uniform to a matrix (3x3)
  57415. * @param uniform defines the webGL uniform location where to store the value
  57416. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57417. * @returns true if value was set
  57418. */
  57419. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57420. /**
  57421. * Set the value of an uniform to a matrix (2x2)
  57422. * @param uniform defines the webGL uniform location where to store the value
  57423. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57424. * @returns true if value was set
  57425. */
  57426. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57427. /**
  57428. * Set the value of an uniform to a number (float)
  57429. * @param uniform defines the webGL uniform location where to store the value
  57430. * @param value defines the float number to store
  57431. * @returns true if value was set
  57432. */
  57433. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57434. /**
  57435. * Set the value of an uniform to a vec2
  57436. * @param uniform defines the webGL uniform location where to store the value
  57437. * @param x defines the 1st component of the value
  57438. * @param y defines the 2nd component of the value
  57439. * @returns true if value was set
  57440. */
  57441. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57442. /**
  57443. * Set the value of an uniform to a vec3
  57444. * @param uniform defines the webGL uniform location where to store the value
  57445. * @param x defines the 1st component of the value
  57446. * @param y defines the 2nd component of the value
  57447. * @param z defines the 3rd component of the value
  57448. * @returns true if value was set
  57449. */
  57450. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57451. /**
  57452. * Set the value of an uniform to a boolean
  57453. * @param uniform defines the webGL uniform location where to store the value
  57454. * @param bool defines the boolean to store
  57455. * @returns true if value was set
  57456. */
  57457. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57458. /**
  57459. * Set the value of an uniform to a vec4
  57460. * @param uniform defines the webGL uniform location where to store the value
  57461. * @param x defines the 1st component of the value
  57462. * @param y defines the 2nd component of the value
  57463. * @param z defines the 3rd component of the value
  57464. * @param w defines the 4th component of the value
  57465. * @returns true if value was set
  57466. */
  57467. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57468. /**
  57469. * Sets the current alpha mode
  57470. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57471. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57472. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57473. */
  57474. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57475. /**
  57476. * Bind webGl buffers directly to the webGL context
  57477. * @param vertexBuffers defines the vertex buffer to bind
  57478. * @param indexBuffer defines the index buffer to bind
  57479. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57480. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57481. * @param effect defines the effect associated with the vertex buffer
  57482. */
  57483. bindBuffers(vertexBuffers: {
  57484. [key: string]: VertexBuffer;
  57485. }, indexBuffer: DataBuffer, effect: Effect): void;
  57486. /**
  57487. * Force the entire cache to be cleared
  57488. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57489. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57490. */
  57491. wipeCaches(bruteForce?: boolean): void;
  57492. /**
  57493. * Send a draw order
  57494. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57495. * @param indexStart defines the starting index
  57496. * @param indexCount defines the number of index to draw
  57497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57498. */
  57499. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57500. /**
  57501. * Draw a list of indexed primitives
  57502. * @param fillMode defines the primitive to use
  57503. * @param indexStart defines the starting index
  57504. * @param indexCount defines the number of index to draw
  57505. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57506. */
  57507. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57508. /**
  57509. * Draw a list of unindexed primitives
  57510. * @param fillMode defines the primitive to use
  57511. * @param verticesStart defines the index of first vertex to draw
  57512. * @param verticesCount defines the count of vertices to draw
  57513. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57514. */
  57515. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57516. /** @hidden */
  57517. _createTexture(): WebGLTexture;
  57518. /** @hidden */
  57519. _releaseTexture(texture: InternalTexture): void;
  57520. /**
  57521. * Usually called from Texture.ts.
  57522. * Passed information to create a WebGLTexture
  57523. * @param urlArg defines a value which contains one of the following:
  57524. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57525. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57526. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57527. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57528. * @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)
  57529. * @param scene needed for loading to the correct scene
  57530. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57531. * @param onLoad optional callback to be called upon successful completion
  57532. * @param onError optional callback to be called upon failure
  57533. * @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
  57534. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57535. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57536. * @param forcedExtension defines the extension to use to pick the right loader
  57537. * @param mimeType defines an optional mime type
  57538. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57539. */
  57540. 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;
  57541. /**
  57542. * Creates a new render target texture
  57543. * @param size defines the size of the texture
  57544. * @param options defines the options used to create the texture
  57545. * @returns a new render target texture stored in an InternalTexture
  57546. */
  57547. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57548. /**
  57549. * Update the sampling mode of a given texture
  57550. * @param samplingMode defines the required sampling mode
  57551. * @param texture defines the texture to update
  57552. */
  57553. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57554. /**
  57555. * Binds the frame buffer to the specified texture.
  57556. * @param texture The texture to render to or null for the default canvas
  57557. * @param faceIndex The face of the texture to render to in case of cube texture
  57558. * @param requiredWidth The width of the target to render to
  57559. * @param requiredHeight The height of the target to render to
  57560. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57561. * @param lodLevel defines le lod level to bind to the frame buffer
  57562. */
  57563. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57564. /**
  57565. * Unbind the current render target texture from the webGL context
  57566. * @param texture defines the render target texture to unbind
  57567. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57568. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57569. */
  57570. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57571. /**
  57572. * Creates a dynamic vertex buffer
  57573. * @param vertices the data for the dynamic vertex buffer
  57574. * @returns the new WebGL dynamic buffer
  57575. */
  57576. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57577. /**
  57578. * Update the content of a dynamic texture
  57579. * @param texture defines the texture to update
  57580. * @param canvas defines the canvas containing the source
  57581. * @param invertY defines if data must be stored with Y axis inverted
  57582. * @param premulAlpha defines if alpha is stored as premultiplied
  57583. * @param format defines the format of the data
  57584. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57585. */
  57586. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57587. /**
  57588. * Gets a boolean indicating if all created effects are ready
  57589. * @returns true if all effects are ready
  57590. */
  57591. areAllEffectsReady(): boolean;
  57592. /**
  57593. * @hidden
  57594. * Get the current error code of the webGL context
  57595. * @returns the error code
  57596. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57597. */
  57598. getError(): number;
  57599. /** @hidden */
  57600. _getUnpackAlignement(): number;
  57601. /** @hidden */
  57602. _unpackFlipY(value: boolean): void;
  57603. /**
  57604. * Update a dynamic index buffer
  57605. * @param indexBuffer defines the target index buffer
  57606. * @param indices defines the data to update
  57607. * @param offset defines the offset in the target index buffer where update should start
  57608. */
  57609. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57610. /**
  57611. * Updates a dynamic vertex buffer.
  57612. * @param vertexBuffer the vertex buffer to update
  57613. * @param vertices the data used to update the vertex buffer
  57614. * @param byteOffset the byte offset of the data (optional)
  57615. * @param byteLength the byte length of the data (optional)
  57616. */
  57617. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57618. /** @hidden */
  57619. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57620. /** @hidden */
  57621. _bindTexture(channel: number, texture: InternalTexture): void;
  57622. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57623. /**
  57624. * 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
  57625. */
  57626. releaseEffects(): void;
  57627. displayLoadingUI(): void;
  57628. hideLoadingUI(): void;
  57629. /** @hidden */
  57630. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57631. /** @hidden */
  57632. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57633. /** @hidden */
  57634. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57635. /** @hidden */
  57636. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57637. }
  57638. }
  57639. declare module "babylonjs/Instrumentation/timeToken" {
  57640. import { Nullable } from "babylonjs/types";
  57641. /**
  57642. * @hidden
  57643. **/
  57644. export class _TimeToken {
  57645. _startTimeQuery: Nullable<WebGLQuery>;
  57646. _endTimeQuery: Nullable<WebGLQuery>;
  57647. _timeElapsedQuery: Nullable<WebGLQuery>;
  57648. _timeElapsedQueryEnded: boolean;
  57649. }
  57650. }
  57651. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57652. import { Nullable, int } from "babylonjs/types";
  57653. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57654. /** @hidden */
  57655. export class _OcclusionDataStorage {
  57656. /** @hidden */
  57657. occlusionInternalRetryCounter: number;
  57658. /** @hidden */
  57659. isOcclusionQueryInProgress: boolean;
  57660. /** @hidden */
  57661. isOccluded: boolean;
  57662. /** @hidden */
  57663. occlusionRetryCount: number;
  57664. /** @hidden */
  57665. occlusionType: number;
  57666. /** @hidden */
  57667. occlusionQueryAlgorithmType: number;
  57668. }
  57669. module "babylonjs/Engines/engine" {
  57670. interface Engine {
  57671. /**
  57672. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57673. * @return the new query
  57674. */
  57675. createQuery(): WebGLQuery;
  57676. /**
  57677. * Delete and release a webGL query
  57678. * @param query defines the query to delete
  57679. * @return the current engine
  57680. */
  57681. deleteQuery(query: WebGLQuery): Engine;
  57682. /**
  57683. * Check if a given query has resolved and got its value
  57684. * @param query defines the query to check
  57685. * @returns true if the query got its value
  57686. */
  57687. isQueryResultAvailable(query: WebGLQuery): boolean;
  57688. /**
  57689. * Gets the value of a given query
  57690. * @param query defines the query to check
  57691. * @returns the value of the query
  57692. */
  57693. getQueryResult(query: WebGLQuery): number;
  57694. /**
  57695. * Initiates an occlusion query
  57696. * @param algorithmType defines the algorithm to use
  57697. * @param query defines the query to use
  57698. * @returns the current engine
  57699. * @see https://doc.babylonjs.com/features/occlusionquery
  57700. */
  57701. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57702. /**
  57703. * Ends an occlusion query
  57704. * @see https://doc.babylonjs.com/features/occlusionquery
  57705. * @param algorithmType defines the algorithm to use
  57706. * @returns the current engine
  57707. */
  57708. endOcclusionQuery(algorithmType: number): Engine;
  57709. /**
  57710. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57711. * Please note that only one query can be issued at a time
  57712. * @returns a time token used to track the time span
  57713. */
  57714. startTimeQuery(): Nullable<_TimeToken>;
  57715. /**
  57716. * Ends a time query
  57717. * @param token defines the token used to measure the time span
  57718. * @returns the time spent (in ns)
  57719. */
  57720. endTimeQuery(token: _TimeToken): int;
  57721. /** @hidden */
  57722. _currentNonTimestampToken: Nullable<_TimeToken>;
  57723. /** @hidden */
  57724. _createTimeQuery(): WebGLQuery;
  57725. /** @hidden */
  57726. _deleteTimeQuery(query: WebGLQuery): void;
  57727. /** @hidden */
  57728. _getGlAlgorithmType(algorithmType: number): number;
  57729. /** @hidden */
  57730. _getTimeQueryResult(query: WebGLQuery): any;
  57731. /** @hidden */
  57732. _getTimeQueryAvailability(query: WebGLQuery): any;
  57733. }
  57734. }
  57735. module "babylonjs/Meshes/abstractMesh" {
  57736. interface AbstractMesh {
  57737. /**
  57738. * Backing filed
  57739. * @hidden
  57740. */
  57741. __occlusionDataStorage: _OcclusionDataStorage;
  57742. /**
  57743. * Access property
  57744. * @hidden
  57745. */
  57746. _occlusionDataStorage: _OcclusionDataStorage;
  57747. /**
  57748. * 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.
  57749. * The default value is -1 which means don't break the query and wait till the result
  57750. * @see https://doc.babylonjs.com/features/occlusionquery
  57751. */
  57752. occlusionRetryCount: number;
  57753. /**
  57754. * 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:
  57755. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57756. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57757. * * 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.
  57758. * @see https://doc.babylonjs.com/features/occlusionquery
  57759. */
  57760. occlusionType: number;
  57761. /**
  57762. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57763. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57764. * * 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.
  57765. * @see https://doc.babylonjs.com/features/occlusionquery
  57766. */
  57767. occlusionQueryAlgorithmType: number;
  57768. /**
  57769. * 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
  57770. * @see https://doc.babylonjs.com/features/occlusionquery
  57771. */
  57772. isOccluded: boolean;
  57773. /**
  57774. * Flag to check the progress status of the query
  57775. * @see https://doc.babylonjs.com/features/occlusionquery
  57776. */
  57777. isOcclusionQueryInProgress: boolean;
  57778. }
  57779. }
  57780. }
  57781. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57782. import { Nullable } from "babylonjs/types";
  57783. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57784. /** @hidden */
  57785. export var _forceTransformFeedbackToBundle: boolean;
  57786. module "babylonjs/Engines/engine" {
  57787. interface Engine {
  57788. /**
  57789. * Creates a webGL transform feedback object
  57790. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57791. * @returns the webGL transform feedback object
  57792. */
  57793. createTransformFeedback(): WebGLTransformFeedback;
  57794. /**
  57795. * Delete a webGL transform feedback object
  57796. * @param value defines the webGL transform feedback object to delete
  57797. */
  57798. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57799. /**
  57800. * Bind a webGL transform feedback object to the webgl context
  57801. * @param value defines the webGL transform feedback object to bind
  57802. */
  57803. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57804. /**
  57805. * Begins a transform feedback operation
  57806. * @param usePoints defines if points or triangles must be used
  57807. */
  57808. beginTransformFeedback(usePoints: boolean): void;
  57809. /**
  57810. * Ends a transform feedback operation
  57811. */
  57812. endTransformFeedback(): void;
  57813. /**
  57814. * Specify the varyings to use with transform feedback
  57815. * @param program defines the associated webGL program
  57816. * @param value defines the list of strings representing the varying names
  57817. */
  57818. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57819. /**
  57820. * Bind a webGL buffer for a transform feedback operation
  57821. * @param value defines the webGL buffer to bind
  57822. */
  57823. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57824. }
  57825. }
  57826. }
  57827. declare module "babylonjs/Engines/Extensions/engine.views" {
  57828. import { Camera } from "babylonjs/Cameras/camera";
  57829. import { Nullable } from "babylonjs/types";
  57830. /**
  57831. * Class used to define an additional view for the engine
  57832. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57833. */
  57834. export class EngineView {
  57835. /** Defines the canvas where to render the view */
  57836. target: HTMLCanvasElement;
  57837. /** Defines an optional camera used to render the view (will use active camera else) */
  57838. camera?: Camera;
  57839. }
  57840. module "babylonjs/Engines/engine" {
  57841. interface Engine {
  57842. /**
  57843. * Gets or sets the HTML element to use for attaching events
  57844. */
  57845. inputElement: Nullable<HTMLElement>;
  57846. /**
  57847. * Gets the current engine view
  57848. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57849. */
  57850. activeView: Nullable<EngineView>;
  57851. /** Gets or sets the list of views */
  57852. views: EngineView[];
  57853. /**
  57854. * Register a new child canvas
  57855. * @param canvas defines the canvas to register
  57856. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57857. * @returns the associated view
  57858. */
  57859. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57860. /**
  57861. * Remove a registered child canvas
  57862. * @param canvas defines the canvas to remove
  57863. * @returns the current engine
  57864. */
  57865. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57866. }
  57867. }
  57868. }
  57869. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57870. import { Nullable } from "babylonjs/types";
  57871. module "babylonjs/Engines/engine" {
  57872. interface Engine {
  57873. /** @hidden */
  57874. _excludedCompressedTextures: string[];
  57875. /** @hidden */
  57876. _textureFormatInUse: string;
  57877. /**
  57878. * Gets the list of texture formats supported
  57879. */
  57880. readonly texturesSupported: Array<string>;
  57881. /**
  57882. * Gets the texture format in use
  57883. */
  57884. readonly textureFormatInUse: Nullable<string>;
  57885. /**
  57886. * Set the compressed texture extensions or file names to skip.
  57887. *
  57888. * @param skippedFiles defines the list of those texture files you want to skip
  57889. * Example: [".dds", ".env", "myfile.png"]
  57890. */
  57891. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57892. /**
  57893. * Set the compressed texture format to use, based on the formats you have, and the formats
  57894. * supported by the hardware / browser.
  57895. *
  57896. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57897. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57898. * to API arguments needed to compressed textures. This puts the burden on the container
  57899. * generator to house the arcane code for determining these for current & future formats.
  57900. *
  57901. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57902. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57903. *
  57904. * Note: The result of this call is not taken into account when a texture is base64.
  57905. *
  57906. * @param formatsAvailable defines the list of those format families you have created
  57907. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57908. *
  57909. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57910. * @returns The extension selected.
  57911. */
  57912. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57913. }
  57914. }
  57915. }
  57916. declare module "babylonjs/Engines/Extensions/index" {
  57917. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57918. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57919. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57920. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57921. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57922. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57923. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57924. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57925. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57926. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57927. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57928. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57929. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57930. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57931. export * from "babylonjs/Engines/Extensions/engine.views";
  57932. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57933. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57934. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57935. }
  57936. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57937. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57938. /** @hidden */
  57939. export var rgbdEncodePixelShader: {
  57940. name: string;
  57941. shader: string;
  57942. };
  57943. }
  57944. declare module "babylonjs/Misc/environmentTextureTools" {
  57945. import { Nullable } from "babylonjs/types";
  57946. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57949. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57950. import "babylonjs/Engines/Extensions/engine.readTexture";
  57951. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57952. import "babylonjs/Shaders/rgbdEncode.fragment";
  57953. import "babylonjs/Shaders/rgbdDecode.fragment";
  57954. /**
  57955. * Raw texture data and descriptor sufficient for WebGL texture upload
  57956. */
  57957. export interface EnvironmentTextureInfo {
  57958. /**
  57959. * Version of the environment map
  57960. */
  57961. version: number;
  57962. /**
  57963. * Width of image
  57964. */
  57965. width: number;
  57966. /**
  57967. * Irradiance information stored in the file.
  57968. */
  57969. irradiance: any;
  57970. /**
  57971. * Specular information stored in the file.
  57972. */
  57973. specular: any;
  57974. }
  57975. /**
  57976. * Defines One Image in the file. It requires only the position in the file
  57977. * as well as the length.
  57978. */
  57979. interface BufferImageData {
  57980. /**
  57981. * Length of the image data.
  57982. */
  57983. length: number;
  57984. /**
  57985. * Position of the data from the null terminator delimiting the end of the JSON.
  57986. */
  57987. position: number;
  57988. }
  57989. /**
  57990. * Defines the specular data enclosed in the file.
  57991. * This corresponds to the version 1 of the data.
  57992. */
  57993. export interface EnvironmentTextureSpecularInfoV1 {
  57994. /**
  57995. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57996. */
  57997. specularDataPosition?: number;
  57998. /**
  57999. * This contains all the images data needed to reconstruct the cubemap.
  58000. */
  58001. mipmaps: Array<BufferImageData>;
  58002. /**
  58003. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  58004. */
  58005. lodGenerationScale: number;
  58006. }
  58007. /**
  58008. * Sets of helpers addressing the serialization and deserialization of environment texture
  58009. * stored in a BabylonJS env file.
  58010. * Those files are usually stored as .env files.
  58011. */
  58012. export class EnvironmentTextureTools {
  58013. /**
  58014. * Magic number identifying the env file.
  58015. */
  58016. private static _MagicBytes;
  58017. /**
  58018. * Gets the environment info from an env file.
  58019. * @param data The array buffer containing the .env bytes.
  58020. * @returns the environment file info (the json header) if successfully parsed.
  58021. */
  58022. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  58023. /**
  58024. * Creates an environment texture from a loaded cube texture.
  58025. * @param texture defines the cube texture to convert in env file
  58026. * @return a promise containing the environment data if succesfull.
  58027. */
  58028. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  58029. /**
  58030. * Creates a JSON representation of the spherical data.
  58031. * @param texture defines the texture containing the polynomials
  58032. * @return the JSON representation of the spherical info
  58033. */
  58034. private static _CreateEnvTextureIrradiance;
  58035. /**
  58036. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58037. * @param data the image data
  58038. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58039. * @return the views described by info providing access to the underlying buffer
  58040. */
  58041. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58042. /**
  58043. * Uploads the texture info contained in the env file to the GPU.
  58044. * @param texture defines the internal texture to upload to
  58045. * @param data defines the data to load
  58046. * @param info defines the texture info retrieved through the GetEnvInfo method
  58047. * @returns a promise
  58048. */
  58049. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58050. private static _OnImageReadyAsync;
  58051. /**
  58052. * Uploads the levels of image data to the GPU.
  58053. * @param texture defines the internal texture to upload to
  58054. * @param imageData defines the array buffer views of image data [mipmap][face]
  58055. * @returns a promise
  58056. */
  58057. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58058. /**
  58059. * Uploads spherical polynomials information to the texture.
  58060. * @param texture defines the texture we are trying to upload the information to
  58061. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58062. */
  58063. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58064. /** @hidden */
  58065. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58066. }
  58067. }
  58068. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58069. /**
  58070. * Class used to inline functions in shader code
  58071. */
  58072. export class ShaderCodeInliner {
  58073. private static readonly _RegexpFindFunctionNameAndType;
  58074. private _sourceCode;
  58075. private _functionDescr;
  58076. private _numMaxIterations;
  58077. /** Gets or sets the token used to mark the functions to inline */
  58078. inlineToken: string;
  58079. /** Gets or sets the debug mode */
  58080. debug: boolean;
  58081. /** Gets the code after the inlining process */
  58082. get code(): string;
  58083. /**
  58084. * Initializes the inliner
  58085. * @param sourceCode shader code source to inline
  58086. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58087. */
  58088. constructor(sourceCode: string, numMaxIterations?: number);
  58089. /**
  58090. * Start the processing of the shader code
  58091. */
  58092. processCode(): void;
  58093. private _collectFunctions;
  58094. private _processInlining;
  58095. private _extractBetweenMarkers;
  58096. private _skipWhitespaces;
  58097. private _removeComments;
  58098. private _replaceFunctionCallsByCode;
  58099. private _findBackward;
  58100. private _escapeRegExp;
  58101. private _replaceNames;
  58102. }
  58103. }
  58104. declare module "babylonjs/Engines/nativeEngine" {
  58105. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58106. import { Engine } from "babylonjs/Engines/engine";
  58107. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58108. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58109. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58110. import { Effect } from "babylonjs/Materials/effect";
  58111. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58112. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58113. import { IColor4Like } from "babylonjs/Maths/math.like";
  58114. import { Scene } from "babylonjs/scene";
  58115. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58116. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58117. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58118. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58119. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58120. /**
  58121. * Container for accessors for natively-stored mesh data buffers.
  58122. */
  58123. class NativeDataBuffer extends DataBuffer {
  58124. /**
  58125. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58126. */
  58127. nativeIndexBuffer?: any;
  58128. /**
  58129. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58130. */
  58131. nativeVertexBuffer?: any;
  58132. }
  58133. /** @hidden */
  58134. class NativeTexture extends InternalTexture {
  58135. getInternalTexture(): InternalTexture;
  58136. getViewCount(): number;
  58137. }
  58138. /** @hidden */
  58139. export class NativeEngine extends Engine {
  58140. private readonly _native;
  58141. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58142. private readonly INVALID_HANDLE;
  58143. private _boundBuffersVertexArray;
  58144. private _currentDepthTest;
  58145. getHardwareScalingLevel(): number;
  58146. constructor();
  58147. dispose(): void;
  58148. /**
  58149. * Can be used to override the current requestAnimationFrame requester.
  58150. * @hidden
  58151. */
  58152. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58153. /**
  58154. * Override default engine behavior.
  58155. * @param color
  58156. * @param backBuffer
  58157. * @param depth
  58158. * @param stencil
  58159. */
  58160. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58161. /**
  58162. * Gets host document
  58163. * @returns the host document object
  58164. */
  58165. getHostDocument(): Nullable<Document>;
  58166. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58167. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58168. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58169. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58170. [key: string]: VertexBuffer;
  58171. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58172. bindBuffers(vertexBuffers: {
  58173. [key: string]: VertexBuffer;
  58174. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58175. recordVertexArrayObject(vertexBuffers: {
  58176. [key: string]: VertexBuffer;
  58177. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58178. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58179. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58180. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58181. /**
  58182. * Draw a list of indexed primitives
  58183. * @param fillMode defines the primitive to use
  58184. * @param indexStart defines the starting index
  58185. * @param indexCount defines the number of index to draw
  58186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58187. */
  58188. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58189. /**
  58190. * Draw a list of unindexed primitives
  58191. * @param fillMode defines the primitive to use
  58192. * @param verticesStart defines the index of first vertex to draw
  58193. * @param verticesCount defines the count of vertices to draw
  58194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58195. */
  58196. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58197. createPipelineContext(): IPipelineContext;
  58198. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58199. /** @hidden */
  58200. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58201. /** @hidden */
  58202. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58203. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58204. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58205. protected _setProgram(program: WebGLProgram): void;
  58206. _releaseEffect(effect: Effect): void;
  58207. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58208. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58209. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58210. bindSamplers(effect: Effect): void;
  58211. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58212. getRenderWidth(useScreen?: boolean): number;
  58213. getRenderHeight(useScreen?: boolean): number;
  58214. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58215. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58216. /**
  58217. * Set the z offset to apply to current rendering
  58218. * @param value defines the offset to apply
  58219. */
  58220. setZOffset(value: number): void;
  58221. /**
  58222. * Gets the current value of the zOffset
  58223. * @returns the current zOffset state
  58224. */
  58225. getZOffset(): number;
  58226. /**
  58227. * Enable or disable depth buffering
  58228. * @param enable defines the state to set
  58229. */
  58230. setDepthBuffer(enable: boolean): void;
  58231. /**
  58232. * Gets a boolean indicating if depth writing is enabled
  58233. * @returns the current depth writing state
  58234. */
  58235. getDepthWrite(): boolean;
  58236. setDepthFunctionToGreater(): void;
  58237. setDepthFunctionToGreaterOrEqual(): void;
  58238. setDepthFunctionToLess(): void;
  58239. setDepthFunctionToLessOrEqual(): void;
  58240. /**
  58241. * Enable or disable depth writing
  58242. * @param enable defines the state to set
  58243. */
  58244. setDepthWrite(enable: boolean): void;
  58245. /**
  58246. * Enable or disable color writing
  58247. * @param enable defines the state to set
  58248. */
  58249. setColorWrite(enable: boolean): void;
  58250. /**
  58251. * Gets a boolean indicating if color writing is enabled
  58252. * @returns the current color writing state
  58253. */
  58254. getColorWrite(): boolean;
  58255. /**
  58256. * Sets alpha constants used by some alpha blending modes
  58257. * @param r defines the red component
  58258. * @param g defines the green component
  58259. * @param b defines the blue component
  58260. * @param a defines the alpha component
  58261. */
  58262. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58263. /**
  58264. * Sets the current alpha mode
  58265. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58266. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58267. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58268. */
  58269. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58270. /**
  58271. * Gets the current alpha mode
  58272. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58273. * @returns the current alpha mode
  58274. */
  58275. getAlphaMode(): number;
  58276. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58277. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58278. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58279. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58280. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58281. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58282. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58283. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58284. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58285. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58286. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58287. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58288. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58289. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58290. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58291. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58292. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58293. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58294. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58295. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58296. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58297. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58298. wipeCaches(bruteForce?: boolean): void;
  58299. _createTexture(): WebGLTexture;
  58300. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58301. /**
  58302. * Update the content of a dynamic texture
  58303. * @param texture defines the texture to update
  58304. * @param canvas defines the canvas containing the source
  58305. * @param invertY defines if data must be stored with Y axis inverted
  58306. * @param premulAlpha defines if alpha is stored as premultiplied
  58307. * @param format defines the format of the data
  58308. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58309. */
  58310. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58311. /**
  58312. * Usually called from Texture.ts.
  58313. * Passed information to create a WebGLTexture
  58314. * @param url defines a value which contains one of the following:
  58315. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58316. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58317. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58318. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58319. * @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)
  58320. * @param scene needed for loading to the correct scene
  58321. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58322. * @param onLoad optional callback to be called upon successful completion
  58323. * @param onError optional callback to be called upon failure
  58324. * @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
  58325. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58326. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58327. * @param forcedExtension defines the extension to use to pick the right loader
  58328. * @param mimeType defines an optional mime type
  58329. * @param loaderOptions options to be passed to the loader
  58330. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58331. */
  58332. 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, loaderOptions?: any): InternalTexture;
  58333. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58334. _releaseFramebufferObjects(texture: InternalTexture): void;
  58335. /**
  58336. * Creates a cube texture
  58337. * @param rootUrl defines the url where the files to load is located
  58338. * @param scene defines the current scene
  58339. * @param files defines the list of files to load (1 per face)
  58340. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58341. * @param onLoad defines an optional callback raised when the texture is loaded
  58342. * @param onError defines an optional callback raised if there is an issue to load the texture
  58343. * @param format defines the format of the data
  58344. * @param forcedExtension defines the extension to use to pick the right loader
  58345. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58346. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58347. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58348. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58349. * @returns the cube texture as an InternalTexture
  58350. */
  58351. 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;
  58352. createRenderTargetTexture(size: number | {
  58353. width: number;
  58354. height: number;
  58355. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58356. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58357. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58358. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58359. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58360. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58361. /**
  58362. * Updates a dynamic vertex buffer.
  58363. * @param vertexBuffer the vertex buffer to update
  58364. * @param data the data used to update the vertex buffer
  58365. * @param byteOffset the byte offset of the data (optional)
  58366. * @param byteLength the byte length of the data (optional)
  58367. */
  58368. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58369. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58370. private _updateAnisotropicLevel;
  58371. private _getAddressMode;
  58372. /** @hidden */
  58373. _bindTexture(channel: number, texture: InternalTexture): void;
  58374. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58375. releaseEffects(): void;
  58376. /** @hidden */
  58377. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58378. /** @hidden */
  58379. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58380. /** @hidden */
  58381. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58382. /** @hidden */
  58383. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58384. private _getNativeSamplingMode;
  58385. private _getNativeTextureFormat;
  58386. private _getNativeAlphaMode;
  58387. private _getNativeAttribType;
  58388. }
  58389. }
  58390. declare module "babylonjs/Engines/index" {
  58391. export * from "babylonjs/Engines/constants";
  58392. export * from "babylonjs/Engines/engineCapabilities";
  58393. export * from "babylonjs/Engines/instancingAttributeInfo";
  58394. export * from "babylonjs/Engines/thinEngine";
  58395. export * from "babylonjs/Engines/engine";
  58396. export * from "babylonjs/Engines/engineStore";
  58397. export * from "babylonjs/Engines/nullEngine";
  58398. export * from "babylonjs/Engines/Extensions/index";
  58399. export * from "babylonjs/Engines/IPipelineContext";
  58400. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58401. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58402. export * from "babylonjs/Engines/nativeEngine";
  58403. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58404. export * from "babylonjs/Engines/performanceConfigurator";
  58405. }
  58406. declare module "babylonjs/Events/clipboardEvents" {
  58407. /**
  58408. * Gather the list of clipboard event types as constants.
  58409. */
  58410. export class ClipboardEventTypes {
  58411. /**
  58412. * The clipboard event is fired when a copy command is active (pressed).
  58413. */
  58414. static readonly COPY: number;
  58415. /**
  58416. * The clipboard event is fired when a cut command is active (pressed).
  58417. */
  58418. static readonly CUT: number;
  58419. /**
  58420. * The clipboard event is fired when a paste command is active (pressed).
  58421. */
  58422. static readonly PASTE: number;
  58423. }
  58424. /**
  58425. * This class is used to store clipboard related info for the onClipboardObservable event.
  58426. */
  58427. export class ClipboardInfo {
  58428. /**
  58429. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58430. */
  58431. type: number;
  58432. /**
  58433. * Defines the related dom event
  58434. */
  58435. event: ClipboardEvent;
  58436. /**
  58437. *Creates an instance of ClipboardInfo.
  58438. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58439. * @param event Defines the related dom event
  58440. */
  58441. constructor(
  58442. /**
  58443. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58444. */
  58445. type: number,
  58446. /**
  58447. * Defines the related dom event
  58448. */
  58449. event: ClipboardEvent);
  58450. /**
  58451. * Get the clipboard event's type from the keycode.
  58452. * @param keyCode Defines the keyCode for the current keyboard event.
  58453. * @return {number}
  58454. */
  58455. static GetTypeFromCharacter(keyCode: number): number;
  58456. }
  58457. }
  58458. declare module "babylonjs/Events/index" {
  58459. export * from "babylonjs/Events/keyboardEvents";
  58460. export * from "babylonjs/Events/pointerEvents";
  58461. export * from "babylonjs/Events/clipboardEvents";
  58462. }
  58463. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58464. import { Scene } from "babylonjs/scene";
  58465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58466. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58467. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58468. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58469. /**
  58470. * Google Daydream controller
  58471. */
  58472. export class DaydreamController extends WebVRController {
  58473. /**
  58474. * Base Url for the controller model.
  58475. */
  58476. static MODEL_BASE_URL: string;
  58477. /**
  58478. * File name for the controller model.
  58479. */
  58480. static MODEL_FILENAME: string;
  58481. /**
  58482. * Gamepad Id prefix used to identify Daydream Controller.
  58483. */
  58484. static readonly GAMEPAD_ID_PREFIX: string;
  58485. /**
  58486. * Creates a new DaydreamController from a gamepad
  58487. * @param vrGamepad the gamepad that the controller should be created from
  58488. */
  58489. constructor(vrGamepad: any);
  58490. /**
  58491. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58492. * @param scene scene in which to add meshes
  58493. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58494. */
  58495. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58496. /**
  58497. * Called once for each button that changed state since the last frame
  58498. * @param buttonIdx Which button index changed
  58499. * @param state New state of the button
  58500. * @param changes Which properties on the state changed since last frame
  58501. */
  58502. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58503. }
  58504. }
  58505. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58506. import { Scene } from "babylonjs/scene";
  58507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58508. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58509. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58510. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58511. /**
  58512. * Gear VR Controller
  58513. */
  58514. export class GearVRController extends WebVRController {
  58515. /**
  58516. * Base Url for the controller model.
  58517. */
  58518. static MODEL_BASE_URL: string;
  58519. /**
  58520. * File name for the controller model.
  58521. */
  58522. static MODEL_FILENAME: string;
  58523. /**
  58524. * Gamepad Id prefix used to identify this controller.
  58525. */
  58526. static readonly GAMEPAD_ID_PREFIX: string;
  58527. private readonly _buttonIndexToObservableNameMap;
  58528. /**
  58529. * Creates a new GearVRController from a gamepad
  58530. * @param vrGamepad the gamepad that the controller should be created from
  58531. */
  58532. constructor(vrGamepad: any);
  58533. /**
  58534. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58535. * @param scene scene in which to add meshes
  58536. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58537. */
  58538. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58539. /**
  58540. * Called once for each button that changed state since the last frame
  58541. * @param buttonIdx Which button index changed
  58542. * @param state New state of the button
  58543. * @param changes Which properties on the state changed since last frame
  58544. */
  58545. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58546. }
  58547. }
  58548. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58549. import { Scene } from "babylonjs/scene";
  58550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58551. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58552. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58553. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58554. /**
  58555. * Generic Controller
  58556. */
  58557. export class GenericController extends WebVRController {
  58558. /**
  58559. * Base Url for the controller model.
  58560. */
  58561. static readonly MODEL_BASE_URL: string;
  58562. /**
  58563. * File name for the controller model.
  58564. */
  58565. static readonly MODEL_FILENAME: string;
  58566. /**
  58567. * Creates a new GenericController from a gamepad
  58568. * @param vrGamepad the gamepad that the controller should be created from
  58569. */
  58570. constructor(vrGamepad: any);
  58571. /**
  58572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58573. * @param scene scene in which to add meshes
  58574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58575. */
  58576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58577. /**
  58578. * Called once for each button that changed state since the last frame
  58579. * @param buttonIdx Which button index changed
  58580. * @param state New state of the button
  58581. * @param changes Which properties on the state changed since last frame
  58582. */
  58583. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58584. }
  58585. }
  58586. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58587. import { Observable } from "babylonjs/Misc/observable";
  58588. import { Scene } from "babylonjs/scene";
  58589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58590. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58591. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58592. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58593. /**
  58594. * Oculus Touch Controller
  58595. */
  58596. export class OculusTouchController extends WebVRController {
  58597. /**
  58598. * Base Url for the controller model.
  58599. */
  58600. static MODEL_BASE_URL: string;
  58601. /**
  58602. * File name for the left controller model.
  58603. */
  58604. static MODEL_LEFT_FILENAME: string;
  58605. /**
  58606. * File name for the right controller model.
  58607. */
  58608. static MODEL_RIGHT_FILENAME: string;
  58609. /**
  58610. * Base Url for the Quest controller model.
  58611. */
  58612. static QUEST_MODEL_BASE_URL: string;
  58613. /**
  58614. * @hidden
  58615. * If the controllers are running on a device that needs the updated Quest controller models
  58616. */
  58617. static _IsQuest: boolean;
  58618. /**
  58619. * Fired when the secondary trigger on this controller is modified
  58620. */
  58621. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58622. /**
  58623. * Fired when the thumb rest on this controller is modified
  58624. */
  58625. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58626. /**
  58627. * Creates a new OculusTouchController from a gamepad
  58628. * @param vrGamepad the gamepad that the controller should be created from
  58629. */
  58630. constructor(vrGamepad: any);
  58631. /**
  58632. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58633. * @param scene scene in which to add meshes
  58634. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58635. */
  58636. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58637. /**
  58638. * Fired when the A button on this controller is modified
  58639. */
  58640. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58641. /**
  58642. * Fired when the B button on this controller is modified
  58643. */
  58644. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58645. /**
  58646. * Fired when the X button on this controller is modified
  58647. */
  58648. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58649. /**
  58650. * Fired when the Y button on this controller is modified
  58651. */
  58652. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58653. /**
  58654. * Called once for each button that changed state since the last frame
  58655. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58656. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58657. * 2) secondary trigger (same)
  58658. * 3) A (right) X (left), touch, pressed = value
  58659. * 4) B / Y
  58660. * 5) thumb rest
  58661. * @param buttonIdx Which button index changed
  58662. * @param state New state of the button
  58663. * @param changes Which properties on the state changed since last frame
  58664. */
  58665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58666. }
  58667. }
  58668. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58669. import { Scene } from "babylonjs/scene";
  58670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58671. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58672. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58673. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58674. import { Observable } from "babylonjs/Misc/observable";
  58675. /**
  58676. * Vive Controller
  58677. */
  58678. export class ViveController extends WebVRController {
  58679. /**
  58680. * Base Url for the controller model.
  58681. */
  58682. static MODEL_BASE_URL: string;
  58683. /**
  58684. * File name for the controller model.
  58685. */
  58686. static MODEL_FILENAME: string;
  58687. /**
  58688. * Creates a new ViveController from a gamepad
  58689. * @param vrGamepad the gamepad that the controller should be created from
  58690. */
  58691. constructor(vrGamepad: any);
  58692. /**
  58693. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58694. * @param scene scene in which to add meshes
  58695. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58696. */
  58697. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58698. /**
  58699. * Fired when the left button on this controller is modified
  58700. */
  58701. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58702. /**
  58703. * Fired when the right button on this controller is modified
  58704. */
  58705. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58706. /**
  58707. * Fired when the menu button on this controller is modified
  58708. */
  58709. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58710. /**
  58711. * Called once for each button that changed state since the last frame
  58712. * Vive mapping:
  58713. * 0: touchpad
  58714. * 1: trigger
  58715. * 2: left AND right buttons
  58716. * 3: menu button
  58717. * @param buttonIdx Which button index changed
  58718. * @param state New state of the button
  58719. * @param changes Which properties on the state changed since last frame
  58720. */
  58721. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58722. }
  58723. }
  58724. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58725. import { Observable } from "babylonjs/Misc/observable";
  58726. import { Scene } from "babylonjs/scene";
  58727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58728. import { Ray } from "babylonjs/Culling/ray";
  58729. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58730. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58731. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58732. /**
  58733. * Defines the WindowsMotionController object that the state of the windows motion controller
  58734. */
  58735. export class WindowsMotionController extends WebVRController {
  58736. /**
  58737. * The base url used to load the left and right controller models
  58738. */
  58739. static MODEL_BASE_URL: string;
  58740. /**
  58741. * The name of the left controller model file
  58742. */
  58743. static MODEL_LEFT_FILENAME: string;
  58744. /**
  58745. * The name of the right controller model file
  58746. */
  58747. static MODEL_RIGHT_FILENAME: string;
  58748. /**
  58749. * The controller name prefix for this controller type
  58750. */
  58751. static readonly GAMEPAD_ID_PREFIX: string;
  58752. /**
  58753. * The controller id pattern for this controller type
  58754. */
  58755. private static readonly GAMEPAD_ID_PATTERN;
  58756. private _loadedMeshInfo;
  58757. protected readonly _mapping: {
  58758. buttons: string[];
  58759. buttonMeshNames: {
  58760. trigger: string;
  58761. menu: string;
  58762. grip: string;
  58763. thumbstick: string;
  58764. trackpad: string;
  58765. };
  58766. buttonObservableNames: {
  58767. trigger: string;
  58768. menu: string;
  58769. grip: string;
  58770. thumbstick: string;
  58771. trackpad: string;
  58772. };
  58773. axisMeshNames: string[];
  58774. pointingPoseMeshName: string;
  58775. };
  58776. /**
  58777. * Fired when the trackpad on this controller is clicked
  58778. */
  58779. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58780. /**
  58781. * Fired when the trackpad on this controller is modified
  58782. */
  58783. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58784. /**
  58785. * The current x and y values of this controller's trackpad
  58786. */
  58787. trackpad: StickValues;
  58788. /**
  58789. * Creates a new WindowsMotionController from a gamepad
  58790. * @param vrGamepad the gamepad that the controller should be created from
  58791. */
  58792. constructor(vrGamepad: any);
  58793. /**
  58794. * Fired when the trigger on this controller is modified
  58795. */
  58796. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58797. /**
  58798. * Fired when the menu button on this controller is modified
  58799. */
  58800. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58801. /**
  58802. * Fired when the grip button on this controller is modified
  58803. */
  58804. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58805. /**
  58806. * Fired when the thumbstick button on this controller is modified
  58807. */
  58808. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58809. /**
  58810. * Fired when the touchpad button on this controller is modified
  58811. */
  58812. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58813. /**
  58814. * Fired when the touchpad values on this controller are modified
  58815. */
  58816. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58817. protected _updateTrackpad(): void;
  58818. /**
  58819. * Called once per frame by the engine.
  58820. */
  58821. update(): void;
  58822. /**
  58823. * Called once for each button that changed state since the last frame
  58824. * @param buttonIdx Which button index changed
  58825. * @param state New state of the button
  58826. * @param changes Which properties on the state changed since last frame
  58827. */
  58828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58829. /**
  58830. * Moves the buttons on the controller mesh based on their current state
  58831. * @param buttonName the name of the button to move
  58832. * @param buttonValue the value of the button which determines the buttons new position
  58833. */
  58834. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58835. /**
  58836. * Moves the axis on the controller mesh based on its current state
  58837. * @param axis the index of the axis
  58838. * @param axisValue the value of the axis which determines the meshes new position
  58839. * @hidden
  58840. */
  58841. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58842. /**
  58843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58844. * @param scene scene in which to add meshes
  58845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58846. */
  58847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58848. /**
  58849. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58850. * can be transformed by button presses and axes values, based on this._mapping.
  58851. *
  58852. * @param scene scene in which the meshes exist
  58853. * @param meshes list of meshes that make up the controller model to process
  58854. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58855. */
  58856. private processModel;
  58857. private createMeshInfo;
  58858. /**
  58859. * Gets the ray of the controller in the direction the controller is pointing
  58860. * @param length the length the resulting ray should be
  58861. * @returns a ray in the direction the controller is pointing
  58862. */
  58863. getForwardRay(length?: number): Ray;
  58864. /**
  58865. * Disposes of the controller
  58866. */
  58867. dispose(): void;
  58868. }
  58869. /**
  58870. * This class represents a new windows motion controller in XR.
  58871. */
  58872. export class XRWindowsMotionController extends WindowsMotionController {
  58873. /**
  58874. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58875. */
  58876. protected readonly _mapping: {
  58877. buttons: string[];
  58878. buttonMeshNames: {
  58879. trigger: string;
  58880. menu: string;
  58881. grip: string;
  58882. thumbstick: string;
  58883. trackpad: string;
  58884. };
  58885. buttonObservableNames: {
  58886. trigger: string;
  58887. menu: string;
  58888. grip: string;
  58889. thumbstick: string;
  58890. trackpad: string;
  58891. };
  58892. axisMeshNames: string[];
  58893. pointingPoseMeshName: string;
  58894. };
  58895. /**
  58896. * Construct a new XR-Based windows motion controller
  58897. *
  58898. * @param gamepadInfo the gamepad object from the browser
  58899. */
  58900. constructor(gamepadInfo: any);
  58901. /**
  58902. * holds the thumbstick values (X,Y)
  58903. */
  58904. thumbstickValues: StickValues;
  58905. /**
  58906. * Fired when the thumbstick on this controller is clicked
  58907. */
  58908. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58909. /**
  58910. * Fired when the thumbstick on this controller is modified
  58911. */
  58912. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58913. /**
  58914. * Fired when the touchpad button on this controller is modified
  58915. */
  58916. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58917. /**
  58918. * Fired when the touchpad values on this controller are modified
  58919. */
  58920. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58921. /**
  58922. * Fired when the thumbstick button on this controller is modified
  58923. * here to prevent breaking changes
  58924. */
  58925. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58926. /**
  58927. * updating the thumbstick(!) and not the trackpad.
  58928. * This is named this way due to the difference between WebVR and XR and to avoid
  58929. * changing the parent class.
  58930. */
  58931. protected _updateTrackpad(): void;
  58932. /**
  58933. * Disposes the class with joy
  58934. */
  58935. dispose(): void;
  58936. }
  58937. }
  58938. declare module "babylonjs/Gamepads/Controllers/index" {
  58939. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58940. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58941. export * from "babylonjs/Gamepads/Controllers/genericController";
  58942. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58943. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58944. export * from "babylonjs/Gamepads/Controllers/viveController";
  58945. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58946. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58947. }
  58948. declare module "babylonjs/Gamepads/index" {
  58949. export * from "babylonjs/Gamepads/Controllers/index";
  58950. export * from "babylonjs/Gamepads/gamepad";
  58951. export * from "babylonjs/Gamepads/gamepadManager";
  58952. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58953. export * from "babylonjs/Gamepads/xboxGamepad";
  58954. export * from "babylonjs/Gamepads/dualShockGamepad";
  58955. }
  58956. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58957. import { Scene } from "babylonjs/scene";
  58958. import { Vector4 } from "babylonjs/Maths/math.vector";
  58959. import { Color4 } from "babylonjs/Maths/math.color";
  58960. import { Mesh } from "babylonjs/Meshes/mesh";
  58961. import { Nullable } from "babylonjs/types";
  58962. /**
  58963. * Class containing static functions to help procedurally build meshes
  58964. */
  58965. export class PolyhedronBuilder {
  58966. /**
  58967. * Creates a polyhedron mesh
  58968. * * 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
  58969. * * The parameter `size` (positive float, default 1) sets the polygon size
  58970. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58971. * * 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`
  58972. * * 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
  58973. * * 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)`)
  58974. * * 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
  58975. * * 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
  58976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58979. * @param name defines the name of the mesh
  58980. * @param options defines the options used to create the mesh
  58981. * @param scene defines the hosting scene
  58982. * @returns the polyhedron mesh
  58983. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58984. */
  58985. static CreatePolyhedron(name: string, options: {
  58986. type?: number;
  58987. size?: number;
  58988. sizeX?: number;
  58989. sizeY?: number;
  58990. sizeZ?: number;
  58991. custom?: any;
  58992. faceUV?: Vector4[];
  58993. faceColors?: Color4[];
  58994. flat?: boolean;
  58995. updatable?: boolean;
  58996. sideOrientation?: number;
  58997. frontUVs?: Vector4;
  58998. backUVs?: Vector4;
  58999. }, scene?: Nullable<Scene>): Mesh;
  59000. }
  59001. }
  59002. declare module "babylonjs/Gizmos/scaleGizmo" {
  59003. import { Observable } from "babylonjs/Misc/observable";
  59004. import { Nullable } from "babylonjs/types";
  59005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59006. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59007. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59008. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59009. import { Node } from "babylonjs/node";
  59010. /**
  59011. * Gizmo that enables scaling a mesh along 3 axis
  59012. */
  59013. export class ScaleGizmo extends Gizmo {
  59014. /**
  59015. * Internal gizmo used for interactions on the x axis
  59016. */
  59017. xGizmo: AxisScaleGizmo;
  59018. /**
  59019. * Internal gizmo used for interactions on the y axis
  59020. */
  59021. yGizmo: AxisScaleGizmo;
  59022. /**
  59023. * Internal gizmo used for interactions on the z axis
  59024. */
  59025. zGizmo: AxisScaleGizmo;
  59026. /**
  59027. * Internal gizmo used to scale all axis equally
  59028. */
  59029. uniformScaleGizmo: AxisScaleGizmo;
  59030. private _meshAttached;
  59031. private _nodeAttached;
  59032. private _snapDistance;
  59033. private _uniformScalingMesh;
  59034. private _octahedron;
  59035. private _sensitivity;
  59036. /** Fires an event when any of it's sub gizmos are dragged */
  59037. onDragStartObservable: Observable<unknown>;
  59038. /** Fires an event when any of it's sub gizmos are released from dragging */
  59039. onDragEndObservable: Observable<unknown>;
  59040. get attachedMesh(): Nullable<AbstractMesh>;
  59041. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59042. get attachedNode(): Nullable<Node>;
  59043. set attachedNode(node: Nullable<Node>);
  59044. /**
  59045. * True when the mouse pointer is hovering a gizmo mesh
  59046. */
  59047. get isHovered(): boolean;
  59048. /**
  59049. * Creates a ScaleGizmo
  59050. * @param gizmoLayer The utility layer the gizmo will be added to
  59051. * @param thickness display gizmo axis thickness
  59052. */
  59053. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59054. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59055. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59056. /**
  59057. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59058. */
  59059. set snapDistance(value: number);
  59060. get snapDistance(): number;
  59061. /**
  59062. * Ratio for the scale of the gizmo (Default: 1)
  59063. */
  59064. set scaleRatio(value: number);
  59065. get scaleRatio(): number;
  59066. /**
  59067. * Sensitivity factor for dragging (Default: 1)
  59068. */
  59069. set sensitivity(value: number);
  59070. get sensitivity(): number;
  59071. /**
  59072. * Disposes of the gizmo
  59073. */
  59074. dispose(): void;
  59075. }
  59076. }
  59077. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59078. import { Observable } from "babylonjs/Misc/observable";
  59079. import { Nullable } from "babylonjs/types";
  59080. import { Vector3 } from "babylonjs/Maths/math.vector";
  59081. import { Node } from "babylonjs/node";
  59082. import { Mesh } from "babylonjs/Meshes/mesh";
  59083. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59084. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59085. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59086. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59087. import { Color3 } from "babylonjs/Maths/math.color";
  59088. /**
  59089. * Single axis scale gizmo
  59090. */
  59091. export class AxisScaleGizmo extends Gizmo {
  59092. /**
  59093. * Drag behavior responsible for the gizmos dragging interactions
  59094. */
  59095. dragBehavior: PointerDragBehavior;
  59096. private _pointerObserver;
  59097. /**
  59098. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59099. */
  59100. snapDistance: number;
  59101. /**
  59102. * Event that fires each time the gizmo snaps to a new location.
  59103. * * snapDistance is the the change in distance
  59104. */
  59105. onSnapObservable: Observable<{
  59106. snapDistance: number;
  59107. }>;
  59108. /**
  59109. * If the scaling operation should be done on all axis (default: false)
  59110. */
  59111. uniformScaling: boolean;
  59112. /**
  59113. * Custom sensitivity value for the drag strength
  59114. */
  59115. sensitivity: number;
  59116. private _isEnabled;
  59117. private _parent;
  59118. private _arrow;
  59119. private _coloredMaterial;
  59120. private _hoverMaterial;
  59121. /**
  59122. * Creates an AxisScaleGizmo
  59123. * @param gizmoLayer The utility layer the gizmo will be added to
  59124. * @param dragAxis The axis which the gizmo will be able to scale on
  59125. * @param color The color of the gizmo
  59126. * @param thickness display gizmo axis thickness
  59127. */
  59128. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59129. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59130. /**
  59131. * If the gizmo is enabled
  59132. */
  59133. set isEnabled(value: boolean);
  59134. get isEnabled(): boolean;
  59135. /**
  59136. * Disposes of the gizmo
  59137. */
  59138. dispose(): void;
  59139. /**
  59140. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59141. * @param mesh The mesh to replace the default mesh of the gizmo
  59142. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59143. */
  59144. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59145. }
  59146. }
  59147. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59148. import { Observable } from "babylonjs/Misc/observable";
  59149. import { Nullable } from "babylonjs/types";
  59150. import { Vector3 } from "babylonjs/Maths/math.vector";
  59151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59152. import { Mesh } from "babylonjs/Meshes/mesh";
  59153. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59154. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59155. import { Color3 } from "babylonjs/Maths/math.color";
  59156. import "babylonjs/Meshes/Builders/boxBuilder";
  59157. /**
  59158. * Bounding box gizmo
  59159. */
  59160. export class BoundingBoxGizmo extends Gizmo {
  59161. private _lineBoundingBox;
  59162. private _rotateSpheresParent;
  59163. private _scaleBoxesParent;
  59164. private _boundingDimensions;
  59165. private _renderObserver;
  59166. private _pointerObserver;
  59167. private _scaleDragSpeed;
  59168. private _tmpQuaternion;
  59169. private _tmpVector;
  59170. private _tmpRotationMatrix;
  59171. /**
  59172. * 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)
  59173. */
  59174. ignoreChildren: boolean;
  59175. /**
  59176. * 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)
  59177. */
  59178. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59179. /**
  59180. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59181. */
  59182. rotationSphereSize: number;
  59183. /**
  59184. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59185. */
  59186. scaleBoxSize: number;
  59187. /**
  59188. * 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)
  59189. */
  59190. fixedDragMeshScreenSize: boolean;
  59191. /**
  59192. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59193. */
  59194. fixedDragMeshScreenSizeDistanceFactor: number;
  59195. /**
  59196. * Fired when a rotation sphere or scale box is dragged
  59197. */
  59198. onDragStartObservable: Observable<{}>;
  59199. /**
  59200. * Fired when a scale box is dragged
  59201. */
  59202. onScaleBoxDragObservable: Observable<{}>;
  59203. /**
  59204. * Fired when a scale box drag is ended
  59205. */
  59206. onScaleBoxDragEndObservable: Observable<{}>;
  59207. /**
  59208. * Fired when a rotation sphere is dragged
  59209. */
  59210. onRotationSphereDragObservable: Observable<{}>;
  59211. /**
  59212. * Fired when a rotation sphere drag is ended
  59213. */
  59214. onRotationSphereDragEndObservable: Observable<{}>;
  59215. /**
  59216. * 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)
  59217. */
  59218. scalePivot: Nullable<Vector3>;
  59219. /**
  59220. * Mesh used as a pivot to rotate the attached node
  59221. */
  59222. private _anchorMesh;
  59223. private _existingMeshScale;
  59224. private _dragMesh;
  59225. private pointerDragBehavior;
  59226. private coloredMaterial;
  59227. private hoverColoredMaterial;
  59228. /**
  59229. * Sets the color of the bounding box gizmo
  59230. * @param color the color to set
  59231. */
  59232. setColor(color: Color3): void;
  59233. /**
  59234. * Creates an BoundingBoxGizmo
  59235. * @param gizmoLayer The utility layer the gizmo will be added to
  59236. * @param color The color of the gizmo
  59237. */
  59238. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59239. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59240. private _selectNode;
  59241. /**
  59242. * Updates the bounding box information for the Gizmo
  59243. */
  59244. updateBoundingBox(): void;
  59245. private _updateRotationSpheres;
  59246. private _updateScaleBoxes;
  59247. /**
  59248. * Enables rotation on the specified axis and disables rotation on the others
  59249. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59250. */
  59251. setEnabledRotationAxis(axis: string): void;
  59252. /**
  59253. * Enables/disables scaling
  59254. * @param enable if scaling should be enabled
  59255. * @param homogeneousScaling defines if scaling should only be homogeneous
  59256. */
  59257. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59258. private _updateDummy;
  59259. /**
  59260. * Enables a pointer drag behavior on the bounding box of the gizmo
  59261. */
  59262. enableDragBehavior(): void;
  59263. /**
  59264. * Disposes of the gizmo
  59265. */
  59266. dispose(): void;
  59267. /**
  59268. * 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)
  59269. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59270. * @returns the bounding box mesh with the passed in mesh as a child
  59271. */
  59272. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59273. /**
  59274. * CustomMeshes are not supported by this gizmo
  59275. * @param mesh The mesh to replace the default mesh of the gizmo
  59276. */
  59277. setCustomMesh(mesh: Mesh): void;
  59278. }
  59279. }
  59280. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59281. import { Observable } from "babylonjs/Misc/observable";
  59282. import { Nullable } from "babylonjs/types";
  59283. import { Vector3 } from "babylonjs/Maths/math.vector";
  59284. import { Color3 } from "babylonjs/Maths/math.color";
  59285. import { Node } from "babylonjs/node";
  59286. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59287. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59288. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59289. import "babylonjs/Meshes/Builders/linesBuilder";
  59290. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59291. /**
  59292. * Single plane rotation gizmo
  59293. */
  59294. export class PlaneRotationGizmo extends Gizmo {
  59295. /**
  59296. * Drag behavior responsible for the gizmos dragging interactions
  59297. */
  59298. dragBehavior: PointerDragBehavior;
  59299. private _pointerObserver;
  59300. /**
  59301. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59302. */
  59303. snapDistance: number;
  59304. /**
  59305. * Event that fires each time the gizmo snaps to a new location.
  59306. * * snapDistance is the the change in distance
  59307. */
  59308. onSnapObservable: Observable<{
  59309. snapDistance: number;
  59310. }>;
  59311. private _isEnabled;
  59312. private _parent;
  59313. /**
  59314. * Creates a PlaneRotationGizmo
  59315. * @param gizmoLayer The utility layer the gizmo will be added to
  59316. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59317. * @param color The color of the gizmo
  59318. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59319. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59320. * @param thickness display gizmo axis thickness
  59321. */
  59322. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59323. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59324. /**
  59325. * If the gizmo is enabled
  59326. */
  59327. set isEnabled(value: boolean);
  59328. get isEnabled(): boolean;
  59329. /**
  59330. * Disposes of the gizmo
  59331. */
  59332. dispose(): void;
  59333. }
  59334. }
  59335. declare module "babylonjs/Gizmos/rotationGizmo" {
  59336. import { Observable } from "babylonjs/Misc/observable";
  59337. import { Nullable } from "babylonjs/types";
  59338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59339. import { Mesh } from "babylonjs/Meshes/mesh";
  59340. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59341. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59342. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59343. import { Node } from "babylonjs/node";
  59344. /**
  59345. * Gizmo that enables rotating a mesh along 3 axis
  59346. */
  59347. export class RotationGizmo extends Gizmo {
  59348. /**
  59349. * Internal gizmo used for interactions on the x axis
  59350. */
  59351. xGizmo: PlaneRotationGizmo;
  59352. /**
  59353. * Internal gizmo used for interactions on the y axis
  59354. */
  59355. yGizmo: PlaneRotationGizmo;
  59356. /**
  59357. * Internal gizmo used for interactions on the z axis
  59358. */
  59359. zGizmo: PlaneRotationGizmo;
  59360. /** Fires an event when any of it's sub gizmos are dragged */
  59361. onDragStartObservable: Observable<unknown>;
  59362. /** Fires an event when any of it's sub gizmos are released from dragging */
  59363. onDragEndObservable: Observable<unknown>;
  59364. private _meshAttached;
  59365. private _nodeAttached;
  59366. get attachedMesh(): Nullable<AbstractMesh>;
  59367. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59368. get attachedNode(): Nullable<Node>;
  59369. set attachedNode(node: Nullable<Node>);
  59370. protected _checkBillboardTransform(): void;
  59371. /**
  59372. * True when the mouse pointer is hovering a gizmo mesh
  59373. */
  59374. get isHovered(): boolean;
  59375. /**
  59376. * Creates a RotationGizmo
  59377. * @param gizmoLayer The utility layer the gizmo will be added to
  59378. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59379. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59380. * @param thickness display gizmo axis thickness
  59381. */
  59382. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59383. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59384. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59385. /**
  59386. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59387. */
  59388. set snapDistance(value: number);
  59389. get snapDistance(): number;
  59390. /**
  59391. * Ratio for the scale of the gizmo (Default: 1)
  59392. */
  59393. set scaleRatio(value: number);
  59394. get scaleRatio(): number;
  59395. /**
  59396. * Disposes of the gizmo
  59397. */
  59398. dispose(): void;
  59399. /**
  59400. * CustomMeshes are not supported by this gizmo
  59401. * @param mesh The mesh to replace the default mesh of the gizmo
  59402. */
  59403. setCustomMesh(mesh: Mesh): void;
  59404. }
  59405. }
  59406. declare module "babylonjs/Gizmos/gizmoManager" {
  59407. import { Observable } from "babylonjs/Misc/observable";
  59408. import { Nullable } from "babylonjs/types";
  59409. import { Scene, IDisposable } from "babylonjs/scene";
  59410. import { Node } from "babylonjs/node";
  59411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59412. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59413. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59414. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59415. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59416. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59417. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59418. /**
  59419. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59420. */
  59421. export class GizmoManager implements IDisposable {
  59422. private scene;
  59423. /**
  59424. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59425. */
  59426. gizmos: {
  59427. positionGizmo: Nullable<PositionGizmo>;
  59428. rotationGizmo: Nullable<RotationGizmo>;
  59429. scaleGizmo: Nullable<ScaleGizmo>;
  59430. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59431. };
  59432. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59433. clearGizmoOnEmptyPointerEvent: boolean;
  59434. /** Fires an event when the manager is attached to a mesh */
  59435. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59436. /** Fires an event when the manager is attached to a node */
  59437. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59438. private _gizmosEnabled;
  59439. private _pointerObserver;
  59440. private _attachedMesh;
  59441. private _attachedNode;
  59442. private _boundingBoxColor;
  59443. private _defaultUtilityLayer;
  59444. private _defaultKeepDepthUtilityLayer;
  59445. private _thickness;
  59446. /**
  59447. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59448. */
  59449. boundingBoxDragBehavior: SixDofDragBehavior;
  59450. /**
  59451. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59452. */
  59453. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59454. /**
  59455. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59456. */
  59457. attachableNodes: Nullable<Array<Node>>;
  59458. /**
  59459. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59460. */
  59461. usePointerToAttachGizmos: boolean;
  59462. /**
  59463. * Utility layer that the bounding box gizmo belongs to
  59464. */
  59465. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59466. /**
  59467. * Utility layer that all gizmos besides bounding box belong to
  59468. */
  59469. get utilityLayer(): UtilityLayerRenderer;
  59470. /**
  59471. * True when the mouse pointer is hovering a gizmo mesh
  59472. */
  59473. get isHovered(): boolean;
  59474. /**
  59475. * Instatiates a gizmo manager
  59476. * @param scene the scene to overlay the gizmos on top of
  59477. * @param thickness display gizmo axis thickness
  59478. */
  59479. constructor(scene: Scene, thickness?: number);
  59480. /**
  59481. * Attaches a set of gizmos to the specified mesh
  59482. * @param mesh The mesh the gizmo's should be attached to
  59483. */
  59484. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59485. /**
  59486. * Attaches a set of gizmos to the specified node
  59487. * @param node The node the gizmo's should be attached to
  59488. */
  59489. attachToNode(node: Nullable<Node>): void;
  59490. /**
  59491. * If the position gizmo is enabled
  59492. */
  59493. set positionGizmoEnabled(value: boolean);
  59494. get positionGizmoEnabled(): boolean;
  59495. /**
  59496. * If the rotation gizmo is enabled
  59497. */
  59498. set rotationGizmoEnabled(value: boolean);
  59499. get rotationGizmoEnabled(): boolean;
  59500. /**
  59501. * If the scale gizmo is enabled
  59502. */
  59503. set scaleGizmoEnabled(value: boolean);
  59504. get scaleGizmoEnabled(): boolean;
  59505. /**
  59506. * If the boundingBox gizmo is enabled
  59507. */
  59508. set boundingBoxGizmoEnabled(value: boolean);
  59509. get boundingBoxGizmoEnabled(): boolean;
  59510. /**
  59511. * Disposes of the gizmo manager
  59512. */
  59513. dispose(): void;
  59514. }
  59515. }
  59516. declare module "babylonjs/Lights/directionalLight" {
  59517. import { Camera } from "babylonjs/Cameras/camera";
  59518. import { Scene } from "babylonjs/scene";
  59519. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59521. import { Light } from "babylonjs/Lights/light";
  59522. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59523. import { Effect } from "babylonjs/Materials/effect";
  59524. /**
  59525. * A directional light is defined by a direction (what a surprise!).
  59526. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59527. * 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.
  59528. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59529. */
  59530. export class DirectionalLight extends ShadowLight {
  59531. private _shadowFrustumSize;
  59532. /**
  59533. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59534. */
  59535. get shadowFrustumSize(): number;
  59536. /**
  59537. * Specifies a fix frustum size for the shadow generation.
  59538. */
  59539. set shadowFrustumSize(value: number);
  59540. private _shadowOrthoScale;
  59541. /**
  59542. * Gets the shadow projection scale against the optimal computed one.
  59543. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59544. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59545. */
  59546. get shadowOrthoScale(): number;
  59547. /**
  59548. * Sets the shadow projection scale against the optimal computed one.
  59549. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59550. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59551. */
  59552. set shadowOrthoScale(value: number);
  59553. /**
  59554. * Automatically compute the projection matrix to best fit (including all the casters)
  59555. * on each frame.
  59556. */
  59557. autoUpdateExtends: boolean;
  59558. /**
  59559. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59560. * on each frame. autoUpdateExtends must be set to true for this to work
  59561. */
  59562. autoCalcShadowZBounds: boolean;
  59563. private _orthoLeft;
  59564. private _orthoRight;
  59565. private _orthoTop;
  59566. private _orthoBottom;
  59567. /**
  59568. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59569. * The directional light is emitted from everywhere in the given direction.
  59570. * It can cast shadows.
  59571. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59572. * @param name The friendly name of the light
  59573. * @param direction The direction of the light
  59574. * @param scene The scene the light belongs to
  59575. */
  59576. constructor(name: string, direction: Vector3, scene: Scene);
  59577. /**
  59578. * Returns the string "DirectionalLight".
  59579. * @return The class name
  59580. */
  59581. getClassName(): string;
  59582. /**
  59583. * Returns the integer 1.
  59584. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59585. */
  59586. getTypeID(): number;
  59587. /**
  59588. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59589. * Returns the DirectionalLight Shadow projection matrix.
  59590. */
  59591. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59592. /**
  59593. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59594. * Returns the DirectionalLight Shadow projection matrix.
  59595. */
  59596. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59597. /**
  59598. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59599. * Returns the DirectionalLight Shadow projection matrix.
  59600. */
  59601. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59602. protected _buildUniformLayout(): void;
  59603. /**
  59604. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59605. * @param effect The effect to update
  59606. * @param lightIndex The index of the light in the effect to update
  59607. * @returns The directional light
  59608. */
  59609. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59610. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59611. /**
  59612. * Gets the minZ used for shadow according to both the scene and the light.
  59613. *
  59614. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59615. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59616. * @param activeCamera The camera we are returning the min for
  59617. * @returns the depth min z
  59618. */
  59619. getDepthMinZ(activeCamera: Camera): number;
  59620. /**
  59621. * Gets the maxZ used for shadow according to both the scene and the light.
  59622. *
  59623. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59624. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59625. * @param activeCamera The camera we are returning the max for
  59626. * @returns the depth max z
  59627. */
  59628. getDepthMaxZ(activeCamera: Camera): number;
  59629. /**
  59630. * Prepares the list of defines specific to the light type.
  59631. * @param defines the list of defines
  59632. * @param lightIndex defines the index of the light for the effect
  59633. */
  59634. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59635. }
  59636. }
  59637. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59638. import { Mesh } from "babylonjs/Meshes/mesh";
  59639. /**
  59640. * Class containing static functions to help procedurally build meshes
  59641. */
  59642. export class HemisphereBuilder {
  59643. /**
  59644. * Creates a hemisphere mesh
  59645. * @param name defines the name of the mesh
  59646. * @param options defines the options used to create the mesh
  59647. * @param scene defines the hosting scene
  59648. * @returns the hemisphere mesh
  59649. */
  59650. static CreateHemisphere(name: string, options: {
  59651. segments?: number;
  59652. diameter?: number;
  59653. sideOrientation?: number;
  59654. }, scene: any): Mesh;
  59655. }
  59656. }
  59657. declare module "babylonjs/Lights/spotLight" {
  59658. import { Nullable } from "babylonjs/types";
  59659. import { Scene } from "babylonjs/scene";
  59660. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59662. import { Effect } from "babylonjs/Materials/effect";
  59663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59664. import { Light } from "babylonjs/Lights/light";
  59665. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59666. /**
  59667. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59668. * These values define a cone of light starting from the position, emitting toward the direction.
  59669. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59670. * and the exponent defines the speed of the decay of the light with distance (reach).
  59671. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59672. */
  59673. export class SpotLight extends ShadowLight {
  59674. private _angle;
  59675. private _innerAngle;
  59676. private _cosHalfAngle;
  59677. private _lightAngleScale;
  59678. private _lightAngleOffset;
  59679. /**
  59680. * Gets the cone angle of the spot light in Radians.
  59681. */
  59682. get angle(): number;
  59683. /**
  59684. * Sets the cone angle of the spot light in Radians.
  59685. */
  59686. set angle(value: number);
  59687. /**
  59688. * Only used in gltf falloff mode, this defines the angle where
  59689. * the directional falloff will start before cutting at angle which could be seen
  59690. * as outer angle.
  59691. */
  59692. get innerAngle(): number;
  59693. /**
  59694. * Only used in gltf falloff mode, this defines the angle where
  59695. * the directional falloff will start before cutting at angle which could be seen
  59696. * as outer angle.
  59697. */
  59698. set innerAngle(value: number);
  59699. private _shadowAngleScale;
  59700. /**
  59701. * Allows scaling the angle of the light for shadow generation only.
  59702. */
  59703. get shadowAngleScale(): number;
  59704. /**
  59705. * Allows scaling the angle of the light for shadow generation only.
  59706. */
  59707. set shadowAngleScale(value: number);
  59708. /**
  59709. * The light decay speed with the distance from the emission spot.
  59710. */
  59711. exponent: number;
  59712. private _projectionTextureMatrix;
  59713. /**
  59714. * Allows reading the projecton texture
  59715. */
  59716. get projectionTextureMatrix(): Matrix;
  59717. protected _projectionTextureLightNear: number;
  59718. /**
  59719. * Gets the near clip of the Spotlight for texture projection.
  59720. */
  59721. get projectionTextureLightNear(): number;
  59722. /**
  59723. * Sets the near clip of the Spotlight for texture projection.
  59724. */
  59725. set projectionTextureLightNear(value: number);
  59726. protected _projectionTextureLightFar: number;
  59727. /**
  59728. * Gets the far clip of the Spotlight for texture projection.
  59729. */
  59730. get projectionTextureLightFar(): number;
  59731. /**
  59732. * Sets the far clip of the Spotlight for texture projection.
  59733. */
  59734. set projectionTextureLightFar(value: number);
  59735. protected _projectionTextureUpDirection: Vector3;
  59736. /**
  59737. * Gets the Up vector of the Spotlight for texture projection.
  59738. */
  59739. get projectionTextureUpDirection(): Vector3;
  59740. /**
  59741. * Sets the Up vector of the Spotlight for texture projection.
  59742. */
  59743. set projectionTextureUpDirection(value: Vector3);
  59744. private _projectionTexture;
  59745. /**
  59746. * Gets the projection texture of the light.
  59747. */
  59748. get projectionTexture(): Nullable<BaseTexture>;
  59749. /**
  59750. * Sets the projection texture of the light.
  59751. */
  59752. set projectionTexture(value: Nullable<BaseTexture>);
  59753. private _projectionTextureViewLightDirty;
  59754. private _projectionTextureProjectionLightDirty;
  59755. private _projectionTextureDirty;
  59756. private _projectionTextureViewTargetVector;
  59757. private _projectionTextureViewLightMatrix;
  59758. private _projectionTextureProjectionLightMatrix;
  59759. private _projectionTextureScalingMatrix;
  59760. /**
  59761. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59762. * It can cast shadows.
  59763. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59764. * @param name The light friendly name
  59765. * @param position The position of the spot light in the scene
  59766. * @param direction The direction of the light in the scene
  59767. * @param angle The cone angle of the light in Radians
  59768. * @param exponent The light decay speed with the distance from the emission spot
  59769. * @param scene The scene the lights belongs to
  59770. */
  59771. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59772. /**
  59773. * Returns the string "SpotLight".
  59774. * @returns the class name
  59775. */
  59776. getClassName(): string;
  59777. /**
  59778. * Returns the integer 2.
  59779. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59780. */
  59781. getTypeID(): number;
  59782. /**
  59783. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59784. */
  59785. protected _setDirection(value: Vector3): void;
  59786. /**
  59787. * Overrides the position setter to recompute the projection texture view light Matrix.
  59788. */
  59789. protected _setPosition(value: Vector3): void;
  59790. /**
  59791. * 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.
  59792. * Returns the SpotLight.
  59793. */
  59794. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59795. protected _computeProjectionTextureViewLightMatrix(): void;
  59796. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59797. /**
  59798. * Main function for light texture projection matrix computing.
  59799. */
  59800. protected _computeProjectionTextureMatrix(): void;
  59801. protected _buildUniformLayout(): void;
  59802. private _computeAngleValues;
  59803. /**
  59804. * Sets the passed Effect "effect" with the Light textures.
  59805. * @param effect The effect to update
  59806. * @param lightIndex The index of the light in the effect to update
  59807. * @returns The light
  59808. */
  59809. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59810. /**
  59811. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59812. * @param effect The effect to update
  59813. * @param lightIndex The index of the light in the effect to update
  59814. * @returns The spot light
  59815. */
  59816. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59817. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59818. /**
  59819. * Disposes the light and the associated resources.
  59820. */
  59821. dispose(): void;
  59822. /**
  59823. * Prepares the list of defines specific to the light type.
  59824. * @param defines the list of defines
  59825. * @param lightIndex defines the index of the light for the effect
  59826. */
  59827. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59828. }
  59829. }
  59830. declare module "babylonjs/Gizmos/lightGizmo" {
  59831. import { Nullable } from "babylonjs/types";
  59832. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59833. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59834. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59835. import { Light } from "babylonjs/Lights/light";
  59836. import { Observable } from "babylonjs/Misc/observable";
  59837. /**
  59838. * Gizmo that enables viewing a light
  59839. */
  59840. export class LightGizmo extends Gizmo {
  59841. private _lightMesh;
  59842. private _material;
  59843. private _cachedPosition;
  59844. private _cachedForward;
  59845. private _attachedMeshParent;
  59846. private _pointerObserver;
  59847. /**
  59848. * Event that fires each time the gizmo is clicked
  59849. */
  59850. onClickedObservable: Observable<Light>;
  59851. /**
  59852. * Creates a LightGizmo
  59853. * @param gizmoLayer The utility layer the gizmo will be added to
  59854. */
  59855. constructor(gizmoLayer?: UtilityLayerRenderer);
  59856. private _light;
  59857. /**
  59858. * The light that the gizmo is attached to
  59859. */
  59860. set light(light: Nullable<Light>);
  59861. get light(): Nullable<Light>;
  59862. /**
  59863. * Gets the material used to render the light gizmo
  59864. */
  59865. get material(): StandardMaterial;
  59866. /**
  59867. * @hidden
  59868. * Updates the gizmo to match the attached mesh's position/rotation
  59869. */
  59870. protected _update(): void;
  59871. private static _Scale;
  59872. /**
  59873. * Creates the lines for a light mesh
  59874. */
  59875. private static _CreateLightLines;
  59876. /**
  59877. * Disposes of the light gizmo
  59878. */
  59879. dispose(): void;
  59880. private static _CreateHemisphericLightMesh;
  59881. private static _CreatePointLightMesh;
  59882. private static _CreateSpotLightMesh;
  59883. private static _CreateDirectionalLightMesh;
  59884. }
  59885. }
  59886. declare module "babylonjs/Gizmos/cameraGizmo" {
  59887. import { Nullable } from "babylonjs/types";
  59888. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59889. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59890. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59891. import { Camera } from "babylonjs/Cameras/camera";
  59892. import { Observable } from "babylonjs/Misc/observable";
  59893. /**
  59894. * Gizmo that enables viewing a camera
  59895. */
  59896. export class CameraGizmo extends Gizmo {
  59897. private _cameraMesh;
  59898. private _cameraLinesMesh;
  59899. private _material;
  59900. private _pointerObserver;
  59901. /**
  59902. * Event that fires each time the gizmo is clicked
  59903. */
  59904. onClickedObservable: Observable<Camera>;
  59905. /**
  59906. * Creates a CameraGizmo
  59907. * @param gizmoLayer The utility layer the gizmo will be added to
  59908. */
  59909. constructor(gizmoLayer?: UtilityLayerRenderer);
  59910. private _camera;
  59911. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59912. get displayFrustum(): boolean;
  59913. set displayFrustum(value: boolean);
  59914. /**
  59915. * The camera that the gizmo is attached to
  59916. */
  59917. set camera(camera: Nullable<Camera>);
  59918. get camera(): Nullable<Camera>;
  59919. /**
  59920. * Gets the material used to render the camera gizmo
  59921. */
  59922. get material(): StandardMaterial;
  59923. /**
  59924. * @hidden
  59925. * Updates the gizmo to match the attached mesh's position/rotation
  59926. */
  59927. protected _update(): void;
  59928. private static _Scale;
  59929. private _invProjection;
  59930. /**
  59931. * Disposes of the camera gizmo
  59932. */
  59933. dispose(): void;
  59934. private static _CreateCameraMesh;
  59935. private static _CreateCameraFrustum;
  59936. }
  59937. }
  59938. declare module "babylonjs/Gizmos/index" {
  59939. export * from "babylonjs/Gizmos/axisDragGizmo";
  59940. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59941. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59942. export * from "babylonjs/Gizmos/gizmo";
  59943. export * from "babylonjs/Gizmos/gizmoManager";
  59944. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59945. export * from "babylonjs/Gizmos/positionGizmo";
  59946. export * from "babylonjs/Gizmos/rotationGizmo";
  59947. export * from "babylonjs/Gizmos/scaleGizmo";
  59948. export * from "babylonjs/Gizmos/lightGizmo";
  59949. export * from "babylonjs/Gizmos/cameraGizmo";
  59950. export * from "babylonjs/Gizmos/planeDragGizmo";
  59951. }
  59952. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59953. /** @hidden */
  59954. export var backgroundFragmentDeclaration: {
  59955. name: string;
  59956. shader: string;
  59957. };
  59958. }
  59959. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59960. /** @hidden */
  59961. export var backgroundUboDeclaration: {
  59962. name: string;
  59963. shader: string;
  59964. };
  59965. }
  59966. declare module "babylonjs/Shaders/background.fragment" {
  59967. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59968. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59969. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59970. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59971. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59972. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59973. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59974. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59975. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59976. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59977. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59978. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59979. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59980. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59981. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59982. /** @hidden */
  59983. export var backgroundPixelShader: {
  59984. name: string;
  59985. shader: string;
  59986. };
  59987. }
  59988. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59989. /** @hidden */
  59990. export var backgroundVertexDeclaration: {
  59991. name: string;
  59992. shader: string;
  59993. };
  59994. }
  59995. declare module "babylonjs/Shaders/background.vertex" {
  59996. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59997. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59998. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59999. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60000. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60001. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60002. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60003. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60004. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60008. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60009. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60010. /** @hidden */
  60011. export var backgroundVertexShader: {
  60012. name: string;
  60013. shader: string;
  60014. };
  60015. }
  60016. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60017. import { Nullable, int, float } from "babylonjs/types";
  60018. import { Scene } from "babylonjs/scene";
  60019. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60020. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60022. import { Mesh } from "babylonjs/Meshes/mesh";
  60023. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60024. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60025. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60027. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60028. import { Color3 } from "babylonjs/Maths/math.color";
  60029. import "babylonjs/Shaders/background.fragment";
  60030. import "babylonjs/Shaders/background.vertex";
  60031. /**
  60032. * Background material used to create an efficient environement around your scene.
  60033. */
  60034. export class BackgroundMaterial extends PushMaterial {
  60035. /**
  60036. * Standard reflectance value at parallel view angle.
  60037. */
  60038. static StandardReflectance0: number;
  60039. /**
  60040. * Standard reflectance value at grazing angle.
  60041. */
  60042. static StandardReflectance90: number;
  60043. protected _primaryColor: Color3;
  60044. /**
  60045. * Key light Color (multiply against the environement texture)
  60046. */
  60047. primaryColor: Color3;
  60048. protected __perceptualColor: Nullable<Color3>;
  60049. /**
  60050. * Experimental Internal Use Only.
  60051. *
  60052. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60053. * This acts as a helper to set the primary color to a more "human friendly" value.
  60054. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60055. * output color as close as possible from the chosen value.
  60056. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60057. * part of lighting setup.)
  60058. */
  60059. get _perceptualColor(): Nullable<Color3>;
  60060. set _perceptualColor(value: Nullable<Color3>);
  60061. protected _primaryColorShadowLevel: float;
  60062. /**
  60063. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60064. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60065. */
  60066. get primaryColorShadowLevel(): float;
  60067. set primaryColorShadowLevel(value: float);
  60068. protected _primaryColorHighlightLevel: float;
  60069. /**
  60070. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60071. * The primary color is used at the level chosen to define what the white area would look.
  60072. */
  60073. get primaryColorHighlightLevel(): float;
  60074. set primaryColorHighlightLevel(value: float);
  60075. protected _reflectionTexture: Nullable<BaseTexture>;
  60076. /**
  60077. * Reflection Texture used in the material.
  60078. * Should be author in a specific way for the best result (refer to the documentation).
  60079. */
  60080. reflectionTexture: Nullable<BaseTexture>;
  60081. protected _reflectionBlur: float;
  60082. /**
  60083. * Reflection Texture level of blur.
  60084. *
  60085. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60086. * texture twice.
  60087. */
  60088. reflectionBlur: float;
  60089. protected _diffuseTexture: Nullable<BaseTexture>;
  60090. /**
  60091. * Diffuse Texture used in the material.
  60092. * Should be author in a specific way for the best result (refer to the documentation).
  60093. */
  60094. diffuseTexture: Nullable<BaseTexture>;
  60095. protected _shadowLights: Nullable<IShadowLight[]>;
  60096. /**
  60097. * Specify the list of lights casting shadow on the material.
  60098. * All scene shadow lights will be included if null.
  60099. */
  60100. shadowLights: Nullable<IShadowLight[]>;
  60101. protected _shadowLevel: float;
  60102. /**
  60103. * Helps adjusting the shadow to a softer level if required.
  60104. * 0 means black shadows and 1 means no shadows.
  60105. */
  60106. shadowLevel: float;
  60107. protected _sceneCenter: Vector3;
  60108. /**
  60109. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60110. * It is usually zero but might be interesting to modify according to your setup.
  60111. */
  60112. sceneCenter: Vector3;
  60113. protected _opacityFresnel: boolean;
  60114. /**
  60115. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60116. * This helps ensuring a nice transition when the camera goes under the ground.
  60117. */
  60118. opacityFresnel: boolean;
  60119. protected _reflectionFresnel: boolean;
  60120. /**
  60121. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60122. * This helps adding a mirror texture on the ground.
  60123. */
  60124. reflectionFresnel: boolean;
  60125. protected _reflectionFalloffDistance: number;
  60126. /**
  60127. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60128. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60129. */
  60130. reflectionFalloffDistance: number;
  60131. protected _reflectionAmount: number;
  60132. /**
  60133. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60134. */
  60135. reflectionAmount: number;
  60136. protected _reflectionReflectance0: number;
  60137. /**
  60138. * This specifies the weight of the reflection at grazing angle.
  60139. */
  60140. reflectionReflectance0: number;
  60141. protected _reflectionReflectance90: number;
  60142. /**
  60143. * This specifies the weight of the reflection at a perpendicular point of view.
  60144. */
  60145. reflectionReflectance90: number;
  60146. /**
  60147. * Sets the reflection reflectance fresnel values according to the default standard
  60148. * empirically know to work well :-)
  60149. */
  60150. set reflectionStandardFresnelWeight(value: number);
  60151. protected _useRGBColor: boolean;
  60152. /**
  60153. * Helps to directly use the maps channels instead of their level.
  60154. */
  60155. useRGBColor: boolean;
  60156. protected _enableNoise: boolean;
  60157. /**
  60158. * This helps reducing the banding effect that could occur on the background.
  60159. */
  60160. enableNoise: boolean;
  60161. /**
  60162. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60163. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60164. * Recommended to be keep at 1.0 except for special cases.
  60165. */
  60166. get fovMultiplier(): number;
  60167. set fovMultiplier(value: number);
  60168. private _fovMultiplier;
  60169. /**
  60170. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60171. */
  60172. useEquirectangularFOV: boolean;
  60173. private _maxSimultaneousLights;
  60174. /**
  60175. * Number of Simultaneous lights allowed on the material.
  60176. */
  60177. maxSimultaneousLights: int;
  60178. private _shadowOnly;
  60179. /**
  60180. * Make the material only render shadows
  60181. */
  60182. shadowOnly: boolean;
  60183. /**
  60184. * Default configuration related to image processing available in the Background Material.
  60185. */
  60186. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60187. /**
  60188. * Keep track of the image processing observer to allow dispose and replace.
  60189. */
  60190. private _imageProcessingObserver;
  60191. /**
  60192. * Attaches a new image processing configuration to the PBR Material.
  60193. * @param configuration (if null the scene configuration will be use)
  60194. */
  60195. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60196. /**
  60197. * Gets the image processing configuration used either in this material.
  60198. */
  60199. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60200. /**
  60201. * Sets the Default image processing configuration used either in the this material.
  60202. *
  60203. * If sets to null, the scene one is in use.
  60204. */
  60205. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60206. /**
  60207. * Gets wether the color curves effect is enabled.
  60208. */
  60209. get cameraColorCurvesEnabled(): boolean;
  60210. /**
  60211. * Sets wether the color curves effect is enabled.
  60212. */
  60213. set cameraColorCurvesEnabled(value: boolean);
  60214. /**
  60215. * Gets wether the color grading effect is enabled.
  60216. */
  60217. get cameraColorGradingEnabled(): boolean;
  60218. /**
  60219. * Gets wether the color grading effect is enabled.
  60220. */
  60221. set cameraColorGradingEnabled(value: boolean);
  60222. /**
  60223. * Gets wether tonemapping is enabled or not.
  60224. */
  60225. get cameraToneMappingEnabled(): boolean;
  60226. /**
  60227. * Sets wether tonemapping is enabled or not
  60228. */
  60229. set cameraToneMappingEnabled(value: boolean);
  60230. /**
  60231. * The camera exposure used on this material.
  60232. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60233. * This corresponds to a photographic exposure.
  60234. */
  60235. get cameraExposure(): float;
  60236. /**
  60237. * The camera exposure used on this material.
  60238. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60239. * This corresponds to a photographic exposure.
  60240. */
  60241. set cameraExposure(value: float);
  60242. /**
  60243. * Gets The camera contrast used on this material.
  60244. */
  60245. get cameraContrast(): float;
  60246. /**
  60247. * Sets The camera contrast used on this material.
  60248. */
  60249. set cameraContrast(value: float);
  60250. /**
  60251. * Gets the Color Grading 2D Lookup Texture.
  60252. */
  60253. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60254. /**
  60255. * Sets the Color Grading 2D Lookup Texture.
  60256. */
  60257. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60258. /**
  60259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60261. * 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;
  60262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60263. */
  60264. get cameraColorCurves(): Nullable<ColorCurves>;
  60265. /**
  60266. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60267. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60268. * 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;
  60269. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60270. */
  60271. set cameraColorCurves(value: Nullable<ColorCurves>);
  60272. /**
  60273. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60274. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60275. */
  60276. switchToBGR: boolean;
  60277. private _renderTargets;
  60278. private _reflectionControls;
  60279. private _white;
  60280. private _primaryShadowColor;
  60281. private _primaryHighlightColor;
  60282. /**
  60283. * Instantiates a Background Material in the given scene
  60284. * @param name The friendly name of the material
  60285. * @param scene The scene to add the material to
  60286. */
  60287. constructor(name: string, scene: Scene);
  60288. /**
  60289. * Gets a boolean indicating that current material needs to register RTT
  60290. */
  60291. get hasRenderTargetTextures(): boolean;
  60292. /**
  60293. * The entire material has been created in order to prevent overdraw.
  60294. * @returns false
  60295. */
  60296. needAlphaTesting(): boolean;
  60297. /**
  60298. * The entire material has been created in order to prevent overdraw.
  60299. * @returns true if blending is enable
  60300. */
  60301. needAlphaBlending(): boolean;
  60302. /**
  60303. * Checks wether the material is ready to be rendered for a given mesh.
  60304. * @param mesh The mesh to render
  60305. * @param subMesh The submesh to check against
  60306. * @param useInstances Specify wether or not the material is used with instances
  60307. * @returns true if all the dependencies are ready (Textures, Effects...)
  60308. */
  60309. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60310. /**
  60311. * Compute the primary color according to the chosen perceptual color.
  60312. */
  60313. private _computePrimaryColorFromPerceptualColor;
  60314. /**
  60315. * Compute the highlights and shadow colors according to their chosen levels.
  60316. */
  60317. private _computePrimaryColors;
  60318. /**
  60319. * Build the uniform buffer used in the material.
  60320. */
  60321. buildUniformLayout(): void;
  60322. /**
  60323. * Unbind the material.
  60324. */
  60325. unbind(): void;
  60326. /**
  60327. * Bind only the world matrix to the material.
  60328. * @param world The world matrix to bind.
  60329. */
  60330. bindOnlyWorldMatrix(world: Matrix): void;
  60331. /**
  60332. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60333. * @param world The world matrix to bind.
  60334. * @param subMesh The submesh to bind for.
  60335. */
  60336. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60337. /**
  60338. * Checks to see if a texture is used in the material.
  60339. * @param texture - Base texture to use.
  60340. * @returns - Boolean specifying if a texture is used in the material.
  60341. */
  60342. hasTexture(texture: BaseTexture): boolean;
  60343. /**
  60344. * Dispose the material.
  60345. * @param forceDisposeEffect Force disposal of the associated effect.
  60346. * @param forceDisposeTextures Force disposal of the associated textures.
  60347. */
  60348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60349. /**
  60350. * Clones the material.
  60351. * @param name The cloned name.
  60352. * @returns The cloned material.
  60353. */
  60354. clone(name: string): BackgroundMaterial;
  60355. /**
  60356. * Serializes the current material to its JSON representation.
  60357. * @returns The JSON representation.
  60358. */
  60359. serialize(): any;
  60360. /**
  60361. * Gets the class name of the material
  60362. * @returns "BackgroundMaterial"
  60363. */
  60364. getClassName(): string;
  60365. /**
  60366. * Parse a JSON input to create back a background material.
  60367. * @param source The JSON data to parse
  60368. * @param scene The scene to create the parsed material in
  60369. * @param rootUrl The root url of the assets the material depends upon
  60370. * @returns the instantiated BackgroundMaterial.
  60371. */
  60372. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60373. }
  60374. }
  60375. declare module "babylonjs/Helpers/environmentHelper" {
  60376. import { Observable } from "babylonjs/Misc/observable";
  60377. import { Nullable } from "babylonjs/types";
  60378. import { Scene } from "babylonjs/scene";
  60379. import { Vector3 } from "babylonjs/Maths/math.vector";
  60380. import { Color3 } from "babylonjs/Maths/math.color";
  60381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60382. import { Mesh } from "babylonjs/Meshes/mesh";
  60383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60384. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60385. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60386. import "babylonjs/Meshes/Builders/planeBuilder";
  60387. import "babylonjs/Meshes/Builders/boxBuilder";
  60388. /**
  60389. * Represents the different options available during the creation of
  60390. * a Environment helper.
  60391. *
  60392. * This can control the default ground, skybox and image processing setup of your scene.
  60393. */
  60394. export interface IEnvironmentHelperOptions {
  60395. /**
  60396. * Specifies whether or not to create a ground.
  60397. * True by default.
  60398. */
  60399. createGround: boolean;
  60400. /**
  60401. * Specifies the ground size.
  60402. * 15 by default.
  60403. */
  60404. groundSize: number;
  60405. /**
  60406. * The texture used on the ground for the main color.
  60407. * Comes from the BabylonJS CDN by default.
  60408. *
  60409. * Remarks: Can be either a texture or a url.
  60410. */
  60411. groundTexture: string | BaseTexture;
  60412. /**
  60413. * The color mixed in the ground texture by default.
  60414. * BabylonJS clearColor by default.
  60415. */
  60416. groundColor: Color3;
  60417. /**
  60418. * Specifies the ground opacity.
  60419. * 1 by default.
  60420. */
  60421. groundOpacity: number;
  60422. /**
  60423. * Enables the ground to receive shadows.
  60424. * True by default.
  60425. */
  60426. enableGroundShadow: boolean;
  60427. /**
  60428. * Helps preventing the shadow to be fully black on the ground.
  60429. * 0.5 by default.
  60430. */
  60431. groundShadowLevel: number;
  60432. /**
  60433. * Creates a mirror texture attach to the ground.
  60434. * false by default.
  60435. */
  60436. enableGroundMirror: boolean;
  60437. /**
  60438. * Specifies the ground mirror size ratio.
  60439. * 0.3 by default as the default kernel is 64.
  60440. */
  60441. groundMirrorSizeRatio: number;
  60442. /**
  60443. * Specifies the ground mirror blur kernel size.
  60444. * 64 by default.
  60445. */
  60446. groundMirrorBlurKernel: number;
  60447. /**
  60448. * Specifies the ground mirror visibility amount.
  60449. * 1 by default
  60450. */
  60451. groundMirrorAmount: number;
  60452. /**
  60453. * Specifies the ground mirror reflectance weight.
  60454. * This uses the standard weight of the background material to setup the fresnel effect
  60455. * of the mirror.
  60456. * 1 by default.
  60457. */
  60458. groundMirrorFresnelWeight: number;
  60459. /**
  60460. * Specifies the ground mirror Falloff distance.
  60461. * This can helps reducing the size of the reflection.
  60462. * 0 by Default.
  60463. */
  60464. groundMirrorFallOffDistance: number;
  60465. /**
  60466. * Specifies the ground mirror texture type.
  60467. * Unsigned Int by Default.
  60468. */
  60469. groundMirrorTextureType: number;
  60470. /**
  60471. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60472. * the shown objects.
  60473. */
  60474. groundYBias: number;
  60475. /**
  60476. * Specifies whether or not to create a skybox.
  60477. * True by default.
  60478. */
  60479. createSkybox: boolean;
  60480. /**
  60481. * Specifies the skybox size.
  60482. * 20 by default.
  60483. */
  60484. skyboxSize: number;
  60485. /**
  60486. * The texture used on the skybox for the main color.
  60487. * Comes from the BabylonJS CDN by default.
  60488. *
  60489. * Remarks: Can be either a texture or a url.
  60490. */
  60491. skyboxTexture: string | BaseTexture;
  60492. /**
  60493. * The color mixed in the skybox texture by default.
  60494. * BabylonJS clearColor by default.
  60495. */
  60496. skyboxColor: Color3;
  60497. /**
  60498. * The background rotation around the Y axis of the scene.
  60499. * This helps aligning the key lights of your scene with the background.
  60500. * 0 by default.
  60501. */
  60502. backgroundYRotation: number;
  60503. /**
  60504. * Compute automatically the size of the elements to best fit with the scene.
  60505. */
  60506. sizeAuto: boolean;
  60507. /**
  60508. * Default position of the rootMesh if autoSize is not true.
  60509. */
  60510. rootPosition: Vector3;
  60511. /**
  60512. * Sets up the image processing in the scene.
  60513. * true by default.
  60514. */
  60515. setupImageProcessing: boolean;
  60516. /**
  60517. * The texture used as your environment texture in the scene.
  60518. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60519. *
  60520. * Remarks: Can be either a texture or a url.
  60521. */
  60522. environmentTexture: string | BaseTexture;
  60523. /**
  60524. * The value of the exposure to apply to the scene.
  60525. * 0.6 by default if setupImageProcessing is true.
  60526. */
  60527. cameraExposure: number;
  60528. /**
  60529. * The value of the contrast to apply to the scene.
  60530. * 1.6 by default if setupImageProcessing is true.
  60531. */
  60532. cameraContrast: number;
  60533. /**
  60534. * Specifies whether or not tonemapping should be enabled in the scene.
  60535. * true by default if setupImageProcessing is true.
  60536. */
  60537. toneMappingEnabled: boolean;
  60538. }
  60539. /**
  60540. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60541. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60542. * It also helps with the default setup of your imageProcessing configuration.
  60543. */
  60544. export class EnvironmentHelper {
  60545. /**
  60546. * Default ground texture URL.
  60547. */
  60548. private static _groundTextureCDNUrl;
  60549. /**
  60550. * Default skybox texture URL.
  60551. */
  60552. private static _skyboxTextureCDNUrl;
  60553. /**
  60554. * Default environment texture URL.
  60555. */
  60556. private static _environmentTextureCDNUrl;
  60557. /**
  60558. * Creates the default options for the helper.
  60559. */
  60560. private static _getDefaultOptions;
  60561. private _rootMesh;
  60562. /**
  60563. * Gets the root mesh created by the helper.
  60564. */
  60565. get rootMesh(): Mesh;
  60566. private _skybox;
  60567. /**
  60568. * Gets the skybox created by the helper.
  60569. */
  60570. get skybox(): Nullable<Mesh>;
  60571. private _skyboxTexture;
  60572. /**
  60573. * Gets the skybox texture created by the helper.
  60574. */
  60575. get skyboxTexture(): Nullable<BaseTexture>;
  60576. private _skyboxMaterial;
  60577. /**
  60578. * Gets the skybox material created by the helper.
  60579. */
  60580. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60581. private _ground;
  60582. /**
  60583. * Gets the ground mesh created by the helper.
  60584. */
  60585. get ground(): Nullable<Mesh>;
  60586. private _groundTexture;
  60587. /**
  60588. * Gets the ground texture created by the helper.
  60589. */
  60590. get groundTexture(): Nullable<BaseTexture>;
  60591. private _groundMirror;
  60592. /**
  60593. * Gets the ground mirror created by the helper.
  60594. */
  60595. get groundMirror(): Nullable<MirrorTexture>;
  60596. /**
  60597. * Gets the ground mirror render list to helps pushing the meshes
  60598. * you wish in the ground reflection.
  60599. */
  60600. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60601. private _groundMaterial;
  60602. /**
  60603. * Gets the ground material created by the helper.
  60604. */
  60605. get groundMaterial(): Nullable<BackgroundMaterial>;
  60606. /**
  60607. * Stores the creation options.
  60608. */
  60609. private readonly _scene;
  60610. private _options;
  60611. /**
  60612. * This observable will be notified with any error during the creation of the environment,
  60613. * mainly texture creation errors.
  60614. */
  60615. onErrorObservable: Observable<{
  60616. message?: string;
  60617. exception?: any;
  60618. }>;
  60619. /**
  60620. * constructor
  60621. * @param options Defines the options we want to customize the helper
  60622. * @param scene The scene to add the material to
  60623. */
  60624. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60625. /**
  60626. * Updates the background according to the new options
  60627. * @param options
  60628. */
  60629. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60630. /**
  60631. * Sets the primary color of all the available elements.
  60632. * @param color the main color to affect to the ground and the background
  60633. */
  60634. setMainColor(color: Color3): void;
  60635. /**
  60636. * Setup the image processing according to the specified options.
  60637. */
  60638. private _setupImageProcessing;
  60639. /**
  60640. * Setup the environment texture according to the specified options.
  60641. */
  60642. private _setupEnvironmentTexture;
  60643. /**
  60644. * Setup the background according to the specified options.
  60645. */
  60646. private _setupBackground;
  60647. /**
  60648. * Get the scene sizes according to the setup.
  60649. */
  60650. private _getSceneSize;
  60651. /**
  60652. * Setup the ground according to the specified options.
  60653. */
  60654. private _setupGround;
  60655. /**
  60656. * Setup the ground material according to the specified options.
  60657. */
  60658. private _setupGroundMaterial;
  60659. /**
  60660. * Setup the ground diffuse texture according to the specified options.
  60661. */
  60662. private _setupGroundDiffuseTexture;
  60663. /**
  60664. * Setup the ground mirror texture according to the specified options.
  60665. */
  60666. private _setupGroundMirrorTexture;
  60667. /**
  60668. * Setup the ground to receive the mirror texture.
  60669. */
  60670. private _setupMirrorInGroundMaterial;
  60671. /**
  60672. * Setup the skybox according to the specified options.
  60673. */
  60674. private _setupSkybox;
  60675. /**
  60676. * Setup the skybox material according to the specified options.
  60677. */
  60678. private _setupSkyboxMaterial;
  60679. /**
  60680. * Setup the skybox reflection texture according to the specified options.
  60681. */
  60682. private _setupSkyboxReflectionTexture;
  60683. private _errorHandler;
  60684. /**
  60685. * Dispose all the elements created by the Helper.
  60686. */
  60687. dispose(): void;
  60688. }
  60689. }
  60690. declare module "babylonjs/Helpers/textureDome" {
  60691. import { Scene } from "babylonjs/scene";
  60692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60693. import { Mesh } from "babylonjs/Meshes/mesh";
  60694. import { Texture } from "babylonjs/Materials/Textures/texture";
  60695. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60696. import "babylonjs/Meshes/Builders/sphereBuilder";
  60697. import { Nullable } from "babylonjs/types";
  60698. import { Observable } from "babylonjs/Misc/observable";
  60699. /**
  60700. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60701. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60702. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60703. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60704. */
  60705. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60706. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60707. /**
  60708. * Define the source as a Monoscopic panoramic 360/180.
  60709. */
  60710. static readonly MODE_MONOSCOPIC: number;
  60711. /**
  60712. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60713. */
  60714. static readonly MODE_TOPBOTTOM: number;
  60715. /**
  60716. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60717. */
  60718. static readonly MODE_SIDEBYSIDE: number;
  60719. private _halfDome;
  60720. private _crossEye;
  60721. protected _useDirectMapping: boolean;
  60722. /**
  60723. * The texture being displayed on the sphere
  60724. */
  60725. protected _texture: T;
  60726. /**
  60727. * Gets the texture being displayed on the sphere
  60728. */
  60729. get texture(): T;
  60730. /**
  60731. * Sets the texture being displayed on the sphere
  60732. */
  60733. set texture(newTexture: T);
  60734. /**
  60735. * The skybox material
  60736. */
  60737. protected _material: BackgroundMaterial;
  60738. /**
  60739. * The surface used for the dome
  60740. */
  60741. protected _mesh: Mesh;
  60742. /**
  60743. * Gets the mesh used for the dome.
  60744. */
  60745. get mesh(): Mesh;
  60746. /**
  60747. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60748. */
  60749. private _halfDomeMask;
  60750. /**
  60751. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60752. * Also see the options.resolution property.
  60753. */
  60754. get fovMultiplier(): number;
  60755. set fovMultiplier(value: number);
  60756. protected _textureMode: number;
  60757. /**
  60758. * Gets or set the current texture mode for the texture. It can be:
  60759. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60760. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60761. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60762. */
  60763. get textureMode(): number;
  60764. /**
  60765. * Sets the current texture mode for the texture. It can be:
  60766. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60767. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60768. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60769. */
  60770. set textureMode(value: number);
  60771. /**
  60772. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60773. */
  60774. get halfDome(): boolean;
  60775. /**
  60776. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60777. */
  60778. set halfDome(enabled: boolean);
  60779. /**
  60780. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  60781. */
  60782. set crossEye(enabled: boolean);
  60783. /**
  60784. * Is it a cross-eye texture?
  60785. */
  60786. get crossEye(): boolean;
  60787. /**
  60788. * The background material of this dome.
  60789. */
  60790. get material(): BackgroundMaterial;
  60791. /**
  60792. * Oberserver used in Stereoscopic VR Mode.
  60793. */
  60794. private _onBeforeCameraRenderObserver;
  60795. /**
  60796. * Observable raised when an error occured while loading the 360 image
  60797. */
  60798. onLoadErrorObservable: Observable<string>;
  60799. /**
  60800. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60801. * @param name Element's name, child elements will append suffixes for their own names.
  60802. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60803. * @param options An object containing optional or exposed sub element properties
  60804. */
  60805. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60806. resolution?: number;
  60807. clickToPlay?: boolean;
  60808. autoPlay?: boolean;
  60809. loop?: boolean;
  60810. size?: number;
  60811. poster?: string;
  60812. faceForward?: boolean;
  60813. useDirectMapping?: boolean;
  60814. halfDomeMode?: boolean;
  60815. crossEyeMode?: boolean;
  60816. generateMipMaps?: boolean;
  60817. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60818. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60819. protected _changeTextureMode(value: number): void;
  60820. /**
  60821. * Releases resources associated with this node.
  60822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60824. */
  60825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60826. }
  60827. }
  60828. declare module "babylonjs/Helpers/photoDome" {
  60829. import { Scene } from "babylonjs/scene";
  60830. import { Texture } from "babylonjs/Materials/Textures/texture";
  60831. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60832. /**
  60833. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60834. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60835. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60836. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60837. */
  60838. export class PhotoDome extends TextureDome<Texture> {
  60839. /**
  60840. * Define the image as a Monoscopic panoramic 360 image.
  60841. */
  60842. static readonly MODE_MONOSCOPIC: number;
  60843. /**
  60844. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60845. */
  60846. static readonly MODE_TOPBOTTOM: number;
  60847. /**
  60848. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60849. */
  60850. static readonly MODE_SIDEBYSIDE: number;
  60851. /**
  60852. * Gets or sets the texture being displayed on the sphere
  60853. */
  60854. get photoTexture(): Texture;
  60855. /**
  60856. * sets the texture being displayed on the sphere
  60857. */
  60858. set photoTexture(value: Texture);
  60859. /**
  60860. * Gets the current video mode for the video. It can be:
  60861. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60862. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60863. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60864. */
  60865. get imageMode(): number;
  60866. /**
  60867. * Sets the current video mode for the video. It can be:
  60868. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60869. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60870. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60871. */
  60872. set imageMode(value: number);
  60873. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60874. }
  60875. }
  60876. declare module "babylonjs/Misc/dds" {
  60877. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60878. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60879. import { Nullable } from "babylonjs/types";
  60880. import { Scene } from "babylonjs/scene";
  60881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60882. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60883. /**
  60884. * Direct draw surface info
  60885. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60886. */
  60887. export interface DDSInfo {
  60888. /**
  60889. * Width of the texture
  60890. */
  60891. width: number;
  60892. /**
  60893. * Width of the texture
  60894. */
  60895. height: number;
  60896. /**
  60897. * Number of Mipmaps for the texture
  60898. * @see https://en.wikipedia.org/wiki/Mipmap
  60899. */
  60900. mipmapCount: number;
  60901. /**
  60902. * If the textures format is a known fourCC format
  60903. * @see https://www.fourcc.org/
  60904. */
  60905. isFourCC: boolean;
  60906. /**
  60907. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60908. */
  60909. isRGB: boolean;
  60910. /**
  60911. * If the texture is a lumincance format
  60912. */
  60913. isLuminance: boolean;
  60914. /**
  60915. * If this is a cube texture
  60916. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60917. */
  60918. isCube: boolean;
  60919. /**
  60920. * If the texture is a compressed format eg. FOURCC_DXT1
  60921. */
  60922. isCompressed: boolean;
  60923. /**
  60924. * The dxgiFormat of the texture
  60925. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60926. */
  60927. dxgiFormat: number;
  60928. /**
  60929. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60930. */
  60931. textureType: number;
  60932. /**
  60933. * Sphericle polynomial created for the dds texture
  60934. */
  60935. sphericalPolynomial?: SphericalPolynomial;
  60936. }
  60937. /**
  60938. * Class used to provide DDS decompression tools
  60939. */
  60940. export class DDSTools {
  60941. /**
  60942. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60943. */
  60944. static StoreLODInAlphaChannel: boolean;
  60945. /**
  60946. * Gets DDS information from an array buffer
  60947. * @param data defines the array buffer view to read data from
  60948. * @returns the DDS information
  60949. */
  60950. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60951. private static _FloatView;
  60952. private static _Int32View;
  60953. private static _ToHalfFloat;
  60954. private static _FromHalfFloat;
  60955. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60956. private static _GetHalfFloatRGBAArrayBuffer;
  60957. private static _GetFloatRGBAArrayBuffer;
  60958. private static _GetFloatAsUIntRGBAArrayBuffer;
  60959. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60960. private static _GetRGBAArrayBuffer;
  60961. private static _ExtractLongWordOrder;
  60962. private static _GetRGBArrayBuffer;
  60963. private static _GetLuminanceArrayBuffer;
  60964. /**
  60965. * Uploads DDS Levels to a Babylon Texture
  60966. * @hidden
  60967. */
  60968. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60969. }
  60970. module "babylonjs/Engines/thinEngine" {
  60971. interface ThinEngine {
  60972. /**
  60973. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60974. * @param rootUrl defines the url where the file to load is located
  60975. * @param scene defines the current scene
  60976. * @param lodScale defines scale to apply to the mip map selection
  60977. * @param lodOffset defines offset to apply to the mip map selection
  60978. * @param onLoad defines an optional callback raised when the texture is loaded
  60979. * @param onError defines an optional callback raised if there is an issue to load the texture
  60980. * @param format defines the format of the data
  60981. * @param forcedExtension defines the extension to use to pick the right loader
  60982. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60983. * @returns the cube texture as an InternalTexture
  60984. */
  60985. 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;
  60986. }
  60987. }
  60988. }
  60989. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60990. import { Nullable } from "babylonjs/types";
  60991. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60992. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60993. /**
  60994. * Implementation of the DDS Texture Loader.
  60995. * @hidden
  60996. */
  60997. export class _DDSTextureLoader implements IInternalTextureLoader {
  60998. /**
  60999. * Defines wether the loader supports cascade loading the different faces.
  61000. */
  61001. readonly supportCascades: boolean;
  61002. /**
  61003. * This returns if the loader support the current file information.
  61004. * @param extension defines the file extension of the file being loaded
  61005. * @returns true if the loader can load the specified file
  61006. */
  61007. canLoad(extension: string): boolean;
  61008. /**
  61009. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61010. * @param data contains the texture data
  61011. * @param texture defines the BabylonJS internal texture
  61012. * @param createPolynomials will be true if polynomials have been requested
  61013. * @param onLoad defines the callback to trigger once the texture is ready
  61014. * @param onError defines the callback to trigger in case of error
  61015. */
  61016. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61017. /**
  61018. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61019. * @param data contains the texture data
  61020. * @param texture defines the BabylonJS internal texture
  61021. * @param callback defines the method to call once ready to upload
  61022. */
  61023. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61024. }
  61025. }
  61026. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61027. import { Nullable } from "babylonjs/types";
  61028. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61029. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61030. /**
  61031. * Implementation of the ENV Texture Loader.
  61032. * @hidden
  61033. */
  61034. export class _ENVTextureLoader implements IInternalTextureLoader {
  61035. /**
  61036. * Defines wether the loader supports cascade loading the different faces.
  61037. */
  61038. readonly supportCascades: boolean;
  61039. /**
  61040. * This returns if the loader support the current file information.
  61041. * @param extension defines the file extension of the file being loaded
  61042. * @returns true if the loader can load the specified file
  61043. */
  61044. canLoad(extension: string): boolean;
  61045. /**
  61046. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61047. * @param data contains the texture data
  61048. * @param texture defines the BabylonJS internal texture
  61049. * @param createPolynomials will be true if polynomials have been requested
  61050. * @param onLoad defines the callback to trigger once the texture is ready
  61051. * @param onError defines the callback to trigger in case of error
  61052. */
  61053. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61054. /**
  61055. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61056. * @param data contains the texture data
  61057. * @param texture defines the BabylonJS internal texture
  61058. * @param callback defines the method to call once ready to upload
  61059. */
  61060. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61061. }
  61062. }
  61063. declare module "babylonjs/Misc/khronosTextureContainer" {
  61064. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61065. /**
  61066. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61067. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61068. */
  61069. export class KhronosTextureContainer {
  61070. /** contents of the KTX container file */
  61071. data: ArrayBufferView;
  61072. private static HEADER_LEN;
  61073. private static COMPRESSED_2D;
  61074. private static COMPRESSED_3D;
  61075. private static TEX_2D;
  61076. private static TEX_3D;
  61077. /**
  61078. * Gets the openGL type
  61079. */
  61080. glType: number;
  61081. /**
  61082. * Gets the openGL type size
  61083. */
  61084. glTypeSize: number;
  61085. /**
  61086. * Gets the openGL format
  61087. */
  61088. glFormat: number;
  61089. /**
  61090. * Gets the openGL internal format
  61091. */
  61092. glInternalFormat: number;
  61093. /**
  61094. * Gets the base internal format
  61095. */
  61096. glBaseInternalFormat: number;
  61097. /**
  61098. * Gets image width in pixel
  61099. */
  61100. pixelWidth: number;
  61101. /**
  61102. * Gets image height in pixel
  61103. */
  61104. pixelHeight: number;
  61105. /**
  61106. * Gets image depth in pixels
  61107. */
  61108. pixelDepth: number;
  61109. /**
  61110. * Gets the number of array elements
  61111. */
  61112. numberOfArrayElements: number;
  61113. /**
  61114. * Gets the number of faces
  61115. */
  61116. numberOfFaces: number;
  61117. /**
  61118. * Gets the number of mipmap levels
  61119. */
  61120. numberOfMipmapLevels: number;
  61121. /**
  61122. * Gets the bytes of key value data
  61123. */
  61124. bytesOfKeyValueData: number;
  61125. /**
  61126. * Gets the load type
  61127. */
  61128. loadType: number;
  61129. /**
  61130. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61131. */
  61132. isInvalid: boolean;
  61133. /**
  61134. * Creates a new KhronosTextureContainer
  61135. * @param data contents of the KTX container file
  61136. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61137. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61138. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61139. */
  61140. constructor(
  61141. /** contents of the KTX container file */
  61142. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61143. /**
  61144. * Uploads KTX content to a Babylon Texture.
  61145. * It is assumed that the texture has already been created & is currently bound
  61146. * @hidden
  61147. */
  61148. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61149. private _upload2DCompressedLevels;
  61150. /**
  61151. * Checks if the given data starts with a KTX file identifier.
  61152. * @param data the data to check
  61153. * @returns true if the data is a KTX file or false otherwise
  61154. */
  61155. static IsValid(data: ArrayBufferView): boolean;
  61156. }
  61157. }
  61158. declare module "babylonjs/Misc/workerPool" {
  61159. import { IDisposable } from "babylonjs/scene";
  61160. /**
  61161. * Helper class to push actions to a pool of workers.
  61162. */
  61163. export class WorkerPool implements IDisposable {
  61164. private _workerInfos;
  61165. private _pendingActions;
  61166. /**
  61167. * Constructor
  61168. * @param workers Array of workers to use for actions
  61169. */
  61170. constructor(workers: Array<Worker>);
  61171. /**
  61172. * Terminates all workers and clears any pending actions.
  61173. */
  61174. dispose(): void;
  61175. /**
  61176. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61177. * pended until a worker has completed its action.
  61178. * @param action The action to perform. Call onComplete when the action is complete.
  61179. */
  61180. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61181. private _execute;
  61182. }
  61183. }
  61184. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61185. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61186. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61187. /**
  61188. * Class for loading KTX2 files
  61189. */
  61190. export class KhronosTextureContainer2 {
  61191. private static _WorkerPoolPromise?;
  61192. private static _Initialized;
  61193. private static _Ktx2Decoder;
  61194. /**
  61195. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61196. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61197. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61198. * Urls you can change:
  61199. * URLConfig.jsDecoderModule
  61200. * URLConfig.wasmUASTCToASTC
  61201. * URLConfig.wasmUASTCToBC7
  61202. * URLConfig.jsMSCTranscoder
  61203. * URLConfig.wasmMSCTranscoder
  61204. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61205. */
  61206. static URLConfig: {
  61207. jsDecoderModule: string;
  61208. wasmUASTCToASTC: null;
  61209. wasmUASTCToBC7: null;
  61210. jsMSCTranscoder: null;
  61211. wasmMSCTranscoder: null;
  61212. };
  61213. /**
  61214. * Default number of workers used to handle data decoding
  61215. */
  61216. static DefaultNumWorkers: number;
  61217. private static GetDefaultNumWorkers;
  61218. private _engine;
  61219. private static _CreateWorkerPool;
  61220. /**
  61221. * Constructor
  61222. * @param engine The engine to use
  61223. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61224. */
  61225. constructor(engine: ThinEngine, numWorkers?: number);
  61226. /** @hidden */
  61227. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61228. /**
  61229. * Stop all async operations and release resources.
  61230. */
  61231. dispose(): void;
  61232. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61233. /**
  61234. * Checks if the given data starts with a KTX2 file identifier.
  61235. * @param data the data to check
  61236. * @returns true if the data is a KTX2 file or false otherwise
  61237. */
  61238. static IsValid(data: ArrayBufferView): boolean;
  61239. }
  61240. }
  61241. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61242. import { Nullable } from "babylonjs/types";
  61243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61244. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61245. /**
  61246. * Implementation of the KTX Texture Loader.
  61247. * @hidden
  61248. */
  61249. export class _KTXTextureLoader implements IInternalTextureLoader {
  61250. /**
  61251. * Defines wether the loader supports cascade loading the different faces.
  61252. */
  61253. readonly supportCascades: boolean;
  61254. /**
  61255. * This returns if the loader support the current file information.
  61256. * @param extension defines the file extension of the file being loaded
  61257. * @param mimeType defines the optional mime type of the file being loaded
  61258. * @returns true if the loader can load the specified file
  61259. */
  61260. canLoad(extension: string, mimeType?: string): boolean;
  61261. /**
  61262. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61263. * @param data contains the texture data
  61264. * @param texture defines the BabylonJS internal texture
  61265. * @param createPolynomials will be true if polynomials have been requested
  61266. * @param onLoad defines the callback to trigger once the texture is ready
  61267. * @param onError defines the callback to trigger in case of error
  61268. */
  61269. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61270. /**
  61271. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61272. * @param data contains the texture data
  61273. * @param texture defines the BabylonJS internal texture
  61274. * @param callback defines the method to call once ready to upload
  61275. */
  61276. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61277. }
  61278. }
  61279. declare module "babylonjs/Helpers/sceneHelpers" {
  61280. import { Nullable } from "babylonjs/types";
  61281. import { Mesh } from "babylonjs/Meshes/mesh";
  61282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61283. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61284. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61285. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61286. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61287. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61288. import "babylonjs/Meshes/Builders/boxBuilder";
  61289. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61290. /** @hidden */
  61291. export var _forceSceneHelpersToBundle: boolean;
  61292. module "babylonjs/scene" {
  61293. interface Scene {
  61294. /**
  61295. * Creates a default light for the scene.
  61296. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61297. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61298. */
  61299. createDefaultLight(replace?: boolean): void;
  61300. /**
  61301. * Creates a default camera for the scene.
  61302. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61303. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61304. * @param replace has default false, when true replaces the active camera in the scene
  61305. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61306. */
  61307. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61308. /**
  61309. * Creates a default camera and a default light.
  61310. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61311. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61312. * @param replace has the default false, when true replaces the active camera/light in the scene
  61313. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61314. */
  61315. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61316. /**
  61317. * Creates a new sky box
  61318. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61319. * @param environmentTexture defines the texture to use as environment texture
  61320. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61321. * @param scale defines the overall scale of the skybox
  61322. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61323. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61324. * @returns a new mesh holding the sky box
  61325. */
  61326. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61327. /**
  61328. * Creates a new environment
  61329. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61330. * @param options defines the options you can use to configure the environment
  61331. * @returns the new EnvironmentHelper
  61332. */
  61333. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61334. /**
  61335. * Creates a new VREXperienceHelper
  61336. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61337. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61338. * @returns a new VREXperienceHelper
  61339. */
  61340. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61341. /**
  61342. * Creates a new WebXRDefaultExperience
  61343. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61344. * @param options experience options
  61345. * @returns a promise for a new WebXRDefaultExperience
  61346. */
  61347. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61348. }
  61349. }
  61350. }
  61351. declare module "babylonjs/Helpers/videoDome" {
  61352. import { Scene } from "babylonjs/scene";
  61353. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61354. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61355. /**
  61356. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61357. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61358. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61359. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61360. */
  61361. export class VideoDome extends TextureDome<VideoTexture> {
  61362. /**
  61363. * Define the video source as a Monoscopic panoramic 360 video.
  61364. */
  61365. static readonly MODE_MONOSCOPIC: number;
  61366. /**
  61367. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61368. */
  61369. static readonly MODE_TOPBOTTOM: number;
  61370. /**
  61371. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61372. */
  61373. static readonly MODE_SIDEBYSIDE: number;
  61374. /**
  61375. * Get the video texture associated with this video dome
  61376. */
  61377. get videoTexture(): VideoTexture;
  61378. /**
  61379. * Get the video mode of this dome
  61380. */
  61381. get videoMode(): number;
  61382. /**
  61383. * Set the video mode of this dome.
  61384. * @see textureMode
  61385. */
  61386. set videoMode(value: number);
  61387. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61388. }
  61389. }
  61390. declare module "babylonjs/Helpers/index" {
  61391. export * from "babylonjs/Helpers/environmentHelper";
  61392. export * from "babylonjs/Helpers/photoDome";
  61393. export * from "babylonjs/Helpers/sceneHelpers";
  61394. export * from "babylonjs/Helpers/videoDome";
  61395. }
  61396. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61397. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61398. import { IDisposable } from "babylonjs/scene";
  61399. import { Engine } from "babylonjs/Engines/engine";
  61400. /**
  61401. * This class can be used to get instrumentation data from a Babylon engine
  61402. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61403. */
  61404. export class EngineInstrumentation implements IDisposable {
  61405. /**
  61406. * Define the instrumented engine.
  61407. */
  61408. engine: Engine;
  61409. private _captureGPUFrameTime;
  61410. private _gpuFrameTimeToken;
  61411. private _gpuFrameTime;
  61412. private _captureShaderCompilationTime;
  61413. private _shaderCompilationTime;
  61414. private _onBeginFrameObserver;
  61415. private _onEndFrameObserver;
  61416. private _onBeforeShaderCompilationObserver;
  61417. private _onAfterShaderCompilationObserver;
  61418. /**
  61419. * Gets the perf counter used for GPU frame time
  61420. */
  61421. get gpuFrameTimeCounter(): PerfCounter;
  61422. /**
  61423. * Gets the GPU frame time capture status
  61424. */
  61425. get captureGPUFrameTime(): boolean;
  61426. /**
  61427. * Enable or disable the GPU frame time capture
  61428. */
  61429. set captureGPUFrameTime(value: boolean);
  61430. /**
  61431. * Gets the perf counter used for shader compilation time
  61432. */
  61433. get shaderCompilationTimeCounter(): PerfCounter;
  61434. /**
  61435. * Gets the shader compilation time capture status
  61436. */
  61437. get captureShaderCompilationTime(): boolean;
  61438. /**
  61439. * Enable or disable the shader compilation time capture
  61440. */
  61441. set captureShaderCompilationTime(value: boolean);
  61442. /**
  61443. * Instantiates a new engine instrumentation.
  61444. * This class can be used to get instrumentation data from a Babylon engine
  61445. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61446. * @param engine Defines the engine to instrument
  61447. */
  61448. constructor(
  61449. /**
  61450. * Define the instrumented engine.
  61451. */
  61452. engine: Engine);
  61453. /**
  61454. * Dispose and release associated resources.
  61455. */
  61456. dispose(): void;
  61457. }
  61458. }
  61459. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61460. import { Scene, IDisposable } from "babylonjs/scene";
  61461. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61462. /**
  61463. * This class can be used to get instrumentation data from a Babylon engine
  61464. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61465. */
  61466. export class SceneInstrumentation implements IDisposable {
  61467. /**
  61468. * Defines the scene to instrument
  61469. */
  61470. scene: Scene;
  61471. private _captureActiveMeshesEvaluationTime;
  61472. private _activeMeshesEvaluationTime;
  61473. private _captureRenderTargetsRenderTime;
  61474. private _renderTargetsRenderTime;
  61475. private _captureFrameTime;
  61476. private _frameTime;
  61477. private _captureRenderTime;
  61478. private _renderTime;
  61479. private _captureInterFrameTime;
  61480. private _interFrameTime;
  61481. private _captureParticlesRenderTime;
  61482. private _particlesRenderTime;
  61483. private _captureSpritesRenderTime;
  61484. private _spritesRenderTime;
  61485. private _capturePhysicsTime;
  61486. private _physicsTime;
  61487. private _captureAnimationsTime;
  61488. private _animationsTime;
  61489. private _captureCameraRenderTime;
  61490. private _cameraRenderTime;
  61491. private _onBeforeActiveMeshesEvaluationObserver;
  61492. private _onAfterActiveMeshesEvaluationObserver;
  61493. private _onBeforeRenderTargetsRenderObserver;
  61494. private _onAfterRenderTargetsRenderObserver;
  61495. private _onAfterRenderObserver;
  61496. private _onBeforeDrawPhaseObserver;
  61497. private _onAfterDrawPhaseObserver;
  61498. private _onBeforeAnimationsObserver;
  61499. private _onBeforeParticlesRenderingObserver;
  61500. private _onAfterParticlesRenderingObserver;
  61501. private _onBeforeSpritesRenderingObserver;
  61502. private _onAfterSpritesRenderingObserver;
  61503. private _onBeforePhysicsObserver;
  61504. private _onAfterPhysicsObserver;
  61505. private _onAfterAnimationsObserver;
  61506. private _onBeforeCameraRenderObserver;
  61507. private _onAfterCameraRenderObserver;
  61508. /**
  61509. * Gets the perf counter used for active meshes evaluation time
  61510. */
  61511. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61512. /**
  61513. * Gets the active meshes evaluation time capture status
  61514. */
  61515. get captureActiveMeshesEvaluationTime(): boolean;
  61516. /**
  61517. * Enable or disable the active meshes evaluation time capture
  61518. */
  61519. set captureActiveMeshesEvaluationTime(value: boolean);
  61520. /**
  61521. * Gets the perf counter used for render targets render time
  61522. */
  61523. get renderTargetsRenderTimeCounter(): PerfCounter;
  61524. /**
  61525. * Gets the render targets render time capture status
  61526. */
  61527. get captureRenderTargetsRenderTime(): boolean;
  61528. /**
  61529. * Enable or disable the render targets render time capture
  61530. */
  61531. set captureRenderTargetsRenderTime(value: boolean);
  61532. /**
  61533. * Gets the perf counter used for particles render time
  61534. */
  61535. get particlesRenderTimeCounter(): PerfCounter;
  61536. /**
  61537. * Gets the particles render time capture status
  61538. */
  61539. get captureParticlesRenderTime(): boolean;
  61540. /**
  61541. * Enable or disable the particles render time capture
  61542. */
  61543. set captureParticlesRenderTime(value: boolean);
  61544. /**
  61545. * Gets the perf counter used for sprites render time
  61546. */
  61547. get spritesRenderTimeCounter(): PerfCounter;
  61548. /**
  61549. * Gets the sprites render time capture status
  61550. */
  61551. get captureSpritesRenderTime(): boolean;
  61552. /**
  61553. * Enable or disable the sprites render time capture
  61554. */
  61555. set captureSpritesRenderTime(value: boolean);
  61556. /**
  61557. * Gets the perf counter used for physics time
  61558. */
  61559. get physicsTimeCounter(): PerfCounter;
  61560. /**
  61561. * Gets the physics time capture status
  61562. */
  61563. get capturePhysicsTime(): boolean;
  61564. /**
  61565. * Enable or disable the physics time capture
  61566. */
  61567. set capturePhysicsTime(value: boolean);
  61568. /**
  61569. * Gets the perf counter used for animations time
  61570. */
  61571. get animationsTimeCounter(): PerfCounter;
  61572. /**
  61573. * Gets the animations time capture status
  61574. */
  61575. get captureAnimationsTime(): boolean;
  61576. /**
  61577. * Enable or disable the animations time capture
  61578. */
  61579. set captureAnimationsTime(value: boolean);
  61580. /**
  61581. * Gets the perf counter used for frame time capture
  61582. */
  61583. get frameTimeCounter(): PerfCounter;
  61584. /**
  61585. * Gets the frame time capture status
  61586. */
  61587. get captureFrameTime(): boolean;
  61588. /**
  61589. * Enable or disable the frame time capture
  61590. */
  61591. set captureFrameTime(value: boolean);
  61592. /**
  61593. * Gets the perf counter used for inter-frames time capture
  61594. */
  61595. get interFrameTimeCounter(): PerfCounter;
  61596. /**
  61597. * Gets the inter-frames time capture status
  61598. */
  61599. get captureInterFrameTime(): boolean;
  61600. /**
  61601. * Enable or disable the inter-frames time capture
  61602. */
  61603. set captureInterFrameTime(value: boolean);
  61604. /**
  61605. * Gets the perf counter used for render time capture
  61606. */
  61607. get renderTimeCounter(): PerfCounter;
  61608. /**
  61609. * Gets the render time capture status
  61610. */
  61611. get captureRenderTime(): boolean;
  61612. /**
  61613. * Enable or disable the render time capture
  61614. */
  61615. set captureRenderTime(value: boolean);
  61616. /**
  61617. * Gets the perf counter used for camera render time capture
  61618. */
  61619. get cameraRenderTimeCounter(): PerfCounter;
  61620. /**
  61621. * Gets the camera render time capture status
  61622. */
  61623. get captureCameraRenderTime(): boolean;
  61624. /**
  61625. * Enable or disable the camera render time capture
  61626. */
  61627. set captureCameraRenderTime(value: boolean);
  61628. /**
  61629. * Gets the perf counter used for draw calls
  61630. */
  61631. get drawCallsCounter(): PerfCounter;
  61632. /**
  61633. * Instantiates a new scene instrumentation.
  61634. * This class can be used to get instrumentation data from a Babylon engine
  61635. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61636. * @param scene Defines the scene to instrument
  61637. */
  61638. constructor(
  61639. /**
  61640. * Defines the scene to instrument
  61641. */
  61642. scene: Scene);
  61643. /**
  61644. * Dispose and release associated resources.
  61645. */
  61646. dispose(): void;
  61647. }
  61648. }
  61649. declare module "babylonjs/Instrumentation/index" {
  61650. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61651. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61652. export * from "babylonjs/Instrumentation/timeToken";
  61653. }
  61654. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61655. /** @hidden */
  61656. export var glowMapGenerationPixelShader: {
  61657. name: string;
  61658. shader: string;
  61659. };
  61660. }
  61661. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61662. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61663. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61664. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61665. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61666. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61667. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61668. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61669. /** @hidden */
  61670. export var glowMapGenerationVertexShader: {
  61671. name: string;
  61672. shader: string;
  61673. };
  61674. }
  61675. declare module "babylonjs/Layers/effectLayer" {
  61676. import { Observable } from "babylonjs/Misc/observable";
  61677. import { Nullable } from "babylonjs/types";
  61678. import { Camera } from "babylonjs/Cameras/camera";
  61679. import { Scene } from "babylonjs/scene";
  61680. import { ISize } from "babylonjs/Maths/math.size";
  61681. import { Color4 } from "babylonjs/Maths/math.color";
  61682. import { Engine } from "babylonjs/Engines/engine";
  61683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61685. import { Mesh } from "babylonjs/Meshes/mesh";
  61686. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61688. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61689. import { Effect } from "babylonjs/Materials/effect";
  61690. import { Material } from "babylonjs/Materials/material";
  61691. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61692. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61693. /**
  61694. * Effect layer options. This helps customizing the behaviour
  61695. * of the effect layer.
  61696. */
  61697. export interface IEffectLayerOptions {
  61698. /**
  61699. * Multiplication factor apply to the canvas size to compute the render target size
  61700. * used to generated the objects (the smaller the faster).
  61701. */
  61702. mainTextureRatio: number;
  61703. /**
  61704. * Enforces a fixed size texture to ensure effect stability across devices.
  61705. */
  61706. mainTextureFixedSize?: number;
  61707. /**
  61708. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61709. */
  61710. alphaBlendingMode: number;
  61711. /**
  61712. * The camera attached to the layer.
  61713. */
  61714. camera: Nullable<Camera>;
  61715. /**
  61716. * The rendering group to draw the layer in.
  61717. */
  61718. renderingGroupId: number;
  61719. }
  61720. /**
  61721. * The effect layer Helps adding post process effect blended with the main pass.
  61722. *
  61723. * This can be for instance use to generate glow or higlight effects on the scene.
  61724. *
  61725. * The effect layer class can not be used directly and is intented to inherited from to be
  61726. * customized per effects.
  61727. */
  61728. export abstract class EffectLayer {
  61729. private _vertexBuffers;
  61730. private _indexBuffer;
  61731. private _cachedDefines;
  61732. private _effectLayerMapGenerationEffect;
  61733. private _effectLayerOptions;
  61734. private _mergeEffect;
  61735. protected _scene: Scene;
  61736. protected _engine: Engine;
  61737. protected _maxSize: number;
  61738. protected _mainTextureDesiredSize: ISize;
  61739. protected _mainTexture: RenderTargetTexture;
  61740. protected _shouldRender: boolean;
  61741. protected _postProcesses: PostProcess[];
  61742. protected _textures: BaseTexture[];
  61743. protected _emissiveTextureAndColor: {
  61744. texture: Nullable<BaseTexture>;
  61745. color: Color4;
  61746. };
  61747. /**
  61748. * The name of the layer
  61749. */
  61750. name: string;
  61751. /**
  61752. * The clear color of the texture used to generate the glow map.
  61753. */
  61754. neutralColor: Color4;
  61755. /**
  61756. * Specifies whether the highlight layer is enabled or not.
  61757. */
  61758. isEnabled: boolean;
  61759. /**
  61760. * Gets the camera attached to the layer.
  61761. */
  61762. get camera(): Nullable<Camera>;
  61763. /**
  61764. * Gets the rendering group id the layer should render in.
  61765. */
  61766. get renderingGroupId(): number;
  61767. set renderingGroupId(renderingGroupId: number);
  61768. /**
  61769. * An event triggered when the effect layer has been disposed.
  61770. */
  61771. onDisposeObservable: Observable<EffectLayer>;
  61772. /**
  61773. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61774. */
  61775. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61776. /**
  61777. * An event triggered when the generated texture is being merged in the scene.
  61778. */
  61779. onBeforeComposeObservable: Observable<EffectLayer>;
  61780. /**
  61781. * An event triggered when the mesh is rendered into the effect render target.
  61782. */
  61783. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61784. /**
  61785. * An event triggered after the mesh has been rendered into the effect render target.
  61786. */
  61787. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61788. /**
  61789. * An event triggered when the generated texture has been merged in the scene.
  61790. */
  61791. onAfterComposeObservable: Observable<EffectLayer>;
  61792. /**
  61793. * An event triggered when the efffect layer changes its size.
  61794. */
  61795. onSizeChangedObservable: Observable<EffectLayer>;
  61796. /** @hidden */
  61797. static _SceneComponentInitialization: (scene: Scene) => void;
  61798. /**
  61799. * Instantiates a new effect Layer and references it in the scene.
  61800. * @param name The name of the layer
  61801. * @param scene The scene to use the layer in
  61802. */
  61803. constructor(
  61804. /** The Friendly of the effect in the scene */
  61805. name: string, scene: Scene);
  61806. /**
  61807. * Get the effect name of the layer.
  61808. * @return The effect name
  61809. */
  61810. abstract getEffectName(): string;
  61811. /**
  61812. * Checks for the readiness of the element composing the layer.
  61813. * @param subMesh the mesh to check for
  61814. * @param useInstances specify whether or not to use instances to render the mesh
  61815. * @return true if ready otherwise, false
  61816. */
  61817. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61818. /**
  61819. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61820. * @returns true if the effect requires stencil during the main canvas render pass.
  61821. */
  61822. abstract needStencil(): boolean;
  61823. /**
  61824. * Create the merge effect. This is the shader use to blit the information back
  61825. * to the main canvas at the end of the scene rendering.
  61826. * @returns The effect containing the shader used to merge the effect on the main canvas
  61827. */
  61828. protected abstract _createMergeEffect(): Effect;
  61829. /**
  61830. * Creates the render target textures and post processes used in the effect layer.
  61831. */
  61832. protected abstract _createTextureAndPostProcesses(): void;
  61833. /**
  61834. * Implementation specific of rendering the generating effect on the main canvas.
  61835. * @param effect The effect used to render through
  61836. */
  61837. protected abstract _internalRender(effect: Effect): void;
  61838. /**
  61839. * Sets the required values for both the emissive texture and and the main color.
  61840. */
  61841. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61842. /**
  61843. * Free any resources and references associated to a mesh.
  61844. * Internal use
  61845. * @param mesh The mesh to free.
  61846. */
  61847. abstract _disposeMesh(mesh: Mesh): void;
  61848. /**
  61849. * Serializes this layer (Glow or Highlight for example)
  61850. * @returns a serialized layer object
  61851. */
  61852. abstract serialize?(): any;
  61853. /**
  61854. * Initializes the effect layer with the required options.
  61855. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61856. */
  61857. protected _init(options: Partial<IEffectLayerOptions>): void;
  61858. /**
  61859. * Generates the index buffer of the full screen quad blending to the main canvas.
  61860. */
  61861. private _generateIndexBuffer;
  61862. /**
  61863. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61864. */
  61865. private _generateVertexBuffer;
  61866. /**
  61867. * Sets the main texture desired size which is the closest power of two
  61868. * of the engine canvas size.
  61869. */
  61870. private _setMainTextureSize;
  61871. /**
  61872. * Creates the main texture for the effect layer.
  61873. */
  61874. protected _createMainTexture(): void;
  61875. /**
  61876. * Adds specific effects defines.
  61877. * @param defines The defines to add specifics to.
  61878. */
  61879. protected _addCustomEffectDefines(defines: string[]): void;
  61880. /**
  61881. * Checks for the readiness of the element composing the layer.
  61882. * @param subMesh the mesh to check for
  61883. * @param useInstances specify whether or not to use instances to render the mesh
  61884. * @param emissiveTexture the associated emissive texture used to generate the glow
  61885. * @return true if ready otherwise, false
  61886. */
  61887. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61888. /**
  61889. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61890. */
  61891. render(): void;
  61892. /**
  61893. * Determine if a given mesh will be used in the current effect.
  61894. * @param mesh mesh to test
  61895. * @returns true if the mesh will be used
  61896. */
  61897. hasMesh(mesh: AbstractMesh): boolean;
  61898. /**
  61899. * Returns true if the layer contains information to display, otherwise false.
  61900. * @returns true if the glow layer should be rendered
  61901. */
  61902. shouldRender(): boolean;
  61903. /**
  61904. * Returns true if the mesh should render, otherwise false.
  61905. * @param mesh The mesh to render
  61906. * @returns true if it should render otherwise false
  61907. */
  61908. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61909. /**
  61910. * Returns true if the mesh can be rendered, otherwise false.
  61911. * @param mesh The mesh to render
  61912. * @param material The material used on the mesh
  61913. * @returns true if it can be rendered otherwise false
  61914. */
  61915. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61916. /**
  61917. * Returns true if the mesh should render, otherwise false.
  61918. * @param mesh The mesh to render
  61919. * @returns true if it should render otherwise false
  61920. */
  61921. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61922. /**
  61923. * Renders the submesh passed in parameter to the generation map.
  61924. */
  61925. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61926. /**
  61927. * Defines whether the current material of the mesh should be use to render the effect.
  61928. * @param mesh defines the current mesh to render
  61929. */
  61930. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61931. /**
  61932. * Rebuild the required buffers.
  61933. * @hidden Internal use only.
  61934. */
  61935. _rebuild(): void;
  61936. /**
  61937. * Dispose only the render target textures and post process.
  61938. */
  61939. private _disposeTextureAndPostProcesses;
  61940. /**
  61941. * Dispose the highlight layer and free resources.
  61942. */
  61943. dispose(): void;
  61944. /**
  61945. * Gets the class name of the effect layer
  61946. * @returns the string with the class name of the effect layer
  61947. */
  61948. getClassName(): string;
  61949. /**
  61950. * Creates an effect layer from parsed effect layer data
  61951. * @param parsedEffectLayer defines effect layer data
  61952. * @param scene defines the current scene
  61953. * @param rootUrl defines the root URL containing the effect layer information
  61954. * @returns a parsed effect Layer
  61955. */
  61956. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61957. }
  61958. }
  61959. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61960. import { Scene } from "babylonjs/scene";
  61961. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61962. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61963. import { AbstractScene } from "babylonjs/abstractScene";
  61964. module "babylonjs/abstractScene" {
  61965. interface AbstractScene {
  61966. /**
  61967. * The list of effect layers (highlights/glow) added to the scene
  61968. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61969. * @see https://doc.babylonjs.com/how_to/glow_layer
  61970. */
  61971. effectLayers: Array<EffectLayer>;
  61972. /**
  61973. * Removes the given effect layer from this scene.
  61974. * @param toRemove defines the effect layer to remove
  61975. * @returns the index of the removed effect layer
  61976. */
  61977. removeEffectLayer(toRemove: EffectLayer): number;
  61978. /**
  61979. * Adds the given effect layer to this scene
  61980. * @param newEffectLayer defines the effect layer to add
  61981. */
  61982. addEffectLayer(newEffectLayer: EffectLayer): void;
  61983. }
  61984. }
  61985. /**
  61986. * Defines the layer scene component responsible to manage any effect layers
  61987. * in a given scene.
  61988. */
  61989. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61990. /**
  61991. * The component name helpfull to identify the component in the list of scene components.
  61992. */
  61993. readonly name: string;
  61994. /**
  61995. * The scene the component belongs to.
  61996. */
  61997. scene: Scene;
  61998. private _engine;
  61999. private _renderEffects;
  62000. private _needStencil;
  62001. private _previousStencilState;
  62002. /**
  62003. * Creates a new instance of the component for the given scene
  62004. * @param scene Defines the scene to register the component in
  62005. */
  62006. constructor(scene: Scene);
  62007. /**
  62008. * Registers the component in a given scene
  62009. */
  62010. register(): void;
  62011. /**
  62012. * Rebuilds the elements related to this component in case of
  62013. * context lost for instance.
  62014. */
  62015. rebuild(): void;
  62016. /**
  62017. * Serializes the component data to the specified json object
  62018. * @param serializationObject The object to serialize to
  62019. */
  62020. serialize(serializationObject: any): void;
  62021. /**
  62022. * Adds all the elements from the container to the scene
  62023. * @param container the container holding the elements
  62024. */
  62025. addFromContainer(container: AbstractScene): void;
  62026. /**
  62027. * Removes all the elements in the container from the scene
  62028. * @param container contains the elements to remove
  62029. * @param dispose if the removed element should be disposed (default: false)
  62030. */
  62031. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62032. /**
  62033. * Disposes the component and the associated ressources.
  62034. */
  62035. dispose(): void;
  62036. private _isReadyForMesh;
  62037. private _renderMainTexture;
  62038. private _setStencil;
  62039. private _setStencilBack;
  62040. private _draw;
  62041. private _drawCamera;
  62042. private _drawRenderingGroup;
  62043. }
  62044. }
  62045. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62046. /** @hidden */
  62047. export var glowMapMergePixelShader: {
  62048. name: string;
  62049. shader: string;
  62050. };
  62051. }
  62052. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62053. /** @hidden */
  62054. export var glowMapMergeVertexShader: {
  62055. name: string;
  62056. shader: string;
  62057. };
  62058. }
  62059. declare module "babylonjs/Layers/glowLayer" {
  62060. import { Nullable } from "babylonjs/types";
  62061. import { Camera } from "babylonjs/Cameras/camera";
  62062. import { Scene } from "babylonjs/scene";
  62063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62065. import { Mesh } from "babylonjs/Meshes/mesh";
  62066. import { Texture } from "babylonjs/Materials/Textures/texture";
  62067. import { Effect } from "babylonjs/Materials/effect";
  62068. import { Material } from "babylonjs/Materials/material";
  62069. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62070. import { Color4 } from "babylonjs/Maths/math.color";
  62071. import "babylonjs/Shaders/glowMapMerge.fragment";
  62072. import "babylonjs/Shaders/glowMapMerge.vertex";
  62073. import "babylonjs/Layers/effectLayerSceneComponent";
  62074. module "babylonjs/abstractScene" {
  62075. interface AbstractScene {
  62076. /**
  62077. * Return a the first highlight layer of the scene with a given name.
  62078. * @param name The name of the highlight layer to look for.
  62079. * @return The highlight layer if found otherwise null.
  62080. */
  62081. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62082. }
  62083. }
  62084. /**
  62085. * Glow layer options. This helps customizing the behaviour
  62086. * of the glow layer.
  62087. */
  62088. export interface IGlowLayerOptions {
  62089. /**
  62090. * Multiplication factor apply to the canvas size to compute the render target size
  62091. * used to generated the glowing objects (the smaller the faster).
  62092. */
  62093. mainTextureRatio: number;
  62094. /**
  62095. * Enforces a fixed size texture to ensure resize independant blur.
  62096. */
  62097. mainTextureFixedSize?: number;
  62098. /**
  62099. * How big is the kernel of the blur texture.
  62100. */
  62101. blurKernelSize: number;
  62102. /**
  62103. * The camera attached to the layer.
  62104. */
  62105. camera: Nullable<Camera>;
  62106. /**
  62107. * Enable MSAA by chosing the number of samples.
  62108. */
  62109. mainTextureSamples?: number;
  62110. /**
  62111. * The rendering group to draw the layer in.
  62112. */
  62113. renderingGroupId: number;
  62114. }
  62115. /**
  62116. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62117. *
  62118. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62119. *
  62120. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62121. */
  62122. export class GlowLayer extends EffectLayer {
  62123. /**
  62124. * Effect Name of the layer.
  62125. */
  62126. static readonly EffectName: string;
  62127. /**
  62128. * The default blur kernel size used for the glow.
  62129. */
  62130. static DefaultBlurKernelSize: number;
  62131. /**
  62132. * The default texture size ratio used for the glow.
  62133. */
  62134. static DefaultTextureRatio: number;
  62135. /**
  62136. * Sets the kernel size of the blur.
  62137. */
  62138. set blurKernelSize(value: number);
  62139. /**
  62140. * Gets the kernel size of the blur.
  62141. */
  62142. get blurKernelSize(): number;
  62143. /**
  62144. * Sets the glow intensity.
  62145. */
  62146. set intensity(value: number);
  62147. /**
  62148. * Gets the glow intensity.
  62149. */
  62150. get intensity(): number;
  62151. private _options;
  62152. private _intensity;
  62153. private _horizontalBlurPostprocess1;
  62154. private _verticalBlurPostprocess1;
  62155. private _horizontalBlurPostprocess2;
  62156. private _verticalBlurPostprocess2;
  62157. private _blurTexture1;
  62158. private _blurTexture2;
  62159. private _postProcesses1;
  62160. private _postProcesses2;
  62161. private _includedOnlyMeshes;
  62162. private _excludedMeshes;
  62163. private _meshesUsingTheirOwnMaterials;
  62164. /**
  62165. * Callback used to let the user override the color selection on a per mesh basis
  62166. */
  62167. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62168. /**
  62169. * Callback used to let the user override the texture selection on a per mesh basis
  62170. */
  62171. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62172. /**
  62173. * Instantiates a new glow Layer and references it to the scene.
  62174. * @param name The name of the layer
  62175. * @param scene The scene to use the layer in
  62176. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62177. */
  62178. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62179. /**
  62180. * Get the effect name of the layer.
  62181. * @return The effect name
  62182. */
  62183. getEffectName(): string;
  62184. /**
  62185. * Create the merge effect. This is the shader use to blit the information back
  62186. * to the main canvas at the end of the scene rendering.
  62187. */
  62188. protected _createMergeEffect(): Effect;
  62189. /**
  62190. * Creates the render target textures and post processes used in the glow layer.
  62191. */
  62192. protected _createTextureAndPostProcesses(): void;
  62193. /**
  62194. * Checks for the readiness of the element composing the layer.
  62195. * @param subMesh the mesh to check for
  62196. * @param useInstances specify wether or not to use instances to render the mesh
  62197. * @param emissiveTexture the associated emissive texture used to generate the glow
  62198. * @return true if ready otherwise, false
  62199. */
  62200. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62201. /**
  62202. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62203. */
  62204. needStencil(): boolean;
  62205. /**
  62206. * Returns true if the mesh can be rendered, otherwise false.
  62207. * @param mesh The mesh to render
  62208. * @param material The material used on the mesh
  62209. * @returns true if it can be rendered otherwise false
  62210. */
  62211. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62212. /**
  62213. * Implementation specific of rendering the generating effect on the main canvas.
  62214. * @param effect The effect used to render through
  62215. */
  62216. protected _internalRender(effect: Effect): void;
  62217. /**
  62218. * Sets the required values for both the emissive texture and and the main color.
  62219. */
  62220. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62221. /**
  62222. * Returns true if the mesh should render, otherwise false.
  62223. * @param mesh The mesh to render
  62224. * @returns true if it should render otherwise false
  62225. */
  62226. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62227. /**
  62228. * Adds specific effects defines.
  62229. * @param defines The defines to add specifics to.
  62230. */
  62231. protected _addCustomEffectDefines(defines: string[]): void;
  62232. /**
  62233. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62234. * @param mesh The mesh to exclude from the glow layer
  62235. */
  62236. addExcludedMesh(mesh: Mesh): void;
  62237. /**
  62238. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62239. * @param mesh The mesh to remove
  62240. */
  62241. removeExcludedMesh(mesh: Mesh): void;
  62242. /**
  62243. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62244. * @param mesh The mesh to include in the glow layer
  62245. */
  62246. addIncludedOnlyMesh(mesh: Mesh): void;
  62247. /**
  62248. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62249. * @param mesh The mesh to remove
  62250. */
  62251. removeIncludedOnlyMesh(mesh: Mesh): void;
  62252. /**
  62253. * Determine if a given mesh will be used in the glow layer
  62254. * @param mesh The mesh to test
  62255. * @returns true if the mesh will be highlighted by the current glow layer
  62256. */
  62257. hasMesh(mesh: AbstractMesh): boolean;
  62258. /**
  62259. * Defines whether the current material of the mesh should be use to render the effect.
  62260. * @param mesh defines the current mesh to render
  62261. */
  62262. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62263. /**
  62264. * Add a mesh to be rendered through its own material and not with emissive only.
  62265. * @param mesh The mesh for which we need to use its material
  62266. */
  62267. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62268. /**
  62269. * Remove a mesh from being rendered through its own material and not with emissive only.
  62270. * @param mesh The mesh for which we need to not use its material
  62271. */
  62272. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62273. /**
  62274. * Free any resources and references associated to a mesh.
  62275. * Internal use
  62276. * @param mesh The mesh to free.
  62277. * @hidden
  62278. */
  62279. _disposeMesh(mesh: Mesh): void;
  62280. /**
  62281. * Gets the class name of the effect layer
  62282. * @returns the string with the class name of the effect layer
  62283. */
  62284. getClassName(): string;
  62285. /**
  62286. * Serializes this glow layer
  62287. * @returns a serialized glow layer object
  62288. */
  62289. serialize(): any;
  62290. /**
  62291. * Creates a Glow Layer from parsed glow layer data
  62292. * @param parsedGlowLayer defines glow layer data
  62293. * @param scene defines the current scene
  62294. * @param rootUrl defines the root URL containing the glow layer information
  62295. * @returns a parsed Glow Layer
  62296. */
  62297. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62298. }
  62299. }
  62300. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62301. /** @hidden */
  62302. export var glowBlurPostProcessPixelShader: {
  62303. name: string;
  62304. shader: string;
  62305. };
  62306. }
  62307. declare module "babylonjs/Layers/highlightLayer" {
  62308. import { Observable } from "babylonjs/Misc/observable";
  62309. import { Nullable } from "babylonjs/types";
  62310. import { Camera } from "babylonjs/Cameras/camera";
  62311. import { Scene } from "babylonjs/scene";
  62312. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62314. import { Mesh } from "babylonjs/Meshes/mesh";
  62315. import { Effect } from "babylonjs/Materials/effect";
  62316. import { Material } from "babylonjs/Materials/material";
  62317. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62318. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62319. import "babylonjs/Shaders/glowMapMerge.fragment";
  62320. import "babylonjs/Shaders/glowMapMerge.vertex";
  62321. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62322. module "babylonjs/abstractScene" {
  62323. interface AbstractScene {
  62324. /**
  62325. * Return a the first highlight layer of the scene with a given name.
  62326. * @param name The name of the highlight layer to look for.
  62327. * @return The highlight layer if found otherwise null.
  62328. */
  62329. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62330. }
  62331. }
  62332. /**
  62333. * Highlight layer options. This helps customizing the behaviour
  62334. * of the highlight layer.
  62335. */
  62336. export interface IHighlightLayerOptions {
  62337. /**
  62338. * Multiplication factor apply to the canvas size to compute the render target size
  62339. * used to generated the glowing objects (the smaller the faster).
  62340. */
  62341. mainTextureRatio: number;
  62342. /**
  62343. * Enforces a fixed size texture to ensure resize independant blur.
  62344. */
  62345. mainTextureFixedSize?: number;
  62346. /**
  62347. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62348. * of the picture to blur (the smaller the faster).
  62349. */
  62350. blurTextureSizeRatio: number;
  62351. /**
  62352. * How big in texel of the blur texture is the vertical blur.
  62353. */
  62354. blurVerticalSize: number;
  62355. /**
  62356. * How big in texel of the blur texture is the horizontal blur.
  62357. */
  62358. blurHorizontalSize: number;
  62359. /**
  62360. * Alpha blending mode used to apply the blur. Default is combine.
  62361. */
  62362. alphaBlendingMode: number;
  62363. /**
  62364. * The camera attached to the layer.
  62365. */
  62366. camera: Nullable<Camera>;
  62367. /**
  62368. * Should we display highlight as a solid stroke?
  62369. */
  62370. isStroke?: boolean;
  62371. /**
  62372. * The rendering group to draw the layer in.
  62373. */
  62374. renderingGroupId: number;
  62375. }
  62376. /**
  62377. * The highlight layer Helps adding a glow effect around a mesh.
  62378. *
  62379. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62380. * glowy meshes to your scene.
  62381. *
  62382. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62383. */
  62384. export class HighlightLayer extends EffectLayer {
  62385. name: string;
  62386. /**
  62387. * Effect Name of the highlight layer.
  62388. */
  62389. static readonly EffectName: string;
  62390. /**
  62391. * The neutral color used during the preparation of the glow effect.
  62392. * This is black by default as the blend operation is a blend operation.
  62393. */
  62394. static NeutralColor: Color4;
  62395. /**
  62396. * Stencil value used for glowing meshes.
  62397. */
  62398. static GlowingMeshStencilReference: number;
  62399. /**
  62400. * Stencil value used for the other meshes in the scene.
  62401. */
  62402. static NormalMeshStencilReference: number;
  62403. /**
  62404. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62405. */
  62406. innerGlow: boolean;
  62407. /**
  62408. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62409. */
  62410. outerGlow: boolean;
  62411. /**
  62412. * Specifies the horizontal size of the blur.
  62413. */
  62414. set blurHorizontalSize(value: number);
  62415. /**
  62416. * Specifies the vertical size of the blur.
  62417. */
  62418. set blurVerticalSize(value: number);
  62419. /**
  62420. * Gets the horizontal size of the blur.
  62421. */
  62422. get blurHorizontalSize(): number;
  62423. /**
  62424. * Gets the vertical size of the blur.
  62425. */
  62426. get blurVerticalSize(): number;
  62427. /**
  62428. * An event triggered when the highlight layer is being blurred.
  62429. */
  62430. onBeforeBlurObservable: Observable<HighlightLayer>;
  62431. /**
  62432. * An event triggered when the highlight layer has been blurred.
  62433. */
  62434. onAfterBlurObservable: Observable<HighlightLayer>;
  62435. private _instanceGlowingMeshStencilReference;
  62436. private _options;
  62437. private _downSamplePostprocess;
  62438. private _horizontalBlurPostprocess;
  62439. private _verticalBlurPostprocess;
  62440. private _blurTexture;
  62441. private _meshes;
  62442. private _excludedMeshes;
  62443. /**
  62444. * Instantiates a new highlight Layer and references it to the scene..
  62445. * @param name The name of the layer
  62446. * @param scene The scene to use the layer in
  62447. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62448. */
  62449. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62450. /**
  62451. * Get the effect name of the layer.
  62452. * @return The effect name
  62453. */
  62454. getEffectName(): string;
  62455. /**
  62456. * Create the merge effect. This is the shader use to blit the information back
  62457. * to the main canvas at the end of the scene rendering.
  62458. */
  62459. protected _createMergeEffect(): Effect;
  62460. /**
  62461. * Creates the render target textures and post processes used in the highlight layer.
  62462. */
  62463. protected _createTextureAndPostProcesses(): void;
  62464. /**
  62465. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62466. */
  62467. needStencil(): boolean;
  62468. /**
  62469. * Checks for the readiness of the element composing the layer.
  62470. * @param subMesh the mesh to check for
  62471. * @param useInstances specify wether or not to use instances to render the mesh
  62472. * @param emissiveTexture the associated emissive texture used to generate the glow
  62473. * @return true if ready otherwise, false
  62474. */
  62475. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62476. /**
  62477. * Implementation specific of rendering the generating effect on the main canvas.
  62478. * @param effect The effect used to render through
  62479. */
  62480. protected _internalRender(effect: Effect): void;
  62481. /**
  62482. * Returns true if the layer contains information to display, otherwise false.
  62483. */
  62484. shouldRender(): boolean;
  62485. /**
  62486. * Returns true if the mesh should render, otherwise false.
  62487. * @param mesh The mesh to render
  62488. * @returns true if it should render otherwise false
  62489. */
  62490. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62491. /**
  62492. * Returns true if the mesh can be rendered, otherwise false.
  62493. * @param mesh The mesh to render
  62494. * @param material The material used on the mesh
  62495. * @returns true if it can be rendered otherwise false
  62496. */
  62497. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62498. /**
  62499. * Adds specific effects defines.
  62500. * @param defines The defines to add specifics to.
  62501. */
  62502. protected _addCustomEffectDefines(defines: string[]): void;
  62503. /**
  62504. * Sets the required values for both the emissive texture and and the main color.
  62505. */
  62506. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62507. /**
  62508. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62509. * @param mesh The mesh to exclude from the highlight layer
  62510. */
  62511. addExcludedMesh(mesh: Mesh): void;
  62512. /**
  62513. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62514. * @param mesh The mesh to highlight
  62515. */
  62516. removeExcludedMesh(mesh: Mesh): void;
  62517. /**
  62518. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62519. * @param mesh mesh to test
  62520. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62521. */
  62522. hasMesh(mesh: AbstractMesh): boolean;
  62523. /**
  62524. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62525. * @param mesh The mesh to highlight
  62526. * @param color The color of the highlight
  62527. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62528. */
  62529. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62530. /**
  62531. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62532. * @param mesh The mesh to highlight
  62533. */
  62534. removeMesh(mesh: Mesh): void;
  62535. /**
  62536. * Remove all the meshes currently referenced in the highlight layer
  62537. */
  62538. removeAllMeshes(): void;
  62539. /**
  62540. * Force the stencil to the normal expected value for none glowing parts
  62541. */
  62542. private _defaultStencilReference;
  62543. /**
  62544. * Free any resources and references associated to a mesh.
  62545. * Internal use
  62546. * @param mesh The mesh to free.
  62547. * @hidden
  62548. */
  62549. _disposeMesh(mesh: Mesh): void;
  62550. /**
  62551. * Dispose the highlight layer and free resources.
  62552. */
  62553. dispose(): void;
  62554. /**
  62555. * Gets the class name of the effect layer
  62556. * @returns the string with the class name of the effect layer
  62557. */
  62558. getClassName(): string;
  62559. /**
  62560. * Serializes this Highlight layer
  62561. * @returns a serialized Highlight layer object
  62562. */
  62563. serialize(): any;
  62564. /**
  62565. * Creates a Highlight layer from parsed Highlight layer data
  62566. * @param parsedHightlightLayer defines the Highlight layer data
  62567. * @param scene defines the current scene
  62568. * @param rootUrl defines the root URL containing the Highlight layer information
  62569. * @returns a parsed Highlight layer
  62570. */
  62571. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62572. }
  62573. }
  62574. declare module "babylonjs/Layers/layerSceneComponent" {
  62575. import { Scene } from "babylonjs/scene";
  62576. import { ISceneComponent } from "babylonjs/sceneComponent";
  62577. import { Layer } from "babylonjs/Layers/layer";
  62578. import { AbstractScene } from "babylonjs/abstractScene";
  62579. module "babylonjs/abstractScene" {
  62580. interface AbstractScene {
  62581. /**
  62582. * The list of layers (background and foreground) of the scene
  62583. */
  62584. layers: Array<Layer>;
  62585. }
  62586. }
  62587. /**
  62588. * Defines the layer scene component responsible to manage any layers
  62589. * in a given scene.
  62590. */
  62591. export class LayerSceneComponent implements ISceneComponent {
  62592. /**
  62593. * The component name helpfull to identify the component in the list of scene components.
  62594. */
  62595. readonly name: string;
  62596. /**
  62597. * The scene the component belongs to.
  62598. */
  62599. scene: Scene;
  62600. private _engine;
  62601. /**
  62602. * Creates a new instance of the component for the given scene
  62603. * @param scene Defines the scene to register the component in
  62604. */
  62605. constructor(scene: Scene);
  62606. /**
  62607. * Registers the component in a given scene
  62608. */
  62609. register(): void;
  62610. /**
  62611. * Rebuilds the elements related to this component in case of
  62612. * context lost for instance.
  62613. */
  62614. rebuild(): void;
  62615. /**
  62616. * Disposes the component and the associated ressources.
  62617. */
  62618. dispose(): void;
  62619. private _draw;
  62620. private _drawCameraPredicate;
  62621. private _drawCameraBackground;
  62622. private _drawCameraForeground;
  62623. private _drawRenderTargetPredicate;
  62624. private _drawRenderTargetBackground;
  62625. private _drawRenderTargetForeground;
  62626. /**
  62627. * Adds all the elements from the container to the scene
  62628. * @param container the container holding the elements
  62629. */
  62630. addFromContainer(container: AbstractScene): void;
  62631. /**
  62632. * Removes all the elements in the container from the scene
  62633. * @param container contains the elements to remove
  62634. * @param dispose if the removed element should be disposed (default: false)
  62635. */
  62636. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62637. }
  62638. }
  62639. declare module "babylonjs/Shaders/layer.fragment" {
  62640. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62641. /** @hidden */
  62642. export var layerPixelShader: {
  62643. name: string;
  62644. shader: string;
  62645. };
  62646. }
  62647. declare module "babylonjs/Shaders/layer.vertex" {
  62648. /** @hidden */
  62649. export var layerVertexShader: {
  62650. name: string;
  62651. shader: string;
  62652. };
  62653. }
  62654. declare module "babylonjs/Layers/layer" {
  62655. import { Observable } from "babylonjs/Misc/observable";
  62656. import { Nullable } from "babylonjs/types";
  62657. import { Scene } from "babylonjs/scene";
  62658. import { Vector2 } from "babylonjs/Maths/math.vector";
  62659. import { Color4 } from "babylonjs/Maths/math.color";
  62660. import { Texture } from "babylonjs/Materials/Textures/texture";
  62661. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62662. import "babylonjs/Shaders/layer.fragment";
  62663. import "babylonjs/Shaders/layer.vertex";
  62664. /**
  62665. * This represents a full screen 2d layer.
  62666. * This can be useful to display a picture in the background of your scene for instance.
  62667. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62668. */
  62669. export class Layer {
  62670. /**
  62671. * Define the name of the layer.
  62672. */
  62673. name: string;
  62674. /**
  62675. * Define the texture the layer should display.
  62676. */
  62677. texture: Nullable<Texture>;
  62678. /**
  62679. * Is the layer in background or foreground.
  62680. */
  62681. isBackground: boolean;
  62682. /**
  62683. * Define the color of the layer (instead of texture).
  62684. */
  62685. color: Color4;
  62686. /**
  62687. * Define the scale of the layer in order to zoom in out of the texture.
  62688. */
  62689. scale: Vector2;
  62690. /**
  62691. * Define an offset for the layer in order to shift the texture.
  62692. */
  62693. offset: Vector2;
  62694. /**
  62695. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62696. */
  62697. alphaBlendingMode: number;
  62698. /**
  62699. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62700. * Alpha test will not mix with the background color in case of transparency.
  62701. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62702. */
  62703. alphaTest: boolean;
  62704. /**
  62705. * Define a mask to restrict the layer to only some of the scene cameras.
  62706. */
  62707. layerMask: number;
  62708. /**
  62709. * Define the list of render target the layer is visible into.
  62710. */
  62711. renderTargetTextures: RenderTargetTexture[];
  62712. /**
  62713. * Define if the layer is only used in renderTarget or if it also
  62714. * renders in the main frame buffer of the canvas.
  62715. */
  62716. renderOnlyInRenderTargetTextures: boolean;
  62717. private _scene;
  62718. private _vertexBuffers;
  62719. private _indexBuffer;
  62720. private _effect;
  62721. private _previousDefines;
  62722. /**
  62723. * An event triggered when the layer is disposed.
  62724. */
  62725. onDisposeObservable: Observable<Layer>;
  62726. private _onDisposeObserver;
  62727. /**
  62728. * Back compatibility with callback before the onDisposeObservable existed.
  62729. * The set callback will be triggered when the layer has been disposed.
  62730. */
  62731. set onDispose(callback: () => void);
  62732. /**
  62733. * An event triggered before rendering the scene
  62734. */
  62735. onBeforeRenderObservable: Observable<Layer>;
  62736. private _onBeforeRenderObserver;
  62737. /**
  62738. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62739. * The set callback will be triggered just before rendering the layer.
  62740. */
  62741. set onBeforeRender(callback: () => void);
  62742. /**
  62743. * An event triggered after rendering the scene
  62744. */
  62745. onAfterRenderObservable: Observable<Layer>;
  62746. private _onAfterRenderObserver;
  62747. /**
  62748. * Back compatibility with callback before the onAfterRenderObservable existed.
  62749. * The set callback will be triggered just after rendering the layer.
  62750. */
  62751. set onAfterRender(callback: () => void);
  62752. /**
  62753. * Instantiates a new layer.
  62754. * This represents a full screen 2d layer.
  62755. * This can be useful to display a picture in the background of your scene for instance.
  62756. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62757. * @param name Define the name of the layer in the scene
  62758. * @param imgUrl Define the url of the texture to display in the layer
  62759. * @param scene Define the scene the layer belongs to
  62760. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62761. * @param color Defines a color for the layer
  62762. */
  62763. constructor(
  62764. /**
  62765. * Define the name of the layer.
  62766. */
  62767. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62768. private _createIndexBuffer;
  62769. /** @hidden */
  62770. _rebuild(): void;
  62771. /**
  62772. * Renders the layer in the scene.
  62773. */
  62774. render(): void;
  62775. /**
  62776. * Disposes and releases the associated ressources.
  62777. */
  62778. dispose(): void;
  62779. }
  62780. }
  62781. declare module "babylonjs/Layers/index" {
  62782. export * from "babylonjs/Layers/effectLayer";
  62783. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62784. export * from "babylonjs/Layers/glowLayer";
  62785. export * from "babylonjs/Layers/highlightLayer";
  62786. export * from "babylonjs/Layers/layer";
  62787. export * from "babylonjs/Layers/layerSceneComponent";
  62788. }
  62789. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62790. /** @hidden */
  62791. export var lensFlarePixelShader: {
  62792. name: string;
  62793. shader: string;
  62794. };
  62795. }
  62796. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62797. /** @hidden */
  62798. export var lensFlareVertexShader: {
  62799. name: string;
  62800. shader: string;
  62801. };
  62802. }
  62803. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62804. import { Scene } from "babylonjs/scene";
  62805. import { Vector3 } from "babylonjs/Maths/math.vector";
  62806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62807. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62808. import "babylonjs/Shaders/lensFlare.fragment";
  62809. import "babylonjs/Shaders/lensFlare.vertex";
  62810. import { Viewport } from "babylonjs/Maths/math.viewport";
  62811. /**
  62812. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62813. * It is usually composed of several `lensFlare`.
  62814. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62815. */
  62816. export class LensFlareSystem {
  62817. /**
  62818. * Define the name of the lens flare system
  62819. */
  62820. name: string;
  62821. /**
  62822. * List of lens flares used in this system.
  62823. */
  62824. lensFlares: LensFlare[];
  62825. /**
  62826. * Define a limit from the border the lens flare can be visible.
  62827. */
  62828. borderLimit: number;
  62829. /**
  62830. * Define a viewport border we do not want to see the lens flare in.
  62831. */
  62832. viewportBorder: number;
  62833. /**
  62834. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62835. */
  62836. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62837. /**
  62838. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62839. */
  62840. layerMask: number;
  62841. /**
  62842. * Define the id of the lens flare system in the scene.
  62843. * (equal to name by default)
  62844. */
  62845. id: string;
  62846. private _scene;
  62847. private _emitter;
  62848. private _vertexBuffers;
  62849. private _indexBuffer;
  62850. private _effect;
  62851. private _positionX;
  62852. private _positionY;
  62853. private _isEnabled;
  62854. /** @hidden */
  62855. static _SceneComponentInitialization: (scene: Scene) => void;
  62856. /**
  62857. * Instantiates a lens flare system.
  62858. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62859. * It is usually composed of several `lensFlare`.
  62860. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62861. * @param name Define the name of the lens flare system in the scene
  62862. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62863. * @param scene Define the scene the lens flare system belongs to
  62864. */
  62865. constructor(
  62866. /**
  62867. * Define the name of the lens flare system
  62868. */
  62869. name: string, emitter: any, scene: Scene);
  62870. /**
  62871. * Define if the lens flare system is enabled.
  62872. */
  62873. get isEnabled(): boolean;
  62874. set isEnabled(value: boolean);
  62875. /**
  62876. * Get the scene the effects belongs to.
  62877. * @returns the scene holding the lens flare system
  62878. */
  62879. getScene(): Scene;
  62880. /**
  62881. * Get the emitter of the lens flare system.
  62882. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62883. * @returns the emitter of the lens flare system
  62884. */
  62885. getEmitter(): any;
  62886. /**
  62887. * Set the emitter of the lens flare system.
  62888. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62889. * @param newEmitter Define the new emitter of the system
  62890. */
  62891. setEmitter(newEmitter: any): void;
  62892. /**
  62893. * Get the lens flare system emitter position.
  62894. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62895. * @returns the position
  62896. */
  62897. getEmitterPosition(): Vector3;
  62898. /**
  62899. * @hidden
  62900. */
  62901. computeEffectivePosition(globalViewport: Viewport): boolean;
  62902. /** @hidden */
  62903. _isVisible(): boolean;
  62904. /**
  62905. * @hidden
  62906. */
  62907. render(): boolean;
  62908. /**
  62909. * Dispose and release the lens flare with its associated resources.
  62910. */
  62911. dispose(): void;
  62912. /**
  62913. * Parse a lens flare system from a JSON repressentation
  62914. * @param parsedLensFlareSystem Define the JSON to parse
  62915. * @param scene Define the scene the parsed system should be instantiated in
  62916. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62917. * @returns the parsed system
  62918. */
  62919. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62920. /**
  62921. * Serialize the current Lens Flare System into a JSON representation.
  62922. * @returns the serialized JSON
  62923. */
  62924. serialize(): any;
  62925. }
  62926. }
  62927. declare module "babylonjs/LensFlares/lensFlare" {
  62928. import { Nullable } from "babylonjs/types";
  62929. import { Color3 } from "babylonjs/Maths/math.color";
  62930. import { Texture } from "babylonjs/Materials/Textures/texture";
  62931. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62932. /**
  62933. * This represents one of the lens effect in a `lensFlareSystem`.
  62934. * It controls one of the indiviual texture used in the effect.
  62935. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62936. */
  62937. export class LensFlare {
  62938. /**
  62939. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62940. */
  62941. size: number;
  62942. /**
  62943. * 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.
  62944. */
  62945. position: number;
  62946. /**
  62947. * Define the lens color.
  62948. */
  62949. color: Color3;
  62950. /**
  62951. * Define the lens texture.
  62952. */
  62953. texture: Nullable<Texture>;
  62954. /**
  62955. * Define the alpha mode to render this particular lens.
  62956. */
  62957. alphaMode: number;
  62958. private _system;
  62959. /**
  62960. * Creates a new Lens Flare.
  62961. * This represents one of the lens effect in a `lensFlareSystem`.
  62962. * It controls one of the indiviual texture used in the effect.
  62963. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62964. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62965. * @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.
  62966. * @param color Define the lens color
  62967. * @param imgUrl Define the lens texture url
  62968. * @param system Define the `lensFlareSystem` this flare is part of
  62969. * @returns The newly created Lens Flare
  62970. */
  62971. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62972. /**
  62973. * Instantiates a new Lens Flare.
  62974. * This represents one of the lens effect in a `lensFlareSystem`.
  62975. * It controls one of the indiviual texture used in the effect.
  62976. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62977. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62978. * @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.
  62979. * @param color Define the lens color
  62980. * @param imgUrl Define the lens texture url
  62981. * @param system Define the `lensFlareSystem` this flare is part of
  62982. */
  62983. constructor(
  62984. /**
  62985. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62986. */
  62987. size: number,
  62988. /**
  62989. * 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.
  62990. */
  62991. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62992. /**
  62993. * Dispose and release the lens flare with its associated resources.
  62994. */
  62995. dispose(): void;
  62996. }
  62997. }
  62998. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62999. import { Nullable } from "babylonjs/types";
  63000. import { Scene } from "babylonjs/scene";
  63001. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63002. import { AbstractScene } from "babylonjs/abstractScene";
  63003. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63004. module "babylonjs/abstractScene" {
  63005. interface AbstractScene {
  63006. /**
  63007. * The list of lens flare system added to the scene
  63008. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63009. */
  63010. lensFlareSystems: Array<LensFlareSystem>;
  63011. /**
  63012. * Removes the given lens flare system from this scene.
  63013. * @param toRemove The lens flare system to remove
  63014. * @returns The index of the removed lens flare system
  63015. */
  63016. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63017. /**
  63018. * Adds the given lens flare system to this scene
  63019. * @param newLensFlareSystem The lens flare system to add
  63020. */
  63021. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63022. /**
  63023. * Gets a lens flare system using its name
  63024. * @param name defines the name to look for
  63025. * @returns the lens flare system or null if not found
  63026. */
  63027. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63028. /**
  63029. * Gets a lens flare system using its id
  63030. * @param id defines the id to look for
  63031. * @returns the lens flare system or null if not found
  63032. */
  63033. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63034. }
  63035. }
  63036. /**
  63037. * Defines the lens flare scene component responsible to manage any lens flares
  63038. * in a given scene.
  63039. */
  63040. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63041. /**
  63042. * The component name helpfull to identify the component in the list of scene components.
  63043. */
  63044. readonly name: string;
  63045. /**
  63046. * The scene the component belongs to.
  63047. */
  63048. scene: Scene;
  63049. /**
  63050. * Creates a new instance of the component for the given scene
  63051. * @param scene Defines the scene to register the component in
  63052. */
  63053. constructor(scene: Scene);
  63054. /**
  63055. * Registers the component in a given scene
  63056. */
  63057. register(): void;
  63058. /**
  63059. * Rebuilds the elements related to this component in case of
  63060. * context lost for instance.
  63061. */
  63062. rebuild(): void;
  63063. /**
  63064. * Adds all the elements from the container to the scene
  63065. * @param container the container holding the elements
  63066. */
  63067. addFromContainer(container: AbstractScene): void;
  63068. /**
  63069. * Removes all the elements in the container from the scene
  63070. * @param container contains the elements to remove
  63071. * @param dispose if the removed element should be disposed (default: false)
  63072. */
  63073. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63074. /**
  63075. * Serializes the component data to the specified json object
  63076. * @param serializationObject The object to serialize to
  63077. */
  63078. serialize(serializationObject: any): void;
  63079. /**
  63080. * Disposes the component and the associated ressources.
  63081. */
  63082. dispose(): void;
  63083. private _draw;
  63084. }
  63085. }
  63086. declare module "babylonjs/LensFlares/index" {
  63087. export * from "babylonjs/LensFlares/lensFlare";
  63088. export * from "babylonjs/LensFlares/lensFlareSystem";
  63089. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63090. }
  63091. declare module "babylonjs/Shaders/depth.fragment" {
  63092. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63093. /** @hidden */
  63094. export var depthPixelShader: {
  63095. name: string;
  63096. shader: string;
  63097. };
  63098. }
  63099. declare module "babylonjs/Shaders/depth.vertex" {
  63100. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63102. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63103. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63104. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63105. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63106. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63107. /** @hidden */
  63108. export var depthVertexShader: {
  63109. name: string;
  63110. shader: string;
  63111. };
  63112. }
  63113. declare module "babylonjs/Rendering/depthRenderer" {
  63114. import { Nullable } from "babylonjs/types";
  63115. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63116. import { Scene } from "babylonjs/scene";
  63117. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63118. import { Camera } from "babylonjs/Cameras/camera";
  63119. import "babylonjs/Shaders/depth.fragment";
  63120. import "babylonjs/Shaders/depth.vertex";
  63121. /**
  63122. * This represents a depth renderer in Babylon.
  63123. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63124. */
  63125. export class DepthRenderer {
  63126. private _scene;
  63127. private _depthMap;
  63128. private _effect;
  63129. private readonly _storeNonLinearDepth;
  63130. private readonly _clearColor;
  63131. /** Get if the depth renderer is using packed depth or not */
  63132. readonly isPacked: boolean;
  63133. private _cachedDefines;
  63134. private _camera;
  63135. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63136. enabled: boolean;
  63137. /**
  63138. * Specifiess that the depth renderer will only be used within
  63139. * the camera it is created for.
  63140. * This can help forcing its rendering during the camera processing.
  63141. */
  63142. useOnlyInActiveCamera: boolean;
  63143. /** @hidden */
  63144. static _SceneComponentInitialization: (scene: Scene) => void;
  63145. /**
  63146. * Instantiates a depth renderer
  63147. * @param scene The scene the renderer belongs to
  63148. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63149. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63150. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63151. */
  63152. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63153. /**
  63154. * Creates the depth rendering effect and checks if the effect is ready.
  63155. * @param subMesh The submesh to be used to render the depth map of
  63156. * @param useInstances If multiple world instances should be used
  63157. * @returns if the depth renderer is ready to render the depth map
  63158. */
  63159. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63160. /**
  63161. * Gets the texture which the depth map will be written to.
  63162. * @returns The depth map texture
  63163. */
  63164. getDepthMap(): RenderTargetTexture;
  63165. /**
  63166. * Disposes of the depth renderer.
  63167. */
  63168. dispose(): void;
  63169. }
  63170. }
  63171. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63172. /** @hidden */
  63173. export var minmaxReduxPixelShader: {
  63174. name: string;
  63175. shader: string;
  63176. };
  63177. }
  63178. declare module "babylonjs/Misc/minMaxReducer" {
  63179. import { Nullable } from "babylonjs/types";
  63180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63181. import { Camera } from "babylonjs/Cameras/camera";
  63182. import { Observer } from "babylonjs/Misc/observable";
  63183. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63184. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63185. import { Observable } from "babylonjs/Misc/observable";
  63186. import "babylonjs/Shaders/minmaxRedux.fragment";
  63187. /**
  63188. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63189. * and maximum values from all values of the texture.
  63190. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63191. * The source values are read from the red channel of the texture.
  63192. */
  63193. export class MinMaxReducer {
  63194. /**
  63195. * Observable triggered when the computation has been performed
  63196. */
  63197. onAfterReductionPerformed: Observable<{
  63198. min: number;
  63199. max: number;
  63200. }>;
  63201. protected _camera: Camera;
  63202. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63203. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63204. protected _postProcessManager: PostProcessManager;
  63205. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63206. protected _forceFullscreenViewport: boolean;
  63207. /**
  63208. * Creates a min/max reducer
  63209. * @param camera The camera to use for the post processes
  63210. */
  63211. constructor(camera: Camera);
  63212. /**
  63213. * Gets the texture used to read the values from.
  63214. */
  63215. get sourceTexture(): Nullable<RenderTargetTexture>;
  63216. /**
  63217. * Sets the source texture to read the values from.
  63218. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63219. * because in such textures '1' value must not be taken into account to compute the maximum
  63220. * as this value is used to clear the texture.
  63221. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63222. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63223. * @param depthRedux Indicates if the texture is a depth texture or not
  63224. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63225. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63226. */
  63227. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63228. /**
  63229. * Defines the refresh rate of the computation.
  63230. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63231. */
  63232. get refreshRate(): number;
  63233. set refreshRate(value: number);
  63234. protected _activated: boolean;
  63235. /**
  63236. * Gets the activation status of the reducer
  63237. */
  63238. get activated(): boolean;
  63239. /**
  63240. * Activates the reduction computation.
  63241. * When activated, the observers registered in onAfterReductionPerformed are
  63242. * called after the compuation is performed
  63243. */
  63244. activate(): void;
  63245. /**
  63246. * Deactivates the reduction computation.
  63247. */
  63248. deactivate(): void;
  63249. /**
  63250. * Disposes the min/max reducer
  63251. * @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.
  63252. */
  63253. dispose(disposeAll?: boolean): void;
  63254. }
  63255. }
  63256. declare module "babylonjs/Misc/depthReducer" {
  63257. import { Nullable } from "babylonjs/types";
  63258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63259. import { Camera } from "babylonjs/Cameras/camera";
  63260. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63261. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63262. /**
  63263. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63264. */
  63265. export class DepthReducer extends MinMaxReducer {
  63266. private _depthRenderer;
  63267. private _depthRendererId;
  63268. /**
  63269. * Gets the depth renderer used for the computation.
  63270. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63271. */
  63272. get depthRenderer(): Nullable<DepthRenderer>;
  63273. /**
  63274. * Creates a depth reducer
  63275. * @param camera The camera used to render the depth texture
  63276. */
  63277. constructor(camera: Camera);
  63278. /**
  63279. * Sets the depth renderer to use to generate the depth map
  63280. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63281. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63282. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63283. */
  63284. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63285. /** @hidden */
  63286. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63287. /**
  63288. * Activates the reduction computation.
  63289. * When activated, the observers registered in onAfterReductionPerformed are
  63290. * called after the compuation is performed
  63291. */
  63292. activate(): void;
  63293. /**
  63294. * Deactivates the reduction computation.
  63295. */
  63296. deactivate(): void;
  63297. /**
  63298. * Disposes the depth reducer
  63299. * @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.
  63300. */
  63301. dispose(disposeAll?: boolean): void;
  63302. }
  63303. }
  63304. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63305. import { Nullable } from "babylonjs/types";
  63306. import { Scene } from "babylonjs/scene";
  63307. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63308. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63310. import { Effect } from "babylonjs/Materials/effect";
  63311. import "babylonjs/Shaders/shadowMap.fragment";
  63312. import "babylonjs/Shaders/shadowMap.vertex";
  63313. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63314. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63315. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63316. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63317. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63318. /**
  63319. * A CSM implementation allowing casting shadows on large scenes.
  63320. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63321. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63322. */
  63323. export class CascadedShadowGenerator extends ShadowGenerator {
  63324. private static readonly frustumCornersNDCSpace;
  63325. /**
  63326. * Name of the CSM class
  63327. */
  63328. static CLASSNAME: string;
  63329. /**
  63330. * Defines the default number of cascades used by the CSM.
  63331. */
  63332. static readonly DEFAULT_CASCADES_COUNT: number;
  63333. /**
  63334. * Defines the minimum number of cascades used by the CSM.
  63335. */
  63336. static readonly MIN_CASCADES_COUNT: number;
  63337. /**
  63338. * Defines the maximum number of cascades used by the CSM.
  63339. */
  63340. static readonly MAX_CASCADES_COUNT: number;
  63341. protected _validateFilter(filter: number): number;
  63342. /**
  63343. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63344. */
  63345. penumbraDarkness: number;
  63346. private _numCascades;
  63347. /**
  63348. * Gets or set the number of cascades used by the CSM.
  63349. */
  63350. get numCascades(): number;
  63351. set numCascades(value: number);
  63352. /**
  63353. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63354. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63355. */
  63356. stabilizeCascades: boolean;
  63357. private _freezeShadowCastersBoundingInfo;
  63358. private _freezeShadowCastersBoundingInfoObservable;
  63359. /**
  63360. * Enables or disables the shadow casters bounding info computation.
  63361. * If your shadow casters don't move, you can disable this feature.
  63362. * If it is enabled, the bounding box computation is done every frame.
  63363. */
  63364. get freezeShadowCastersBoundingInfo(): boolean;
  63365. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63366. private _scbiMin;
  63367. private _scbiMax;
  63368. protected _computeShadowCastersBoundingInfo(): void;
  63369. protected _shadowCastersBoundingInfo: BoundingInfo;
  63370. /**
  63371. * Gets or sets the shadow casters bounding info.
  63372. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63373. * so that the system won't overwrite the bounds you provide
  63374. */
  63375. get shadowCastersBoundingInfo(): BoundingInfo;
  63376. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63377. protected _breaksAreDirty: boolean;
  63378. protected _minDistance: number;
  63379. protected _maxDistance: number;
  63380. /**
  63381. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63382. *
  63383. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63384. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63385. * @param min minimal distance for the breaks (default to 0.)
  63386. * @param max maximal distance for the breaks (default to 1.)
  63387. */
  63388. setMinMaxDistance(min: number, max: number): void;
  63389. /** Gets the minimal distance used in the cascade break computation */
  63390. get minDistance(): number;
  63391. /** Gets the maximal distance used in the cascade break computation */
  63392. get maxDistance(): number;
  63393. /**
  63394. * Gets the class name of that object
  63395. * @returns "CascadedShadowGenerator"
  63396. */
  63397. getClassName(): string;
  63398. private _cascadeMinExtents;
  63399. private _cascadeMaxExtents;
  63400. /**
  63401. * Gets a cascade minimum extents
  63402. * @param cascadeIndex index of the cascade
  63403. * @returns the minimum cascade extents
  63404. */
  63405. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63406. /**
  63407. * Gets a cascade maximum extents
  63408. * @param cascadeIndex index of the cascade
  63409. * @returns the maximum cascade extents
  63410. */
  63411. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63412. private _cascades;
  63413. private _currentLayer;
  63414. private _viewSpaceFrustumsZ;
  63415. private _viewMatrices;
  63416. private _projectionMatrices;
  63417. private _transformMatrices;
  63418. private _transformMatricesAsArray;
  63419. private _frustumLengths;
  63420. private _lightSizeUVCorrection;
  63421. private _depthCorrection;
  63422. private _frustumCornersWorldSpace;
  63423. private _frustumCenter;
  63424. private _shadowCameraPos;
  63425. private _shadowMaxZ;
  63426. /**
  63427. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63428. * It defaults to camera.maxZ
  63429. */
  63430. get shadowMaxZ(): number;
  63431. /**
  63432. * Sets the shadow max z distance.
  63433. */
  63434. set shadowMaxZ(value: number);
  63435. protected _debug: boolean;
  63436. /**
  63437. * Gets or sets the debug flag.
  63438. * When enabled, the cascades are materialized by different colors on the screen.
  63439. */
  63440. get debug(): boolean;
  63441. set debug(dbg: boolean);
  63442. private _depthClamp;
  63443. /**
  63444. * Gets or sets the depth clamping value.
  63445. *
  63446. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63447. * to account for the shadow casters far away.
  63448. *
  63449. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63450. */
  63451. get depthClamp(): boolean;
  63452. set depthClamp(value: boolean);
  63453. private _cascadeBlendPercentage;
  63454. /**
  63455. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63456. * It defaults to 0.1 (10% blending).
  63457. */
  63458. get cascadeBlendPercentage(): number;
  63459. set cascadeBlendPercentage(value: number);
  63460. private _lambda;
  63461. /**
  63462. * Gets or set the lambda parameter.
  63463. * This parameter is used to split the camera frustum and create the cascades.
  63464. * 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.
  63465. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63466. */
  63467. get lambda(): number;
  63468. set lambda(value: number);
  63469. /**
  63470. * Gets the view matrix corresponding to a given cascade
  63471. * @param cascadeNum cascade to retrieve the view matrix from
  63472. * @returns the cascade view matrix
  63473. */
  63474. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63475. /**
  63476. * Gets the projection matrix corresponding to a given cascade
  63477. * @param cascadeNum cascade to retrieve the projection matrix from
  63478. * @returns the cascade projection matrix
  63479. */
  63480. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63481. /**
  63482. * Gets the transformation matrix corresponding to a given cascade
  63483. * @param cascadeNum cascade to retrieve the transformation matrix from
  63484. * @returns the cascade transformation matrix
  63485. */
  63486. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63487. private _depthRenderer;
  63488. /**
  63489. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63490. *
  63491. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63492. *
  63493. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63494. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63495. * @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
  63496. */
  63497. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63498. private _depthReducer;
  63499. private _autoCalcDepthBounds;
  63500. /**
  63501. * Gets or sets the autoCalcDepthBounds property.
  63502. *
  63503. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63504. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63505. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63506. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63507. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63508. */
  63509. get autoCalcDepthBounds(): boolean;
  63510. set autoCalcDepthBounds(value: boolean);
  63511. /**
  63512. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63513. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63514. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63515. * for setting the refresh rate on the renderer yourself!
  63516. */
  63517. get autoCalcDepthBoundsRefreshRate(): number;
  63518. set autoCalcDepthBoundsRefreshRate(value: number);
  63519. /**
  63520. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63521. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63522. * you change the camera near/far planes!
  63523. */
  63524. splitFrustum(): void;
  63525. private _splitFrustum;
  63526. private _computeMatrices;
  63527. private _computeFrustumInWorldSpace;
  63528. private _computeCascadeFrustum;
  63529. /**
  63530. * Support test.
  63531. */
  63532. static get IsSupported(): boolean;
  63533. /** @hidden */
  63534. static _SceneComponentInitialization: (scene: Scene) => void;
  63535. /**
  63536. * Creates a Cascaded Shadow Generator object.
  63537. * A ShadowGenerator is the required tool to use the shadows.
  63538. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63539. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63540. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63541. * @param light The directional light object generating the shadows.
  63542. * @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.
  63543. */
  63544. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63545. protected _initializeGenerator(): void;
  63546. protected _createTargetRenderTexture(): void;
  63547. protected _initializeShadowMap(): void;
  63548. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63549. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63550. /**
  63551. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63552. * @param defines Defines of the material we want to update
  63553. * @param lightIndex Index of the light in the enabled light list of the material
  63554. */
  63555. prepareDefines(defines: any, lightIndex: number): void;
  63556. /**
  63557. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63558. * defined in the generator but impacting the effect).
  63559. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63560. * @param effect The effect we are binfing the information for
  63561. */
  63562. bindShadowLight(lightIndex: string, effect: Effect): void;
  63563. /**
  63564. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63565. * (eq to view projection * shadow projection matrices)
  63566. * @returns The transform matrix used to create the shadow map
  63567. */
  63568. getTransformMatrix(): Matrix;
  63569. /**
  63570. * Disposes the ShadowGenerator.
  63571. * Returns nothing.
  63572. */
  63573. dispose(): void;
  63574. /**
  63575. * Serializes the shadow generator setup to a json object.
  63576. * @returns The serialized JSON object
  63577. */
  63578. serialize(): any;
  63579. /**
  63580. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63581. * @param parsedShadowGenerator The JSON object to parse
  63582. * @param scene The scene to create the shadow map for
  63583. * @returns The parsed shadow generator
  63584. */
  63585. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63586. }
  63587. }
  63588. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63589. import { Scene } from "babylonjs/scene";
  63590. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63591. import { AbstractScene } from "babylonjs/abstractScene";
  63592. /**
  63593. * Defines the shadow generator component responsible to manage any shadow generators
  63594. * in a given scene.
  63595. */
  63596. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63597. /**
  63598. * The component name helpfull to identify the component in the list of scene components.
  63599. */
  63600. readonly name: string;
  63601. /**
  63602. * The scene the component belongs to.
  63603. */
  63604. scene: Scene;
  63605. /**
  63606. * Creates a new instance of the component for the given scene
  63607. * @param scene Defines the scene to register the component in
  63608. */
  63609. constructor(scene: Scene);
  63610. /**
  63611. * Registers the component in a given scene
  63612. */
  63613. register(): void;
  63614. /**
  63615. * Rebuilds the elements related to this component in case of
  63616. * context lost for instance.
  63617. */
  63618. rebuild(): void;
  63619. /**
  63620. * Serializes the component data to the specified json object
  63621. * @param serializationObject The object to serialize to
  63622. */
  63623. serialize(serializationObject: any): void;
  63624. /**
  63625. * Adds all the elements from the container to the scene
  63626. * @param container the container holding the elements
  63627. */
  63628. addFromContainer(container: AbstractScene): void;
  63629. /**
  63630. * Removes all the elements in the container from the scene
  63631. * @param container contains the elements to remove
  63632. * @param dispose if the removed element should be disposed (default: false)
  63633. */
  63634. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63635. /**
  63636. * Rebuilds the elements related to this component in case of
  63637. * context lost for instance.
  63638. */
  63639. dispose(): void;
  63640. private _gatherRenderTargets;
  63641. }
  63642. }
  63643. declare module "babylonjs/Lights/Shadows/index" {
  63644. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63645. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63646. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63647. }
  63648. declare module "babylonjs/Lights/pointLight" {
  63649. import { Scene } from "babylonjs/scene";
  63650. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63652. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63653. import { Effect } from "babylonjs/Materials/effect";
  63654. /**
  63655. * A point light is a light defined by an unique point in world space.
  63656. * The light is emitted in every direction from this point.
  63657. * A good example of a point light is a standard light bulb.
  63658. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63659. */
  63660. export class PointLight extends ShadowLight {
  63661. private _shadowAngle;
  63662. /**
  63663. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63664. * This specifies what angle the shadow will use to be created.
  63665. *
  63666. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63667. */
  63668. get shadowAngle(): number;
  63669. /**
  63670. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63671. * This specifies what angle the shadow will use to be created.
  63672. *
  63673. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63674. */
  63675. set shadowAngle(value: number);
  63676. /**
  63677. * Gets the direction if it has been set.
  63678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63679. */
  63680. get direction(): Vector3;
  63681. /**
  63682. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63683. */
  63684. set direction(value: Vector3);
  63685. /**
  63686. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63687. * A PointLight emits the light in every direction.
  63688. * It can cast shadows.
  63689. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63690. * ```javascript
  63691. * var pointLight = new PointLight("pl", camera.position, scene);
  63692. * ```
  63693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63694. * @param name The light friendly name
  63695. * @param position The position of the point light in the scene
  63696. * @param scene The scene the lights belongs to
  63697. */
  63698. constructor(name: string, position: Vector3, scene: Scene);
  63699. /**
  63700. * Returns the string "PointLight"
  63701. * @returns the class name
  63702. */
  63703. getClassName(): string;
  63704. /**
  63705. * Returns the integer 0.
  63706. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63707. */
  63708. getTypeID(): number;
  63709. /**
  63710. * Specifies wether or not the shadowmap should be a cube texture.
  63711. * @returns true if the shadowmap needs to be a cube texture.
  63712. */
  63713. needCube(): boolean;
  63714. /**
  63715. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63716. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63717. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63718. */
  63719. getShadowDirection(faceIndex?: number): Vector3;
  63720. /**
  63721. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63722. * - fov = PI / 2
  63723. * - aspect ratio : 1.0
  63724. * - z-near and far equal to the active camera minZ and maxZ.
  63725. * Returns the PointLight.
  63726. */
  63727. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63728. protected _buildUniformLayout(): void;
  63729. /**
  63730. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63731. * @param effect The effect to update
  63732. * @param lightIndex The index of the light in the effect to update
  63733. * @returns The point light
  63734. */
  63735. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63736. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63737. /**
  63738. * Prepares the list of defines specific to the light type.
  63739. * @param defines the list of defines
  63740. * @param lightIndex defines the index of the light for the effect
  63741. */
  63742. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63743. }
  63744. }
  63745. declare module "babylonjs/Lights/index" {
  63746. export * from "babylonjs/Lights/light";
  63747. export * from "babylonjs/Lights/shadowLight";
  63748. export * from "babylonjs/Lights/Shadows/index";
  63749. export * from "babylonjs/Lights/directionalLight";
  63750. export * from "babylonjs/Lights/hemisphericLight";
  63751. export * from "babylonjs/Lights/pointLight";
  63752. export * from "babylonjs/Lights/spotLight";
  63753. }
  63754. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63755. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63756. /**
  63757. * Header information of HDR texture files.
  63758. */
  63759. export interface HDRInfo {
  63760. /**
  63761. * The height of the texture in pixels.
  63762. */
  63763. height: number;
  63764. /**
  63765. * The width of the texture in pixels.
  63766. */
  63767. width: number;
  63768. /**
  63769. * The index of the beginning of the data in the binary file.
  63770. */
  63771. dataPosition: number;
  63772. }
  63773. /**
  63774. * This groups tools to convert HDR texture to native colors array.
  63775. */
  63776. export class HDRTools {
  63777. private static Ldexp;
  63778. private static Rgbe2float;
  63779. private static readStringLine;
  63780. /**
  63781. * Reads header information from an RGBE texture stored in a native array.
  63782. * More information on this format are available here:
  63783. * https://en.wikipedia.org/wiki/RGBE_image_format
  63784. *
  63785. * @param uint8array The binary file stored in native array.
  63786. * @return The header information.
  63787. */
  63788. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63789. /**
  63790. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63791. * This RGBE texture needs to store the information as a panorama.
  63792. *
  63793. * More information on this format are available here:
  63794. * https://en.wikipedia.org/wiki/RGBE_image_format
  63795. *
  63796. * @param buffer The binary file stored in an array buffer.
  63797. * @param size The expected size of the extracted cubemap.
  63798. * @return The Cube Map information.
  63799. */
  63800. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63801. /**
  63802. * Returns the pixels data extracted from an RGBE texture.
  63803. * This pixels will be stored left to right up to down in the R G B order in one array.
  63804. *
  63805. * More information on this format are available here:
  63806. * https://en.wikipedia.org/wiki/RGBE_image_format
  63807. *
  63808. * @param uint8array The binary file stored in an array buffer.
  63809. * @param hdrInfo The header information of the file.
  63810. * @return The pixels data in RGB right to left up to down order.
  63811. */
  63812. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63813. private static RGBE_ReadPixels_RLE;
  63814. private static RGBE_ReadPixels_NOT_RLE;
  63815. }
  63816. }
  63817. declare module "babylonjs/Materials/effectRenderer" {
  63818. import { Nullable } from "babylonjs/types";
  63819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63821. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63822. import { Viewport } from "babylonjs/Maths/math.viewport";
  63823. import { Observable } from "babylonjs/Misc/observable";
  63824. import { Effect } from "babylonjs/Materials/effect";
  63825. import "babylonjs/Shaders/postprocess.vertex";
  63826. /**
  63827. * Effect Render Options
  63828. */
  63829. export interface IEffectRendererOptions {
  63830. /**
  63831. * Defines the vertices positions.
  63832. */
  63833. positions?: number[];
  63834. /**
  63835. * Defines the indices.
  63836. */
  63837. indices?: number[];
  63838. }
  63839. /**
  63840. * Helper class to render one or more effects.
  63841. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63842. */
  63843. export class EffectRenderer {
  63844. private engine;
  63845. private static _DefaultOptions;
  63846. private _vertexBuffers;
  63847. private _indexBuffer;
  63848. private _fullscreenViewport;
  63849. /**
  63850. * Creates an effect renderer
  63851. * @param engine the engine to use for rendering
  63852. * @param options defines the options of the effect renderer
  63853. */
  63854. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63855. /**
  63856. * Sets the current viewport in normalized coordinates 0-1
  63857. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63858. */
  63859. setViewport(viewport?: Viewport): void;
  63860. /**
  63861. * Binds the embedded attributes buffer to the effect.
  63862. * @param effect Defines the effect to bind the attributes for
  63863. */
  63864. bindBuffers(effect: Effect): void;
  63865. /**
  63866. * Sets the current effect wrapper to use during draw.
  63867. * The effect needs to be ready before calling this api.
  63868. * This also sets the default full screen position attribute.
  63869. * @param effectWrapper Defines the effect to draw with
  63870. */
  63871. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63872. /**
  63873. * Restores engine states
  63874. */
  63875. restoreStates(): void;
  63876. /**
  63877. * Draws a full screen quad.
  63878. */
  63879. draw(): void;
  63880. private isRenderTargetTexture;
  63881. /**
  63882. * renders one or more effects to a specified texture
  63883. * @param effectWrapper the effect to renderer
  63884. * @param outputTexture texture to draw to, if null it will render to the screen.
  63885. */
  63886. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63887. /**
  63888. * Disposes of the effect renderer
  63889. */
  63890. dispose(): void;
  63891. }
  63892. /**
  63893. * Options to create an EffectWrapper
  63894. */
  63895. interface EffectWrapperCreationOptions {
  63896. /**
  63897. * Engine to use to create the effect
  63898. */
  63899. engine: ThinEngine;
  63900. /**
  63901. * Fragment shader for the effect
  63902. */
  63903. fragmentShader: string;
  63904. /**
  63905. * Use the shader store instead of direct source code
  63906. */
  63907. useShaderStore?: boolean;
  63908. /**
  63909. * Vertex shader for the effect
  63910. */
  63911. vertexShader?: string;
  63912. /**
  63913. * Attributes to use in the shader
  63914. */
  63915. attributeNames?: Array<string>;
  63916. /**
  63917. * Uniforms to use in the shader
  63918. */
  63919. uniformNames?: Array<string>;
  63920. /**
  63921. * Texture sampler names to use in the shader
  63922. */
  63923. samplerNames?: Array<string>;
  63924. /**
  63925. * Defines to use in the shader
  63926. */
  63927. defines?: Array<string>;
  63928. /**
  63929. * Callback when effect is compiled
  63930. */
  63931. onCompiled?: Nullable<(effect: Effect) => void>;
  63932. /**
  63933. * The friendly name of the effect displayed in Spector.
  63934. */
  63935. name?: string;
  63936. }
  63937. /**
  63938. * Wraps an effect to be used for rendering
  63939. */
  63940. export class EffectWrapper {
  63941. /**
  63942. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63943. */
  63944. onApplyObservable: Observable<{}>;
  63945. /**
  63946. * The underlying effect
  63947. */
  63948. effect: Effect;
  63949. /**
  63950. * Creates an effect to be renderer
  63951. * @param creationOptions options to create the effect
  63952. */
  63953. constructor(creationOptions: EffectWrapperCreationOptions);
  63954. /**
  63955. * Disposes of the effect wrapper
  63956. */
  63957. dispose(): void;
  63958. }
  63959. }
  63960. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63961. /** @hidden */
  63962. export var hdrFilteringVertexShader: {
  63963. name: string;
  63964. shader: string;
  63965. };
  63966. }
  63967. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63968. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63969. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63970. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63971. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63972. /** @hidden */
  63973. export var hdrFilteringPixelShader: {
  63974. name: string;
  63975. shader: string;
  63976. };
  63977. }
  63978. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63980. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63981. import { Nullable } from "babylonjs/types";
  63982. import "babylonjs/Shaders/hdrFiltering.vertex";
  63983. import "babylonjs/Shaders/hdrFiltering.fragment";
  63984. /**
  63985. * Options for texture filtering
  63986. */
  63987. interface IHDRFilteringOptions {
  63988. /**
  63989. * Scales pixel intensity for the input HDR map.
  63990. */
  63991. hdrScale?: number;
  63992. /**
  63993. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63994. */
  63995. quality?: number;
  63996. }
  63997. /**
  63998. * Filters HDR maps to get correct renderings of PBR reflections
  63999. */
  64000. export class HDRFiltering {
  64001. private _engine;
  64002. private _effectRenderer;
  64003. private _effectWrapper;
  64004. private _lodGenerationOffset;
  64005. private _lodGenerationScale;
  64006. /**
  64007. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64008. * you care about baking speed.
  64009. */
  64010. quality: number;
  64011. /**
  64012. * Scales pixel intensity for the input HDR map.
  64013. */
  64014. hdrScale: number;
  64015. /**
  64016. * Instantiates HDR filter for reflection maps
  64017. *
  64018. * @param engine Thin engine
  64019. * @param options Options
  64020. */
  64021. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64022. private _createRenderTarget;
  64023. private _prefilterInternal;
  64024. private _createEffect;
  64025. /**
  64026. * Get a value indicating if the filter is ready to be used
  64027. * @param texture Texture to filter
  64028. * @returns true if the filter is ready
  64029. */
  64030. isReady(texture: BaseTexture): boolean;
  64031. /**
  64032. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64033. * Prefiltering will be invoked at the end of next rendering pass.
  64034. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64035. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64036. * @param texture Texture to filter
  64037. * @param onFinished Callback when filtering is done
  64038. * @return Promise called when prefiltering is done
  64039. */
  64040. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64041. }
  64042. }
  64043. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64044. import { Nullable } from "babylonjs/types";
  64045. import { Scene } from "babylonjs/scene";
  64046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64048. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64049. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64050. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64051. /**
  64052. * This represents a texture coming from an HDR input.
  64053. *
  64054. * The only supported format is currently panorama picture stored in RGBE format.
  64055. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64056. */
  64057. export class HDRCubeTexture extends BaseTexture {
  64058. private static _facesMapping;
  64059. private _generateHarmonics;
  64060. private _noMipmap;
  64061. private _prefilterOnLoad;
  64062. private _textureMatrix;
  64063. private _size;
  64064. private _onLoad;
  64065. private _onError;
  64066. /**
  64067. * The texture URL.
  64068. */
  64069. url: string;
  64070. protected _isBlocking: boolean;
  64071. /**
  64072. * Sets wether or not the texture is blocking during loading.
  64073. */
  64074. set isBlocking(value: boolean);
  64075. /**
  64076. * Gets wether or not the texture is blocking during loading.
  64077. */
  64078. get isBlocking(): boolean;
  64079. protected _rotationY: number;
  64080. /**
  64081. * Sets texture matrix rotation angle around Y axis in radians.
  64082. */
  64083. set rotationY(value: number);
  64084. /**
  64085. * Gets texture matrix rotation angle around Y axis radians.
  64086. */
  64087. get rotationY(): number;
  64088. /**
  64089. * Gets or sets the center of the bounding box associated with the cube texture
  64090. * It must define where the camera used to render the texture was set
  64091. */
  64092. boundingBoxPosition: Vector3;
  64093. private _boundingBoxSize;
  64094. /**
  64095. * Gets or sets the size of the bounding box associated with the cube texture
  64096. * When defined, the cubemap will switch to local mode
  64097. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64098. * @example https://www.babylonjs-playground.com/#RNASML
  64099. */
  64100. set boundingBoxSize(value: Vector3);
  64101. get boundingBoxSize(): Vector3;
  64102. /**
  64103. * Instantiates an HDRTexture from the following parameters.
  64104. *
  64105. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64106. * @param sceneOrEngine The scene or engine the texture will be used in
  64107. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64108. * @param noMipmap Forces to not generate the mipmap if true
  64109. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64110. * @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)
  64111. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64112. */
  64113. 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>);
  64114. /**
  64115. * Get the current class name of the texture useful for serialization or dynamic coding.
  64116. * @returns "HDRCubeTexture"
  64117. */
  64118. getClassName(): string;
  64119. /**
  64120. * Occurs when the file is raw .hdr file.
  64121. */
  64122. private loadTexture;
  64123. clone(): HDRCubeTexture;
  64124. delayLoad(): void;
  64125. /**
  64126. * Get the texture reflection matrix used to rotate/transform the reflection.
  64127. * @returns the reflection matrix
  64128. */
  64129. getReflectionTextureMatrix(): Matrix;
  64130. /**
  64131. * Set the texture reflection matrix used to rotate/transform the reflection.
  64132. * @param value Define the reflection matrix to set
  64133. */
  64134. setReflectionTextureMatrix(value: Matrix): void;
  64135. /**
  64136. * Parses a JSON representation of an HDR Texture in order to create the texture
  64137. * @param parsedTexture Define the JSON representation
  64138. * @param scene Define the scene the texture should be created in
  64139. * @param rootUrl Define the root url in case we need to load relative dependencies
  64140. * @returns the newly created texture after parsing
  64141. */
  64142. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64143. serialize(): any;
  64144. }
  64145. }
  64146. declare module "babylonjs/Physics/physicsEngine" {
  64147. import { Nullable } from "babylonjs/types";
  64148. import { Vector3 } from "babylonjs/Maths/math.vector";
  64149. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64150. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64151. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64152. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64153. /**
  64154. * Class used to control physics engine
  64155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64156. */
  64157. export class PhysicsEngine implements IPhysicsEngine {
  64158. private _physicsPlugin;
  64159. /**
  64160. * Global value used to control the smallest number supported by the simulation
  64161. */
  64162. static Epsilon: number;
  64163. private _impostors;
  64164. private _joints;
  64165. private _subTimeStep;
  64166. /**
  64167. * Gets the gravity vector used by the simulation
  64168. */
  64169. gravity: Vector3;
  64170. /**
  64171. * Factory used to create the default physics plugin.
  64172. * @returns The default physics plugin
  64173. */
  64174. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64175. /**
  64176. * Creates a new Physics Engine
  64177. * @param gravity defines the gravity vector used by the simulation
  64178. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64179. */
  64180. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64181. /**
  64182. * Sets the gravity vector used by the simulation
  64183. * @param gravity defines the gravity vector to use
  64184. */
  64185. setGravity(gravity: Vector3): void;
  64186. /**
  64187. * Set the time step of the physics engine.
  64188. * Default is 1/60.
  64189. * To slow it down, enter 1/600 for example.
  64190. * To speed it up, 1/30
  64191. * @param newTimeStep defines the new timestep to apply to this world.
  64192. */
  64193. setTimeStep(newTimeStep?: number): void;
  64194. /**
  64195. * Get the time step of the physics engine.
  64196. * @returns the current time step
  64197. */
  64198. getTimeStep(): number;
  64199. /**
  64200. * Set the sub time step of the physics engine.
  64201. * Default is 0 meaning there is no sub steps
  64202. * To increase physics resolution precision, set a small value (like 1 ms)
  64203. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64204. */
  64205. setSubTimeStep(subTimeStep?: number): void;
  64206. /**
  64207. * Get the sub time step of the physics engine.
  64208. * @returns the current sub time step
  64209. */
  64210. getSubTimeStep(): number;
  64211. /**
  64212. * Release all resources
  64213. */
  64214. dispose(): void;
  64215. /**
  64216. * Gets the name of the current physics plugin
  64217. * @returns the name of the plugin
  64218. */
  64219. getPhysicsPluginName(): string;
  64220. /**
  64221. * Adding a new impostor for the impostor tracking.
  64222. * This will be done by the impostor itself.
  64223. * @param impostor the impostor to add
  64224. */
  64225. addImpostor(impostor: PhysicsImpostor): void;
  64226. /**
  64227. * Remove an impostor from the engine.
  64228. * This impostor and its mesh will not longer be updated by the physics engine.
  64229. * @param impostor the impostor to remove
  64230. */
  64231. removeImpostor(impostor: PhysicsImpostor): void;
  64232. /**
  64233. * Add a joint to the physics engine
  64234. * @param mainImpostor defines the main impostor to which the joint is added.
  64235. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64236. * @param joint defines the joint that will connect both impostors.
  64237. */
  64238. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64239. /**
  64240. * Removes a joint from the simulation
  64241. * @param mainImpostor defines the impostor used with the joint
  64242. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64243. * @param joint defines the joint to remove
  64244. */
  64245. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64246. /**
  64247. * Called by the scene. No need to call it.
  64248. * @param delta defines the timespam between frames
  64249. */
  64250. _step(delta: number): void;
  64251. /**
  64252. * Gets the current plugin used to run the simulation
  64253. * @returns current plugin
  64254. */
  64255. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64256. /**
  64257. * Gets the list of physic impostors
  64258. * @returns an array of PhysicsImpostor
  64259. */
  64260. getImpostors(): Array<PhysicsImpostor>;
  64261. /**
  64262. * Gets the impostor for a physics enabled object
  64263. * @param object defines the object impersonated by the impostor
  64264. * @returns the PhysicsImpostor or null if not found
  64265. */
  64266. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64267. /**
  64268. * Gets the impostor for a physics body object
  64269. * @param body defines physics body used by the impostor
  64270. * @returns the PhysicsImpostor or null if not found
  64271. */
  64272. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64273. /**
  64274. * Does a raycast in the physics world
  64275. * @param from when should the ray start?
  64276. * @param to when should the ray end?
  64277. * @returns PhysicsRaycastResult
  64278. */
  64279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64280. }
  64281. }
  64282. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64283. import { Nullable } from "babylonjs/types";
  64284. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64286. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64287. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64288. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64289. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64290. /** @hidden */
  64291. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64292. private _useDeltaForWorldStep;
  64293. world: any;
  64294. name: string;
  64295. private _physicsMaterials;
  64296. private _fixedTimeStep;
  64297. private _cannonRaycastResult;
  64298. private _raycastResult;
  64299. private _physicsBodysToRemoveAfterStep;
  64300. private _firstFrame;
  64301. BJSCANNON: any;
  64302. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64303. setGravity(gravity: Vector3): void;
  64304. setTimeStep(timeStep: number): void;
  64305. getTimeStep(): number;
  64306. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64307. private _removeMarkedPhysicsBodiesFromWorld;
  64308. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64309. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64310. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64311. private _processChildMeshes;
  64312. removePhysicsBody(impostor: PhysicsImpostor): void;
  64313. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64314. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64315. private _addMaterial;
  64316. private _checkWithEpsilon;
  64317. private _createShape;
  64318. private _createHeightmap;
  64319. private _minus90X;
  64320. private _plus90X;
  64321. private _tmpPosition;
  64322. private _tmpDeltaPosition;
  64323. private _tmpUnityRotation;
  64324. private _updatePhysicsBodyTransformation;
  64325. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64326. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64327. isSupported(): boolean;
  64328. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64329. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64330. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64332. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64333. getBodyMass(impostor: PhysicsImpostor): number;
  64334. getBodyFriction(impostor: PhysicsImpostor): number;
  64335. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64336. getBodyRestitution(impostor: PhysicsImpostor): number;
  64337. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64338. sleepBody(impostor: PhysicsImpostor): void;
  64339. wakeUpBody(impostor: PhysicsImpostor): void;
  64340. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64341. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64342. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64343. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64344. getRadius(impostor: PhysicsImpostor): number;
  64345. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64346. dispose(): void;
  64347. private _extendNamespace;
  64348. /**
  64349. * Does a raycast in the physics world
  64350. * @param from when should the ray start?
  64351. * @param to when should the ray end?
  64352. * @returns PhysicsRaycastResult
  64353. */
  64354. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64355. }
  64356. }
  64357. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64358. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64359. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64360. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64362. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64363. import { Nullable } from "babylonjs/types";
  64364. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64365. /** @hidden */
  64366. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64367. private _useDeltaForWorldStep;
  64368. world: any;
  64369. name: string;
  64370. BJSOIMO: any;
  64371. private _raycastResult;
  64372. private _fixedTimeStep;
  64373. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64374. setGravity(gravity: Vector3): void;
  64375. setTimeStep(timeStep: number): void;
  64376. getTimeStep(): number;
  64377. private _tmpImpostorsArray;
  64378. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64379. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64380. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64381. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64382. private _tmpPositionVector;
  64383. removePhysicsBody(impostor: PhysicsImpostor): void;
  64384. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64385. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64386. isSupported(): boolean;
  64387. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64388. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64389. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64390. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64391. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64392. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64393. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64394. getBodyMass(impostor: PhysicsImpostor): number;
  64395. getBodyFriction(impostor: PhysicsImpostor): number;
  64396. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64397. getBodyRestitution(impostor: PhysicsImpostor): number;
  64398. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64399. sleepBody(impostor: PhysicsImpostor): void;
  64400. wakeUpBody(impostor: PhysicsImpostor): void;
  64401. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64402. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64403. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64404. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64405. getRadius(impostor: PhysicsImpostor): number;
  64406. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64407. dispose(): void;
  64408. /**
  64409. * Does a raycast in the physics world
  64410. * @param from when should the ray start?
  64411. * @param to when should the ray end?
  64412. * @returns PhysicsRaycastResult
  64413. */
  64414. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64415. }
  64416. }
  64417. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64418. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64419. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64420. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64421. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64422. import { Nullable } from "babylonjs/types";
  64423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64424. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64425. /**
  64426. * AmmoJS Physics plugin
  64427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64428. * @see https://github.com/kripken/ammo.js/
  64429. */
  64430. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64431. private _useDeltaForWorldStep;
  64432. /**
  64433. * Reference to the Ammo library
  64434. */
  64435. bjsAMMO: any;
  64436. /**
  64437. * Created ammoJS world which physics bodies are added to
  64438. */
  64439. world: any;
  64440. /**
  64441. * Name of the plugin
  64442. */
  64443. name: string;
  64444. private _timeStep;
  64445. private _fixedTimeStep;
  64446. private _maxSteps;
  64447. private _tmpQuaternion;
  64448. private _tmpAmmoTransform;
  64449. private _tmpAmmoQuaternion;
  64450. private _tmpAmmoConcreteContactResultCallback;
  64451. private _collisionConfiguration;
  64452. private _dispatcher;
  64453. private _overlappingPairCache;
  64454. private _solver;
  64455. private _softBodySolver;
  64456. private _tmpAmmoVectorA;
  64457. private _tmpAmmoVectorB;
  64458. private _tmpAmmoVectorC;
  64459. private _tmpAmmoVectorD;
  64460. private _tmpContactCallbackResult;
  64461. private _tmpAmmoVectorRCA;
  64462. private _tmpAmmoVectorRCB;
  64463. private _raycastResult;
  64464. private _tmpContactPoint;
  64465. private static readonly DISABLE_COLLISION_FLAG;
  64466. private static readonly KINEMATIC_FLAG;
  64467. private static readonly DISABLE_DEACTIVATION_FLAG;
  64468. /**
  64469. * Initializes the ammoJS plugin
  64470. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64471. * @param ammoInjection can be used to inject your own ammo reference
  64472. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64473. */
  64474. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64475. /**
  64476. * Sets the gravity of the physics world (m/(s^2))
  64477. * @param gravity Gravity to set
  64478. */
  64479. setGravity(gravity: Vector3): void;
  64480. /**
  64481. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64482. * @param timeStep timestep to use in seconds
  64483. */
  64484. setTimeStep(timeStep: number): void;
  64485. /**
  64486. * 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)
  64487. * @param fixedTimeStep fixedTimeStep to use in seconds
  64488. */
  64489. setFixedTimeStep(fixedTimeStep: number): void;
  64490. /**
  64491. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64492. * @param maxSteps the maximum number of steps by the physics engine per frame
  64493. */
  64494. setMaxSteps(maxSteps: number): void;
  64495. /**
  64496. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64497. * @returns the current timestep in seconds
  64498. */
  64499. getTimeStep(): number;
  64500. /**
  64501. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64502. */
  64503. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64504. private _isImpostorInContact;
  64505. private _isImpostorPairInContact;
  64506. private _stepSimulation;
  64507. /**
  64508. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64509. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64510. * After the step the babylon meshes are set to the position of the physics imposters
  64511. * @param delta amount of time to step forward
  64512. * @param impostors array of imposters to update before/after the step
  64513. */
  64514. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64515. /**
  64516. * Update babylon mesh to match physics world object
  64517. * @param impostor imposter to match
  64518. */
  64519. private _afterSoftStep;
  64520. /**
  64521. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64522. * @param impostor imposter to match
  64523. */
  64524. private _ropeStep;
  64525. /**
  64526. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64527. * @param impostor imposter to match
  64528. */
  64529. private _softbodyOrClothStep;
  64530. private _tmpMatrix;
  64531. /**
  64532. * Applies an impulse on the imposter
  64533. * @param impostor imposter to apply impulse to
  64534. * @param force amount of force to be applied to the imposter
  64535. * @param contactPoint the location to apply the impulse on the imposter
  64536. */
  64537. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64538. /**
  64539. * Applies a force on the imposter
  64540. * @param impostor imposter to apply force
  64541. * @param force amount of force to be applied to the imposter
  64542. * @param contactPoint the location to apply the force on the imposter
  64543. */
  64544. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64545. /**
  64546. * Creates a physics body using the plugin
  64547. * @param impostor the imposter to create the physics body on
  64548. */
  64549. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64550. /**
  64551. * Removes the physics body from the imposter and disposes of the body's memory
  64552. * @param impostor imposter to remove the physics body from
  64553. */
  64554. removePhysicsBody(impostor: PhysicsImpostor): void;
  64555. /**
  64556. * Generates a joint
  64557. * @param impostorJoint the imposter joint to create the joint with
  64558. */
  64559. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64560. /**
  64561. * Removes a joint
  64562. * @param impostorJoint the imposter joint to remove the joint from
  64563. */
  64564. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64565. private _addMeshVerts;
  64566. /**
  64567. * Initialise the soft body vertices to match its object's (mesh) vertices
  64568. * Softbody vertices (nodes) are in world space and to match this
  64569. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64570. * @param impostor to create the softbody for
  64571. */
  64572. private _softVertexData;
  64573. /**
  64574. * Create an impostor's soft body
  64575. * @param impostor to create the softbody for
  64576. */
  64577. private _createSoftbody;
  64578. /**
  64579. * Create cloth for an impostor
  64580. * @param impostor to create the softbody for
  64581. */
  64582. private _createCloth;
  64583. /**
  64584. * Create rope for an impostor
  64585. * @param impostor to create the softbody for
  64586. */
  64587. private _createRope;
  64588. /**
  64589. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64590. * @param impostor to create the custom physics shape for
  64591. */
  64592. private _createCustom;
  64593. private _addHullVerts;
  64594. private _createShape;
  64595. /**
  64596. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64597. * @param impostor imposter containing the physics body and babylon object
  64598. */
  64599. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64600. /**
  64601. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64602. * @param impostor imposter containing the physics body and babylon object
  64603. * @param newPosition new position
  64604. * @param newRotation new rotation
  64605. */
  64606. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64607. /**
  64608. * If this plugin is supported
  64609. * @returns true if its supported
  64610. */
  64611. isSupported(): boolean;
  64612. /**
  64613. * Sets the linear velocity of the physics body
  64614. * @param impostor imposter to set the velocity on
  64615. * @param velocity velocity to set
  64616. */
  64617. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64618. /**
  64619. * Sets the angular velocity of the physics body
  64620. * @param impostor imposter to set the velocity on
  64621. * @param velocity velocity to set
  64622. */
  64623. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64624. /**
  64625. * gets the linear velocity
  64626. * @param impostor imposter to get linear velocity from
  64627. * @returns linear velocity
  64628. */
  64629. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64630. /**
  64631. * gets the angular velocity
  64632. * @param impostor imposter to get angular velocity from
  64633. * @returns angular velocity
  64634. */
  64635. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64636. /**
  64637. * Sets the mass of physics body
  64638. * @param impostor imposter to set the mass on
  64639. * @param mass mass to set
  64640. */
  64641. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64642. /**
  64643. * Gets the mass of the physics body
  64644. * @param impostor imposter to get the mass from
  64645. * @returns mass
  64646. */
  64647. getBodyMass(impostor: PhysicsImpostor): number;
  64648. /**
  64649. * Gets friction of the impostor
  64650. * @param impostor impostor to get friction from
  64651. * @returns friction value
  64652. */
  64653. getBodyFriction(impostor: PhysicsImpostor): number;
  64654. /**
  64655. * Sets friction of the impostor
  64656. * @param impostor impostor to set friction on
  64657. * @param friction friction value
  64658. */
  64659. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64660. /**
  64661. * Gets restitution of the impostor
  64662. * @param impostor impostor to get restitution from
  64663. * @returns restitution value
  64664. */
  64665. getBodyRestitution(impostor: PhysicsImpostor): number;
  64666. /**
  64667. * Sets resitution of the impostor
  64668. * @param impostor impostor to set resitution on
  64669. * @param restitution resitution value
  64670. */
  64671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64672. /**
  64673. * Gets pressure inside the impostor
  64674. * @param impostor impostor to get pressure from
  64675. * @returns pressure value
  64676. */
  64677. getBodyPressure(impostor: PhysicsImpostor): number;
  64678. /**
  64679. * Sets pressure inside a soft body impostor
  64680. * Cloth and rope must remain 0 pressure
  64681. * @param impostor impostor to set pressure on
  64682. * @param pressure pressure value
  64683. */
  64684. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64685. /**
  64686. * Gets stiffness of the impostor
  64687. * @param impostor impostor to get stiffness from
  64688. * @returns pressure value
  64689. */
  64690. getBodyStiffness(impostor: PhysicsImpostor): number;
  64691. /**
  64692. * Sets stiffness of the impostor
  64693. * @param impostor impostor to set stiffness on
  64694. * @param stiffness stiffness value from 0 to 1
  64695. */
  64696. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64697. /**
  64698. * Gets velocityIterations of the impostor
  64699. * @param impostor impostor to get velocity iterations from
  64700. * @returns velocityIterations value
  64701. */
  64702. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64703. /**
  64704. * Sets velocityIterations of the impostor
  64705. * @param impostor impostor to set velocity iterations on
  64706. * @param velocityIterations velocityIterations value
  64707. */
  64708. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64709. /**
  64710. * Gets positionIterations of the impostor
  64711. * @param impostor impostor to get position iterations from
  64712. * @returns positionIterations value
  64713. */
  64714. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64715. /**
  64716. * Sets positionIterations of the impostor
  64717. * @param impostor impostor to set position on
  64718. * @param positionIterations positionIterations value
  64719. */
  64720. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64721. /**
  64722. * Append an anchor to a cloth object
  64723. * @param impostor is the cloth impostor to add anchor to
  64724. * @param otherImpostor is the rigid impostor to anchor to
  64725. * @param width ratio across width from 0 to 1
  64726. * @param height ratio up height from 0 to 1
  64727. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64728. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64729. */
  64730. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64731. /**
  64732. * Append an hook to a rope object
  64733. * @param impostor is the rope impostor to add hook to
  64734. * @param otherImpostor is the rigid impostor to hook to
  64735. * @param length ratio along the rope from 0 to 1
  64736. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64737. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64738. */
  64739. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64740. /**
  64741. * Sleeps the physics body and stops it from being active
  64742. * @param impostor impostor to sleep
  64743. */
  64744. sleepBody(impostor: PhysicsImpostor): void;
  64745. /**
  64746. * Activates the physics body
  64747. * @param impostor impostor to activate
  64748. */
  64749. wakeUpBody(impostor: PhysicsImpostor): void;
  64750. /**
  64751. * Updates the distance parameters of the joint
  64752. * @param joint joint to update
  64753. * @param maxDistance maximum distance of the joint
  64754. * @param minDistance minimum distance of the joint
  64755. */
  64756. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64757. /**
  64758. * Sets a motor on the joint
  64759. * @param joint joint to set motor on
  64760. * @param speed speed of the motor
  64761. * @param maxForce maximum force of the motor
  64762. * @param motorIndex index of the motor
  64763. */
  64764. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64765. /**
  64766. * Sets the motors limit
  64767. * @param joint joint to set limit on
  64768. * @param upperLimit upper limit
  64769. * @param lowerLimit lower limit
  64770. */
  64771. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64772. /**
  64773. * Syncs the position and rotation of a mesh with the impostor
  64774. * @param mesh mesh to sync
  64775. * @param impostor impostor to update the mesh with
  64776. */
  64777. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64778. /**
  64779. * Gets the radius of the impostor
  64780. * @param impostor impostor to get radius from
  64781. * @returns the radius
  64782. */
  64783. getRadius(impostor: PhysicsImpostor): number;
  64784. /**
  64785. * Gets the box size of the impostor
  64786. * @param impostor impostor to get box size from
  64787. * @param result the resulting box size
  64788. */
  64789. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64790. /**
  64791. * Disposes of the impostor
  64792. */
  64793. dispose(): void;
  64794. /**
  64795. * Does a raycast in the physics world
  64796. * @param from when should the ray start?
  64797. * @param to when should the ray end?
  64798. * @returns PhysicsRaycastResult
  64799. */
  64800. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64801. }
  64802. }
  64803. declare module "babylonjs/Probes/reflectionProbe" {
  64804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64805. import { Vector3 } from "babylonjs/Maths/math.vector";
  64806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64807. import { Nullable } from "babylonjs/types";
  64808. import { Scene } from "babylonjs/scene";
  64809. module "babylonjs/abstractScene" {
  64810. interface AbstractScene {
  64811. /**
  64812. * The list of reflection probes added to the scene
  64813. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64814. */
  64815. reflectionProbes: Array<ReflectionProbe>;
  64816. /**
  64817. * Removes the given reflection probe from this scene.
  64818. * @param toRemove The reflection probe to remove
  64819. * @returns The index of the removed reflection probe
  64820. */
  64821. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64822. /**
  64823. * Adds the given reflection probe to this scene.
  64824. * @param newReflectionProbe The reflection probe to add
  64825. */
  64826. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64827. }
  64828. }
  64829. /**
  64830. * Class used to generate realtime reflection / refraction cube textures
  64831. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64832. */
  64833. export class ReflectionProbe {
  64834. /** defines the name of the probe */
  64835. name: string;
  64836. private _scene;
  64837. private _renderTargetTexture;
  64838. private _projectionMatrix;
  64839. private _viewMatrix;
  64840. private _target;
  64841. private _add;
  64842. private _attachedMesh;
  64843. private _invertYAxis;
  64844. /** Gets or sets probe position (center of the cube map) */
  64845. position: Vector3;
  64846. /**
  64847. * Creates a new reflection probe
  64848. * @param name defines the name of the probe
  64849. * @param size defines the texture resolution (for each face)
  64850. * @param scene defines the hosting scene
  64851. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64852. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64853. */
  64854. constructor(
  64855. /** defines the name of the probe */
  64856. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64857. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64858. get samples(): number;
  64859. set samples(value: number);
  64860. /** Gets or sets the refresh rate to use (on every frame by default) */
  64861. get refreshRate(): number;
  64862. set refreshRate(value: number);
  64863. /**
  64864. * Gets the hosting scene
  64865. * @returns a Scene
  64866. */
  64867. getScene(): Scene;
  64868. /** Gets the internal CubeTexture used to render to */
  64869. get cubeTexture(): RenderTargetTexture;
  64870. /** Gets the list of meshes to render */
  64871. get renderList(): Nullable<AbstractMesh[]>;
  64872. /**
  64873. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64874. * @param mesh defines the mesh to attach to
  64875. */
  64876. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64877. /**
  64878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64879. * @param renderingGroupId The rendering group id corresponding to its index
  64880. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64881. */
  64882. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64883. /**
  64884. * Clean all associated resources
  64885. */
  64886. dispose(): void;
  64887. /**
  64888. * Converts the reflection probe information to a readable string for debug purpose.
  64889. * @param fullDetails Supports for multiple levels of logging within scene loading
  64890. * @returns the human readable reflection probe info
  64891. */
  64892. toString(fullDetails?: boolean): string;
  64893. /**
  64894. * Get the class name of the relfection probe.
  64895. * @returns "ReflectionProbe"
  64896. */
  64897. getClassName(): string;
  64898. /**
  64899. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64900. * @returns The JSON representation of the texture
  64901. */
  64902. serialize(): any;
  64903. /**
  64904. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64905. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64906. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64907. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64908. * @returns The parsed reflection probe if successful
  64909. */
  64910. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64911. }
  64912. }
  64913. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64914. /** @hidden */
  64915. export var _BabylonLoaderRegistered: boolean;
  64916. /**
  64917. * Helps setting up some configuration for the babylon file loader.
  64918. */
  64919. export class BabylonFileLoaderConfiguration {
  64920. /**
  64921. * The loader does not allow injecting custom physix engine into the plugins.
  64922. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64923. * So you could set this variable to your engine import to make it work.
  64924. */
  64925. static LoaderInjectedPhysicsEngine: any;
  64926. }
  64927. }
  64928. declare module "babylonjs/Loading/Plugins/index" {
  64929. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64930. }
  64931. declare module "babylonjs/Loading/index" {
  64932. export * from "babylonjs/Loading/loadingScreen";
  64933. export * from "babylonjs/Loading/Plugins/index";
  64934. export * from "babylonjs/Loading/sceneLoader";
  64935. export * from "babylonjs/Loading/sceneLoaderFlags";
  64936. }
  64937. declare module "babylonjs/Materials/Background/index" {
  64938. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64939. }
  64940. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64941. import { Scene } from "babylonjs/scene";
  64942. import { Color3 } from "babylonjs/Maths/math.color";
  64943. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64945. /**
  64946. * The Physically based simple base material of BJS.
  64947. *
  64948. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64949. * It is used as the base class for both the specGloss and metalRough conventions.
  64950. */
  64951. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64952. /**
  64953. * Number of Simultaneous lights allowed on the material.
  64954. */
  64955. maxSimultaneousLights: number;
  64956. /**
  64957. * If sets to true, disables all the lights affecting the material.
  64958. */
  64959. disableLighting: boolean;
  64960. /**
  64961. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64962. */
  64963. environmentTexture: BaseTexture;
  64964. /**
  64965. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64966. */
  64967. invertNormalMapX: boolean;
  64968. /**
  64969. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64970. */
  64971. invertNormalMapY: boolean;
  64972. /**
  64973. * Normal map used in the model.
  64974. */
  64975. normalTexture: BaseTexture;
  64976. /**
  64977. * Emissivie color used to self-illuminate the model.
  64978. */
  64979. emissiveColor: Color3;
  64980. /**
  64981. * Emissivie texture used to self-illuminate the model.
  64982. */
  64983. emissiveTexture: BaseTexture;
  64984. /**
  64985. * Occlusion Channel Strenght.
  64986. */
  64987. occlusionStrength: number;
  64988. /**
  64989. * Occlusion Texture of the material (adding extra occlusion effects).
  64990. */
  64991. occlusionTexture: BaseTexture;
  64992. /**
  64993. * Defines the alpha limits in alpha test mode.
  64994. */
  64995. alphaCutOff: number;
  64996. /**
  64997. * Gets the current double sided mode.
  64998. */
  64999. get doubleSided(): boolean;
  65000. /**
  65001. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65002. */
  65003. set doubleSided(value: boolean);
  65004. /**
  65005. * Stores the pre-calculated light information of a mesh in a texture.
  65006. */
  65007. lightmapTexture: BaseTexture;
  65008. /**
  65009. * If true, the light map contains occlusion information instead of lighting info.
  65010. */
  65011. useLightmapAsShadowmap: boolean;
  65012. /**
  65013. * Instantiates a new PBRMaterial instance.
  65014. *
  65015. * @param name The material name
  65016. * @param scene The scene the material will be use in.
  65017. */
  65018. constructor(name: string, scene: Scene);
  65019. getClassName(): string;
  65020. }
  65021. }
  65022. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65023. import { Scene } from "babylonjs/scene";
  65024. import { Color3 } from "babylonjs/Maths/math.color";
  65025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65026. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65027. /**
  65028. * The PBR material of BJS following the metal roughness convention.
  65029. *
  65030. * This fits to the PBR convention in the GLTF definition:
  65031. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65032. */
  65033. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65034. /**
  65035. * The base color has two different interpretations depending on the value of metalness.
  65036. * When the material is a metal, the base color is the specific measured reflectance value
  65037. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65038. * of the material.
  65039. */
  65040. baseColor: Color3;
  65041. /**
  65042. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65043. * well as opacity information in the alpha channel.
  65044. */
  65045. baseTexture: BaseTexture;
  65046. /**
  65047. * Specifies the metallic scalar value of the material.
  65048. * Can also be used to scale the metalness values of the metallic texture.
  65049. */
  65050. metallic: number;
  65051. /**
  65052. * Specifies the roughness scalar value of the material.
  65053. * Can also be used to scale the roughness values of the metallic texture.
  65054. */
  65055. roughness: number;
  65056. /**
  65057. * Texture containing both the metallic value in the B channel and the
  65058. * roughness value in the G channel to keep better precision.
  65059. */
  65060. metallicRoughnessTexture: BaseTexture;
  65061. /**
  65062. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65063. *
  65064. * @param name The material name
  65065. * @param scene The scene the material will be use in.
  65066. */
  65067. constructor(name: string, scene: Scene);
  65068. /**
  65069. * Return the currrent class name of the material.
  65070. */
  65071. getClassName(): string;
  65072. /**
  65073. * Makes a duplicate of the current material.
  65074. * @param name - name to use for the new material.
  65075. */
  65076. clone(name: string): PBRMetallicRoughnessMaterial;
  65077. /**
  65078. * Serialize the material to a parsable JSON object.
  65079. */
  65080. serialize(): any;
  65081. /**
  65082. * Parses a JSON object correponding to the serialize function.
  65083. */
  65084. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65085. }
  65086. }
  65087. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65088. import { Scene } from "babylonjs/scene";
  65089. import { Color3 } from "babylonjs/Maths/math.color";
  65090. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65091. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65092. /**
  65093. * The PBR material of BJS following the specular glossiness convention.
  65094. *
  65095. * This fits to the PBR convention in the GLTF definition:
  65096. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65097. */
  65098. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65099. /**
  65100. * Specifies the diffuse color of the material.
  65101. */
  65102. diffuseColor: Color3;
  65103. /**
  65104. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65105. * channel.
  65106. */
  65107. diffuseTexture: BaseTexture;
  65108. /**
  65109. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65110. */
  65111. specularColor: Color3;
  65112. /**
  65113. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65114. */
  65115. glossiness: number;
  65116. /**
  65117. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65118. */
  65119. specularGlossinessTexture: BaseTexture;
  65120. /**
  65121. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65122. *
  65123. * @param name The material name
  65124. * @param scene The scene the material will be use in.
  65125. */
  65126. constructor(name: string, scene: Scene);
  65127. /**
  65128. * Return the currrent class name of the material.
  65129. */
  65130. getClassName(): string;
  65131. /**
  65132. * Makes a duplicate of the current material.
  65133. * @param name - name to use for the new material.
  65134. */
  65135. clone(name: string): PBRSpecularGlossinessMaterial;
  65136. /**
  65137. * Serialize the material to a parsable JSON object.
  65138. */
  65139. serialize(): any;
  65140. /**
  65141. * Parses a JSON object correponding to the serialize function.
  65142. */
  65143. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65144. }
  65145. }
  65146. declare module "babylonjs/Materials/PBR/index" {
  65147. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65148. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65149. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65150. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65151. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65152. }
  65153. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65154. import { Nullable } from "babylonjs/types";
  65155. import { Scene } from "babylonjs/scene";
  65156. import { Matrix } from "babylonjs/Maths/math.vector";
  65157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65158. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65159. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65160. /**
  65161. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65162. * It can help converting any input color in a desired output one. This can then be used to create effects
  65163. * from sepia, black and white to sixties or futuristic rendering...
  65164. *
  65165. * The only supported format is currently 3dl.
  65166. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65167. */
  65168. export class ColorGradingTexture extends BaseTexture {
  65169. /**
  65170. * The texture URL.
  65171. */
  65172. url: string;
  65173. /**
  65174. * Empty line regex stored for GC.
  65175. */
  65176. private static _noneEmptyLineRegex;
  65177. private _textureMatrix;
  65178. private _onLoad;
  65179. /**
  65180. * Instantiates a ColorGradingTexture from the following parameters.
  65181. *
  65182. * @param url The location of the color gradind data (currently only supporting 3dl)
  65183. * @param sceneOrEngine The scene or engine the texture will be used in
  65184. * @param onLoad defines a callback triggered when the texture has been loaded
  65185. */
  65186. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65187. /**
  65188. * Fires the onload event from the constructor if requested.
  65189. */
  65190. private _triggerOnLoad;
  65191. /**
  65192. * Returns the texture matrix used in most of the material.
  65193. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65194. */
  65195. getTextureMatrix(): Matrix;
  65196. /**
  65197. * Occurs when the file being loaded is a .3dl LUT file.
  65198. */
  65199. private load3dlTexture;
  65200. /**
  65201. * Starts the loading process of the texture.
  65202. */
  65203. private loadTexture;
  65204. /**
  65205. * Clones the color gradind texture.
  65206. */
  65207. clone(): ColorGradingTexture;
  65208. /**
  65209. * Called during delayed load for textures.
  65210. */
  65211. delayLoad(): void;
  65212. /**
  65213. * Parses a color grading texture serialized by Babylon.
  65214. * @param parsedTexture The texture information being parsedTexture
  65215. * @param scene The scene to load the texture in
  65216. * @param rootUrl The root url of the data assets to load
  65217. * @return A color gradind texture
  65218. */
  65219. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65220. /**
  65221. * Serializes the LUT texture to json format.
  65222. */
  65223. serialize(): any;
  65224. }
  65225. }
  65226. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65228. import { Scene } from "babylonjs/scene";
  65229. import { Nullable } from "babylonjs/types";
  65230. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65231. /**
  65232. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65233. */
  65234. export class EquiRectangularCubeTexture extends BaseTexture {
  65235. /** The six faces of the cube. */
  65236. private static _FacesMapping;
  65237. private _noMipmap;
  65238. private _onLoad;
  65239. private _onError;
  65240. /** The size of the cubemap. */
  65241. private _size;
  65242. /** The buffer of the image. */
  65243. private _buffer;
  65244. /** The width of the input image. */
  65245. private _width;
  65246. /** The height of the input image. */
  65247. private _height;
  65248. /** The URL to the image. */
  65249. url: string;
  65250. /**
  65251. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65252. * @param url The location of the image
  65253. * @param scene The scene the texture will be used in
  65254. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65255. * @param noMipmap Forces to not generate the mipmap if true
  65256. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65257. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65258. * @param onLoad — defines a callback called when texture is loaded
  65259. * @param onError — defines a callback called if there is an error
  65260. */
  65261. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65262. /**
  65263. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65264. */
  65265. private loadImage;
  65266. /**
  65267. * Convert the image buffer into a cubemap and create a CubeTexture.
  65268. */
  65269. private loadTexture;
  65270. /**
  65271. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65272. * @param buffer The ArrayBuffer that should be converted.
  65273. * @returns The buffer as Float32Array.
  65274. */
  65275. private getFloat32ArrayFromArrayBuffer;
  65276. /**
  65277. * Get the current class name of the texture useful for serialization or dynamic coding.
  65278. * @returns "EquiRectangularCubeTexture"
  65279. */
  65280. getClassName(): string;
  65281. /**
  65282. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65283. * @returns A clone of the current EquiRectangularCubeTexture.
  65284. */
  65285. clone(): EquiRectangularCubeTexture;
  65286. }
  65287. }
  65288. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65289. import { Nullable } from "babylonjs/types";
  65290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65291. import { Matrix } from "babylonjs/Maths/math.vector";
  65292. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65293. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65294. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65295. import { Scene } from "babylonjs/scene";
  65296. /**
  65297. * Defines the options related to the creation of an HtmlElementTexture
  65298. */
  65299. export interface IHtmlElementTextureOptions {
  65300. /**
  65301. * Defines wether mip maps should be created or not.
  65302. */
  65303. generateMipMaps?: boolean;
  65304. /**
  65305. * Defines the sampling mode of the texture.
  65306. */
  65307. samplingMode?: number;
  65308. /**
  65309. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65310. */
  65311. engine: Nullable<ThinEngine>;
  65312. /**
  65313. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65314. */
  65315. scene: Nullable<Scene>;
  65316. }
  65317. /**
  65318. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65319. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65320. * is automatically managed.
  65321. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65322. * in your application.
  65323. *
  65324. * As the update is not automatic, you need to call them manually.
  65325. */
  65326. export class HtmlElementTexture extends BaseTexture {
  65327. /**
  65328. * The texture URL.
  65329. */
  65330. element: HTMLVideoElement | HTMLCanvasElement;
  65331. private static readonly DefaultOptions;
  65332. private _textureMatrix;
  65333. private _isVideo;
  65334. private _generateMipMaps;
  65335. private _samplingMode;
  65336. /**
  65337. * Instantiates a HtmlElementTexture from the following parameters.
  65338. *
  65339. * @param name Defines the name of the texture
  65340. * @param element Defines the video or canvas the texture is filled with
  65341. * @param options Defines the other none mandatory texture creation options
  65342. */
  65343. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65344. private _createInternalTexture;
  65345. /**
  65346. * Returns the texture matrix used in most of the material.
  65347. */
  65348. getTextureMatrix(): Matrix;
  65349. /**
  65350. * Updates the content of the texture.
  65351. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65352. */
  65353. update(invertY?: Nullable<boolean>): void;
  65354. }
  65355. }
  65356. declare module "babylonjs/Misc/tga" {
  65357. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65358. /**
  65359. * Based on jsTGALoader - Javascript loader for TGA file
  65360. * By Vincent Thibault
  65361. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65362. */
  65363. export class TGATools {
  65364. private static _TYPE_INDEXED;
  65365. private static _TYPE_RGB;
  65366. private static _TYPE_GREY;
  65367. private static _TYPE_RLE_INDEXED;
  65368. private static _TYPE_RLE_RGB;
  65369. private static _TYPE_RLE_GREY;
  65370. private static _ORIGIN_MASK;
  65371. private static _ORIGIN_SHIFT;
  65372. private static _ORIGIN_BL;
  65373. private static _ORIGIN_BR;
  65374. private static _ORIGIN_UL;
  65375. private static _ORIGIN_UR;
  65376. /**
  65377. * Gets the header of a TGA file
  65378. * @param data defines the TGA data
  65379. * @returns the header
  65380. */
  65381. static GetTGAHeader(data: Uint8Array): any;
  65382. /**
  65383. * Uploads TGA content to a Babylon Texture
  65384. * @hidden
  65385. */
  65386. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65387. /** @hidden */
  65388. 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;
  65389. /** @hidden */
  65390. 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;
  65391. /** @hidden */
  65392. 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;
  65393. /** @hidden */
  65394. 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;
  65395. /** @hidden */
  65396. 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;
  65397. /** @hidden */
  65398. 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;
  65399. }
  65400. }
  65401. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65402. import { Nullable } from "babylonjs/types";
  65403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65404. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65405. /**
  65406. * Implementation of the TGA Texture Loader.
  65407. * @hidden
  65408. */
  65409. export class _TGATextureLoader implements IInternalTextureLoader {
  65410. /**
  65411. * Defines wether the loader supports cascade loading the different faces.
  65412. */
  65413. readonly supportCascades: boolean;
  65414. /**
  65415. * This returns if the loader support the current file information.
  65416. * @param extension defines the file extension of the file being loaded
  65417. * @returns true if the loader can load the specified file
  65418. */
  65419. canLoad(extension: string): boolean;
  65420. /**
  65421. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65422. * @param data contains the texture data
  65423. * @param texture defines the BabylonJS internal texture
  65424. * @param createPolynomials will be true if polynomials have been requested
  65425. * @param onLoad defines the callback to trigger once the texture is ready
  65426. * @param onError defines the callback to trigger in case of error
  65427. */
  65428. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65429. /**
  65430. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65431. * @param data contains the texture data
  65432. * @param texture defines the BabylonJS internal texture
  65433. * @param callback defines the method to call once ready to upload
  65434. */
  65435. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65436. }
  65437. }
  65438. declare module "babylonjs/Misc/basis" {
  65439. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65440. /**
  65441. * Info about the .basis files
  65442. */
  65443. class BasisFileInfo {
  65444. /**
  65445. * If the file has alpha
  65446. */
  65447. hasAlpha: boolean;
  65448. /**
  65449. * Info about each image of the basis file
  65450. */
  65451. images: Array<{
  65452. levels: Array<{
  65453. width: number;
  65454. height: number;
  65455. transcodedPixels: ArrayBufferView;
  65456. }>;
  65457. }>;
  65458. }
  65459. /**
  65460. * Result of transcoding a basis file
  65461. */
  65462. class TranscodeResult {
  65463. /**
  65464. * Info about the .basis file
  65465. */
  65466. fileInfo: BasisFileInfo;
  65467. /**
  65468. * Format to use when loading the file
  65469. */
  65470. format: number;
  65471. }
  65472. /**
  65473. * Configuration options for the Basis transcoder
  65474. */
  65475. export class BasisTranscodeConfiguration {
  65476. /**
  65477. * Supported compression formats used to determine the supported output format of the transcoder
  65478. */
  65479. supportedCompressionFormats?: {
  65480. /**
  65481. * etc1 compression format
  65482. */
  65483. etc1?: boolean;
  65484. /**
  65485. * s3tc compression format
  65486. */
  65487. s3tc?: boolean;
  65488. /**
  65489. * pvrtc compression format
  65490. */
  65491. pvrtc?: boolean;
  65492. /**
  65493. * etc2 compression format
  65494. */
  65495. etc2?: boolean;
  65496. };
  65497. /**
  65498. * If mipmap levels should be loaded for transcoded images (Default: true)
  65499. */
  65500. loadMipmapLevels?: boolean;
  65501. /**
  65502. * Index of a single image to load (Default: all images)
  65503. */
  65504. loadSingleImage?: number;
  65505. }
  65506. /**
  65507. * Used to load .Basis files
  65508. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65509. */
  65510. export class BasisTools {
  65511. private static _IgnoreSupportedFormats;
  65512. /**
  65513. * URL to use when loading the basis transcoder
  65514. */
  65515. static JSModuleURL: string;
  65516. /**
  65517. * URL to use when loading the wasm module for the transcoder
  65518. */
  65519. static WasmModuleURL: string;
  65520. /**
  65521. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65522. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65523. * @returns internal format corresponding to the Basis format
  65524. */
  65525. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65526. private static _WorkerPromise;
  65527. private static _Worker;
  65528. private static _actionId;
  65529. private static _CreateWorkerAsync;
  65530. /**
  65531. * Transcodes a loaded image file to compressed pixel data
  65532. * @param data image data to transcode
  65533. * @param config configuration options for the transcoding
  65534. * @returns a promise resulting in the transcoded image
  65535. */
  65536. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65537. /**
  65538. * Loads a texture from the transcode result
  65539. * @param texture texture load to
  65540. * @param transcodeResult the result of transcoding the basis file to load from
  65541. */
  65542. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65543. }
  65544. }
  65545. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65546. import { Nullable } from "babylonjs/types";
  65547. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65548. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65549. /**
  65550. * Loader for .basis file format
  65551. */
  65552. export class _BasisTextureLoader implements IInternalTextureLoader {
  65553. /**
  65554. * Defines whether the loader supports cascade loading the different faces.
  65555. */
  65556. readonly supportCascades: boolean;
  65557. /**
  65558. * This returns if the loader support the current file information.
  65559. * @param extension defines the file extension of the file being loaded
  65560. * @returns true if the loader can load the specified file
  65561. */
  65562. canLoad(extension: string): boolean;
  65563. /**
  65564. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65565. * @param data contains the texture data
  65566. * @param texture defines the BabylonJS internal texture
  65567. * @param createPolynomials will be true if polynomials have been requested
  65568. * @param onLoad defines the callback to trigger once the texture is ready
  65569. * @param onError defines the callback to trigger in case of error
  65570. */
  65571. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65572. /**
  65573. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65574. * @param data contains the texture data
  65575. * @param texture defines the BabylonJS internal texture
  65576. * @param callback defines the method to call once ready to upload
  65577. */
  65578. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65579. }
  65580. }
  65581. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65582. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65583. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65584. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65585. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65586. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65587. }
  65588. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65589. import { Vector2 } from "babylonjs/Maths/math.vector";
  65590. /**
  65591. * Defines the basic options interface of a TexturePacker Frame
  65592. */
  65593. export interface ITexturePackerFrame {
  65594. /**
  65595. * The frame ID
  65596. */
  65597. id: number;
  65598. /**
  65599. * The frames Scale
  65600. */
  65601. scale: Vector2;
  65602. /**
  65603. * The Frames offset
  65604. */
  65605. offset: Vector2;
  65606. }
  65607. /**
  65608. * This is a support class for frame Data on texture packer sets.
  65609. */
  65610. export class TexturePackerFrame implements ITexturePackerFrame {
  65611. /**
  65612. * The frame ID
  65613. */
  65614. id: number;
  65615. /**
  65616. * The frames Scale
  65617. */
  65618. scale: Vector2;
  65619. /**
  65620. * The Frames offset
  65621. */
  65622. offset: Vector2;
  65623. /**
  65624. * Initializes a texture package frame.
  65625. * @param id The numerical frame identifier
  65626. * @param scale Scalar Vector2 for UV frame
  65627. * @param offset Vector2 for the frame position in UV units.
  65628. * @returns TexturePackerFrame
  65629. */
  65630. constructor(id: number, scale: Vector2, offset: Vector2);
  65631. }
  65632. }
  65633. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65635. import { Scene } from "babylonjs/scene";
  65636. import { Nullable } from "babylonjs/types";
  65637. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65638. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65639. /**
  65640. * Defines the basic options interface of a TexturePacker
  65641. */
  65642. export interface ITexturePackerOptions {
  65643. /**
  65644. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65645. */
  65646. map?: string[];
  65647. /**
  65648. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65649. */
  65650. uvsIn?: string;
  65651. /**
  65652. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65653. */
  65654. uvsOut?: string;
  65655. /**
  65656. * number representing the layout style. Defaults to LAYOUT_STRIP
  65657. */
  65658. layout?: number;
  65659. /**
  65660. * number of columns if using custom column count layout(2). This defaults to 4.
  65661. */
  65662. colnum?: number;
  65663. /**
  65664. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65665. */
  65666. updateInputMeshes?: boolean;
  65667. /**
  65668. * boolean flag to dispose all the source textures. Defaults to true.
  65669. */
  65670. disposeSources?: boolean;
  65671. /**
  65672. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65673. */
  65674. fillBlanks?: boolean;
  65675. /**
  65676. * string value representing the context fill style color. Defaults to 'black'.
  65677. */
  65678. customFillColor?: string;
  65679. /**
  65680. * Width and Height Value of each Frame in the TexturePacker Sets
  65681. */
  65682. frameSize?: number;
  65683. /**
  65684. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65685. */
  65686. paddingRatio?: number;
  65687. /**
  65688. * Number that declares the fill method for the padding gutter.
  65689. */
  65690. paddingMode?: number;
  65691. /**
  65692. * If in SUBUV_COLOR padding mode what color to use.
  65693. */
  65694. paddingColor?: Color3 | Color4;
  65695. }
  65696. /**
  65697. * Defines the basic interface of a TexturePacker JSON File
  65698. */
  65699. export interface ITexturePackerJSON {
  65700. /**
  65701. * The frame ID
  65702. */
  65703. name: string;
  65704. /**
  65705. * The base64 channel data
  65706. */
  65707. sets: any;
  65708. /**
  65709. * The options of the Packer
  65710. */
  65711. options: ITexturePackerOptions;
  65712. /**
  65713. * The frame data of the Packer
  65714. */
  65715. frames: Array<number>;
  65716. }
  65717. /**
  65718. * This is a support class that generates a series of packed texture sets.
  65719. * @see https://doc.babylonjs.com/babylon101/materials
  65720. */
  65721. export class TexturePacker {
  65722. /** Packer Layout Constant 0 */
  65723. static readonly LAYOUT_STRIP: number;
  65724. /** Packer Layout Constant 1 */
  65725. static readonly LAYOUT_POWER2: number;
  65726. /** Packer Layout Constant 2 */
  65727. static readonly LAYOUT_COLNUM: number;
  65728. /** Packer Layout Constant 0 */
  65729. static readonly SUBUV_WRAP: number;
  65730. /** Packer Layout Constant 1 */
  65731. static readonly SUBUV_EXTEND: number;
  65732. /** Packer Layout Constant 2 */
  65733. static readonly SUBUV_COLOR: number;
  65734. /** The Name of the Texture Package */
  65735. name: string;
  65736. /** The scene scope of the TexturePacker */
  65737. scene: Scene;
  65738. /** The Meshes to target */
  65739. meshes: AbstractMesh[];
  65740. /** Arguments passed with the Constructor */
  65741. options: ITexturePackerOptions;
  65742. /** The promise that is started upon initialization */
  65743. promise: Nullable<Promise<TexturePacker | string>>;
  65744. /** The Container object for the channel sets that are generated */
  65745. sets: object;
  65746. /** The Container array for the frames that are generated */
  65747. frames: TexturePackerFrame[];
  65748. /** The expected number of textures the system is parsing. */
  65749. private _expecting;
  65750. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65751. private _paddingValue;
  65752. /**
  65753. * Initializes a texture package series from an array of meshes or a single mesh.
  65754. * @param name The name of the package
  65755. * @param meshes The target meshes to compose the package from
  65756. * @param options The arguments that texture packer should follow while building.
  65757. * @param scene The scene which the textures are scoped to.
  65758. * @returns TexturePacker
  65759. */
  65760. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65761. /**
  65762. * Starts the package process
  65763. * @param resolve The promises resolution function
  65764. * @returns TexturePacker
  65765. */
  65766. private _createFrames;
  65767. /**
  65768. * Calculates the Size of the Channel Sets
  65769. * @returns Vector2
  65770. */
  65771. private _calculateSize;
  65772. /**
  65773. * Calculates the UV data for the frames.
  65774. * @param baseSize the base frameSize
  65775. * @param padding the base frame padding
  65776. * @param dtSize size of the Dynamic Texture for that channel
  65777. * @param dtUnits is 1/dtSize
  65778. * @param update flag to update the input meshes
  65779. */
  65780. private _calculateMeshUVFrames;
  65781. /**
  65782. * Calculates the frames Offset.
  65783. * @param index of the frame
  65784. * @returns Vector2
  65785. */
  65786. private _getFrameOffset;
  65787. /**
  65788. * Updates a Mesh to the frame data
  65789. * @param mesh that is the target
  65790. * @param frameID or the frame index
  65791. */
  65792. private _updateMeshUV;
  65793. /**
  65794. * Updates a Meshes materials to use the texture packer channels
  65795. * @param m is the mesh to target
  65796. * @param force all channels on the packer to be set.
  65797. */
  65798. private _updateTextureReferences;
  65799. /**
  65800. * Public method to set a Mesh to a frame
  65801. * @param m that is the target
  65802. * @param frameID or the frame index
  65803. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65804. */
  65805. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65806. /**
  65807. * Starts the async promise to compile the texture packer.
  65808. * @returns Promise<void>
  65809. */
  65810. processAsync(): Promise<void>;
  65811. /**
  65812. * Disposes all textures associated with this packer
  65813. */
  65814. dispose(): void;
  65815. /**
  65816. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65817. * @param imageType is the image type to use.
  65818. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65819. */
  65820. download(imageType?: string, quality?: number): void;
  65821. /**
  65822. * Public method to load a texturePacker JSON file.
  65823. * @param data of the JSON file in string format.
  65824. */
  65825. updateFromJSON(data: string): void;
  65826. }
  65827. }
  65828. declare module "babylonjs/Materials/Textures/Packer/index" {
  65829. export * from "babylonjs/Materials/Textures/Packer/packer";
  65830. export * from "babylonjs/Materials/Textures/Packer/frame";
  65831. }
  65832. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65833. import { Scene } from "babylonjs/scene";
  65834. import { Texture } from "babylonjs/Materials/Textures/texture";
  65835. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65836. /**
  65837. * 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.
  65838. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65839. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65840. */
  65841. export class CustomProceduralTexture extends ProceduralTexture {
  65842. private _animate;
  65843. private _time;
  65844. private _config;
  65845. private _texturePath;
  65846. /**
  65847. * Instantiates a new Custom Procedural Texture.
  65848. * 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.
  65849. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65850. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65851. * @param name Define the name of the texture
  65852. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65853. * @param size Define the size of the texture to create
  65854. * @param scene Define the scene the texture belongs to
  65855. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65856. * @param generateMipMaps Define if the texture should creates mip maps or not
  65857. */
  65858. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65859. private _loadJson;
  65860. /**
  65861. * Is the texture ready to be used ? (rendered at least once)
  65862. * @returns true if ready, otherwise, false.
  65863. */
  65864. isReady(): boolean;
  65865. /**
  65866. * Render the texture to its associated render target.
  65867. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65868. */
  65869. render(useCameraPostProcess?: boolean): void;
  65870. /**
  65871. * Update the list of dependant textures samplers in the shader.
  65872. */
  65873. updateTextures(): void;
  65874. /**
  65875. * Update the uniform values of the procedural texture in the shader.
  65876. */
  65877. updateShaderUniforms(): void;
  65878. /**
  65879. * Define if the texture animates or not.
  65880. */
  65881. get animate(): boolean;
  65882. set animate(value: boolean);
  65883. }
  65884. }
  65885. declare module "babylonjs/Shaders/noise.fragment" {
  65886. /** @hidden */
  65887. export var noisePixelShader: {
  65888. name: string;
  65889. shader: string;
  65890. };
  65891. }
  65892. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65893. import { Nullable } from "babylonjs/types";
  65894. import { Scene } from "babylonjs/scene";
  65895. import { Texture } from "babylonjs/Materials/Textures/texture";
  65896. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65897. import "babylonjs/Shaders/noise.fragment";
  65898. /**
  65899. * Class used to generate noise procedural textures
  65900. */
  65901. export class NoiseProceduralTexture extends ProceduralTexture {
  65902. /** Gets or sets the start time (default is 0) */
  65903. time: number;
  65904. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65905. brightness: number;
  65906. /** Defines the number of octaves to process */
  65907. octaves: number;
  65908. /** Defines the level of persistence (0.8 by default) */
  65909. persistence: number;
  65910. /** Gets or sets animation speed factor (default is 1) */
  65911. animationSpeedFactor: number;
  65912. /**
  65913. * Creates a new NoiseProceduralTexture
  65914. * @param name defines the name fo the texture
  65915. * @param size defines the size of the texture (default is 256)
  65916. * @param scene defines the hosting scene
  65917. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65918. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65919. */
  65920. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65921. private _updateShaderUniforms;
  65922. protected _getDefines(): string;
  65923. /** Generate the current state of the procedural texture */
  65924. render(useCameraPostProcess?: boolean): void;
  65925. /**
  65926. * Serializes this noise procedural texture
  65927. * @returns a serialized noise procedural texture object
  65928. */
  65929. serialize(): any;
  65930. /**
  65931. * Clone the texture.
  65932. * @returns the cloned texture
  65933. */
  65934. clone(): NoiseProceduralTexture;
  65935. /**
  65936. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65937. * @param parsedTexture defines parsed texture data
  65938. * @param scene defines the current scene
  65939. * @param rootUrl defines the root URL containing noise procedural texture information
  65940. * @returns a parsed NoiseProceduralTexture
  65941. */
  65942. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65943. }
  65944. }
  65945. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65946. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65947. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65948. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65949. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65950. }
  65951. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65952. import { Nullable } from "babylonjs/types";
  65953. import { Scene } from "babylonjs/scene";
  65954. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65956. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65957. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65958. /**
  65959. * Raw cube texture where the raw buffers are passed in
  65960. */
  65961. export class RawCubeTexture extends CubeTexture {
  65962. /**
  65963. * Creates a cube texture where the raw buffers are passed in.
  65964. * @param scene defines the scene the texture is attached to
  65965. * @param data defines the array of data to use to create each face
  65966. * @param size defines the size of the textures
  65967. * @param format defines the format of the data
  65968. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65969. * @param generateMipMaps defines if the engine should generate the mip levels
  65970. * @param invertY defines if data must be stored with Y axis inverted
  65971. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65972. * @param compression defines the compression used (null by default)
  65973. */
  65974. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65975. /**
  65976. * Updates the raw cube texture.
  65977. * @param data defines the data to store
  65978. * @param format defines the data format
  65979. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65980. * @param invertY defines if data must be stored with Y axis inverted
  65981. * @param compression defines the compression used (null by default)
  65982. * @param level defines which level of the texture to update
  65983. */
  65984. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65985. /**
  65986. * Updates a raw cube texture with RGBD encoded data.
  65987. * @param data defines the array of data [mipmap][face] to use to create each face
  65988. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65989. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65990. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65991. * @returns a promsie that resolves when the operation is complete
  65992. */
  65993. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65994. /**
  65995. * Clones the raw cube texture.
  65996. * @return a new cube texture
  65997. */
  65998. clone(): CubeTexture;
  65999. /** @hidden */
  66000. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66001. }
  66002. }
  66003. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66004. import { Scene } from "babylonjs/scene";
  66005. import { Texture } from "babylonjs/Materials/Textures/texture";
  66006. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66007. /**
  66008. * Class used to store 2D array textures containing user data
  66009. */
  66010. export class RawTexture2DArray extends Texture {
  66011. /** Gets or sets the texture format to use */
  66012. format: number;
  66013. /**
  66014. * Create a new RawTexture2DArray
  66015. * @param data defines the data of the texture
  66016. * @param width defines the width of the texture
  66017. * @param height defines the height of the texture
  66018. * @param depth defines the number of layers of the texture
  66019. * @param format defines the texture format to use
  66020. * @param scene defines the hosting scene
  66021. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66022. * @param invertY defines if texture must be stored with Y axis inverted
  66023. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66024. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66025. */
  66026. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66027. /** Gets or sets the texture format to use */
  66028. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66029. /**
  66030. * Update the texture with new data
  66031. * @param data defines the data to store in the texture
  66032. */
  66033. update(data: ArrayBufferView): void;
  66034. }
  66035. }
  66036. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66037. import { Scene } from "babylonjs/scene";
  66038. import { Texture } from "babylonjs/Materials/Textures/texture";
  66039. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66040. /**
  66041. * Class used to store 3D textures containing user data
  66042. */
  66043. export class RawTexture3D extends Texture {
  66044. /** Gets or sets the texture format to use */
  66045. format: number;
  66046. /**
  66047. * Create a new RawTexture3D
  66048. * @param data defines the data of the texture
  66049. * @param width defines the width of the texture
  66050. * @param height defines the height of the texture
  66051. * @param depth defines the depth of the texture
  66052. * @param format defines the texture format to use
  66053. * @param scene defines the hosting scene
  66054. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66055. * @param invertY defines if texture must be stored with Y axis inverted
  66056. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66057. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66058. */
  66059. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66060. /** Gets or sets the texture format to use */
  66061. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66062. /**
  66063. * Update the texture with new data
  66064. * @param data defines the data to store in the texture
  66065. */
  66066. update(data: ArrayBufferView): void;
  66067. }
  66068. }
  66069. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66070. import { Scene } from "babylonjs/scene";
  66071. import { Plane } from "babylonjs/Maths/math.plane";
  66072. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66073. /**
  66074. * Creates a refraction texture used by refraction channel of the standard material.
  66075. * It is like a mirror but to see through a material.
  66076. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66077. */
  66078. export class RefractionTexture extends RenderTargetTexture {
  66079. /**
  66080. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66081. * 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.
  66082. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66083. */
  66084. refractionPlane: Plane;
  66085. /**
  66086. * Define how deep under the surface we should see.
  66087. */
  66088. depth: number;
  66089. /**
  66090. * Creates a refraction texture used by refraction channel of the standard material.
  66091. * It is like a mirror but to see through a material.
  66092. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66093. * @param name Define the texture name
  66094. * @param size Define the size of the underlying texture
  66095. * @param scene Define the scene the refraction belongs to
  66096. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66097. */
  66098. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66099. /**
  66100. * Clone the refraction texture.
  66101. * @returns the cloned texture
  66102. */
  66103. clone(): RefractionTexture;
  66104. /**
  66105. * Serialize the texture to a JSON representation you could use in Parse later on
  66106. * @returns the serialized JSON representation
  66107. */
  66108. serialize(): any;
  66109. }
  66110. }
  66111. declare module "babylonjs/Materials/Textures/index" {
  66112. export * from "babylonjs/Materials/Textures/baseTexture";
  66113. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66114. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66115. export * from "babylonjs/Materials/Textures/cubeTexture";
  66116. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66117. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66118. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66119. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66120. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66121. export * from "babylonjs/Materials/Textures/internalTexture";
  66122. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66123. export * from "babylonjs/Materials/Textures/Loaders/index";
  66124. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66125. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66126. export * from "babylonjs/Materials/Textures/Packer/index";
  66127. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66128. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66129. export * from "babylonjs/Materials/Textures/rawTexture";
  66130. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66131. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66132. export * from "babylonjs/Materials/Textures/refractionTexture";
  66133. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66134. export * from "babylonjs/Materials/Textures/texture";
  66135. export * from "babylonjs/Materials/Textures/videoTexture";
  66136. }
  66137. declare module "babylonjs/Materials/Node/Enums/index" {
  66138. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66139. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66140. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66141. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66142. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66143. }
  66144. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66148. import { Mesh } from "babylonjs/Meshes/mesh";
  66149. import { Effect } from "babylonjs/Materials/effect";
  66150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66151. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66152. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66153. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66154. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66155. /**
  66156. * Block used to add support for vertex skinning (bones)
  66157. */
  66158. export class BonesBlock extends NodeMaterialBlock {
  66159. /**
  66160. * Creates a new BonesBlock
  66161. * @param name defines the block name
  66162. */
  66163. constructor(name: string);
  66164. /**
  66165. * Initialize the block and prepare the context for build
  66166. * @param state defines the state that will be used for the build
  66167. */
  66168. initialize(state: NodeMaterialBuildState): void;
  66169. /**
  66170. * Gets the current class name
  66171. * @returns the class name
  66172. */
  66173. getClassName(): string;
  66174. /**
  66175. * Gets the matrix indices input component
  66176. */
  66177. get matricesIndices(): NodeMaterialConnectionPoint;
  66178. /**
  66179. * Gets the matrix weights input component
  66180. */
  66181. get matricesWeights(): NodeMaterialConnectionPoint;
  66182. /**
  66183. * Gets the extra matrix indices input component
  66184. */
  66185. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66186. /**
  66187. * Gets the extra matrix weights input component
  66188. */
  66189. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66190. /**
  66191. * Gets the world input component
  66192. */
  66193. get world(): NodeMaterialConnectionPoint;
  66194. /**
  66195. * Gets the output component
  66196. */
  66197. get output(): NodeMaterialConnectionPoint;
  66198. autoConfigure(material: NodeMaterial): void;
  66199. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66200. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66202. protected _buildBlock(state: NodeMaterialBuildState): this;
  66203. }
  66204. }
  66205. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66210. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66212. /**
  66213. * Block used to add support for instances
  66214. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66215. */
  66216. export class InstancesBlock extends NodeMaterialBlock {
  66217. /**
  66218. * Creates a new InstancesBlock
  66219. * @param name defines the block name
  66220. */
  66221. constructor(name: string);
  66222. /**
  66223. * Gets the current class name
  66224. * @returns the class name
  66225. */
  66226. getClassName(): string;
  66227. /**
  66228. * Gets the first world row input component
  66229. */
  66230. get world0(): NodeMaterialConnectionPoint;
  66231. /**
  66232. * Gets the second world row input component
  66233. */
  66234. get world1(): NodeMaterialConnectionPoint;
  66235. /**
  66236. * Gets the third world row input component
  66237. */
  66238. get world2(): NodeMaterialConnectionPoint;
  66239. /**
  66240. * Gets the forth world row input component
  66241. */
  66242. get world3(): NodeMaterialConnectionPoint;
  66243. /**
  66244. * Gets the world input component
  66245. */
  66246. get world(): NodeMaterialConnectionPoint;
  66247. /**
  66248. * Gets the output component
  66249. */
  66250. get output(): NodeMaterialConnectionPoint;
  66251. /**
  66252. * Gets the isntanceID component
  66253. */
  66254. get instanceID(): NodeMaterialConnectionPoint;
  66255. autoConfigure(material: NodeMaterial): void;
  66256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66257. protected _buildBlock(state: NodeMaterialBuildState): this;
  66258. }
  66259. }
  66260. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66265. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66266. import { Effect } from "babylonjs/Materials/effect";
  66267. import { Mesh } from "babylonjs/Meshes/mesh";
  66268. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66269. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66270. /**
  66271. * Block used to add morph targets support to vertex shader
  66272. */
  66273. export class MorphTargetsBlock extends NodeMaterialBlock {
  66274. private _repeatableContentAnchor;
  66275. /**
  66276. * Create a new MorphTargetsBlock
  66277. * @param name defines the block name
  66278. */
  66279. constructor(name: string);
  66280. /**
  66281. * Gets the current class name
  66282. * @returns the class name
  66283. */
  66284. getClassName(): string;
  66285. /**
  66286. * Gets the position input component
  66287. */
  66288. get position(): NodeMaterialConnectionPoint;
  66289. /**
  66290. * Gets the normal input component
  66291. */
  66292. get normal(): NodeMaterialConnectionPoint;
  66293. /**
  66294. * Gets the tangent input component
  66295. */
  66296. get tangent(): NodeMaterialConnectionPoint;
  66297. /**
  66298. * Gets the tangent input component
  66299. */
  66300. get uv(): NodeMaterialConnectionPoint;
  66301. /**
  66302. * Gets the position output component
  66303. */
  66304. get positionOutput(): NodeMaterialConnectionPoint;
  66305. /**
  66306. * Gets the normal output component
  66307. */
  66308. get normalOutput(): NodeMaterialConnectionPoint;
  66309. /**
  66310. * Gets the tangent output component
  66311. */
  66312. get tangentOutput(): NodeMaterialConnectionPoint;
  66313. /**
  66314. * Gets the tangent output component
  66315. */
  66316. get uvOutput(): NodeMaterialConnectionPoint;
  66317. initialize(state: NodeMaterialBuildState): void;
  66318. autoConfigure(material: NodeMaterial): void;
  66319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66320. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66321. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66322. protected _buildBlock(state: NodeMaterialBuildState): this;
  66323. }
  66324. }
  66325. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66329. import { Nullable } from "babylonjs/types";
  66330. import { Scene } from "babylonjs/scene";
  66331. import { Effect } from "babylonjs/Materials/effect";
  66332. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66333. import { Mesh } from "babylonjs/Meshes/mesh";
  66334. import { Light } from "babylonjs/Lights/light";
  66335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66336. /**
  66337. * Block used to get data information from a light
  66338. */
  66339. export class LightInformationBlock extends NodeMaterialBlock {
  66340. private _lightDataUniformName;
  66341. private _lightColorUniformName;
  66342. private _lightTypeDefineName;
  66343. /**
  66344. * Gets or sets the light associated with this block
  66345. */
  66346. light: Nullable<Light>;
  66347. /**
  66348. * Creates a new LightInformationBlock
  66349. * @param name defines the block name
  66350. */
  66351. constructor(name: string);
  66352. /**
  66353. * Gets the current class name
  66354. * @returns the class name
  66355. */
  66356. getClassName(): string;
  66357. /**
  66358. * Gets the world position input component
  66359. */
  66360. get worldPosition(): NodeMaterialConnectionPoint;
  66361. /**
  66362. * Gets the direction output component
  66363. */
  66364. get direction(): NodeMaterialConnectionPoint;
  66365. /**
  66366. * Gets the direction output component
  66367. */
  66368. get color(): NodeMaterialConnectionPoint;
  66369. /**
  66370. * Gets the direction output component
  66371. */
  66372. get intensity(): NodeMaterialConnectionPoint;
  66373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66375. protected _buildBlock(state: NodeMaterialBuildState): this;
  66376. serialize(): any;
  66377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66378. }
  66379. }
  66380. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66381. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66382. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66383. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66384. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66385. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66386. }
  66387. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66392. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66393. import { Effect } from "babylonjs/Materials/effect";
  66394. import { Mesh } from "babylonjs/Meshes/mesh";
  66395. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66396. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66397. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66398. /**
  66399. * Block used to add image processing support to fragment shader
  66400. */
  66401. export class ImageProcessingBlock extends NodeMaterialBlock {
  66402. /**
  66403. * Create a new ImageProcessingBlock
  66404. * @param name defines the block name
  66405. */
  66406. constructor(name: string);
  66407. /**
  66408. * Gets the current class name
  66409. * @returns the class name
  66410. */
  66411. getClassName(): string;
  66412. /**
  66413. * Gets the color input component
  66414. */
  66415. get color(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the output component
  66418. */
  66419. get output(): NodeMaterialConnectionPoint;
  66420. /**
  66421. * Initialize the block and prepare the context for build
  66422. * @param state defines the state that will be used for the build
  66423. */
  66424. initialize(state: NodeMaterialBuildState): void;
  66425. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66427. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66428. protected _buildBlock(state: NodeMaterialBuildState): this;
  66429. }
  66430. }
  66431. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66435. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66437. import { Effect } from "babylonjs/Materials/effect";
  66438. import { Mesh } from "babylonjs/Meshes/mesh";
  66439. import { Scene } from "babylonjs/scene";
  66440. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66441. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66442. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66443. /**
  66444. * Block used to pertub normals based on a normal map
  66445. */
  66446. export class PerturbNormalBlock extends NodeMaterialBlock {
  66447. private _tangentSpaceParameterName;
  66448. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66449. invertX: boolean;
  66450. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66451. invertY: boolean;
  66452. /**
  66453. * Create a new PerturbNormalBlock
  66454. * @param name defines the block name
  66455. */
  66456. constructor(name: string);
  66457. /**
  66458. * Gets the current class name
  66459. * @returns the class name
  66460. */
  66461. getClassName(): string;
  66462. /**
  66463. * Gets the world position input component
  66464. */
  66465. get worldPosition(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the world normal input component
  66468. */
  66469. get worldNormal(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the world tangent input component
  66472. */
  66473. get worldTangent(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the uv input component
  66476. */
  66477. get uv(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the normal map color input component
  66480. */
  66481. get normalMapColor(): NodeMaterialConnectionPoint;
  66482. /**
  66483. * Gets the strength input component
  66484. */
  66485. get strength(): NodeMaterialConnectionPoint;
  66486. /**
  66487. * Gets the output component
  66488. */
  66489. get output(): NodeMaterialConnectionPoint;
  66490. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66491. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66492. autoConfigure(material: NodeMaterial): void;
  66493. protected _buildBlock(state: NodeMaterialBuildState): this;
  66494. protected _dumpPropertiesCode(): string;
  66495. serialize(): any;
  66496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66497. }
  66498. }
  66499. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66503. /**
  66504. * Block used to discard a pixel if a value is smaller than a cutoff
  66505. */
  66506. export class DiscardBlock extends NodeMaterialBlock {
  66507. /**
  66508. * Create a new DiscardBlock
  66509. * @param name defines the block name
  66510. */
  66511. constructor(name: string);
  66512. /**
  66513. * Gets the current class name
  66514. * @returns the class name
  66515. */
  66516. getClassName(): string;
  66517. /**
  66518. * Gets the color input component
  66519. */
  66520. get value(): NodeMaterialConnectionPoint;
  66521. /**
  66522. * Gets the cutoff input component
  66523. */
  66524. get cutoff(): NodeMaterialConnectionPoint;
  66525. protected _buildBlock(state: NodeMaterialBuildState): this;
  66526. }
  66527. }
  66528. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66532. /**
  66533. * Block used to test if the fragment shader is front facing
  66534. */
  66535. export class FrontFacingBlock extends NodeMaterialBlock {
  66536. /**
  66537. * Creates a new FrontFacingBlock
  66538. * @param name defines the block name
  66539. */
  66540. constructor(name: string);
  66541. /**
  66542. * Gets the current class name
  66543. * @returns the class name
  66544. */
  66545. getClassName(): string;
  66546. /**
  66547. * Gets the output component
  66548. */
  66549. get output(): NodeMaterialConnectionPoint;
  66550. protected _buildBlock(state: NodeMaterialBuildState): this;
  66551. }
  66552. }
  66553. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66557. /**
  66558. * Block used to get the derivative value on x and y of a given input
  66559. */
  66560. export class DerivativeBlock extends NodeMaterialBlock {
  66561. /**
  66562. * Create a new DerivativeBlock
  66563. * @param name defines the block name
  66564. */
  66565. constructor(name: string);
  66566. /**
  66567. * Gets the current class name
  66568. * @returns the class name
  66569. */
  66570. getClassName(): string;
  66571. /**
  66572. * Gets the input component
  66573. */
  66574. get input(): NodeMaterialConnectionPoint;
  66575. /**
  66576. * Gets the derivative output on x
  66577. */
  66578. get dx(): NodeMaterialConnectionPoint;
  66579. /**
  66580. * Gets the derivative output on y
  66581. */
  66582. get dy(): NodeMaterialConnectionPoint;
  66583. protected _buildBlock(state: NodeMaterialBuildState): this;
  66584. }
  66585. }
  66586. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66590. /**
  66591. * Block used to make gl_FragCoord available
  66592. */
  66593. export class FragCoordBlock extends NodeMaterialBlock {
  66594. /**
  66595. * Creates a new FragCoordBlock
  66596. * @param name defines the block name
  66597. */
  66598. constructor(name: string);
  66599. /**
  66600. * Gets the current class name
  66601. * @returns the class name
  66602. */
  66603. getClassName(): string;
  66604. /**
  66605. * Gets the xy component
  66606. */
  66607. get xy(): NodeMaterialConnectionPoint;
  66608. /**
  66609. * Gets the xyz component
  66610. */
  66611. get xyz(): NodeMaterialConnectionPoint;
  66612. /**
  66613. * Gets the xyzw component
  66614. */
  66615. get xyzw(): NodeMaterialConnectionPoint;
  66616. /**
  66617. * Gets the x component
  66618. */
  66619. get x(): NodeMaterialConnectionPoint;
  66620. /**
  66621. * Gets the y component
  66622. */
  66623. get y(): NodeMaterialConnectionPoint;
  66624. /**
  66625. * Gets the z component
  66626. */
  66627. get z(): NodeMaterialConnectionPoint;
  66628. /**
  66629. * Gets the w component
  66630. */
  66631. get output(): NodeMaterialConnectionPoint;
  66632. protected writeOutputs(state: NodeMaterialBuildState): string;
  66633. protected _buildBlock(state: NodeMaterialBuildState): this;
  66634. }
  66635. }
  66636. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66638. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66640. import { Effect } from "babylonjs/Materials/effect";
  66641. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66642. import { Mesh } from "babylonjs/Meshes/mesh";
  66643. /**
  66644. * Block used to get the screen sizes
  66645. */
  66646. export class ScreenSizeBlock extends NodeMaterialBlock {
  66647. private _varName;
  66648. private _scene;
  66649. /**
  66650. * Creates a new ScreenSizeBlock
  66651. * @param name defines the block name
  66652. */
  66653. constructor(name: string);
  66654. /**
  66655. * Gets the current class name
  66656. * @returns the class name
  66657. */
  66658. getClassName(): string;
  66659. /**
  66660. * Gets the xy component
  66661. */
  66662. get xy(): NodeMaterialConnectionPoint;
  66663. /**
  66664. * Gets the x component
  66665. */
  66666. get x(): NodeMaterialConnectionPoint;
  66667. /**
  66668. * Gets the y component
  66669. */
  66670. get y(): NodeMaterialConnectionPoint;
  66671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66672. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66673. protected _buildBlock(state: NodeMaterialBuildState): this;
  66674. }
  66675. }
  66676. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66677. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66678. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66679. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66680. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66681. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66682. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66683. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66684. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66685. }
  66686. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66689. import { Mesh } from "babylonjs/Meshes/mesh";
  66690. import { Effect } from "babylonjs/Materials/effect";
  66691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66693. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66694. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66695. /**
  66696. * Block used to add support for scene fog
  66697. */
  66698. export class FogBlock extends NodeMaterialBlock {
  66699. private _fogDistanceName;
  66700. private _fogParameters;
  66701. /**
  66702. * Create a new FogBlock
  66703. * @param name defines the block name
  66704. */
  66705. constructor(name: string);
  66706. /**
  66707. * Gets the current class name
  66708. * @returns the class name
  66709. */
  66710. getClassName(): string;
  66711. /**
  66712. * Gets the world position input component
  66713. */
  66714. get worldPosition(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the view input component
  66717. */
  66718. get view(): NodeMaterialConnectionPoint;
  66719. /**
  66720. * Gets the color input component
  66721. */
  66722. get input(): NodeMaterialConnectionPoint;
  66723. /**
  66724. * Gets the fog color input component
  66725. */
  66726. get fogColor(): NodeMaterialConnectionPoint;
  66727. /**
  66728. * Gets the output component
  66729. */
  66730. get output(): NodeMaterialConnectionPoint;
  66731. autoConfigure(material: NodeMaterial): void;
  66732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66734. protected _buildBlock(state: NodeMaterialBuildState): this;
  66735. }
  66736. }
  66737. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66742. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66743. import { Effect } from "babylonjs/Materials/effect";
  66744. import { Mesh } from "babylonjs/Meshes/mesh";
  66745. import { Light } from "babylonjs/Lights/light";
  66746. import { Nullable } from "babylonjs/types";
  66747. import { Scene } from "babylonjs/scene";
  66748. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66749. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66750. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66751. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66752. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66753. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66754. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66755. /**
  66756. * Block used to add light in the fragment shader
  66757. */
  66758. export class LightBlock extends NodeMaterialBlock {
  66759. private _lightId;
  66760. /**
  66761. * Gets or sets the light associated with this block
  66762. */
  66763. light: Nullable<Light>;
  66764. /**
  66765. * Create a new LightBlock
  66766. * @param name defines the block name
  66767. */
  66768. constructor(name: string);
  66769. /**
  66770. * Gets the current class name
  66771. * @returns the class name
  66772. */
  66773. getClassName(): string;
  66774. /**
  66775. * Gets the world position input component
  66776. */
  66777. get worldPosition(): NodeMaterialConnectionPoint;
  66778. /**
  66779. * Gets the world normal input component
  66780. */
  66781. get worldNormal(): NodeMaterialConnectionPoint;
  66782. /**
  66783. * Gets the camera (or eye) position component
  66784. */
  66785. get cameraPosition(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the glossiness component
  66788. */
  66789. get glossiness(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the glossinness power component
  66792. */
  66793. get glossPower(): NodeMaterialConnectionPoint;
  66794. /**
  66795. * Gets the diffuse color component
  66796. */
  66797. get diffuseColor(): NodeMaterialConnectionPoint;
  66798. /**
  66799. * Gets the specular color component
  66800. */
  66801. get specularColor(): NodeMaterialConnectionPoint;
  66802. /**
  66803. * Gets the view matrix component
  66804. */
  66805. get view(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the diffuse output component
  66808. */
  66809. get diffuseOutput(): NodeMaterialConnectionPoint;
  66810. /**
  66811. * Gets the specular output component
  66812. */
  66813. get specularOutput(): NodeMaterialConnectionPoint;
  66814. /**
  66815. * Gets the shadow output component
  66816. */
  66817. get shadow(): NodeMaterialConnectionPoint;
  66818. autoConfigure(material: NodeMaterial): void;
  66819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66820. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66822. private _injectVertexCode;
  66823. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66824. serialize(): any;
  66825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66826. }
  66827. }
  66828. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66831. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66832. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66833. /**
  66834. * Block used to read a reflection texture from a sampler
  66835. */
  66836. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66837. /**
  66838. * Create a new ReflectionTextureBlock
  66839. * @param name defines the block name
  66840. */
  66841. constructor(name: string);
  66842. /**
  66843. * Gets the current class name
  66844. * @returns the class name
  66845. */
  66846. getClassName(): string;
  66847. /**
  66848. * Gets the world position input component
  66849. */
  66850. get position(): NodeMaterialConnectionPoint;
  66851. /**
  66852. * Gets the world position input component
  66853. */
  66854. get worldPosition(): NodeMaterialConnectionPoint;
  66855. /**
  66856. * Gets the world normal input component
  66857. */
  66858. get worldNormal(): NodeMaterialConnectionPoint;
  66859. /**
  66860. * Gets the world input component
  66861. */
  66862. get world(): NodeMaterialConnectionPoint;
  66863. /**
  66864. * Gets the camera (or eye) position component
  66865. */
  66866. get cameraPosition(): NodeMaterialConnectionPoint;
  66867. /**
  66868. * Gets the view input component
  66869. */
  66870. get view(): NodeMaterialConnectionPoint;
  66871. /**
  66872. * Gets the rgb output component
  66873. */
  66874. get rgb(): NodeMaterialConnectionPoint;
  66875. /**
  66876. * Gets the rgba output component
  66877. */
  66878. get rgba(): NodeMaterialConnectionPoint;
  66879. /**
  66880. * Gets the r output component
  66881. */
  66882. get r(): NodeMaterialConnectionPoint;
  66883. /**
  66884. * Gets the g output component
  66885. */
  66886. get g(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the b output component
  66889. */
  66890. get b(): NodeMaterialConnectionPoint;
  66891. /**
  66892. * Gets the a output component
  66893. */
  66894. get a(): NodeMaterialConnectionPoint;
  66895. autoConfigure(material: NodeMaterial): void;
  66896. protected _buildBlock(state: NodeMaterialBuildState): this;
  66897. }
  66898. }
  66899. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66900. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66901. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66902. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66903. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66904. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66905. }
  66906. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66907. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66908. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66909. }
  66910. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66914. /**
  66915. * Block used to add 2 vectors
  66916. */
  66917. export class AddBlock extends NodeMaterialBlock {
  66918. /**
  66919. * Creates a new AddBlock
  66920. * @param name defines the block name
  66921. */
  66922. constructor(name: string);
  66923. /**
  66924. * Gets the current class name
  66925. * @returns the class name
  66926. */
  66927. getClassName(): string;
  66928. /**
  66929. * Gets the left operand input component
  66930. */
  66931. get left(): NodeMaterialConnectionPoint;
  66932. /**
  66933. * Gets the right operand input component
  66934. */
  66935. get right(): NodeMaterialConnectionPoint;
  66936. /**
  66937. * Gets the output component
  66938. */
  66939. get output(): NodeMaterialConnectionPoint;
  66940. protected _buildBlock(state: NodeMaterialBuildState): this;
  66941. }
  66942. }
  66943. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66947. /**
  66948. * Block used to scale a vector by a float
  66949. */
  66950. export class ScaleBlock extends NodeMaterialBlock {
  66951. /**
  66952. * Creates a new ScaleBlock
  66953. * @param name defines the block name
  66954. */
  66955. constructor(name: string);
  66956. /**
  66957. * Gets the current class name
  66958. * @returns the class name
  66959. */
  66960. getClassName(): string;
  66961. /**
  66962. * Gets the input component
  66963. */
  66964. get input(): NodeMaterialConnectionPoint;
  66965. /**
  66966. * Gets the factor input component
  66967. */
  66968. get factor(): NodeMaterialConnectionPoint;
  66969. /**
  66970. * Gets the output component
  66971. */
  66972. get output(): NodeMaterialConnectionPoint;
  66973. protected _buildBlock(state: NodeMaterialBuildState): this;
  66974. }
  66975. }
  66976. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66980. import { Scene } from "babylonjs/scene";
  66981. /**
  66982. * Block used to clamp a float
  66983. */
  66984. export class ClampBlock extends NodeMaterialBlock {
  66985. /** Gets or sets the minimum range */
  66986. minimum: number;
  66987. /** Gets or sets the maximum range */
  66988. maximum: number;
  66989. /**
  66990. * Creates a new ClampBlock
  66991. * @param name defines the block name
  66992. */
  66993. constructor(name: string);
  66994. /**
  66995. * Gets the current class name
  66996. * @returns the class name
  66997. */
  66998. getClassName(): string;
  66999. /**
  67000. * Gets the value input component
  67001. */
  67002. get value(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Gets the output component
  67005. */
  67006. get output(): NodeMaterialConnectionPoint;
  67007. protected _buildBlock(state: NodeMaterialBuildState): this;
  67008. protected _dumpPropertiesCode(): string;
  67009. serialize(): any;
  67010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67011. }
  67012. }
  67013. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67017. /**
  67018. * Block used to apply a cross product between 2 vectors
  67019. */
  67020. export class CrossBlock extends NodeMaterialBlock {
  67021. /**
  67022. * Creates a new CrossBlock
  67023. * @param name defines the block name
  67024. */
  67025. constructor(name: string);
  67026. /**
  67027. * Gets the current class name
  67028. * @returns the class name
  67029. */
  67030. getClassName(): string;
  67031. /**
  67032. * Gets the left operand input component
  67033. */
  67034. get left(): NodeMaterialConnectionPoint;
  67035. /**
  67036. * Gets the right operand input component
  67037. */
  67038. get right(): NodeMaterialConnectionPoint;
  67039. /**
  67040. * Gets the output component
  67041. */
  67042. get output(): NodeMaterialConnectionPoint;
  67043. protected _buildBlock(state: NodeMaterialBuildState): this;
  67044. }
  67045. }
  67046. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67050. /**
  67051. * Block used to apply a dot product between 2 vectors
  67052. */
  67053. export class DotBlock extends NodeMaterialBlock {
  67054. /**
  67055. * Creates a new DotBlock
  67056. * @param name defines the block name
  67057. */
  67058. constructor(name: string);
  67059. /**
  67060. * Gets the current class name
  67061. * @returns the class name
  67062. */
  67063. getClassName(): string;
  67064. /**
  67065. * Gets the left operand input component
  67066. */
  67067. get left(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the right operand input component
  67070. */
  67071. get right(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the output component
  67074. */
  67075. get output(): NodeMaterialConnectionPoint;
  67076. protected _buildBlock(state: NodeMaterialBuildState): this;
  67077. }
  67078. }
  67079. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67083. /**
  67084. * Block used to normalize a vector
  67085. */
  67086. export class NormalizeBlock extends NodeMaterialBlock {
  67087. /**
  67088. * Creates a new NormalizeBlock
  67089. * @param name defines the block name
  67090. */
  67091. constructor(name: string);
  67092. /**
  67093. * Gets the current class name
  67094. * @returns the class name
  67095. */
  67096. getClassName(): string;
  67097. /**
  67098. * Gets the input component
  67099. */
  67100. get input(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the output component
  67103. */
  67104. get output(): NodeMaterialConnectionPoint;
  67105. protected _buildBlock(state: NodeMaterialBuildState): this;
  67106. }
  67107. }
  67108. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67112. /**
  67113. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67114. */
  67115. export class ColorMergerBlock extends NodeMaterialBlock {
  67116. /**
  67117. * Create a new ColorMergerBlock
  67118. * @param name defines the block name
  67119. */
  67120. constructor(name: string);
  67121. /**
  67122. * Gets the current class name
  67123. * @returns the class name
  67124. */
  67125. getClassName(): string;
  67126. /**
  67127. * Gets the rgb component (input)
  67128. */
  67129. get rgbIn(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the r component (input)
  67132. */
  67133. get r(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the g component (input)
  67136. */
  67137. get g(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the b component (input)
  67140. */
  67141. get b(): NodeMaterialConnectionPoint;
  67142. /**
  67143. * Gets the a component (input)
  67144. */
  67145. get a(): NodeMaterialConnectionPoint;
  67146. /**
  67147. * Gets the rgba component (output)
  67148. */
  67149. get rgba(): NodeMaterialConnectionPoint;
  67150. /**
  67151. * Gets the rgb component (output)
  67152. */
  67153. get rgbOut(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the rgb component (output)
  67156. * @deprecated Please use rgbOut instead.
  67157. */
  67158. get rgb(): NodeMaterialConnectionPoint;
  67159. protected _buildBlock(state: NodeMaterialBuildState): this;
  67160. }
  67161. }
  67162. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67166. /**
  67167. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67168. */
  67169. export class VectorSplitterBlock extends NodeMaterialBlock {
  67170. /**
  67171. * Create a new VectorSplitterBlock
  67172. * @param name defines the block name
  67173. */
  67174. constructor(name: string);
  67175. /**
  67176. * Gets the current class name
  67177. * @returns the class name
  67178. */
  67179. getClassName(): string;
  67180. /**
  67181. * Gets the xyzw component (input)
  67182. */
  67183. get xyzw(): NodeMaterialConnectionPoint;
  67184. /**
  67185. * Gets the xyz component (input)
  67186. */
  67187. get xyzIn(): NodeMaterialConnectionPoint;
  67188. /**
  67189. * Gets the xy component (input)
  67190. */
  67191. get xyIn(): NodeMaterialConnectionPoint;
  67192. /**
  67193. * Gets the xyz component (output)
  67194. */
  67195. get xyzOut(): NodeMaterialConnectionPoint;
  67196. /**
  67197. * Gets the xy component (output)
  67198. */
  67199. get xyOut(): NodeMaterialConnectionPoint;
  67200. /**
  67201. * Gets the x component (output)
  67202. */
  67203. get x(): NodeMaterialConnectionPoint;
  67204. /**
  67205. * Gets the y component (output)
  67206. */
  67207. get y(): NodeMaterialConnectionPoint;
  67208. /**
  67209. * Gets the z component (output)
  67210. */
  67211. get z(): NodeMaterialConnectionPoint;
  67212. /**
  67213. * Gets the w component (output)
  67214. */
  67215. get w(): NodeMaterialConnectionPoint;
  67216. protected _inputRename(name: string): string;
  67217. protected _outputRename(name: string): string;
  67218. protected _buildBlock(state: NodeMaterialBuildState): this;
  67219. }
  67220. }
  67221. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67225. /**
  67226. * Block used to lerp between 2 values
  67227. */
  67228. export class LerpBlock extends NodeMaterialBlock {
  67229. /**
  67230. * Creates a new LerpBlock
  67231. * @param name defines the block name
  67232. */
  67233. constructor(name: string);
  67234. /**
  67235. * Gets the current class name
  67236. * @returns the class name
  67237. */
  67238. getClassName(): string;
  67239. /**
  67240. * Gets the left operand input component
  67241. */
  67242. get left(): NodeMaterialConnectionPoint;
  67243. /**
  67244. * Gets the right operand input component
  67245. */
  67246. get right(): NodeMaterialConnectionPoint;
  67247. /**
  67248. * Gets the gradient operand input component
  67249. */
  67250. get gradient(): NodeMaterialConnectionPoint;
  67251. /**
  67252. * Gets the output component
  67253. */
  67254. get output(): NodeMaterialConnectionPoint;
  67255. protected _buildBlock(state: NodeMaterialBuildState): this;
  67256. }
  67257. }
  67258. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67261. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67262. /**
  67263. * Block used to divide 2 vectors
  67264. */
  67265. export class DivideBlock extends NodeMaterialBlock {
  67266. /**
  67267. * Creates a new DivideBlock
  67268. * @param name defines the block name
  67269. */
  67270. constructor(name: string);
  67271. /**
  67272. * Gets the current class name
  67273. * @returns the class name
  67274. */
  67275. getClassName(): string;
  67276. /**
  67277. * Gets the left operand input component
  67278. */
  67279. get left(): NodeMaterialConnectionPoint;
  67280. /**
  67281. * Gets the right operand input component
  67282. */
  67283. get right(): NodeMaterialConnectionPoint;
  67284. /**
  67285. * Gets the output component
  67286. */
  67287. get output(): NodeMaterialConnectionPoint;
  67288. protected _buildBlock(state: NodeMaterialBuildState): this;
  67289. }
  67290. }
  67291. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67295. /**
  67296. * Block used to subtract 2 vectors
  67297. */
  67298. export class SubtractBlock extends NodeMaterialBlock {
  67299. /**
  67300. * Creates a new SubtractBlock
  67301. * @param name defines the block name
  67302. */
  67303. constructor(name: string);
  67304. /**
  67305. * Gets the current class name
  67306. * @returns the class name
  67307. */
  67308. getClassName(): string;
  67309. /**
  67310. * Gets the left operand input component
  67311. */
  67312. get left(): NodeMaterialConnectionPoint;
  67313. /**
  67314. * Gets the right operand input component
  67315. */
  67316. get right(): NodeMaterialConnectionPoint;
  67317. /**
  67318. * Gets the output component
  67319. */
  67320. get output(): NodeMaterialConnectionPoint;
  67321. protected _buildBlock(state: NodeMaterialBuildState): this;
  67322. }
  67323. }
  67324. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67328. /**
  67329. * Block used to step a value
  67330. */
  67331. export class StepBlock extends NodeMaterialBlock {
  67332. /**
  67333. * Creates a new StepBlock
  67334. * @param name defines the block name
  67335. */
  67336. constructor(name: string);
  67337. /**
  67338. * Gets the current class name
  67339. * @returns the class name
  67340. */
  67341. getClassName(): string;
  67342. /**
  67343. * Gets the value operand input component
  67344. */
  67345. get value(): NodeMaterialConnectionPoint;
  67346. /**
  67347. * Gets the edge operand input component
  67348. */
  67349. get edge(): NodeMaterialConnectionPoint;
  67350. /**
  67351. * Gets the output component
  67352. */
  67353. get output(): NodeMaterialConnectionPoint;
  67354. protected _buildBlock(state: NodeMaterialBuildState): this;
  67355. }
  67356. }
  67357. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67358. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67359. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67361. /**
  67362. * Block used to get the opposite (1 - x) of a value
  67363. */
  67364. export class OneMinusBlock extends NodeMaterialBlock {
  67365. /**
  67366. * Creates a new OneMinusBlock
  67367. * @param name defines the block name
  67368. */
  67369. constructor(name: string);
  67370. /**
  67371. * Gets the current class name
  67372. * @returns the class name
  67373. */
  67374. getClassName(): string;
  67375. /**
  67376. * Gets the input component
  67377. */
  67378. get input(): NodeMaterialConnectionPoint;
  67379. /**
  67380. * Gets the output component
  67381. */
  67382. get output(): NodeMaterialConnectionPoint;
  67383. protected _buildBlock(state: NodeMaterialBuildState): this;
  67384. }
  67385. }
  67386. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67390. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67391. /**
  67392. * Block used to get the view direction
  67393. */
  67394. export class ViewDirectionBlock extends NodeMaterialBlock {
  67395. /**
  67396. * Creates a new ViewDirectionBlock
  67397. * @param name defines the block name
  67398. */
  67399. constructor(name: string);
  67400. /**
  67401. * Gets the current class name
  67402. * @returns the class name
  67403. */
  67404. getClassName(): string;
  67405. /**
  67406. * Gets the world position component
  67407. */
  67408. get worldPosition(): NodeMaterialConnectionPoint;
  67409. /**
  67410. * Gets the camera position component
  67411. */
  67412. get cameraPosition(): NodeMaterialConnectionPoint;
  67413. /**
  67414. * Gets the output component
  67415. */
  67416. get output(): NodeMaterialConnectionPoint;
  67417. autoConfigure(material: NodeMaterial): void;
  67418. protected _buildBlock(state: NodeMaterialBuildState): this;
  67419. }
  67420. }
  67421. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67425. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67426. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67427. /**
  67428. * Block used to compute fresnel value
  67429. */
  67430. export class FresnelBlock extends NodeMaterialBlock {
  67431. /**
  67432. * Create a new FresnelBlock
  67433. * @param name defines the block name
  67434. */
  67435. constructor(name: string);
  67436. /**
  67437. * Gets the current class name
  67438. * @returns the class name
  67439. */
  67440. getClassName(): string;
  67441. /**
  67442. * Gets the world normal input component
  67443. */
  67444. get worldNormal(): NodeMaterialConnectionPoint;
  67445. /**
  67446. * Gets the view direction input component
  67447. */
  67448. get viewDirection(): NodeMaterialConnectionPoint;
  67449. /**
  67450. * Gets the bias input component
  67451. */
  67452. get bias(): NodeMaterialConnectionPoint;
  67453. /**
  67454. * Gets the camera (or eye) position component
  67455. */
  67456. get power(): NodeMaterialConnectionPoint;
  67457. /**
  67458. * Gets the fresnel output component
  67459. */
  67460. get fresnel(): NodeMaterialConnectionPoint;
  67461. autoConfigure(material: NodeMaterial): void;
  67462. protected _buildBlock(state: NodeMaterialBuildState): this;
  67463. }
  67464. }
  67465. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67469. /**
  67470. * Block used to get the max of 2 values
  67471. */
  67472. export class MaxBlock extends NodeMaterialBlock {
  67473. /**
  67474. * Creates a new MaxBlock
  67475. * @param name defines the block name
  67476. */
  67477. constructor(name: string);
  67478. /**
  67479. * Gets the current class name
  67480. * @returns the class name
  67481. */
  67482. getClassName(): string;
  67483. /**
  67484. * Gets the left operand input component
  67485. */
  67486. get left(): NodeMaterialConnectionPoint;
  67487. /**
  67488. * Gets the right operand input component
  67489. */
  67490. get right(): NodeMaterialConnectionPoint;
  67491. /**
  67492. * Gets the output component
  67493. */
  67494. get output(): NodeMaterialConnectionPoint;
  67495. protected _buildBlock(state: NodeMaterialBuildState): this;
  67496. }
  67497. }
  67498. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67502. /**
  67503. * Block used to get the min of 2 values
  67504. */
  67505. export class MinBlock extends NodeMaterialBlock {
  67506. /**
  67507. * Creates a new MinBlock
  67508. * @param name defines the block name
  67509. */
  67510. constructor(name: string);
  67511. /**
  67512. * Gets the current class name
  67513. * @returns the class name
  67514. */
  67515. getClassName(): string;
  67516. /**
  67517. * Gets the left operand input component
  67518. */
  67519. get left(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the right operand input component
  67522. */
  67523. get right(): NodeMaterialConnectionPoint;
  67524. /**
  67525. * Gets the output component
  67526. */
  67527. get output(): NodeMaterialConnectionPoint;
  67528. protected _buildBlock(state: NodeMaterialBuildState): this;
  67529. }
  67530. }
  67531. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67535. /**
  67536. * Block used to get the distance between 2 values
  67537. */
  67538. export class DistanceBlock extends NodeMaterialBlock {
  67539. /**
  67540. * Creates a new DistanceBlock
  67541. * @param name defines the block name
  67542. */
  67543. constructor(name: string);
  67544. /**
  67545. * Gets the current class name
  67546. * @returns the class name
  67547. */
  67548. getClassName(): string;
  67549. /**
  67550. * Gets the left operand input component
  67551. */
  67552. get left(): NodeMaterialConnectionPoint;
  67553. /**
  67554. * Gets the right operand input component
  67555. */
  67556. get right(): NodeMaterialConnectionPoint;
  67557. /**
  67558. * Gets the output component
  67559. */
  67560. get output(): NodeMaterialConnectionPoint;
  67561. protected _buildBlock(state: NodeMaterialBuildState): this;
  67562. }
  67563. }
  67564. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67568. /**
  67569. * Block used to get the length of a vector
  67570. */
  67571. export class LengthBlock extends NodeMaterialBlock {
  67572. /**
  67573. * Creates a new LengthBlock
  67574. * @param name defines the block name
  67575. */
  67576. constructor(name: string);
  67577. /**
  67578. * Gets the current class name
  67579. * @returns the class name
  67580. */
  67581. getClassName(): string;
  67582. /**
  67583. * Gets the value input component
  67584. */
  67585. get value(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the output component
  67588. */
  67589. get output(): NodeMaterialConnectionPoint;
  67590. protected _buildBlock(state: NodeMaterialBuildState): this;
  67591. }
  67592. }
  67593. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67597. /**
  67598. * Block used to get negative version of a value (i.e. x * -1)
  67599. */
  67600. export class NegateBlock extends NodeMaterialBlock {
  67601. /**
  67602. * Creates a new NegateBlock
  67603. * @param name defines the block name
  67604. */
  67605. constructor(name: string);
  67606. /**
  67607. * Gets the current class name
  67608. * @returns the class name
  67609. */
  67610. getClassName(): string;
  67611. /**
  67612. * Gets the value input component
  67613. */
  67614. get value(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the output component
  67617. */
  67618. get output(): NodeMaterialConnectionPoint;
  67619. protected _buildBlock(state: NodeMaterialBuildState): this;
  67620. }
  67621. }
  67622. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67626. /**
  67627. * Block used to get the value of the first parameter raised to the power of the second
  67628. */
  67629. export class PowBlock extends NodeMaterialBlock {
  67630. /**
  67631. * Creates a new PowBlock
  67632. * @param name defines the block name
  67633. */
  67634. constructor(name: string);
  67635. /**
  67636. * Gets the current class name
  67637. * @returns the class name
  67638. */
  67639. getClassName(): string;
  67640. /**
  67641. * Gets the value operand input component
  67642. */
  67643. get value(): NodeMaterialConnectionPoint;
  67644. /**
  67645. * Gets the power operand input component
  67646. */
  67647. get power(): NodeMaterialConnectionPoint;
  67648. /**
  67649. * Gets the output component
  67650. */
  67651. get output(): NodeMaterialConnectionPoint;
  67652. protected _buildBlock(state: NodeMaterialBuildState): this;
  67653. }
  67654. }
  67655. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67659. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67660. /**
  67661. * Block used to get a random number
  67662. */
  67663. export class RandomNumberBlock extends NodeMaterialBlock {
  67664. /**
  67665. * Creates a new RandomNumberBlock
  67666. * @param name defines the block name
  67667. */
  67668. constructor(name: string);
  67669. /**
  67670. * Gets the current class name
  67671. * @returns the class name
  67672. */
  67673. getClassName(): string;
  67674. /**
  67675. * Gets the seed input component
  67676. */
  67677. get seed(): NodeMaterialConnectionPoint;
  67678. /**
  67679. * Gets the output component
  67680. */
  67681. get output(): NodeMaterialConnectionPoint;
  67682. protected _buildBlock(state: NodeMaterialBuildState): this;
  67683. }
  67684. }
  67685. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67686. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67687. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67689. /**
  67690. * Block used to compute arc tangent of 2 values
  67691. */
  67692. export class ArcTan2Block extends NodeMaterialBlock {
  67693. /**
  67694. * Creates a new ArcTan2Block
  67695. * @param name defines the block name
  67696. */
  67697. constructor(name: string);
  67698. /**
  67699. * Gets the current class name
  67700. * @returns the class name
  67701. */
  67702. getClassName(): string;
  67703. /**
  67704. * Gets the x operand input component
  67705. */
  67706. get x(): NodeMaterialConnectionPoint;
  67707. /**
  67708. * Gets the y operand input component
  67709. */
  67710. get y(): NodeMaterialConnectionPoint;
  67711. /**
  67712. * Gets the output component
  67713. */
  67714. get output(): NodeMaterialConnectionPoint;
  67715. protected _buildBlock(state: NodeMaterialBuildState): this;
  67716. }
  67717. }
  67718. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67722. /**
  67723. * Block used to smooth step a value
  67724. */
  67725. export class SmoothStepBlock extends NodeMaterialBlock {
  67726. /**
  67727. * Creates a new SmoothStepBlock
  67728. * @param name defines the block name
  67729. */
  67730. constructor(name: string);
  67731. /**
  67732. * Gets the current class name
  67733. * @returns the class name
  67734. */
  67735. getClassName(): string;
  67736. /**
  67737. * Gets the value operand input component
  67738. */
  67739. get value(): NodeMaterialConnectionPoint;
  67740. /**
  67741. * Gets the first edge operand input component
  67742. */
  67743. get edge0(): NodeMaterialConnectionPoint;
  67744. /**
  67745. * Gets the second edge operand input component
  67746. */
  67747. get edge1(): NodeMaterialConnectionPoint;
  67748. /**
  67749. * Gets the output component
  67750. */
  67751. get output(): NodeMaterialConnectionPoint;
  67752. protected _buildBlock(state: NodeMaterialBuildState): this;
  67753. }
  67754. }
  67755. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67759. /**
  67760. * Block used to get the reciprocal (1 / x) of a value
  67761. */
  67762. export class ReciprocalBlock extends NodeMaterialBlock {
  67763. /**
  67764. * Creates a new ReciprocalBlock
  67765. * @param name defines the block name
  67766. */
  67767. constructor(name: string);
  67768. /**
  67769. * Gets the current class name
  67770. * @returns the class name
  67771. */
  67772. getClassName(): string;
  67773. /**
  67774. * Gets the input component
  67775. */
  67776. get input(): NodeMaterialConnectionPoint;
  67777. /**
  67778. * Gets the output component
  67779. */
  67780. get output(): NodeMaterialConnectionPoint;
  67781. protected _buildBlock(state: NodeMaterialBuildState): this;
  67782. }
  67783. }
  67784. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67788. /**
  67789. * Block used to replace a color by another one
  67790. */
  67791. export class ReplaceColorBlock extends NodeMaterialBlock {
  67792. /**
  67793. * Creates a new ReplaceColorBlock
  67794. * @param name defines the block name
  67795. */
  67796. constructor(name: string);
  67797. /**
  67798. * Gets the current class name
  67799. * @returns the class name
  67800. */
  67801. getClassName(): string;
  67802. /**
  67803. * Gets the value input component
  67804. */
  67805. get value(): NodeMaterialConnectionPoint;
  67806. /**
  67807. * Gets the reference input component
  67808. */
  67809. get reference(): NodeMaterialConnectionPoint;
  67810. /**
  67811. * Gets the distance input component
  67812. */
  67813. get distance(): NodeMaterialConnectionPoint;
  67814. /**
  67815. * Gets the replacement input component
  67816. */
  67817. get replacement(): NodeMaterialConnectionPoint;
  67818. /**
  67819. * Gets the output component
  67820. */
  67821. get output(): NodeMaterialConnectionPoint;
  67822. protected _buildBlock(state: NodeMaterialBuildState): this;
  67823. }
  67824. }
  67825. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67829. /**
  67830. * Block used to posterize a value
  67831. * @see https://en.wikipedia.org/wiki/Posterization
  67832. */
  67833. export class PosterizeBlock extends NodeMaterialBlock {
  67834. /**
  67835. * Creates a new PosterizeBlock
  67836. * @param name defines the block name
  67837. */
  67838. constructor(name: string);
  67839. /**
  67840. * Gets the current class name
  67841. * @returns the class name
  67842. */
  67843. getClassName(): string;
  67844. /**
  67845. * Gets the value input component
  67846. */
  67847. get value(): NodeMaterialConnectionPoint;
  67848. /**
  67849. * Gets the steps input component
  67850. */
  67851. get steps(): NodeMaterialConnectionPoint;
  67852. /**
  67853. * Gets the output component
  67854. */
  67855. get output(): NodeMaterialConnectionPoint;
  67856. protected _buildBlock(state: NodeMaterialBuildState): this;
  67857. }
  67858. }
  67859. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67863. import { Scene } from "babylonjs/scene";
  67864. /**
  67865. * Operations supported by the Wave block
  67866. */
  67867. export enum WaveBlockKind {
  67868. /** SawTooth */
  67869. SawTooth = 0,
  67870. /** Square */
  67871. Square = 1,
  67872. /** Triangle */
  67873. Triangle = 2
  67874. }
  67875. /**
  67876. * Block used to apply wave operation to floats
  67877. */
  67878. export class WaveBlock extends NodeMaterialBlock {
  67879. /**
  67880. * Gets or sets the kibnd of wave to be applied by the block
  67881. */
  67882. kind: WaveBlockKind;
  67883. /**
  67884. * Creates a new WaveBlock
  67885. * @param name defines the block name
  67886. */
  67887. constructor(name: string);
  67888. /**
  67889. * Gets the current class name
  67890. * @returns the class name
  67891. */
  67892. getClassName(): string;
  67893. /**
  67894. * Gets the input component
  67895. */
  67896. get input(): NodeMaterialConnectionPoint;
  67897. /**
  67898. * Gets the output component
  67899. */
  67900. get output(): NodeMaterialConnectionPoint;
  67901. protected _buildBlock(state: NodeMaterialBuildState): this;
  67902. serialize(): any;
  67903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67904. }
  67905. }
  67906. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67910. import { Color3 } from "babylonjs/Maths/math.color";
  67911. import { Scene } from "babylonjs/scene";
  67912. import { Observable } from "babylonjs/Misc/observable";
  67913. /**
  67914. * Class used to store a color step for the GradientBlock
  67915. */
  67916. export class GradientBlockColorStep {
  67917. private _step;
  67918. /**
  67919. * Gets value indicating which step this color is associated with (between 0 and 1)
  67920. */
  67921. get step(): number;
  67922. /**
  67923. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67924. */
  67925. set step(val: number);
  67926. private _color;
  67927. /**
  67928. * Gets the color associated with this step
  67929. */
  67930. get color(): Color3;
  67931. /**
  67932. * Sets the color associated with this step
  67933. */
  67934. set color(val: Color3);
  67935. /**
  67936. * Creates a new GradientBlockColorStep
  67937. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67938. * @param color defines the color associated with this step
  67939. */
  67940. constructor(step: number, color: Color3);
  67941. }
  67942. /**
  67943. * Block used to return a color from a gradient based on an input value between 0 and 1
  67944. */
  67945. export class GradientBlock extends NodeMaterialBlock {
  67946. /**
  67947. * Gets or sets the list of color steps
  67948. */
  67949. colorSteps: GradientBlockColorStep[];
  67950. /** Gets an observable raised when the value is changed */
  67951. onValueChangedObservable: Observable<GradientBlock>;
  67952. /** calls observable when the value is changed*/
  67953. colorStepsUpdated(): void;
  67954. /**
  67955. * Creates a new GradientBlock
  67956. * @param name defines the block name
  67957. */
  67958. constructor(name: string);
  67959. /**
  67960. * Gets the current class name
  67961. * @returns the class name
  67962. */
  67963. getClassName(): string;
  67964. /**
  67965. * Gets the gradient input component
  67966. */
  67967. get gradient(): NodeMaterialConnectionPoint;
  67968. /**
  67969. * Gets the output component
  67970. */
  67971. get output(): NodeMaterialConnectionPoint;
  67972. private _writeColorConstant;
  67973. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67974. serialize(): any;
  67975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67976. protected _dumpPropertiesCode(): string;
  67977. }
  67978. }
  67979. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67983. /**
  67984. * Block used to normalize lerp between 2 values
  67985. */
  67986. export class NLerpBlock extends NodeMaterialBlock {
  67987. /**
  67988. * Creates a new NLerpBlock
  67989. * @param name defines the block name
  67990. */
  67991. constructor(name: string);
  67992. /**
  67993. * Gets the current class name
  67994. * @returns the class name
  67995. */
  67996. getClassName(): string;
  67997. /**
  67998. * Gets the left operand input component
  67999. */
  68000. get left(): NodeMaterialConnectionPoint;
  68001. /**
  68002. * Gets the right operand input component
  68003. */
  68004. get right(): NodeMaterialConnectionPoint;
  68005. /**
  68006. * Gets the gradient operand input component
  68007. */
  68008. get gradient(): NodeMaterialConnectionPoint;
  68009. /**
  68010. * Gets the output component
  68011. */
  68012. get output(): NodeMaterialConnectionPoint;
  68013. protected _buildBlock(state: NodeMaterialBuildState): this;
  68014. }
  68015. }
  68016. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68020. import { Scene } from "babylonjs/scene";
  68021. /**
  68022. * block used to Generate a Worley Noise 3D Noise Pattern
  68023. */
  68024. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68025. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68026. manhattanDistance: boolean;
  68027. /**
  68028. * Creates a new WorleyNoise3DBlock
  68029. * @param name defines the block name
  68030. */
  68031. constructor(name: string);
  68032. /**
  68033. * Gets the current class name
  68034. * @returns the class name
  68035. */
  68036. getClassName(): string;
  68037. /**
  68038. * Gets the seed input component
  68039. */
  68040. get seed(): NodeMaterialConnectionPoint;
  68041. /**
  68042. * Gets the jitter input component
  68043. */
  68044. get jitter(): NodeMaterialConnectionPoint;
  68045. /**
  68046. * Gets the output component
  68047. */
  68048. get output(): NodeMaterialConnectionPoint;
  68049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68050. /**
  68051. * Exposes the properties to the UI?
  68052. */
  68053. protected _dumpPropertiesCode(): string;
  68054. /**
  68055. * Exposes the properties to the Seralize?
  68056. */
  68057. serialize(): any;
  68058. /**
  68059. * Exposes the properties to the deseralize?
  68060. */
  68061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68062. }
  68063. }
  68064. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68068. /**
  68069. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68070. */
  68071. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68072. /**
  68073. * Creates a new SimplexPerlin3DBlock
  68074. * @param name defines the block name
  68075. */
  68076. constructor(name: string);
  68077. /**
  68078. * Gets the current class name
  68079. * @returns the class name
  68080. */
  68081. getClassName(): string;
  68082. /**
  68083. * Gets the seed operand input component
  68084. */
  68085. get seed(): NodeMaterialConnectionPoint;
  68086. /**
  68087. * Gets the output component
  68088. */
  68089. get output(): NodeMaterialConnectionPoint;
  68090. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68091. }
  68092. }
  68093. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68097. /**
  68098. * Block used to blend normals
  68099. */
  68100. export class NormalBlendBlock extends NodeMaterialBlock {
  68101. /**
  68102. * Creates a new NormalBlendBlock
  68103. * @param name defines the block name
  68104. */
  68105. constructor(name: string);
  68106. /**
  68107. * Gets the current class name
  68108. * @returns the class name
  68109. */
  68110. getClassName(): string;
  68111. /**
  68112. * Gets the first input component
  68113. */
  68114. get normalMap0(): NodeMaterialConnectionPoint;
  68115. /**
  68116. * Gets the second input component
  68117. */
  68118. get normalMap1(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the output component
  68121. */
  68122. get output(): NodeMaterialConnectionPoint;
  68123. protected _buildBlock(state: NodeMaterialBuildState): this;
  68124. }
  68125. }
  68126. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68130. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68131. /**
  68132. * Block used to rotate a 2d vector by a given angle
  68133. */
  68134. export class Rotate2dBlock extends NodeMaterialBlock {
  68135. /**
  68136. * Creates a new Rotate2dBlock
  68137. * @param name defines the block name
  68138. */
  68139. constructor(name: string);
  68140. /**
  68141. * Gets the current class name
  68142. * @returns the class name
  68143. */
  68144. getClassName(): string;
  68145. /**
  68146. * Gets the input vector
  68147. */
  68148. get input(): NodeMaterialConnectionPoint;
  68149. /**
  68150. * Gets the input angle
  68151. */
  68152. get angle(): NodeMaterialConnectionPoint;
  68153. /**
  68154. * Gets the output component
  68155. */
  68156. get output(): NodeMaterialConnectionPoint;
  68157. autoConfigure(material: NodeMaterial): void;
  68158. protected _buildBlock(state: NodeMaterialBuildState): this;
  68159. }
  68160. }
  68161. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68165. /**
  68166. * Block used to get the reflected vector from a direction and a normal
  68167. */
  68168. export class ReflectBlock extends NodeMaterialBlock {
  68169. /**
  68170. * Creates a new ReflectBlock
  68171. * @param name defines the block name
  68172. */
  68173. constructor(name: string);
  68174. /**
  68175. * Gets the current class name
  68176. * @returns the class name
  68177. */
  68178. getClassName(): string;
  68179. /**
  68180. * Gets the incident component
  68181. */
  68182. get incident(): NodeMaterialConnectionPoint;
  68183. /**
  68184. * Gets the normal component
  68185. */
  68186. get normal(): NodeMaterialConnectionPoint;
  68187. /**
  68188. * Gets the output component
  68189. */
  68190. get output(): NodeMaterialConnectionPoint;
  68191. protected _buildBlock(state: NodeMaterialBuildState): this;
  68192. }
  68193. }
  68194. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68198. /**
  68199. * Block used to get the refracted vector from a direction and a normal
  68200. */
  68201. export class RefractBlock extends NodeMaterialBlock {
  68202. /**
  68203. * Creates a new RefractBlock
  68204. * @param name defines the block name
  68205. */
  68206. constructor(name: string);
  68207. /**
  68208. * Gets the current class name
  68209. * @returns the class name
  68210. */
  68211. getClassName(): string;
  68212. /**
  68213. * Gets the incident component
  68214. */
  68215. get incident(): NodeMaterialConnectionPoint;
  68216. /**
  68217. * Gets the normal component
  68218. */
  68219. get normal(): NodeMaterialConnectionPoint;
  68220. /**
  68221. * Gets the index of refraction component
  68222. */
  68223. get ior(): NodeMaterialConnectionPoint;
  68224. /**
  68225. * Gets the output component
  68226. */
  68227. get output(): NodeMaterialConnectionPoint;
  68228. protected _buildBlock(state: NodeMaterialBuildState): this;
  68229. }
  68230. }
  68231. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68235. /**
  68236. * Block used to desaturate a color
  68237. */
  68238. export class DesaturateBlock extends NodeMaterialBlock {
  68239. /**
  68240. * Creates a new DesaturateBlock
  68241. * @param name defines the block name
  68242. */
  68243. constructor(name: string);
  68244. /**
  68245. * Gets the current class name
  68246. * @returns the class name
  68247. */
  68248. getClassName(): string;
  68249. /**
  68250. * Gets the color operand input component
  68251. */
  68252. get color(): NodeMaterialConnectionPoint;
  68253. /**
  68254. * Gets the level operand input component
  68255. */
  68256. get level(): NodeMaterialConnectionPoint;
  68257. /**
  68258. * Gets the output component
  68259. */
  68260. get output(): NodeMaterialConnectionPoint;
  68261. protected _buildBlock(state: NodeMaterialBuildState): this;
  68262. }
  68263. }
  68264. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68268. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68269. import { Nullable } from "babylonjs/types";
  68270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68271. import { Scene } from "babylonjs/scene";
  68272. /**
  68273. * Block used to implement the ambient occlusion module of the PBR material
  68274. */
  68275. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68276. /**
  68277. * Create a new AmbientOcclusionBlock
  68278. * @param name defines the block name
  68279. */
  68280. constructor(name: string);
  68281. /**
  68282. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68283. */
  68284. useAmbientInGrayScale: boolean;
  68285. /**
  68286. * Initialize the block and prepare the context for build
  68287. * @param state defines the state that will be used for the build
  68288. */
  68289. initialize(state: NodeMaterialBuildState): void;
  68290. /**
  68291. * Gets the current class name
  68292. * @returns the class name
  68293. */
  68294. getClassName(): string;
  68295. /**
  68296. * Gets the texture input component
  68297. */
  68298. get texture(): NodeMaterialConnectionPoint;
  68299. /**
  68300. * Gets the texture intensity component
  68301. */
  68302. get intensity(): NodeMaterialConnectionPoint;
  68303. /**
  68304. * Gets the direct light intensity input component
  68305. */
  68306. get directLightIntensity(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the ambient occlusion object output component
  68309. */
  68310. get ambientOcc(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the main code of the block (fragment side)
  68313. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68314. * @returns the shader code
  68315. */
  68316. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68317. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68318. protected _buildBlock(state: NodeMaterialBuildState): this;
  68319. protected _dumpPropertiesCode(): string;
  68320. serialize(): any;
  68321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68322. }
  68323. }
  68324. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68327. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68328. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68330. import { Nullable } from "babylonjs/types";
  68331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68332. import { Mesh } from "babylonjs/Meshes/mesh";
  68333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68334. import { Effect } from "babylonjs/Materials/effect";
  68335. import { Scene } from "babylonjs/scene";
  68336. /**
  68337. * Block used to implement the reflection module of the PBR material
  68338. */
  68339. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68340. /** @hidden */
  68341. _defineLODReflectionAlpha: string;
  68342. /** @hidden */
  68343. _defineLinearSpecularReflection: string;
  68344. private _vEnvironmentIrradianceName;
  68345. /** @hidden */
  68346. _vReflectionMicrosurfaceInfosName: string;
  68347. /** @hidden */
  68348. _vReflectionInfosName: string;
  68349. /** @hidden */
  68350. _vReflectionFilteringInfoName: string;
  68351. private _scene;
  68352. /**
  68353. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68354. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68355. * It's less burden on the user side in the editor part.
  68356. */
  68357. /** @hidden */
  68358. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68359. /** @hidden */
  68360. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68361. /** @hidden */
  68362. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68363. /**
  68364. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68365. * diffuse part of the IBL.
  68366. */
  68367. useSphericalHarmonics: boolean;
  68368. /**
  68369. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68370. */
  68371. forceIrradianceInFragment: boolean;
  68372. /**
  68373. * Create a new ReflectionBlock
  68374. * @param name defines the block name
  68375. */
  68376. constructor(name: string);
  68377. /**
  68378. * Gets the current class name
  68379. * @returns the class name
  68380. */
  68381. getClassName(): string;
  68382. /**
  68383. * Gets the position input component
  68384. */
  68385. get position(): NodeMaterialConnectionPoint;
  68386. /**
  68387. * Gets the world position input component
  68388. */
  68389. get worldPosition(): NodeMaterialConnectionPoint;
  68390. /**
  68391. * Gets the world normal input component
  68392. */
  68393. get worldNormal(): NodeMaterialConnectionPoint;
  68394. /**
  68395. * Gets the world input component
  68396. */
  68397. get world(): NodeMaterialConnectionPoint;
  68398. /**
  68399. * Gets the camera (or eye) position component
  68400. */
  68401. get cameraPosition(): NodeMaterialConnectionPoint;
  68402. /**
  68403. * Gets the view input component
  68404. */
  68405. get view(): NodeMaterialConnectionPoint;
  68406. /**
  68407. * Gets the color input component
  68408. */
  68409. get color(): NodeMaterialConnectionPoint;
  68410. /**
  68411. * Gets the reflection object output component
  68412. */
  68413. get reflection(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68416. */
  68417. get hasTexture(): boolean;
  68418. /**
  68419. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68420. */
  68421. get reflectionColor(): string;
  68422. protected _getTexture(): Nullable<BaseTexture>;
  68423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68424. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68425. /**
  68426. * Gets the code to inject in the vertex shader
  68427. * @param state current state of the node material building
  68428. * @returns the shader code
  68429. */
  68430. handleVertexSide(state: NodeMaterialBuildState): string;
  68431. /**
  68432. * Gets the main code of the block (fragment side)
  68433. * @param state current state of the node material building
  68434. * @param normalVarName name of the existing variable corresponding to the normal
  68435. * @returns the shader code
  68436. */
  68437. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68438. protected _buildBlock(state: NodeMaterialBuildState): this;
  68439. protected _dumpPropertiesCode(): string;
  68440. serialize(): any;
  68441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68442. }
  68443. }
  68444. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68448. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68450. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68451. import { Scene } from "babylonjs/scene";
  68452. import { Nullable } from "babylonjs/types";
  68453. /**
  68454. * Block used to implement the sheen module of the PBR material
  68455. */
  68456. export class SheenBlock extends NodeMaterialBlock {
  68457. /**
  68458. * Create a new SheenBlock
  68459. * @param name defines the block name
  68460. */
  68461. constructor(name: string);
  68462. /**
  68463. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68464. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68465. * making it easier to setup and tweak the effect
  68466. */
  68467. albedoScaling: boolean;
  68468. /**
  68469. * Defines if the sheen is linked to the sheen color.
  68470. */
  68471. linkSheenWithAlbedo: boolean;
  68472. /**
  68473. * Initialize the block and prepare the context for build
  68474. * @param state defines the state that will be used for the build
  68475. */
  68476. initialize(state: NodeMaterialBuildState): void;
  68477. /**
  68478. * Gets the current class name
  68479. * @returns the class name
  68480. */
  68481. getClassName(): string;
  68482. /**
  68483. * Gets the intensity input component
  68484. */
  68485. get intensity(): NodeMaterialConnectionPoint;
  68486. /**
  68487. * Gets the color input component
  68488. */
  68489. get color(): NodeMaterialConnectionPoint;
  68490. /**
  68491. * Gets the roughness input component
  68492. */
  68493. get roughness(): NodeMaterialConnectionPoint;
  68494. /**
  68495. * Gets the sheen object output component
  68496. */
  68497. get sheen(): NodeMaterialConnectionPoint;
  68498. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68499. /**
  68500. * Gets the main code of the block (fragment side)
  68501. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68502. * @returns the shader code
  68503. */
  68504. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68505. protected _buildBlock(state: NodeMaterialBuildState): this;
  68506. protected _dumpPropertiesCode(): string;
  68507. serialize(): any;
  68508. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68509. }
  68510. }
  68511. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68512. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68517. import { Scene } from "babylonjs/scene";
  68518. import { Nullable } from "babylonjs/types";
  68519. import { Mesh } from "babylonjs/Meshes/mesh";
  68520. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68521. import { Effect } from "babylonjs/Materials/effect";
  68522. /**
  68523. * Block used to implement the reflectivity module of the PBR material
  68524. */
  68525. export class ReflectivityBlock extends NodeMaterialBlock {
  68526. private _metallicReflectanceColor;
  68527. private _metallicF0Factor;
  68528. /** @hidden */
  68529. _vMetallicReflectanceFactorsName: string;
  68530. /**
  68531. * The property below is set by the main PBR block prior to calling methods of this class.
  68532. */
  68533. /** @hidden */
  68534. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68535. /**
  68536. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68537. */
  68538. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68539. /**
  68540. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68541. */
  68542. useMetallnessFromMetallicTextureBlue: boolean;
  68543. /**
  68544. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68545. */
  68546. useRoughnessFromMetallicTextureAlpha: boolean;
  68547. /**
  68548. * Specifies if the metallic texture contains the roughness information in its green channel.
  68549. */
  68550. useRoughnessFromMetallicTextureGreen: boolean;
  68551. /**
  68552. * Create a new ReflectivityBlock
  68553. * @param name defines the block name
  68554. */
  68555. constructor(name: string);
  68556. /**
  68557. * Initialize the block and prepare the context for build
  68558. * @param state defines the state that will be used for the build
  68559. */
  68560. initialize(state: NodeMaterialBuildState): void;
  68561. /**
  68562. * Gets the current class name
  68563. * @returns the class name
  68564. */
  68565. getClassName(): string;
  68566. /**
  68567. * Gets the metallic input component
  68568. */
  68569. get metallic(): NodeMaterialConnectionPoint;
  68570. /**
  68571. * Gets the roughness input component
  68572. */
  68573. get roughness(): NodeMaterialConnectionPoint;
  68574. /**
  68575. * Gets the texture input component
  68576. */
  68577. get texture(): NodeMaterialConnectionPoint;
  68578. /**
  68579. * Gets the reflectivity object output component
  68580. */
  68581. get reflectivity(): NodeMaterialConnectionPoint;
  68582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68583. /**
  68584. * Gets the main code of the block (fragment side)
  68585. * @param state current state of the node material building
  68586. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68587. * @returns the shader code
  68588. */
  68589. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68591. protected _buildBlock(state: NodeMaterialBuildState): this;
  68592. protected _dumpPropertiesCode(): string;
  68593. serialize(): any;
  68594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68595. }
  68596. }
  68597. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68598. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68603. /**
  68604. * Block used to implement the anisotropy module of the PBR material
  68605. */
  68606. export class AnisotropyBlock extends NodeMaterialBlock {
  68607. /**
  68608. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68609. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68610. * It's less burden on the user side in the editor part.
  68611. */
  68612. /** @hidden */
  68613. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68614. /** @hidden */
  68615. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68616. /**
  68617. * Create a new AnisotropyBlock
  68618. * @param name defines the block name
  68619. */
  68620. constructor(name: string);
  68621. /**
  68622. * Initialize the block and prepare the context for build
  68623. * @param state defines the state that will be used for the build
  68624. */
  68625. initialize(state: NodeMaterialBuildState): void;
  68626. /**
  68627. * Gets the current class name
  68628. * @returns the class name
  68629. */
  68630. getClassName(): string;
  68631. /**
  68632. * Gets the intensity input component
  68633. */
  68634. get intensity(): NodeMaterialConnectionPoint;
  68635. /**
  68636. * Gets the direction input component
  68637. */
  68638. get direction(): NodeMaterialConnectionPoint;
  68639. /**
  68640. * Gets the texture input component
  68641. */
  68642. get texture(): NodeMaterialConnectionPoint;
  68643. /**
  68644. * Gets the uv input component
  68645. */
  68646. get uv(): NodeMaterialConnectionPoint;
  68647. /**
  68648. * Gets the worldTangent input component
  68649. */
  68650. get worldTangent(): NodeMaterialConnectionPoint;
  68651. /**
  68652. * Gets the anisotropy object output component
  68653. */
  68654. get anisotropy(): NodeMaterialConnectionPoint;
  68655. private _generateTBNSpace;
  68656. /**
  68657. * Gets the main code of the block (fragment side)
  68658. * @param state current state of the node material building
  68659. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68660. * @returns the shader code
  68661. */
  68662. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68664. protected _buildBlock(state: NodeMaterialBuildState): this;
  68665. }
  68666. }
  68667. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68671. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68673. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68674. import { Nullable } from "babylonjs/types";
  68675. import { Mesh } from "babylonjs/Meshes/mesh";
  68676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68677. import { Effect } from "babylonjs/Materials/effect";
  68678. /**
  68679. * Block used to implement the clear coat module of the PBR material
  68680. */
  68681. export class ClearCoatBlock extends NodeMaterialBlock {
  68682. private _scene;
  68683. /**
  68684. * Create a new ClearCoatBlock
  68685. * @param name defines the block name
  68686. */
  68687. constructor(name: string);
  68688. /**
  68689. * Initialize the block and prepare the context for build
  68690. * @param state defines the state that will be used for the build
  68691. */
  68692. initialize(state: NodeMaterialBuildState): void;
  68693. /**
  68694. * Gets the current class name
  68695. * @returns the class name
  68696. */
  68697. getClassName(): string;
  68698. /**
  68699. * Gets the intensity input component
  68700. */
  68701. get intensity(): NodeMaterialConnectionPoint;
  68702. /**
  68703. * Gets the roughness input component
  68704. */
  68705. get roughness(): NodeMaterialConnectionPoint;
  68706. /**
  68707. * Gets the ior input component
  68708. */
  68709. get ior(): NodeMaterialConnectionPoint;
  68710. /**
  68711. * Gets the texture input component
  68712. */
  68713. get texture(): NodeMaterialConnectionPoint;
  68714. /**
  68715. * Gets the bump texture input component
  68716. */
  68717. get bumpTexture(): NodeMaterialConnectionPoint;
  68718. /**
  68719. * Gets the uv input component
  68720. */
  68721. get uv(): NodeMaterialConnectionPoint;
  68722. /**
  68723. * Gets the tint color input component
  68724. */
  68725. get tintColor(): NodeMaterialConnectionPoint;
  68726. /**
  68727. * Gets the tint "at distance" input component
  68728. */
  68729. get tintAtDistance(): NodeMaterialConnectionPoint;
  68730. /**
  68731. * Gets the tint thickness input component
  68732. */
  68733. get tintThickness(): NodeMaterialConnectionPoint;
  68734. /**
  68735. * Gets the world tangent input component
  68736. */
  68737. get worldTangent(): NodeMaterialConnectionPoint;
  68738. /**
  68739. * Gets the clear coat object output component
  68740. */
  68741. get clearcoat(): NodeMaterialConnectionPoint;
  68742. autoConfigure(material: NodeMaterial): void;
  68743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68744. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68745. private _generateTBNSpace;
  68746. /**
  68747. * Gets the main code of the block (fragment side)
  68748. * @param state current state of the node material building
  68749. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68750. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68751. * @param worldPosVarName name of the variable holding the world position
  68752. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68753. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68754. * @param worldNormalVarName name of the variable holding the world normal
  68755. * @returns the shader code
  68756. */
  68757. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68758. protected _buildBlock(state: NodeMaterialBuildState): this;
  68759. }
  68760. }
  68761. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68765. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68767. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68768. import { Nullable } from "babylonjs/types";
  68769. /**
  68770. * Block used to implement the sub surface module of the PBR material
  68771. */
  68772. export class SubSurfaceBlock extends NodeMaterialBlock {
  68773. /**
  68774. * Create a new SubSurfaceBlock
  68775. * @param name defines the block name
  68776. */
  68777. constructor(name: string);
  68778. /**
  68779. * Stores the intensity of the different subsurface effects in the thickness texture.
  68780. * * the green channel is the translucency intensity.
  68781. * * the blue channel is the scattering intensity.
  68782. * * the alpha channel is the refraction intensity.
  68783. */
  68784. useMaskFromThicknessTexture: boolean;
  68785. /**
  68786. * Initialize the block and prepare the context for build
  68787. * @param state defines the state that will be used for the build
  68788. */
  68789. initialize(state: NodeMaterialBuildState): void;
  68790. /**
  68791. * Gets the current class name
  68792. * @returns the class name
  68793. */
  68794. getClassName(): string;
  68795. /**
  68796. * Gets the min thickness input component
  68797. */
  68798. get minThickness(): NodeMaterialConnectionPoint;
  68799. /**
  68800. * Gets the max thickness input component
  68801. */
  68802. get maxThickness(): NodeMaterialConnectionPoint;
  68803. /**
  68804. * Gets the thickness texture component
  68805. */
  68806. get thicknessTexture(): NodeMaterialConnectionPoint;
  68807. /**
  68808. * Gets the tint color input component
  68809. */
  68810. get tintColor(): NodeMaterialConnectionPoint;
  68811. /**
  68812. * Gets the translucency intensity input component
  68813. */
  68814. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68815. /**
  68816. * Gets the translucency diffusion distance input component
  68817. */
  68818. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68819. /**
  68820. * Gets the refraction object parameters
  68821. */
  68822. get refraction(): NodeMaterialConnectionPoint;
  68823. /**
  68824. * Gets the sub surface object output component
  68825. */
  68826. get subsurface(): NodeMaterialConnectionPoint;
  68827. autoConfigure(material: NodeMaterial): void;
  68828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68829. /**
  68830. * Gets the main code of the block (fragment side)
  68831. * @param state current state of the node material building
  68832. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68833. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68834. * @param worldPosVarName name of the variable holding the world position
  68835. * @returns the shader code
  68836. */
  68837. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68838. protected _buildBlock(state: NodeMaterialBuildState): this;
  68839. }
  68840. }
  68841. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68845. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68846. import { Light } from "babylonjs/Lights/light";
  68847. import { Nullable } from "babylonjs/types";
  68848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68849. import { Effect } from "babylonjs/Materials/effect";
  68850. import { Mesh } from "babylonjs/Meshes/mesh";
  68851. import { Scene } from "babylonjs/scene";
  68852. /**
  68853. * Block used to implement the PBR metallic/roughness model
  68854. */
  68855. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68856. /**
  68857. * Gets or sets the light associated with this block
  68858. */
  68859. light: Nullable<Light>;
  68860. private _lightId;
  68861. private _scene;
  68862. private _environmentBRDFTexture;
  68863. private _environmentBrdfSamplerName;
  68864. private _vNormalWName;
  68865. private _invertNormalName;
  68866. /**
  68867. * Create a new ReflectionBlock
  68868. * @param name defines the block name
  68869. */
  68870. constructor(name: string);
  68871. /**
  68872. * Intensity of the direct lights e.g. the four lights available in your scene.
  68873. * This impacts both the direct diffuse and specular highlights.
  68874. */
  68875. directIntensity: number;
  68876. /**
  68877. * Intensity of the environment e.g. how much the environment will light the object
  68878. * either through harmonics for rough material or through the refelction for shiny ones.
  68879. */
  68880. environmentIntensity: number;
  68881. /**
  68882. * This is a special control allowing the reduction of the specular highlights coming from the
  68883. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68884. */
  68885. specularIntensity: number;
  68886. /**
  68887. * Defines the falloff type used in this material.
  68888. * It by default is Physical.
  68889. */
  68890. lightFalloff: number;
  68891. /**
  68892. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68893. */
  68894. useAlphaFromAlbedoTexture: boolean;
  68895. /**
  68896. * Specifies that alpha test should be used
  68897. */
  68898. useAlphaTest: boolean;
  68899. /**
  68900. * Defines the alpha limits in alpha test mode.
  68901. */
  68902. alphaTestCutoff: number;
  68903. /**
  68904. * Specifies that alpha blending should be used
  68905. */
  68906. useAlphaBlending: boolean;
  68907. /**
  68908. * Defines if the alpha value should be determined via the rgb values.
  68909. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68910. */
  68911. opacityRGB: boolean;
  68912. /**
  68913. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68914. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68915. */
  68916. useRadianceOverAlpha: boolean;
  68917. /**
  68918. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68919. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68920. */
  68921. useSpecularOverAlpha: boolean;
  68922. /**
  68923. * Enables specular anti aliasing in the PBR shader.
  68924. * It will both interacts on the Geometry for analytical and IBL lighting.
  68925. * It also prefilter the roughness map based on the bump values.
  68926. */
  68927. enableSpecularAntiAliasing: boolean;
  68928. /**
  68929. * Enables realtime filtering on the texture.
  68930. */
  68931. realTimeFiltering: boolean;
  68932. /**
  68933. * Quality switch for realtime filtering
  68934. */
  68935. realTimeFilteringQuality: number;
  68936. /**
  68937. * Defines if the material uses energy conservation.
  68938. */
  68939. useEnergyConservation: boolean;
  68940. /**
  68941. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68942. * too much the area relying on ambient texture to define their ambient occlusion.
  68943. */
  68944. useRadianceOcclusion: boolean;
  68945. /**
  68946. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68947. * makes the reflect vector face the model (under horizon).
  68948. */
  68949. useHorizonOcclusion: boolean;
  68950. /**
  68951. * If set to true, no lighting calculations will be applied.
  68952. */
  68953. unlit: boolean;
  68954. /**
  68955. * Force normal to face away from face.
  68956. */
  68957. forceNormalForward: boolean;
  68958. /**
  68959. * Defines the material debug mode.
  68960. * It helps seeing only some components of the material while troubleshooting.
  68961. */
  68962. debugMode: number;
  68963. /**
  68964. * Specify from where on screen the debug mode should start.
  68965. * The value goes from -1 (full screen) to 1 (not visible)
  68966. * It helps with side by side comparison against the final render
  68967. * This defaults to 0
  68968. */
  68969. debugLimit: number;
  68970. /**
  68971. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68972. * You can use the factor to better multiply the final value.
  68973. */
  68974. debugFactor: number;
  68975. /**
  68976. * Initialize the block and prepare the context for build
  68977. * @param state defines the state that will be used for the build
  68978. */
  68979. initialize(state: NodeMaterialBuildState): void;
  68980. /**
  68981. * Gets the current class name
  68982. * @returns the class name
  68983. */
  68984. getClassName(): string;
  68985. /**
  68986. * Gets the world position input component
  68987. */
  68988. get worldPosition(): NodeMaterialConnectionPoint;
  68989. /**
  68990. * Gets the world normal input component
  68991. */
  68992. get worldNormal(): NodeMaterialConnectionPoint;
  68993. /**
  68994. * Gets the perturbed normal input component
  68995. */
  68996. get perturbedNormal(): NodeMaterialConnectionPoint;
  68997. /**
  68998. * Gets the camera position input component
  68999. */
  69000. get cameraPosition(): NodeMaterialConnectionPoint;
  69001. /**
  69002. * Gets the base color input component
  69003. */
  69004. get baseColor(): NodeMaterialConnectionPoint;
  69005. /**
  69006. * Gets the opacity texture input component
  69007. */
  69008. get opacityTexture(): NodeMaterialConnectionPoint;
  69009. /**
  69010. * Gets the ambient color input component
  69011. */
  69012. get ambientColor(): NodeMaterialConnectionPoint;
  69013. /**
  69014. * Gets the reflectivity object parameters
  69015. */
  69016. get reflectivity(): NodeMaterialConnectionPoint;
  69017. /**
  69018. * Gets the ambient occlusion object parameters
  69019. */
  69020. get ambientOcc(): NodeMaterialConnectionPoint;
  69021. /**
  69022. * Gets the reflection object parameters
  69023. */
  69024. get reflection(): NodeMaterialConnectionPoint;
  69025. /**
  69026. * Gets the sheen object parameters
  69027. */
  69028. get sheen(): NodeMaterialConnectionPoint;
  69029. /**
  69030. * Gets the clear coat object parameters
  69031. */
  69032. get clearcoat(): NodeMaterialConnectionPoint;
  69033. /**
  69034. * Gets the sub surface object parameters
  69035. */
  69036. get subsurface(): NodeMaterialConnectionPoint;
  69037. /**
  69038. * Gets the anisotropy object parameters
  69039. */
  69040. get anisotropy(): NodeMaterialConnectionPoint;
  69041. /**
  69042. * Gets the view matrix parameter
  69043. */
  69044. get view(): NodeMaterialConnectionPoint;
  69045. /**
  69046. * Gets the ambient output component
  69047. */
  69048. get ambient(): NodeMaterialConnectionPoint;
  69049. /**
  69050. * Gets the diffuse output component
  69051. */
  69052. get diffuse(): NodeMaterialConnectionPoint;
  69053. /**
  69054. * Gets the specular output component
  69055. */
  69056. get specular(): NodeMaterialConnectionPoint;
  69057. /**
  69058. * Gets the sheen output component
  69059. */
  69060. get sheenDir(): NodeMaterialConnectionPoint;
  69061. /**
  69062. * Gets the clear coat output component
  69063. */
  69064. get clearcoatDir(): NodeMaterialConnectionPoint;
  69065. /**
  69066. * Gets the indirect diffuse output component
  69067. */
  69068. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69069. /**
  69070. * Gets the indirect specular output component
  69071. */
  69072. get specularIndirect(): NodeMaterialConnectionPoint;
  69073. /**
  69074. * Gets the indirect sheen output component
  69075. */
  69076. get sheenIndirect(): NodeMaterialConnectionPoint;
  69077. /**
  69078. * Gets the indirect clear coat output component
  69079. */
  69080. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69081. /**
  69082. * Gets the refraction output component
  69083. */
  69084. get refraction(): NodeMaterialConnectionPoint;
  69085. /**
  69086. * Gets the global lighting output component
  69087. */
  69088. get lighting(): NodeMaterialConnectionPoint;
  69089. /**
  69090. * Gets the shadow output component
  69091. */
  69092. get shadow(): NodeMaterialConnectionPoint;
  69093. /**
  69094. * Gets the alpha output component
  69095. */
  69096. get alpha(): NodeMaterialConnectionPoint;
  69097. autoConfigure(material: NodeMaterial): void;
  69098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69099. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69101. private _injectVertexCode;
  69102. /**
  69103. * Gets the code corresponding to the albedo/opacity module
  69104. * @returns the shader code
  69105. */
  69106. getAlbedoOpacityCode(): string;
  69107. protected _buildBlock(state: NodeMaterialBuildState): this;
  69108. protected _dumpPropertiesCode(): string;
  69109. serialize(): any;
  69110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69111. }
  69112. }
  69113. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69114. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69115. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69116. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69117. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69118. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69119. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69120. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69121. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69122. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69123. }
  69124. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69125. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69126. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69127. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69128. }
  69129. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69133. /**
  69134. * Block used to compute value of one parameter modulo another
  69135. */
  69136. export class ModBlock extends NodeMaterialBlock {
  69137. /**
  69138. * Creates a new ModBlock
  69139. * @param name defines the block name
  69140. */
  69141. constructor(name: string);
  69142. /**
  69143. * Gets the current class name
  69144. * @returns the class name
  69145. */
  69146. getClassName(): string;
  69147. /**
  69148. * Gets the left operand input component
  69149. */
  69150. get left(): NodeMaterialConnectionPoint;
  69151. /**
  69152. * Gets the right operand input component
  69153. */
  69154. get right(): NodeMaterialConnectionPoint;
  69155. /**
  69156. * Gets the output component
  69157. */
  69158. get output(): NodeMaterialConnectionPoint;
  69159. protected _buildBlock(state: NodeMaterialBuildState): this;
  69160. }
  69161. }
  69162. declare module "babylonjs/Materials/Node/Blocks/index" {
  69163. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69164. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69165. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69166. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69167. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69168. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69169. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69170. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69171. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69172. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69173. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69174. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69175. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69176. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69177. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69178. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69179. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69180. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69181. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69182. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69183. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69184. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69185. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69186. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69187. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69188. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69189. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69190. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69191. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69192. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69193. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69194. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69195. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69196. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69197. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69198. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69199. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69200. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69201. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69202. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69203. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69204. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69205. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69206. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69207. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69208. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69209. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69210. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69211. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69212. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69213. }
  69214. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69215. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69216. }
  69217. declare module "babylonjs/Materials/Node/index" {
  69218. export * from "babylonjs/Materials/Node/Enums/index";
  69219. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69220. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69221. export * from "babylonjs/Materials/Node/nodeMaterial";
  69222. export * from "babylonjs/Materials/Node/Blocks/index";
  69223. export * from "babylonjs/Materials/Node/Optimizers/index";
  69224. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69225. }
  69226. declare module "babylonjs/Materials/index" {
  69227. export * from "babylonjs/Materials/Background/index";
  69228. export * from "babylonjs/Materials/colorCurves";
  69229. export * from "babylonjs/Materials/iEffectFallbacks";
  69230. export * from "babylonjs/Materials/effectFallbacks";
  69231. export * from "babylonjs/Materials/effect";
  69232. export * from "babylonjs/Materials/fresnelParameters";
  69233. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69234. export * from "babylonjs/Materials/material";
  69235. export * from "babylonjs/Materials/materialDefines";
  69236. export * from "babylonjs/Materials/thinMaterialHelper";
  69237. export * from "babylonjs/Materials/materialHelper";
  69238. export * from "babylonjs/Materials/multiMaterial";
  69239. export * from "babylonjs/Materials/PBR/index";
  69240. export * from "babylonjs/Materials/pushMaterial";
  69241. export * from "babylonjs/Materials/shaderMaterial";
  69242. export * from "babylonjs/Materials/standardMaterial";
  69243. export * from "babylonjs/Materials/Textures/index";
  69244. export * from "babylonjs/Materials/uniformBuffer";
  69245. export * from "babylonjs/Materials/materialFlags";
  69246. export * from "babylonjs/Materials/Node/index";
  69247. export * from "babylonjs/Materials/effectRenderer";
  69248. export * from "babylonjs/Materials/shadowDepthWrapper";
  69249. }
  69250. declare module "babylonjs/Maths/index" {
  69251. export * from "babylonjs/Maths/math.scalar";
  69252. export * from "babylonjs/Maths/math";
  69253. export * from "babylonjs/Maths/sphericalPolynomial";
  69254. }
  69255. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69256. import { IDisposable } from "babylonjs/scene";
  69257. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69258. /**
  69259. * Configuration for Draco compression
  69260. */
  69261. export interface IDracoCompressionConfiguration {
  69262. /**
  69263. * Configuration for the decoder.
  69264. */
  69265. decoder: {
  69266. /**
  69267. * The url to the WebAssembly module.
  69268. */
  69269. wasmUrl?: string;
  69270. /**
  69271. * The url to the WebAssembly binary.
  69272. */
  69273. wasmBinaryUrl?: string;
  69274. /**
  69275. * The url to the fallback JavaScript module.
  69276. */
  69277. fallbackUrl?: string;
  69278. };
  69279. }
  69280. /**
  69281. * Draco compression (https://google.github.io/draco/)
  69282. *
  69283. * This class wraps the Draco module.
  69284. *
  69285. * **Encoder**
  69286. *
  69287. * The encoder is not currently implemented.
  69288. *
  69289. * **Decoder**
  69290. *
  69291. * 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.
  69292. *
  69293. * To update the configuration, use the following code:
  69294. * ```javascript
  69295. * DracoCompression.Configuration = {
  69296. * decoder: {
  69297. * wasmUrl: "<url to the WebAssembly library>",
  69298. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69299. * fallbackUrl: "<url to the fallback JavaScript library>",
  69300. * }
  69301. * };
  69302. * ```
  69303. *
  69304. * 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.
  69305. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69306. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69307. *
  69308. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69309. * ```javascript
  69310. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69311. * ```
  69312. *
  69313. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69314. */
  69315. export class DracoCompression implements IDisposable {
  69316. private _workerPoolPromise?;
  69317. private _decoderModulePromise?;
  69318. /**
  69319. * The configuration. Defaults to the following urls:
  69320. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69321. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69322. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69323. */
  69324. static Configuration: IDracoCompressionConfiguration;
  69325. /**
  69326. * Returns true if the decoder configuration is available.
  69327. */
  69328. static get DecoderAvailable(): boolean;
  69329. /**
  69330. * Default number of workers to create when creating the draco compression object.
  69331. */
  69332. static DefaultNumWorkers: number;
  69333. private static GetDefaultNumWorkers;
  69334. private static _Default;
  69335. /**
  69336. * Default instance for the draco compression object.
  69337. */
  69338. static get Default(): DracoCompression;
  69339. /**
  69340. * Constructor
  69341. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69342. */
  69343. constructor(numWorkers?: number);
  69344. /**
  69345. * Stop all async operations and release resources.
  69346. */
  69347. dispose(): void;
  69348. /**
  69349. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69350. * @returns a promise that resolves when ready
  69351. */
  69352. whenReadyAsync(): Promise<void>;
  69353. /**
  69354. * Decode Draco compressed mesh data to vertex data.
  69355. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69356. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69357. * @returns A promise that resolves with the decoded vertex data
  69358. */
  69359. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69360. [kind: string]: number;
  69361. }): Promise<VertexData>;
  69362. }
  69363. }
  69364. declare module "babylonjs/Meshes/Compression/index" {
  69365. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69366. }
  69367. declare module "babylonjs/Meshes/csg" {
  69368. import { Nullable } from "babylonjs/types";
  69369. import { Scene } from "babylonjs/scene";
  69370. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69371. import { Mesh } from "babylonjs/Meshes/mesh";
  69372. import { Material } from "babylonjs/Materials/material";
  69373. /**
  69374. * Class for building Constructive Solid Geometry
  69375. */
  69376. export class CSG {
  69377. private polygons;
  69378. /**
  69379. * The world matrix
  69380. */
  69381. matrix: Matrix;
  69382. /**
  69383. * Stores the position
  69384. */
  69385. position: Vector3;
  69386. /**
  69387. * Stores the rotation
  69388. */
  69389. rotation: Vector3;
  69390. /**
  69391. * Stores the rotation quaternion
  69392. */
  69393. rotationQuaternion: Nullable<Quaternion>;
  69394. /**
  69395. * Stores the scaling vector
  69396. */
  69397. scaling: Vector3;
  69398. /**
  69399. * Convert the Mesh to CSG
  69400. * @param mesh The Mesh to convert to CSG
  69401. * @returns A new CSG from the Mesh
  69402. */
  69403. static FromMesh(mesh: Mesh): CSG;
  69404. /**
  69405. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69406. * @param polygons Polygons used to construct a CSG solid
  69407. */
  69408. private static FromPolygons;
  69409. /**
  69410. * Clones, or makes a deep copy, of the CSG
  69411. * @returns A new CSG
  69412. */
  69413. clone(): CSG;
  69414. /**
  69415. * Unions this CSG with another CSG
  69416. * @param csg The CSG to union against this CSG
  69417. * @returns The unioned CSG
  69418. */
  69419. union(csg: CSG): CSG;
  69420. /**
  69421. * Unions this CSG with another CSG in place
  69422. * @param csg The CSG to union against this CSG
  69423. */
  69424. unionInPlace(csg: CSG): void;
  69425. /**
  69426. * Subtracts this CSG with another CSG
  69427. * @param csg The CSG to subtract against this CSG
  69428. * @returns A new CSG
  69429. */
  69430. subtract(csg: CSG): CSG;
  69431. /**
  69432. * Subtracts this CSG with another CSG in place
  69433. * @param csg The CSG to subtact against this CSG
  69434. */
  69435. subtractInPlace(csg: CSG): void;
  69436. /**
  69437. * Intersect this CSG with another CSG
  69438. * @param csg The CSG to intersect against this CSG
  69439. * @returns A new CSG
  69440. */
  69441. intersect(csg: CSG): CSG;
  69442. /**
  69443. * Intersects this CSG with another CSG in place
  69444. * @param csg The CSG to intersect against this CSG
  69445. */
  69446. intersectInPlace(csg: CSG): void;
  69447. /**
  69448. * Return a new CSG solid with solid and empty space switched. This solid is
  69449. * not modified.
  69450. * @returns A new CSG solid with solid and empty space switched
  69451. */
  69452. inverse(): CSG;
  69453. /**
  69454. * Inverses the CSG in place
  69455. */
  69456. inverseInPlace(): void;
  69457. /**
  69458. * This is used to keep meshes transformations so they can be restored
  69459. * when we build back a Babylon Mesh
  69460. * NB : All CSG operations are performed in world coordinates
  69461. * @param csg The CSG to copy the transform attributes from
  69462. * @returns This CSG
  69463. */
  69464. copyTransformAttributes(csg: CSG): CSG;
  69465. /**
  69466. * Build Raw mesh from CSG
  69467. * Coordinates here are in world space
  69468. * @param name The name of the mesh geometry
  69469. * @param scene The Scene
  69470. * @param keepSubMeshes Specifies if the submeshes should be kept
  69471. * @returns A new Mesh
  69472. */
  69473. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69474. /**
  69475. * Build Mesh from CSG taking material and transforms into account
  69476. * @param name The name of the Mesh
  69477. * @param material The material of the Mesh
  69478. * @param scene The Scene
  69479. * @param keepSubMeshes Specifies if submeshes should be kept
  69480. * @returns The new Mesh
  69481. */
  69482. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69483. }
  69484. }
  69485. declare module "babylonjs/Meshes/trailMesh" {
  69486. import { Mesh } from "babylonjs/Meshes/mesh";
  69487. import { Scene } from "babylonjs/scene";
  69488. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69489. /**
  69490. * Class used to create a trail following a mesh
  69491. */
  69492. export class TrailMesh extends Mesh {
  69493. private _generator;
  69494. private _autoStart;
  69495. private _running;
  69496. private _diameter;
  69497. private _length;
  69498. private _sectionPolygonPointsCount;
  69499. private _sectionVectors;
  69500. private _sectionNormalVectors;
  69501. private _beforeRenderObserver;
  69502. /**
  69503. * @constructor
  69504. * @param name The value used by scene.getMeshByName() to do a lookup.
  69505. * @param generator The mesh or transform node to generate a trail.
  69506. * @param scene The scene to add this mesh to.
  69507. * @param diameter Diameter of trailing mesh. Default is 1.
  69508. * @param length Length of trailing mesh. Default is 60.
  69509. * @param autoStart Automatically start trailing mesh. Default true.
  69510. */
  69511. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69512. /**
  69513. * "TrailMesh"
  69514. * @returns "TrailMesh"
  69515. */
  69516. getClassName(): string;
  69517. private _createMesh;
  69518. /**
  69519. * Start trailing mesh.
  69520. */
  69521. start(): void;
  69522. /**
  69523. * Stop trailing mesh.
  69524. */
  69525. stop(): void;
  69526. /**
  69527. * Update trailing mesh geometry.
  69528. */
  69529. update(): void;
  69530. /**
  69531. * Returns a new TrailMesh object.
  69532. * @param name is a string, the name given to the new mesh
  69533. * @param newGenerator use new generator object for cloned trail mesh
  69534. * @returns a new mesh
  69535. */
  69536. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69537. /**
  69538. * Serializes this trail mesh
  69539. * @param serializationObject object to write serialization to
  69540. */
  69541. serialize(serializationObject: any): void;
  69542. /**
  69543. * Parses a serialized trail mesh
  69544. * @param parsedMesh the serialized mesh
  69545. * @param scene the scene to create the trail mesh in
  69546. * @returns the created trail mesh
  69547. */
  69548. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69549. }
  69550. }
  69551. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69552. import { Nullable } from "babylonjs/types";
  69553. import { Scene } from "babylonjs/scene";
  69554. import { Vector4 } from "babylonjs/Maths/math.vector";
  69555. import { Color4 } from "babylonjs/Maths/math.color";
  69556. import { Mesh } from "babylonjs/Meshes/mesh";
  69557. /**
  69558. * Class containing static functions to help procedurally build meshes
  69559. */
  69560. export class TiledBoxBuilder {
  69561. /**
  69562. * Creates a box mesh
  69563. * 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)
  69564. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69568. * @param name defines the name of the mesh
  69569. * @param options defines the options used to create the mesh
  69570. * @param scene defines the hosting scene
  69571. * @returns the box mesh
  69572. */
  69573. static CreateTiledBox(name: string, options: {
  69574. pattern?: number;
  69575. width?: number;
  69576. height?: number;
  69577. depth?: number;
  69578. tileSize?: number;
  69579. tileWidth?: number;
  69580. tileHeight?: number;
  69581. alignHorizontal?: number;
  69582. alignVertical?: number;
  69583. faceUV?: Vector4[];
  69584. faceColors?: Color4[];
  69585. sideOrientation?: number;
  69586. updatable?: boolean;
  69587. }, scene?: Nullable<Scene>): Mesh;
  69588. }
  69589. }
  69590. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69591. import { Vector4 } from "babylonjs/Maths/math.vector";
  69592. import { Mesh } from "babylonjs/Meshes/mesh";
  69593. /**
  69594. * Class containing static functions to help procedurally build meshes
  69595. */
  69596. export class TorusKnotBuilder {
  69597. /**
  69598. * Creates a torus knot mesh
  69599. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69600. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69601. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69602. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69606. * @param name defines the name of the mesh
  69607. * @param options defines the options used to create the mesh
  69608. * @param scene defines the hosting scene
  69609. * @returns the torus knot mesh
  69610. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69611. */
  69612. static CreateTorusKnot(name: string, options: {
  69613. radius?: number;
  69614. tube?: number;
  69615. radialSegments?: number;
  69616. tubularSegments?: number;
  69617. p?: number;
  69618. q?: number;
  69619. updatable?: boolean;
  69620. sideOrientation?: number;
  69621. frontUVs?: Vector4;
  69622. backUVs?: Vector4;
  69623. }, scene: any): Mesh;
  69624. }
  69625. }
  69626. declare module "babylonjs/Meshes/polygonMesh" {
  69627. import { Scene } from "babylonjs/scene";
  69628. import { Vector2 } from "babylonjs/Maths/math.vector";
  69629. import { Mesh } from "babylonjs/Meshes/mesh";
  69630. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69631. import { Path2 } from "babylonjs/Maths/math.path";
  69632. /**
  69633. * Polygon
  69634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69635. */
  69636. export class Polygon {
  69637. /**
  69638. * Creates a rectangle
  69639. * @param xmin bottom X coord
  69640. * @param ymin bottom Y coord
  69641. * @param xmax top X coord
  69642. * @param ymax top Y coord
  69643. * @returns points that make the resulting rectation
  69644. */
  69645. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69646. /**
  69647. * Creates a circle
  69648. * @param radius radius of circle
  69649. * @param cx scale in x
  69650. * @param cy scale in y
  69651. * @param numberOfSides number of sides that make up the circle
  69652. * @returns points that make the resulting circle
  69653. */
  69654. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69655. /**
  69656. * Creates a polygon from input string
  69657. * @param input Input polygon data
  69658. * @returns the parsed points
  69659. */
  69660. static Parse(input: string): Vector2[];
  69661. /**
  69662. * Starts building a polygon from x and y coordinates
  69663. * @param x x coordinate
  69664. * @param y y coordinate
  69665. * @returns the started path2
  69666. */
  69667. static StartingAt(x: number, y: number): Path2;
  69668. }
  69669. /**
  69670. * Builds a polygon
  69671. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69672. */
  69673. export class PolygonMeshBuilder {
  69674. private _points;
  69675. private _outlinepoints;
  69676. private _holes;
  69677. private _name;
  69678. private _scene;
  69679. private _epoints;
  69680. private _eholes;
  69681. private _addToepoint;
  69682. /**
  69683. * Babylon reference to the earcut plugin.
  69684. */
  69685. bjsEarcut: any;
  69686. /**
  69687. * Creates a PolygonMeshBuilder
  69688. * @param name name of the builder
  69689. * @param contours Path of the polygon
  69690. * @param scene scene to add to when creating the mesh
  69691. * @param earcutInjection can be used to inject your own earcut reference
  69692. */
  69693. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69694. /**
  69695. * Adds a whole within the polygon
  69696. * @param hole Array of points defining the hole
  69697. * @returns this
  69698. */
  69699. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69700. /**
  69701. * Creates the polygon
  69702. * @param updatable If the mesh should be updatable
  69703. * @param depth The depth of the mesh created
  69704. * @returns the created mesh
  69705. */
  69706. build(updatable?: boolean, depth?: number): Mesh;
  69707. /**
  69708. * Creates the polygon
  69709. * @param depth The depth of the mesh created
  69710. * @returns the created VertexData
  69711. */
  69712. buildVertexData(depth?: number): VertexData;
  69713. /**
  69714. * Adds a side to the polygon
  69715. * @param positions points that make the polygon
  69716. * @param normals normals of the polygon
  69717. * @param uvs uvs of the polygon
  69718. * @param indices indices of the polygon
  69719. * @param bounds bounds of the polygon
  69720. * @param points points of the polygon
  69721. * @param depth depth of the polygon
  69722. * @param flip flip of the polygon
  69723. */
  69724. private addSide;
  69725. }
  69726. }
  69727. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69728. import { Scene } from "babylonjs/scene";
  69729. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69730. import { Color4 } from "babylonjs/Maths/math.color";
  69731. import { Mesh } from "babylonjs/Meshes/mesh";
  69732. import { Nullable } from "babylonjs/types";
  69733. /**
  69734. * Class containing static functions to help procedurally build meshes
  69735. */
  69736. export class PolygonBuilder {
  69737. /**
  69738. * Creates a polygon mesh
  69739. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69740. * * 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
  69741. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69744. * * Remember you can only change the shape positions, not their number when updating a polygon
  69745. * @param name defines the name of the mesh
  69746. * @param options defines the options used to create the mesh
  69747. * @param scene defines the hosting scene
  69748. * @param earcutInjection can be used to inject your own earcut reference
  69749. * @returns the polygon mesh
  69750. */
  69751. static CreatePolygon(name: string, options: {
  69752. shape: Vector3[];
  69753. holes?: Vector3[][];
  69754. depth?: number;
  69755. faceUV?: Vector4[];
  69756. faceColors?: Color4[];
  69757. updatable?: boolean;
  69758. sideOrientation?: number;
  69759. frontUVs?: Vector4;
  69760. backUVs?: Vector4;
  69761. wrap?: boolean;
  69762. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69763. /**
  69764. * Creates an extruded polygon mesh, with depth in the Y direction.
  69765. * * 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)
  69766. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69767. * @param name defines the name of the mesh
  69768. * @param options defines the options used to create the mesh
  69769. * @param scene defines the hosting scene
  69770. * @param earcutInjection can be used to inject your own earcut reference
  69771. * @returns the polygon mesh
  69772. */
  69773. static ExtrudePolygon(name: string, options: {
  69774. shape: Vector3[];
  69775. holes?: Vector3[][];
  69776. depth?: number;
  69777. faceUV?: Vector4[];
  69778. faceColors?: Color4[];
  69779. updatable?: boolean;
  69780. sideOrientation?: number;
  69781. frontUVs?: Vector4;
  69782. backUVs?: Vector4;
  69783. wrap?: boolean;
  69784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69785. }
  69786. }
  69787. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69788. import { Scene } from "babylonjs/scene";
  69789. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69790. import { Mesh } from "babylonjs/Meshes/mesh";
  69791. import { Nullable } from "babylonjs/types";
  69792. /**
  69793. * Class containing static functions to help procedurally build meshes
  69794. */
  69795. export class LatheBuilder {
  69796. /**
  69797. * Creates lathe mesh.
  69798. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69799. * * 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
  69800. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69801. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69802. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69803. * * 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
  69804. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69805. * * 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
  69806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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. * @param name defines the name of the mesh
  69811. * @param options defines the options used to create the mesh
  69812. * @param scene defines the hosting scene
  69813. * @returns the lathe mesh
  69814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69815. */
  69816. static CreateLathe(name: string, options: {
  69817. shape: Vector3[];
  69818. radius?: number;
  69819. tessellation?: number;
  69820. clip?: number;
  69821. arc?: number;
  69822. closed?: boolean;
  69823. updatable?: boolean;
  69824. sideOrientation?: number;
  69825. frontUVs?: Vector4;
  69826. backUVs?: Vector4;
  69827. cap?: number;
  69828. invertUV?: boolean;
  69829. }, scene?: Nullable<Scene>): Mesh;
  69830. }
  69831. }
  69832. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69833. import { Nullable } from "babylonjs/types";
  69834. import { Scene } from "babylonjs/scene";
  69835. import { Vector4 } from "babylonjs/Maths/math.vector";
  69836. import { Mesh } from "babylonjs/Meshes/mesh";
  69837. /**
  69838. * Class containing static functions to help procedurally build meshes
  69839. */
  69840. export class TiledPlaneBuilder {
  69841. /**
  69842. * Creates a tiled plane mesh
  69843. * * The parameter `pattern` will, depending on value, do nothing or
  69844. * * * flip (reflect about central vertical) alternate tiles across and up
  69845. * * * flip every tile on alternate rows
  69846. * * * rotate (180 degs) alternate tiles across and up
  69847. * * * rotate every tile on alternate rows
  69848. * * * flip and rotate alternate tiles across and up
  69849. * * * flip and rotate every tile on alternate rows
  69850. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69851. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69854. * * 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)
  69855. * * 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)
  69856. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69857. * @param name defines the name of the mesh
  69858. * @param options defines the options used to create the mesh
  69859. * @param scene defines the hosting scene
  69860. * @returns the box mesh
  69861. */
  69862. static CreateTiledPlane(name: string, options: {
  69863. pattern?: number;
  69864. tileSize?: number;
  69865. tileWidth?: number;
  69866. tileHeight?: number;
  69867. size?: number;
  69868. width?: number;
  69869. height?: number;
  69870. alignHorizontal?: number;
  69871. alignVertical?: number;
  69872. sideOrientation?: number;
  69873. frontUVs?: Vector4;
  69874. backUVs?: Vector4;
  69875. updatable?: boolean;
  69876. }, scene?: Nullable<Scene>): Mesh;
  69877. }
  69878. }
  69879. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69880. import { Nullable } from "babylonjs/types";
  69881. import { Scene } from "babylonjs/scene";
  69882. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69883. import { Mesh } from "babylonjs/Meshes/mesh";
  69884. /**
  69885. * Class containing static functions to help procedurally build meshes
  69886. */
  69887. export class TubeBuilder {
  69888. /**
  69889. * Creates a tube mesh.
  69890. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69891. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69892. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69893. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69894. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69895. * * 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)
  69896. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69897. * * 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
  69898. * * 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
  69899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69903. * @param name defines the name of the mesh
  69904. * @param options defines the options used to create the mesh
  69905. * @param scene defines the hosting scene
  69906. * @returns the tube mesh
  69907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69908. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69909. */
  69910. static CreateTube(name: string, options: {
  69911. path: Vector3[];
  69912. radius?: number;
  69913. tessellation?: number;
  69914. radiusFunction?: {
  69915. (i: number, distance: number): number;
  69916. };
  69917. cap?: number;
  69918. arc?: number;
  69919. updatable?: boolean;
  69920. sideOrientation?: number;
  69921. frontUVs?: Vector4;
  69922. backUVs?: Vector4;
  69923. instance?: Mesh;
  69924. invertUV?: boolean;
  69925. }, scene?: Nullable<Scene>): Mesh;
  69926. }
  69927. }
  69928. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69929. import { Scene } from "babylonjs/scene";
  69930. import { Vector4 } from "babylonjs/Maths/math.vector";
  69931. import { Mesh } from "babylonjs/Meshes/mesh";
  69932. import { Nullable } from "babylonjs/types";
  69933. /**
  69934. * Class containing static functions to help procedurally build meshes
  69935. */
  69936. export class IcoSphereBuilder {
  69937. /**
  69938. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69939. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69940. * * 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`)
  69941. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69942. * * 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
  69943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69946. * @param name defines the name of the mesh
  69947. * @param options defines the options used to create the mesh
  69948. * @param scene defines the hosting scene
  69949. * @returns the icosahedron mesh
  69950. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69951. */
  69952. static CreateIcoSphere(name: string, options: {
  69953. radius?: number;
  69954. radiusX?: number;
  69955. radiusY?: number;
  69956. radiusZ?: number;
  69957. flat?: boolean;
  69958. subdivisions?: number;
  69959. sideOrientation?: number;
  69960. frontUVs?: Vector4;
  69961. backUVs?: Vector4;
  69962. updatable?: boolean;
  69963. }, scene?: Nullable<Scene>): Mesh;
  69964. }
  69965. }
  69966. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69967. import { Vector3 } from "babylonjs/Maths/math.vector";
  69968. import { Mesh } from "babylonjs/Meshes/mesh";
  69969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69970. /**
  69971. * Class containing static functions to help procedurally build meshes
  69972. */
  69973. export class DecalBuilder {
  69974. /**
  69975. * Creates a decal mesh.
  69976. * 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
  69977. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69978. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69979. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69980. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69981. * @param name defines the name of the mesh
  69982. * @param sourceMesh defines the mesh where the decal must be applied
  69983. * @param options defines the options used to create the mesh
  69984. * @param scene defines the hosting scene
  69985. * @returns the decal mesh
  69986. * @see https://doc.babylonjs.com/how_to/decals
  69987. */
  69988. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69989. position?: Vector3;
  69990. normal?: Vector3;
  69991. size?: Vector3;
  69992. angle?: number;
  69993. }): Mesh;
  69994. }
  69995. }
  69996. declare module "babylonjs/Meshes/meshBuilder" {
  69997. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69998. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69999. import { Nullable } from "babylonjs/types";
  70000. import { Scene } from "babylonjs/scene";
  70001. import { Mesh } from "babylonjs/Meshes/mesh";
  70002. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70003. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70005. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70006. import { Plane } from "babylonjs/Maths/math.plane";
  70007. /**
  70008. * Class containing static functions to help procedurally build meshes
  70009. */
  70010. export class MeshBuilder {
  70011. /**
  70012. * Creates a box mesh
  70013. * * The parameter `size` sets the size (float) of each box side (default 1)
  70014. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70015. * * 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)
  70016. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70020. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70021. * @param name defines the name of the mesh
  70022. * @param options defines the options used to create the mesh
  70023. * @param scene defines the hosting scene
  70024. * @returns the box mesh
  70025. */
  70026. static CreateBox(name: string, options: {
  70027. size?: number;
  70028. width?: number;
  70029. height?: number;
  70030. depth?: number;
  70031. faceUV?: Vector4[];
  70032. faceColors?: Color4[];
  70033. sideOrientation?: number;
  70034. frontUVs?: Vector4;
  70035. backUVs?: Vector4;
  70036. wrap?: boolean;
  70037. topBaseAt?: number;
  70038. bottomBaseAt?: number;
  70039. updatable?: boolean;
  70040. }, scene?: Nullable<Scene>): Mesh;
  70041. /**
  70042. * Creates a tiled box mesh
  70043. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70045. * @param name defines the name of the mesh
  70046. * @param options defines the options used to create the mesh
  70047. * @param scene defines the hosting scene
  70048. * @returns the tiled box mesh
  70049. */
  70050. static CreateTiledBox(name: string, options: {
  70051. pattern?: number;
  70052. size?: number;
  70053. width?: number;
  70054. height?: number;
  70055. depth: number;
  70056. tileSize?: number;
  70057. tileWidth?: number;
  70058. tileHeight?: number;
  70059. faceUV?: Vector4[];
  70060. faceColors?: Color4[];
  70061. alignHorizontal?: number;
  70062. alignVertical?: number;
  70063. sideOrientation?: number;
  70064. updatable?: boolean;
  70065. }, scene?: Nullable<Scene>): Mesh;
  70066. /**
  70067. * Creates a sphere mesh
  70068. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70069. * * 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`)
  70070. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70071. * * 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
  70072. * * 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)
  70073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70076. * @param name defines the name of the mesh
  70077. * @param options defines the options used to create the mesh
  70078. * @param scene defines the hosting scene
  70079. * @returns the sphere mesh
  70080. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70081. */
  70082. static CreateSphere(name: string, options: {
  70083. segments?: number;
  70084. diameter?: number;
  70085. diameterX?: number;
  70086. diameterY?: number;
  70087. diameterZ?: number;
  70088. arc?: number;
  70089. slice?: number;
  70090. sideOrientation?: number;
  70091. frontUVs?: Vector4;
  70092. backUVs?: Vector4;
  70093. updatable?: boolean;
  70094. }, scene?: Nullable<Scene>): Mesh;
  70095. /**
  70096. * Creates a plane polygonal mesh. By default, this is a disc
  70097. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70098. * * 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
  70099. * * 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
  70100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70103. * @param name defines the name of the mesh
  70104. * @param options defines the options used to create the mesh
  70105. * @param scene defines the hosting scene
  70106. * @returns the plane polygonal mesh
  70107. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70108. */
  70109. static CreateDisc(name: string, options: {
  70110. radius?: number;
  70111. tessellation?: number;
  70112. arc?: number;
  70113. updatable?: boolean;
  70114. sideOrientation?: number;
  70115. frontUVs?: Vector4;
  70116. backUVs?: Vector4;
  70117. }, scene?: Nullable<Scene>): Mesh;
  70118. /**
  70119. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70120. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70121. * * 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`)
  70122. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70123. * * 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
  70124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70127. * @param name defines the name of the mesh
  70128. * @param options defines the options used to create the mesh
  70129. * @param scene defines the hosting scene
  70130. * @returns the icosahedron mesh
  70131. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70132. */
  70133. static CreateIcoSphere(name: string, options: {
  70134. radius?: number;
  70135. radiusX?: number;
  70136. radiusY?: number;
  70137. radiusZ?: number;
  70138. flat?: boolean;
  70139. subdivisions?: number;
  70140. sideOrientation?: number;
  70141. frontUVs?: Vector4;
  70142. backUVs?: Vector4;
  70143. updatable?: boolean;
  70144. }, scene?: Nullable<Scene>): Mesh;
  70145. /**
  70146. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70147. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70148. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70149. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70150. * * 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
  70151. * * 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
  70152. * * 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
  70153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70156. * * 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
  70157. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70158. * * 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
  70159. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70161. * @param name defines the name of the mesh
  70162. * @param options defines the options used to create the mesh
  70163. * @param scene defines the hosting scene
  70164. * @returns the ribbon mesh
  70165. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70166. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70167. */
  70168. static CreateRibbon(name: string, options: {
  70169. pathArray: Vector3[][];
  70170. closeArray?: boolean;
  70171. closePath?: boolean;
  70172. offset?: number;
  70173. updatable?: boolean;
  70174. sideOrientation?: number;
  70175. frontUVs?: Vector4;
  70176. backUVs?: Vector4;
  70177. instance?: Mesh;
  70178. invertUV?: boolean;
  70179. uvs?: Vector2[];
  70180. colors?: Color4[];
  70181. }, scene?: Nullable<Scene>): Mesh;
  70182. /**
  70183. * Creates a cylinder or a cone mesh
  70184. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70185. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70186. * * 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.
  70187. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70188. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70189. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70190. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70191. * * 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).
  70192. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70193. * * 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).
  70194. * * 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
  70195. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70196. * * 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
  70197. * * 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.
  70198. * * If `enclose` is false, a ring surface is one element.
  70199. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70200. * * 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
  70201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70204. * @param name defines the name of the mesh
  70205. * @param options defines the options used to create the mesh
  70206. * @param scene defines the hosting scene
  70207. * @returns the cylinder mesh
  70208. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70209. */
  70210. static CreateCylinder(name: string, options: {
  70211. height?: number;
  70212. diameterTop?: number;
  70213. diameterBottom?: number;
  70214. diameter?: number;
  70215. tessellation?: number;
  70216. subdivisions?: number;
  70217. arc?: number;
  70218. faceColors?: Color4[];
  70219. faceUV?: Vector4[];
  70220. updatable?: boolean;
  70221. hasRings?: boolean;
  70222. enclose?: boolean;
  70223. cap?: number;
  70224. sideOrientation?: number;
  70225. frontUVs?: Vector4;
  70226. backUVs?: Vector4;
  70227. }, scene?: Nullable<Scene>): Mesh;
  70228. /**
  70229. * Creates a torus mesh
  70230. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70231. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70232. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70236. * @param name defines the name of the mesh
  70237. * @param options defines the options used to create the mesh
  70238. * @param scene defines the hosting scene
  70239. * @returns the torus mesh
  70240. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70241. */
  70242. static CreateTorus(name: string, options: {
  70243. diameter?: number;
  70244. thickness?: number;
  70245. tessellation?: number;
  70246. updatable?: boolean;
  70247. sideOrientation?: number;
  70248. frontUVs?: Vector4;
  70249. backUVs?: Vector4;
  70250. }, scene?: Nullable<Scene>): Mesh;
  70251. /**
  70252. * Creates a torus knot mesh
  70253. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70254. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70255. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70256. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70260. * @param name defines the name of the mesh
  70261. * @param options defines the options used to create the mesh
  70262. * @param scene defines the hosting scene
  70263. * @returns the torus knot mesh
  70264. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70265. */
  70266. static CreateTorusKnot(name: string, options: {
  70267. radius?: number;
  70268. tube?: number;
  70269. radialSegments?: number;
  70270. tubularSegments?: number;
  70271. p?: number;
  70272. q?: number;
  70273. updatable?: boolean;
  70274. sideOrientation?: number;
  70275. frontUVs?: Vector4;
  70276. backUVs?: Vector4;
  70277. }, scene?: Nullable<Scene>): Mesh;
  70278. /**
  70279. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70280. * * 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
  70281. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70282. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70283. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70284. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70285. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70286. * * 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
  70287. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70290. * @param name defines the name of the new line system
  70291. * @param options defines the options used to create the line system
  70292. * @param scene defines the hosting scene
  70293. * @returns a new line system mesh
  70294. */
  70295. static CreateLineSystem(name: string, options: {
  70296. lines: Vector3[][];
  70297. updatable?: boolean;
  70298. instance?: Nullable<LinesMesh>;
  70299. colors?: Nullable<Color4[][]>;
  70300. useVertexAlpha?: boolean;
  70301. }, scene: Nullable<Scene>): LinesMesh;
  70302. /**
  70303. * Creates a line mesh
  70304. * 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
  70305. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70306. * * The parameter `points` is an array successive Vector3
  70307. * * 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
  70308. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70310. * * When updating an instance, remember that only point positions can change, not the number of points
  70311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70313. * @param name defines the name of the new line system
  70314. * @param options defines the options used to create the line system
  70315. * @param scene defines the hosting scene
  70316. * @returns a new line mesh
  70317. */
  70318. static CreateLines(name: string, options: {
  70319. points: Vector3[];
  70320. updatable?: boolean;
  70321. instance?: Nullable<LinesMesh>;
  70322. colors?: Color4[];
  70323. useVertexAlpha?: boolean;
  70324. }, scene?: Nullable<Scene>): LinesMesh;
  70325. /**
  70326. * Creates a dashed line mesh
  70327. * * 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
  70328. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70329. * * The parameter `points` is an array successive Vector3
  70330. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70331. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70332. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70333. * * 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
  70334. * * When updating an instance, remember that only point positions can change, not the number of points
  70335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70336. * @param name defines the name of the mesh
  70337. * @param options defines the options used to create the mesh
  70338. * @param scene defines the hosting scene
  70339. * @returns the dashed line mesh
  70340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70341. */
  70342. static CreateDashedLines(name: string, options: {
  70343. points: Vector3[];
  70344. dashSize?: number;
  70345. gapSize?: number;
  70346. dashNb?: number;
  70347. updatable?: boolean;
  70348. instance?: LinesMesh;
  70349. }, scene?: Nullable<Scene>): LinesMesh;
  70350. /**
  70351. * 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.
  70352. * * 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.
  70353. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70354. * * 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.
  70355. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70356. * * 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
  70357. * * 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
  70358. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70363. * @param name defines the name of the mesh
  70364. * @param options defines the options used to create the mesh
  70365. * @param scene defines the hosting scene
  70366. * @returns the extruded shape mesh
  70367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70369. */
  70370. static ExtrudeShape(name: string, options: {
  70371. shape: Vector3[];
  70372. path: Vector3[];
  70373. scale?: number;
  70374. rotation?: number;
  70375. cap?: number;
  70376. updatable?: boolean;
  70377. sideOrientation?: number;
  70378. frontUVs?: Vector4;
  70379. backUVs?: Vector4;
  70380. instance?: Mesh;
  70381. invertUV?: boolean;
  70382. }, scene?: Nullable<Scene>): Mesh;
  70383. /**
  70384. * Creates an custom extruded shape mesh.
  70385. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70386. * * 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.
  70387. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70388. * * 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
  70389. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70390. * * 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
  70391. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70392. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70393. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70394. * * 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
  70395. * * 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
  70396. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70401. * @param name defines the name of the mesh
  70402. * @param options defines the options used to create the mesh
  70403. * @param scene defines the hosting scene
  70404. * @returns the custom extruded shape mesh
  70405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70408. */
  70409. static ExtrudeShapeCustom(name: string, options: {
  70410. shape: Vector3[];
  70411. path: Vector3[];
  70412. scaleFunction?: any;
  70413. rotationFunction?: any;
  70414. ribbonCloseArray?: boolean;
  70415. ribbonClosePath?: boolean;
  70416. cap?: number;
  70417. updatable?: boolean;
  70418. sideOrientation?: number;
  70419. frontUVs?: Vector4;
  70420. backUVs?: Vector4;
  70421. instance?: Mesh;
  70422. invertUV?: boolean;
  70423. }, scene?: Nullable<Scene>): Mesh;
  70424. /**
  70425. * Creates lathe mesh.
  70426. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70427. * * 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
  70428. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70429. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70430. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70431. * * 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
  70432. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70433. * * 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
  70434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70438. * @param name defines the name of the mesh
  70439. * @param options defines the options used to create the mesh
  70440. * @param scene defines the hosting scene
  70441. * @returns the lathe mesh
  70442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70443. */
  70444. static CreateLathe(name: string, options: {
  70445. shape: Vector3[];
  70446. radius?: number;
  70447. tessellation?: number;
  70448. clip?: number;
  70449. arc?: number;
  70450. closed?: boolean;
  70451. updatable?: boolean;
  70452. sideOrientation?: number;
  70453. frontUVs?: Vector4;
  70454. backUVs?: Vector4;
  70455. cap?: number;
  70456. invertUV?: boolean;
  70457. }, scene?: Nullable<Scene>): Mesh;
  70458. /**
  70459. * Creates a tiled plane mesh
  70460. * * You can set a limited pattern arrangement with the tiles
  70461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70464. * @param name defines the name of the mesh
  70465. * @param options defines the options used to create the mesh
  70466. * @param scene defines the hosting scene
  70467. * @returns the plane mesh
  70468. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70469. */
  70470. static CreateTiledPlane(name: string, options: {
  70471. pattern?: number;
  70472. tileSize?: number;
  70473. tileWidth?: number;
  70474. tileHeight?: number;
  70475. size?: number;
  70476. width?: number;
  70477. height?: number;
  70478. alignHorizontal?: number;
  70479. alignVertical?: number;
  70480. sideOrientation?: number;
  70481. frontUVs?: Vector4;
  70482. backUVs?: Vector4;
  70483. updatable?: boolean;
  70484. }, scene?: Nullable<Scene>): Mesh;
  70485. /**
  70486. * Creates a plane mesh
  70487. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70488. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70489. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70493. * @param name defines the name of the mesh
  70494. * @param options defines the options used to create the mesh
  70495. * @param scene defines the hosting scene
  70496. * @returns the plane mesh
  70497. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70498. */
  70499. static CreatePlane(name: string, options: {
  70500. size?: number;
  70501. width?: number;
  70502. height?: number;
  70503. sideOrientation?: number;
  70504. frontUVs?: Vector4;
  70505. backUVs?: Vector4;
  70506. updatable?: boolean;
  70507. sourcePlane?: Plane;
  70508. }, scene?: Nullable<Scene>): Mesh;
  70509. /**
  70510. * Creates a ground mesh
  70511. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70512. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70514. * @param name defines the name of the mesh
  70515. * @param options defines the options used to create the mesh
  70516. * @param scene defines the hosting scene
  70517. * @returns the ground mesh
  70518. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70519. */
  70520. static CreateGround(name: string, options: {
  70521. width?: number;
  70522. height?: number;
  70523. subdivisions?: number;
  70524. subdivisionsX?: number;
  70525. subdivisionsY?: number;
  70526. updatable?: boolean;
  70527. }, scene?: Nullable<Scene>): Mesh;
  70528. /**
  70529. * Creates a tiled ground mesh
  70530. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70531. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70532. * * 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
  70533. * * 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
  70534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70535. * @param name defines the name of the mesh
  70536. * @param options defines the options used to create the mesh
  70537. * @param scene defines the hosting scene
  70538. * @returns the tiled ground mesh
  70539. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70540. */
  70541. static CreateTiledGround(name: string, options: {
  70542. xmin: number;
  70543. zmin: number;
  70544. xmax: number;
  70545. zmax: number;
  70546. subdivisions?: {
  70547. w: number;
  70548. h: number;
  70549. };
  70550. precision?: {
  70551. w: number;
  70552. h: number;
  70553. };
  70554. updatable?: boolean;
  70555. }, scene?: Nullable<Scene>): Mesh;
  70556. /**
  70557. * Creates a ground mesh from a height map
  70558. * * The parameter `url` sets the URL of the height map image resource.
  70559. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70560. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70561. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70562. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70563. * * 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.
  70564. * * 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).
  70565. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70567. * @param name defines the name of the mesh
  70568. * @param url defines the url to the height map
  70569. * @param options defines the options used to create the mesh
  70570. * @param scene defines the hosting scene
  70571. * @returns the ground mesh
  70572. * @see https://doc.babylonjs.com/babylon101/height_map
  70573. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70574. */
  70575. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70576. width?: number;
  70577. height?: number;
  70578. subdivisions?: number;
  70579. minHeight?: number;
  70580. maxHeight?: number;
  70581. colorFilter?: Color3;
  70582. alphaFilter?: number;
  70583. updatable?: boolean;
  70584. onReady?: (mesh: GroundMesh) => void;
  70585. }, scene?: Nullable<Scene>): GroundMesh;
  70586. /**
  70587. * Creates a polygon mesh
  70588. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70589. * * 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
  70590. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70593. * * Remember you can only change the shape positions, not their number when updating a polygon
  70594. * @param name defines the name of the mesh
  70595. * @param options defines the options used to create the mesh
  70596. * @param scene defines the hosting scene
  70597. * @param earcutInjection can be used to inject your own earcut reference
  70598. * @returns the polygon mesh
  70599. */
  70600. static CreatePolygon(name: string, options: {
  70601. shape: Vector3[];
  70602. holes?: Vector3[][];
  70603. depth?: number;
  70604. faceUV?: Vector4[];
  70605. faceColors?: Color4[];
  70606. updatable?: boolean;
  70607. sideOrientation?: number;
  70608. frontUVs?: Vector4;
  70609. backUVs?: Vector4;
  70610. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70611. /**
  70612. * Creates an extruded polygon mesh, with depth in the Y direction.
  70613. * * 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)
  70614. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70615. * @param name defines the name of the mesh
  70616. * @param options defines the options used to create the mesh
  70617. * @param scene defines the hosting scene
  70618. * @param earcutInjection can be used to inject your own earcut reference
  70619. * @returns the polygon mesh
  70620. */
  70621. static ExtrudePolygon(name: string, options: {
  70622. shape: Vector3[];
  70623. holes?: Vector3[][];
  70624. depth?: number;
  70625. faceUV?: Vector4[];
  70626. faceColors?: Color4[];
  70627. updatable?: boolean;
  70628. sideOrientation?: number;
  70629. frontUVs?: Vector4;
  70630. backUVs?: Vector4;
  70631. wrap?: boolean;
  70632. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70633. /**
  70634. * Creates a tube mesh.
  70635. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70636. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70637. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70638. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70639. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70640. * * 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)
  70641. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70642. * * 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
  70643. * * 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
  70644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70648. * @param name defines the name of the mesh
  70649. * @param options defines the options used to create the mesh
  70650. * @param scene defines the hosting scene
  70651. * @returns the tube mesh
  70652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70653. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70654. */
  70655. static CreateTube(name: string, options: {
  70656. path: Vector3[];
  70657. radius?: number;
  70658. tessellation?: number;
  70659. radiusFunction?: {
  70660. (i: number, distance: number): number;
  70661. };
  70662. cap?: number;
  70663. arc?: number;
  70664. updatable?: boolean;
  70665. sideOrientation?: number;
  70666. frontUVs?: Vector4;
  70667. backUVs?: Vector4;
  70668. instance?: Mesh;
  70669. invertUV?: boolean;
  70670. }, scene?: Nullable<Scene>): Mesh;
  70671. /**
  70672. * Creates a polyhedron mesh
  70673. * * 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
  70674. * * The parameter `size` (positive float, default 1) sets the polygon size
  70675. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70676. * * 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`
  70677. * * 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
  70678. * * 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)`)
  70679. * * 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
  70680. * * 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
  70681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70684. * @param name defines the name of the mesh
  70685. * @param options defines the options used to create the mesh
  70686. * @param scene defines the hosting scene
  70687. * @returns the polyhedron mesh
  70688. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70689. */
  70690. static CreatePolyhedron(name: string, options: {
  70691. type?: number;
  70692. size?: number;
  70693. sizeX?: number;
  70694. sizeY?: number;
  70695. sizeZ?: number;
  70696. custom?: any;
  70697. faceUV?: Vector4[];
  70698. faceColors?: Color4[];
  70699. flat?: boolean;
  70700. updatable?: boolean;
  70701. sideOrientation?: number;
  70702. frontUVs?: Vector4;
  70703. backUVs?: Vector4;
  70704. }, scene?: Nullable<Scene>): Mesh;
  70705. /**
  70706. * Creates a decal mesh.
  70707. * 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
  70708. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70709. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70710. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70711. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70712. * @param name defines the name of the mesh
  70713. * @param sourceMesh defines the mesh where the decal must be applied
  70714. * @param options defines the options used to create the mesh
  70715. * @param scene defines the hosting scene
  70716. * @returns the decal mesh
  70717. * @see https://doc.babylonjs.com/how_to/decals
  70718. */
  70719. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70720. position?: Vector3;
  70721. normal?: Vector3;
  70722. size?: Vector3;
  70723. angle?: number;
  70724. }): Mesh;
  70725. /**
  70726. * Creates a Capsule Mesh
  70727. * @param name defines the name of the mesh.
  70728. * @param options the constructors options used to shape the mesh.
  70729. * @param scene defines the scene the mesh is scoped to.
  70730. * @returns the capsule mesh
  70731. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70732. */
  70733. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70734. }
  70735. }
  70736. declare module "babylonjs/Meshes/meshSimplification" {
  70737. import { Mesh } from "babylonjs/Meshes/mesh";
  70738. /**
  70739. * A simplifier interface for future simplification implementations
  70740. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70741. */
  70742. export interface ISimplifier {
  70743. /**
  70744. * Simplification of a given mesh according to the given settings.
  70745. * Since this requires computation, it is assumed that the function runs async.
  70746. * @param settings The settings of the simplification, including quality and distance
  70747. * @param successCallback A callback that will be called after the mesh was simplified.
  70748. * @param errorCallback in case of an error, this callback will be called. optional.
  70749. */
  70750. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70751. }
  70752. /**
  70753. * Expected simplification settings.
  70754. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70755. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70756. */
  70757. export interface ISimplificationSettings {
  70758. /**
  70759. * Gets or sets the expected quality
  70760. */
  70761. quality: number;
  70762. /**
  70763. * Gets or sets the distance when this optimized version should be used
  70764. */
  70765. distance: number;
  70766. /**
  70767. * Gets an already optimized mesh
  70768. */
  70769. optimizeMesh?: boolean;
  70770. }
  70771. /**
  70772. * Class used to specify simplification options
  70773. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70774. */
  70775. export class SimplificationSettings implements ISimplificationSettings {
  70776. /** expected quality */
  70777. quality: number;
  70778. /** distance when this optimized version should be used */
  70779. distance: number;
  70780. /** already optimized mesh */
  70781. optimizeMesh?: boolean | undefined;
  70782. /**
  70783. * Creates a SimplificationSettings
  70784. * @param quality expected quality
  70785. * @param distance distance when this optimized version should be used
  70786. * @param optimizeMesh already optimized mesh
  70787. */
  70788. constructor(
  70789. /** expected quality */
  70790. quality: number,
  70791. /** distance when this optimized version should be used */
  70792. distance: number,
  70793. /** already optimized mesh */
  70794. optimizeMesh?: boolean | undefined);
  70795. }
  70796. /**
  70797. * Interface used to define a simplification task
  70798. */
  70799. export interface ISimplificationTask {
  70800. /**
  70801. * Array of settings
  70802. */
  70803. settings: Array<ISimplificationSettings>;
  70804. /**
  70805. * Simplification type
  70806. */
  70807. simplificationType: SimplificationType;
  70808. /**
  70809. * Mesh to simplify
  70810. */
  70811. mesh: Mesh;
  70812. /**
  70813. * Callback called on success
  70814. */
  70815. successCallback?: () => void;
  70816. /**
  70817. * Defines if parallel processing can be used
  70818. */
  70819. parallelProcessing: boolean;
  70820. }
  70821. /**
  70822. * Queue used to order the simplification tasks
  70823. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70824. */
  70825. export class SimplificationQueue {
  70826. private _simplificationArray;
  70827. /**
  70828. * Gets a boolean indicating that the process is still running
  70829. */
  70830. running: boolean;
  70831. /**
  70832. * Creates a new queue
  70833. */
  70834. constructor();
  70835. /**
  70836. * Adds a new simplification task
  70837. * @param task defines a task to add
  70838. */
  70839. addTask(task: ISimplificationTask): void;
  70840. /**
  70841. * Execute next task
  70842. */
  70843. executeNext(): void;
  70844. /**
  70845. * Execute a simplification task
  70846. * @param task defines the task to run
  70847. */
  70848. runSimplification(task: ISimplificationTask): void;
  70849. private getSimplifier;
  70850. }
  70851. /**
  70852. * The implemented types of simplification
  70853. * At the moment only Quadratic Error Decimation is implemented
  70854. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70855. */
  70856. export enum SimplificationType {
  70857. /** Quadratic error decimation */
  70858. QUADRATIC = 0
  70859. }
  70860. /**
  70861. * An implementation of the Quadratic Error simplification algorithm.
  70862. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70863. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70864. * @author RaananW
  70865. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70866. */
  70867. export class QuadraticErrorSimplification implements ISimplifier {
  70868. private _mesh;
  70869. private triangles;
  70870. private vertices;
  70871. private references;
  70872. private _reconstructedMesh;
  70873. /** Gets or sets the number pf sync interations */
  70874. syncIterations: number;
  70875. /** Gets or sets the aggressiveness of the simplifier */
  70876. aggressiveness: number;
  70877. /** Gets or sets the number of allowed iterations for decimation */
  70878. decimationIterations: number;
  70879. /** Gets or sets the espilon to use for bounding box computation */
  70880. boundingBoxEpsilon: number;
  70881. /**
  70882. * Creates a new QuadraticErrorSimplification
  70883. * @param _mesh defines the target mesh
  70884. */
  70885. constructor(_mesh: Mesh);
  70886. /**
  70887. * Simplification of a given mesh according to the given settings.
  70888. * Since this requires computation, it is assumed that the function runs async.
  70889. * @param settings The settings of the simplification, including quality and distance
  70890. * @param successCallback A callback that will be called after the mesh was simplified.
  70891. */
  70892. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70893. private runDecimation;
  70894. private initWithMesh;
  70895. private init;
  70896. private reconstructMesh;
  70897. private initDecimatedMesh;
  70898. private isFlipped;
  70899. private updateTriangles;
  70900. private identifyBorder;
  70901. private updateMesh;
  70902. private vertexError;
  70903. private calculateError;
  70904. }
  70905. }
  70906. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70907. import { Scene } from "babylonjs/scene";
  70908. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70909. import { ISceneComponent } from "babylonjs/sceneComponent";
  70910. module "babylonjs/scene" {
  70911. interface Scene {
  70912. /** @hidden (Backing field) */
  70913. _simplificationQueue: SimplificationQueue;
  70914. /**
  70915. * Gets or sets the simplification queue attached to the scene
  70916. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70917. */
  70918. simplificationQueue: SimplificationQueue;
  70919. }
  70920. }
  70921. module "babylonjs/Meshes/mesh" {
  70922. interface Mesh {
  70923. /**
  70924. * Simplify the mesh according to the given array of settings.
  70925. * Function will return immediately and will simplify async
  70926. * @param settings a collection of simplification settings
  70927. * @param parallelProcessing should all levels calculate parallel or one after the other
  70928. * @param simplificationType the type of simplification to run
  70929. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70930. * @returns the current mesh
  70931. */
  70932. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70933. }
  70934. }
  70935. /**
  70936. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70937. * created in a scene
  70938. */
  70939. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70940. /**
  70941. * The component name helpfull to identify the component in the list of scene components.
  70942. */
  70943. readonly name: string;
  70944. /**
  70945. * The scene the component belongs to.
  70946. */
  70947. scene: Scene;
  70948. /**
  70949. * Creates a new instance of the component for the given scene
  70950. * @param scene Defines the scene to register the component in
  70951. */
  70952. constructor(scene: Scene);
  70953. /**
  70954. * Registers the component in a given scene
  70955. */
  70956. register(): void;
  70957. /**
  70958. * Rebuilds the elements related to this component in case of
  70959. * context lost for instance.
  70960. */
  70961. rebuild(): void;
  70962. /**
  70963. * Disposes the component and the associated ressources
  70964. */
  70965. dispose(): void;
  70966. private _beforeCameraUpdate;
  70967. }
  70968. }
  70969. declare module "babylonjs/Meshes/Builders/index" {
  70970. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70971. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70972. export * from "babylonjs/Meshes/Builders/discBuilder";
  70973. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70974. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70975. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70976. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70977. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70978. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70979. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70980. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70981. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70982. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70983. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70984. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70985. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70986. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70987. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70988. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70989. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70990. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70991. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70992. }
  70993. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70994. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70995. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70996. import { Matrix } from "babylonjs/Maths/math.vector";
  70997. module "babylonjs/Meshes/mesh" {
  70998. interface Mesh {
  70999. /**
  71000. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71001. */
  71002. thinInstanceEnablePicking: boolean;
  71003. /**
  71004. * Creates a new thin instance
  71005. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71006. * @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
  71007. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71008. */
  71009. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71010. /**
  71011. * Adds the transformation (matrix) of the current mesh as a thin instance
  71012. * @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
  71013. * @returns the thin instance index number
  71014. */
  71015. thinInstanceAddSelf(refresh: boolean): number;
  71016. /**
  71017. * Registers a custom attribute to be used with thin instances
  71018. * @param kind name of the attribute
  71019. * @param stride size in floats of the attribute
  71020. */
  71021. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71022. /**
  71023. * Sets the matrix of a thin instance
  71024. * @param index index of the thin instance
  71025. * @param matrix matrix to set
  71026. * @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
  71027. */
  71028. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71029. /**
  71030. * Sets the value of a custom attribute for a thin instance
  71031. * @param kind name of the attribute
  71032. * @param index index of the thin instance
  71033. * @param value value to set
  71034. * @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
  71035. */
  71036. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71037. /**
  71038. * 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.
  71039. */
  71040. thinInstanceCount: number;
  71041. /**
  71042. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71043. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71044. * @param buffer buffer to set
  71045. * @param stride size in floats of each value of the buffer
  71046. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71047. */
  71048. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71049. /**
  71050. * Gets the list of world matrices
  71051. * @return an array containing all the world matrices from the thin instances
  71052. */
  71053. thinInstanceGetWorldMatrices(): Matrix[];
  71054. /**
  71055. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71056. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71057. */
  71058. thinInstanceBufferUpdated(kind: string): void;
  71059. /**
  71060. * Applies a partial update to a buffer directly on the GPU
  71061. * 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
  71062. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71063. * @param data the data to set in the GPU buffer
  71064. * @param offset the offset in the GPU buffer where to update the data
  71065. */
  71066. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71067. /**
  71068. * Refreshes the bounding info, taking into account all the thin instances defined
  71069. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71070. */
  71071. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71072. /** @hidden */
  71073. _thinInstanceInitializeUserStorage(): void;
  71074. /** @hidden */
  71075. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71076. /** @hidden */
  71077. _userThinInstanceBuffersStorage: {
  71078. data: {
  71079. [key: string]: Float32Array;
  71080. };
  71081. sizes: {
  71082. [key: string]: number;
  71083. };
  71084. vertexBuffers: {
  71085. [key: string]: Nullable<VertexBuffer>;
  71086. };
  71087. strides: {
  71088. [key: string]: number;
  71089. };
  71090. };
  71091. }
  71092. }
  71093. }
  71094. declare module "babylonjs/Meshes/index" {
  71095. export * from "babylonjs/Meshes/abstractMesh";
  71096. export * from "babylonjs/Meshes/buffer";
  71097. export * from "babylonjs/Meshes/Compression/index";
  71098. export * from "babylonjs/Meshes/csg";
  71099. export * from "babylonjs/Meshes/geometry";
  71100. export * from "babylonjs/Meshes/groundMesh";
  71101. export * from "babylonjs/Meshes/trailMesh";
  71102. export * from "babylonjs/Meshes/instancedMesh";
  71103. export * from "babylonjs/Meshes/linesMesh";
  71104. export * from "babylonjs/Meshes/mesh";
  71105. export * from "babylonjs/Meshes/mesh.vertexData";
  71106. export * from "babylonjs/Meshes/meshBuilder";
  71107. export * from "babylonjs/Meshes/meshSimplification";
  71108. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71109. export * from "babylonjs/Meshes/polygonMesh";
  71110. export * from "babylonjs/Meshes/subMesh";
  71111. export * from "babylonjs/Meshes/meshLODLevel";
  71112. export * from "babylonjs/Meshes/transformNode";
  71113. export * from "babylonjs/Meshes/Builders/index";
  71114. export * from "babylonjs/Meshes/dataBuffer";
  71115. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71116. import "babylonjs/Meshes/thinInstanceMesh";
  71117. export * from "babylonjs/Meshes/thinInstanceMesh";
  71118. }
  71119. declare module "babylonjs/Morph/index" {
  71120. export * from "babylonjs/Morph/morphTarget";
  71121. export * from "babylonjs/Morph/morphTargetManager";
  71122. }
  71123. declare module "babylonjs/Navigation/INavigationEngine" {
  71124. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71125. import { Vector3 } from "babylonjs/Maths/math";
  71126. import { Mesh } from "babylonjs/Meshes/mesh";
  71127. import { Scene } from "babylonjs/scene";
  71128. /**
  71129. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71130. */
  71131. export interface INavigationEnginePlugin {
  71132. /**
  71133. * plugin name
  71134. */
  71135. name: string;
  71136. /**
  71137. * Creates a navigation mesh
  71138. * @param meshes array of all the geometry used to compute the navigatio mesh
  71139. * @param parameters bunch of parameters used to filter geometry
  71140. */
  71141. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71142. /**
  71143. * Create a navigation mesh debug mesh
  71144. * @param scene is where the mesh will be added
  71145. * @returns debug display mesh
  71146. */
  71147. createDebugNavMesh(scene: Scene): Mesh;
  71148. /**
  71149. * Get a navigation mesh constrained position, closest to the parameter position
  71150. * @param position world position
  71151. * @returns the closest point to position constrained by the navigation mesh
  71152. */
  71153. getClosestPoint(position: Vector3): Vector3;
  71154. /**
  71155. * Get a navigation mesh constrained position, closest to the parameter position
  71156. * @param position world position
  71157. * @param result output the closest point to position constrained by the navigation mesh
  71158. */
  71159. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71160. /**
  71161. * Get a navigation mesh constrained position, within a particular radius
  71162. * @param position world position
  71163. * @param maxRadius the maximum distance to the constrained world position
  71164. * @returns the closest point to position constrained by the navigation mesh
  71165. */
  71166. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71167. /**
  71168. * Get a navigation mesh constrained position, within a particular radius
  71169. * @param position world position
  71170. * @param maxRadius the maximum distance to the constrained world position
  71171. * @param result output the closest point to position constrained by the navigation mesh
  71172. */
  71173. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71174. /**
  71175. * Compute the final position from a segment made of destination-position
  71176. * @param position world position
  71177. * @param destination world position
  71178. * @returns the resulting point along the navmesh
  71179. */
  71180. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71181. /**
  71182. * Compute the final position from a segment made of destination-position
  71183. * @param position world position
  71184. * @param destination world position
  71185. * @param result output the resulting point along the navmesh
  71186. */
  71187. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71188. /**
  71189. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71190. * @param start world position
  71191. * @param end world position
  71192. * @returns array containing world position composing the path
  71193. */
  71194. computePath(start: Vector3, end: Vector3): Vector3[];
  71195. /**
  71196. * If this plugin is supported
  71197. * @returns true if plugin is supported
  71198. */
  71199. isSupported(): boolean;
  71200. /**
  71201. * Create a new Crowd so you can add agents
  71202. * @param maxAgents the maximum agent count in the crowd
  71203. * @param maxAgentRadius the maximum radius an agent can have
  71204. * @param scene to attach the crowd to
  71205. * @returns the crowd you can add agents to
  71206. */
  71207. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71208. /**
  71209. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71210. * The queries will try to find a solution within those bounds
  71211. * default is (1,1,1)
  71212. * @param extent x,y,z value that define the extent around the queries point of reference
  71213. */
  71214. setDefaultQueryExtent(extent: Vector3): void;
  71215. /**
  71216. * Get the Bounding box extent specified by setDefaultQueryExtent
  71217. * @returns the box extent values
  71218. */
  71219. getDefaultQueryExtent(): Vector3;
  71220. /**
  71221. * build the navmesh from a previously saved state using getNavmeshData
  71222. * @param data the Uint8Array returned by getNavmeshData
  71223. */
  71224. buildFromNavmeshData(data: Uint8Array): void;
  71225. /**
  71226. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71227. * @returns data the Uint8Array that can be saved and reused
  71228. */
  71229. getNavmeshData(): Uint8Array;
  71230. /**
  71231. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71232. * @param result output the box extent values
  71233. */
  71234. getDefaultQueryExtentToRef(result: Vector3): void;
  71235. /**
  71236. * Release all resources
  71237. */
  71238. dispose(): void;
  71239. }
  71240. /**
  71241. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71242. */
  71243. export interface ICrowd {
  71244. /**
  71245. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71246. * You can attach anything to that node. The node position is updated in the scene update tick.
  71247. * @param pos world position that will be constrained by the navigation mesh
  71248. * @param parameters agent parameters
  71249. * @param transform hooked to the agent that will be update by the scene
  71250. * @returns agent index
  71251. */
  71252. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71253. /**
  71254. * Returns the agent position in world space
  71255. * @param index agent index returned by addAgent
  71256. * @returns world space position
  71257. */
  71258. getAgentPosition(index: number): Vector3;
  71259. /**
  71260. * Gets the agent position result in world space
  71261. * @param index agent index returned by addAgent
  71262. * @param result output world space position
  71263. */
  71264. getAgentPositionToRef(index: number, result: Vector3): void;
  71265. /**
  71266. * Gets the agent velocity in world space
  71267. * @param index agent index returned by addAgent
  71268. * @returns world space velocity
  71269. */
  71270. getAgentVelocity(index: number): Vector3;
  71271. /**
  71272. * Gets the agent velocity result in world space
  71273. * @param index agent index returned by addAgent
  71274. * @param result output world space velocity
  71275. */
  71276. getAgentVelocityToRef(index: number, result: Vector3): void;
  71277. /**
  71278. * remove a particular agent previously created
  71279. * @param index agent index returned by addAgent
  71280. */
  71281. removeAgent(index: number): void;
  71282. /**
  71283. * get the list of all agents attached to this crowd
  71284. * @returns list of agent indices
  71285. */
  71286. getAgents(): number[];
  71287. /**
  71288. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71289. * @param deltaTime in seconds
  71290. */
  71291. update(deltaTime: number): void;
  71292. /**
  71293. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71294. * @param index agent index returned by addAgent
  71295. * @param destination targeted world position
  71296. */
  71297. agentGoto(index: number, destination: Vector3): void;
  71298. /**
  71299. * Teleport the agent to a new position
  71300. * @param index agent index returned by addAgent
  71301. * @param destination targeted world position
  71302. */
  71303. agentTeleport(index: number, destination: Vector3): void;
  71304. /**
  71305. * Update agent parameters
  71306. * @param index agent index returned by addAgent
  71307. * @param parameters agent parameters
  71308. */
  71309. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71310. /**
  71311. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71312. * The queries will try to find a solution within those bounds
  71313. * default is (1,1,1)
  71314. * @param extent x,y,z value that define the extent around the queries point of reference
  71315. */
  71316. setDefaultQueryExtent(extent: Vector3): void;
  71317. /**
  71318. * Get the Bounding box extent specified by setDefaultQueryExtent
  71319. * @returns the box extent values
  71320. */
  71321. getDefaultQueryExtent(): Vector3;
  71322. /**
  71323. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71324. * @param result output the box extent values
  71325. */
  71326. getDefaultQueryExtentToRef(result: Vector3): void;
  71327. /**
  71328. * Release all resources
  71329. */
  71330. dispose(): void;
  71331. }
  71332. /**
  71333. * Configures an agent
  71334. */
  71335. export interface IAgentParameters {
  71336. /**
  71337. * Agent radius. [Limit: >= 0]
  71338. */
  71339. radius: number;
  71340. /**
  71341. * Agent height. [Limit: > 0]
  71342. */
  71343. height: number;
  71344. /**
  71345. * Maximum allowed acceleration. [Limit: >= 0]
  71346. */
  71347. maxAcceleration: number;
  71348. /**
  71349. * Maximum allowed speed. [Limit: >= 0]
  71350. */
  71351. maxSpeed: number;
  71352. /**
  71353. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71354. */
  71355. collisionQueryRange: number;
  71356. /**
  71357. * The path visibility optimization range. [Limit: > 0]
  71358. */
  71359. pathOptimizationRange: number;
  71360. /**
  71361. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71362. */
  71363. separationWeight: number;
  71364. }
  71365. /**
  71366. * Configures the navigation mesh creation
  71367. */
  71368. export interface INavMeshParameters {
  71369. /**
  71370. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71371. */
  71372. cs: number;
  71373. /**
  71374. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71375. */
  71376. ch: number;
  71377. /**
  71378. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71379. */
  71380. walkableSlopeAngle: number;
  71381. /**
  71382. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71383. * be considered walkable. [Limit: >= 3] [Units: vx]
  71384. */
  71385. walkableHeight: number;
  71386. /**
  71387. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71388. */
  71389. walkableClimb: number;
  71390. /**
  71391. * The distance to erode/shrink the walkable area of the heightfield away from
  71392. * obstructions. [Limit: >=0] [Units: vx]
  71393. */
  71394. walkableRadius: number;
  71395. /**
  71396. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71397. */
  71398. maxEdgeLen: number;
  71399. /**
  71400. * The maximum distance a simplfied contour's border edges should deviate
  71401. * the original raw contour. [Limit: >=0] [Units: vx]
  71402. */
  71403. maxSimplificationError: number;
  71404. /**
  71405. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71406. */
  71407. minRegionArea: number;
  71408. /**
  71409. * Any regions with a span count smaller than this value will, if possible,
  71410. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71411. */
  71412. mergeRegionArea: number;
  71413. /**
  71414. * The maximum number of vertices allowed for polygons generated during the
  71415. * contour to polygon conversion process. [Limit: >= 3]
  71416. */
  71417. maxVertsPerPoly: number;
  71418. /**
  71419. * Sets the sampling distance to use when generating the detail mesh.
  71420. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71421. */
  71422. detailSampleDist: number;
  71423. /**
  71424. * The maximum distance the detail mesh surface should deviate from heightfield
  71425. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71426. */
  71427. detailSampleMaxError: number;
  71428. }
  71429. }
  71430. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71431. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71432. import { Mesh } from "babylonjs/Meshes/mesh";
  71433. import { Scene } from "babylonjs/scene";
  71434. import { Vector3 } from "babylonjs/Maths/math";
  71435. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71436. /**
  71437. * RecastJS navigation plugin
  71438. */
  71439. export class RecastJSPlugin implements INavigationEnginePlugin {
  71440. /**
  71441. * Reference to the Recast library
  71442. */
  71443. bjsRECAST: any;
  71444. /**
  71445. * plugin name
  71446. */
  71447. name: string;
  71448. /**
  71449. * the first navmesh created. We might extend this to support multiple navmeshes
  71450. */
  71451. navMesh: any;
  71452. /**
  71453. * Initializes the recastJS plugin
  71454. * @param recastInjection can be used to inject your own recast reference
  71455. */
  71456. constructor(recastInjection?: any);
  71457. /**
  71458. * Creates a navigation mesh
  71459. * @param meshes array of all the geometry used to compute the navigatio mesh
  71460. * @param parameters bunch of parameters used to filter geometry
  71461. */
  71462. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71463. /**
  71464. * Create a navigation mesh debug mesh
  71465. * @param scene is where the mesh will be added
  71466. * @returns debug display mesh
  71467. */
  71468. createDebugNavMesh(scene: Scene): Mesh;
  71469. /**
  71470. * Get a navigation mesh constrained position, closest to the parameter position
  71471. * @param position world position
  71472. * @returns the closest point to position constrained by the navigation mesh
  71473. */
  71474. getClosestPoint(position: Vector3): Vector3;
  71475. /**
  71476. * Get a navigation mesh constrained position, closest to the parameter position
  71477. * @param position world position
  71478. * @param result output the closest point to position constrained by the navigation mesh
  71479. */
  71480. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71481. /**
  71482. * Get a navigation mesh constrained position, within a particular radius
  71483. * @param position world position
  71484. * @param maxRadius the maximum distance to the constrained world position
  71485. * @returns the closest point to position constrained by the navigation mesh
  71486. */
  71487. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71488. /**
  71489. * Get a navigation mesh constrained position, within a particular radius
  71490. * @param position world position
  71491. * @param maxRadius the maximum distance to the constrained world position
  71492. * @param result output the closest point to position constrained by the navigation mesh
  71493. */
  71494. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71495. /**
  71496. * Compute the final position from a segment made of destination-position
  71497. * @param position world position
  71498. * @param destination world position
  71499. * @returns the resulting point along the navmesh
  71500. */
  71501. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71502. /**
  71503. * Compute the final position from a segment made of destination-position
  71504. * @param position world position
  71505. * @param destination world position
  71506. * @param result output the resulting point along the navmesh
  71507. */
  71508. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71509. /**
  71510. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71511. * @param start world position
  71512. * @param end world position
  71513. * @returns array containing world position composing the path
  71514. */
  71515. computePath(start: Vector3, end: Vector3): Vector3[];
  71516. /**
  71517. * Create a new Crowd so you can add agents
  71518. * @param maxAgents the maximum agent count in the crowd
  71519. * @param maxAgentRadius the maximum radius an agent can have
  71520. * @param scene to attach the crowd to
  71521. * @returns the crowd you can add agents to
  71522. */
  71523. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71524. /**
  71525. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71526. * The queries will try to find a solution within those bounds
  71527. * default is (1,1,1)
  71528. * @param extent x,y,z value that define the extent around the queries point of reference
  71529. */
  71530. setDefaultQueryExtent(extent: Vector3): void;
  71531. /**
  71532. * Get the Bounding box extent specified by setDefaultQueryExtent
  71533. * @returns the box extent values
  71534. */
  71535. getDefaultQueryExtent(): Vector3;
  71536. /**
  71537. * build the navmesh from a previously saved state using getNavmeshData
  71538. * @param data the Uint8Array returned by getNavmeshData
  71539. */
  71540. buildFromNavmeshData(data: Uint8Array): void;
  71541. /**
  71542. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71543. * @returns data the Uint8Array that can be saved and reused
  71544. */
  71545. getNavmeshData(): Uint8Array;
  71546. /**
  71547. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71548. * @param result output the box extent values
  71549. */
  71550. getDefaultQueryExtentToRef(result: Vector3): void;
  71551. /**
  71552. * Disposes
  71553. */
  71554. dispose(): void;
  71555. /**
  71556. * If this plugin is supported
  71557. * @returns true if plugin is supported
  71558. */
  71559. isSupported(): boolean;
  71560. }
  71561. /**
  71562. * Recast detour crowd implementation
  71563. */
  71564. export class RecastJSCrowd implements ICrowd {
  71565. /**
  71566. * Recast/detour plugin
  71567. */
  71568. bjsRECASTPlugin: RecastJSPlugin;
  71569. /**
  71570. * Link to the detour crowd
  71571. */
  71572. recastCrowd: any;
  71573. /**
  71574. * One transform per agent
  71575. */
  71576. transforms: TransformNode[];
  71577. /**
  71578. * All agents created
  71579. */
  71580. agents: number[];
  71581. /**
  71582. * Link to the scene is kept to unregister the crowd from the scene
  71583. */
  71584. private _scene;
  71585. /**
  71586. * Observer for crowd updates
  71587. */
  71588. private _onBeforeAnimationsObserver;
  71589. /**
  71590. * Constructor
  71591. * @param plugin recastJS plugin
  71592. * @param maxAgents the maximum agent count in the crowd
  71593. * @param maxAgentRadius the maximum radius an agent can have
  71594. * @param scene to attach the crowd to
  71595. * @returns the crowd you can add agents to
  71596. */
  71597. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71598. /**
  71599. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71600. * You can attach anything to that node. The node position is updated in the scene update tick.
  71601. * @param pos world position that will be constrained by the navigation mesh
  71602. * @param parameters agent parameters
  71603. * @param transform hooked to the agent that will be update by the scene
  71604. * @returns agent index
  71605. */
  71606. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71607. /**
  71608. * Returns the agent position in world space
  71609. * @param index agent index returned by addAgent
  71610. * @returns world space position
  71611. */
  71612. getAgentPosition(index: number): Vector3;
  71613. /**
  71614. * Returns the agent position result in world space
  71615. * @param index agent index returned by addAgent
  71616. * @param result output world space position
  71617. */
  71618. getAgentPositionToRef(index: number, result: Vector3): void;
  71619. /**
  71620. * Returns the agent velocity in world space
  71621. * @param index agent index returned by addAgent
  71622. * @returns world space velocity
  71623. */
  71624. getAgentVelocity(index: number): Vector3;
  71625. /**
  71626. * Returns the agent velocity result in world space
  71627. * @param index agent index returned by addAgent
  71628. * @param result output world space velocity
  71629. */
  71630. getAgentVelocityToRef(index: number, result: Vector3): void;
  71631. /**
  71632. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71633. * @param index agent index returned by addAgent
  71634. * @param destination targeted world position
  71635. */
  71636. agentGoto(index: number, destination: Vector3): void;
  71637. /**
  71638. * Teleport the agent to a new position
  71639. * @param index agent index returned by addAgent
  71640. * @param destination targeted world position
  71641. */
  71642. agentTeleport(index: number, destination: Vector3): void;
  71643. /**
  71644. * Update agent parameters
  71645. * @param index agent index returned by addAgent
  71646. * @param parameters agent parameters
  71647. */
  71648. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71649. /**
  71650. * remove a particular agent previously created
  71651. * @param index agent index returned by addAgent
  71652. */
  71653. removeAgent(index: number): void;
  71654. /**
  71655. * get the list of all agents attached to this crowd
  71656. * @returns list of agent indices
  71657. */
  71658. getAgents(): number[];
  71659. /**
  71660. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71661. * @param deltaTime in seconds
  71662. */
  71663. update(deltaTime: number): void;
  71664. /**
  71665. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71666. * The queries will try to find a solution within those bounds
  71667. * default is (1,1,1)
  71668. * @param extent x,y,z value that define the extent around the queries point of reference
  71669. */
  71670. setDefaultQueryExtent(extent: Vector3): void;
  71671. /**
  71672. * Get the Bounding box extent specified by setDefaultQueryExtent
  71673. * @returns the box extent values
  71674. */
  71675. getDefaultQueryExtent(): Vector3;
  71676. /**
  71677. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71678. * @param result output the box extent values
  71679. */
  71680. getDefaultQueryExtentToRef(result: Vector3): void;
  71681. /**
  71682. * Release all resources
  71683. */
  71684. dispose(): void;
  71685. }
  71686. }
  71687. declare module "babylonjs/Navigation/Plugins/index" {
  71688. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71689. }
  71690. declare module "babylonjs/Navigation/index" {
  71691. export * from "babylonjs/Navigation/INavigationEngine";
  71692. export * from "babylonjs/Navigation/Plugins/index";
  71693. }
  71694. declare module "babylonjs/Offline/database" {
  71695. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71696. /**
  71697. * Class used to enable access to IndexedDB
  71698. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71699. */
  71700. export class Database implements IOfflineProvider {
  71701. private _callbackManifestChecked;
  71702. private _currentSceneUrl;
  71703. private _db;
  71704. private _enableSceneOffline;
  71705. private _enableTexturesOffline;
  71706. private _manifestVersionFound;
  71707. private _mustUpdateRessources;
  71708. private _hasReachedQuota;
  71709. private _isSupported;
  71710. private _idbFactory;
  71711. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71712. private static IsUASupportingBlobStorage;
  71713. /**
  71714. * Gets a boolean indicating if Database storate is enabled (off by default)
  71715. */
  71716. static IDBStorageEnabled: boolean;
  71717. /**
  71718. * Gets a boolean indicating if scene must be saved in the database
  71719. */
  71720. get enableSceneOffline(): boolean;
  71721. /**
  71722. * Gets a boolean indicating if textures must be saved in the database
  71723. */
  71724. get enableTexturesOffline(): boolean;
  71725. /**
  71726. * Creates a new Database
  71727. * @param urlToScene defines the url to load the scene
  71728. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71729. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71730. */
  71731. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71732. private static _ParseURL;
  71733. private static _ReturnFullUrlLocation;
  71734. private _checkManifestFile;
  71735. /**
  71736. * Open the database and make it available
  71737. * @param successCallback defines the callback to call on success
  71738. * @param errorCallback defines the callback to call on error
  71739. */
  71740. open(successCallback: () => void, errorCallback: () => void): void;
  71741. /**
  71742. * Loads an image from the database
  71743. * @param url defines the url to load from
  71744. * @param image defines the target DOM image
  71745. */
  71746. loadImage(url: string, image: HTMLImageElement): void;
  71747. private _loadImageFromDBAsync;
  71748. private _saveImageIntoDBAsync;
  71749. private _checkVersionFromDB;
  71750. private _loadVersionFromDBAsync;
  71751. private _saveVersionIntoDBAsync;
  71752. /**
  71753. * Loads a file from database
  71754. * @param url defines the URL to load from
  71755. * @param sceneLoaded defines a callback to call on success
  71756. * @param progressCallBack defines a callback to call when progress changed
  71757. * @param errorCallback defines a callback to call on error
  71758. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71759. */
  71760. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71761. private _loadFileAsync;
  71762. private _saveFileAsync;
  71763. /**
  71764. * Validates if xhr data is correct
  71765. * @param xhr defines the request to validate
  71766. * @param dataType defines the expected data type
  71767. * @returns true if data is correct
  71768. */
  71769. private static _ValidateXHRData;
  71770. }
  71771. }
  71772. declare module "babylonjs/Offline/index" {
  71773. export * from "babylonjs/Offline/database";
  71774. export * from "babylonjs/Offline/IOfflineProvider";
  71775. }
  71776. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71777. /** @hidden */
  71778. export var gpuUpdateParticlesPixelShader: {
  71779. name: string;
  71780. shader: string;
  71781. };
  71782. }
  71783. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71784. /** @hidden */
  71785. export var gpuUpdateParticlesVertexShader: {
  71786. name: string;
  71787. shader: string;
  71788. };
  71789. }
  71790. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71791. /** @hidden */
  71792. export var clipPlaneFragmentDeclaration2: {
  71793. name: string;
  71794. shader: string;
  71795. };
  71796. }
  71797. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71798. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71799. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71800. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71801. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71802. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71803. /** @hidden */
  71804. export var gpuRenderParticlesPixelShader: {
  71805. name: string;
  71806. shader: string;
  71807. };
  71808. }
  71809. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71810. /** @hidden */
  71811. export var clipPlaneVertexDeclaration2: {
  71812. name: string;
  71813. shader: string;
  71814. };
  71815. }
  71816. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71817. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71818. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71819. /** @hidden */
  71820. export var gpuRenderParticlesVertexShader: {
  71821. name: string;
  71822. shader: string;
  71823. };
  71824. }
  71825. declare module "babylonjs/Particles/gpuParticleSystem" {
  71826. import { Nullable } from "babylonjs/types";
  71827. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71828. import { Observable } from "babylonjs/Misc/observable";
  71829. import { Matrix } from "babylonjs/Maths/math.vector";
  71830. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71831. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71832. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71833. import { IDisposable } from "babylonjs/scene";
  71834. import { Effect } from "babylonjs/Materials/effect";
  71835. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71836. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71837. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71838. import { Scene } from "babylonjs/scene";
  71839. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71840. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71841. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71842. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71843. /**
  71844. * This represents a GPU particle system in Babylon
  71845. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71846. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71847. */
  71848. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71849. /**
  71850. * The layer mask we are rendering the particles through.
  71851. */
  71852. layerMask: number;
  71853. private _capacity;
  71854. private _activeCount;
  71855. private _currentActiveCount;
  71856. private _accumulatedCount;
  71857. private _renderEffect;
  71858. private _updateEffect;
  71859. private _buffer0;
  71860. private _buffer1;
  71861. private _spriteBuffer;
  71862. private _updateVAO;
  71863. private _renderVAO;
  71864. private _targetIndex;
  71865. private _sourceBuffer;
  71866. private _targetBuffer;
  71867. private _currentRenderId;
  71868. private _started;
  71869. private _stopped;
  71870. private _timeDelta;
  71871. private _randomTexture;
  71872. private _randomTexture2;
  71873. private _attributesStrideSize;
  71874. private _updateEffectOptions;
  71875. private _randomTextureSize;
  71876. private _actualFrame;
  71877. private _customEffect;
  71878. private readonly _rawTextureWidth;
  71879. /**
  71880. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71881. */
  71882. static get IsSupported(): boolean;
  71883. /**
  71884. * An event triggered when the system is disposed.
  71885. */
  71886. onDisposeObservable: Observable<IParticleSystem>;
  71887. /**
  71888. * An event triggered when the system is stopped
  71889. */
  71890. onStoppedObservable: Observable<IParticleSystem>;
  71891. /**
  71892. * Gets the maximum number of particles active at the same time.
  71893. * @returns The max number of active particles.
  71894. */
  71895. getCapacity(): number;
  71896. /**
  71897. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71898. * to override the particles.
  71899. */
  71900. forceDepthWrite: boolean;
  71901. /**
  71902. * Gets or set the number of active particles
  71903. */
  71904. get activeParticleCount(): number;
  71905. set activeParticleCount(value: number);
  71906. private _preWarmDone;
  71907. /**
  71908. * Specifies if the particles are updated in emitter local space or world space.
  71909. */
  71910. isLocal: boolean;
  71911. /** Gets or sets a matrix to use to compute projection */
  71912. defaultProjectionMatrix: Matrix;
  71913. /**
  71914. * Is this system ready to be used/rendered
  71915. * @return true if the system is ready
  71916. */
  71917. isReady(): boolean;
  71918. /**
  71919. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71920. * @returns True if it has been started, otherwise false.
  71921. */
  71922. isStarted(): boolean;
  71923. /**
  71924. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71925. * @returns True if it has been stopped, otherwise false.
  71926. */
  71927. isStopped(): boolean;
  71928. /**
  71929. * Gets a boolean indicating that the system is stopping
  71930. * @returns true if the system is currently stopping
  71931. */
  71932. isStopping(): boolean;
  71933. /**
  71934. * Gets the number of particles active at the same time.
  71935. * @returns The number of active particles.
  71936. */
  71937. getActiveCount(): number;
  71938. /**
  71939. * Starts the particle system and begins to emit
  71940. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71941. */
  71942. start(delay?: number): void;
  71943. /**
  71944. * Stops the particle system.
  71945. */
  71946. stop(): void;
  71947. /**
  71948. * Remove all active particles
  71949. */
  71950. reset(): void;
  71951. /**
  71952. * Returns the string "GPUParticleSystem"
  71953. * @returns a string containing the class name
  71954. */
  71955. getClassName(): string;
  71956. /**
  71957. * Gets the custom effect used to render the particles
  71958. * @param blendMode Blend mode for which the effect should be retrieved
  71959. * @returns The effect
  71960. */
  71961. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71962. /**
  71963. * Sets the custom effect used to render the particles
  71964. * @param effect The effect to set
  71965. * @param blendMode Blend mode for which the effect should be set
  71966. */
  71967. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71968. /** @hidden */
  71969. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71970. /**
  71971. * Observable that will be called just before the particles are drawn
  71972. */
  71973. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71974. /**
  71975. * Gets the name of the particle vertex shader
  71976. */
  71977. get vertexShaderName(): string;
  71978. private _colorGradientsTexture;
  71979. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71980. /**
  71981. * Adds a new color gradient
  71982. * @param gradient defines the gradient to use (between 0 and 1)
  71983. * @param color1 defines the color to affect to the specified gradient
  71984. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71985. * @returns the current particle system
  71986. */
  71987. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71988. private _refreshColorGradient;
  71989. /** Force the system to rebuild all gradients that need to be resync */
  71990. forceRefreshGradients(): void;
  71991. /**
  71992. * Remove a specific color gradient
  71993. * @param gradient defines the gradient to remove
  71994. * @returns the current particle system
  71995. */
  71996. removeColorGradient(gradient: number): GPUParticleSystem;
  71997. private _angularSpeedGradientsTexture;
  71998. private _sizeGradientsTexture;
  71999. private _velocityGradientsTexture;
  72000. private _limitVelocityGradientsTexture;
  72001. private _dragGradientsTexture;
  72002. private _addFactorGradient;
  72003. /**
  72004. * Adds a new size gradient
  72005. * @param gradient defines the gradient to use (between 0 and 1)
  72006. * @param factor defines the size factor to affect to the specified gradient
  72007. * @returns the current particle system
  72008. */
  72009. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72010. /**
  72011. * Remove a specific size gradient
  72012. * @param gradient defines the gradient to remove
  72013. * @returns the current particle system
  72014. */
  72015. removeSizeGradient(gradient: number): GPUParticleSystem;
  72016. private _refreshFactorGradient;
  72017. /**
  72018. * Adds a new angular speed gradient
  72019. * @param gradient defines the gradient to use (between 0 and 1)
  72020. * @param factor defines the angular speed to affect to the specified gradient
  72021. * @returns the current particle system
  72022. */
  72023. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72024. /**
  72025. * Remove a specific angular speed gradient
  72026. * @param gradient defines the gradient to remove
  72027. * @returns the current particle system
  72028. */
  72029. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72030. /**
  72031. * Adds a new velocity gradient
  72032. * @param gradient defines the gradient to use (between 0 and 1)
  72033. * @param factor defines the velocity to affect to the specified gradient
  72034. * @returns the current particle system
  72035. */
  72036. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72037. /**
  72038. * Remove a specific velocity gradient
  72039. * @param gradient defines the gradient to remove
  72040. * @returns the current particle system
  72041. */
  72042. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72043. /**
  72044. * Adds a new limit velocity gradient
  72045. * @param gradient defines the gradient to use (between 0 and 1)
  72046. * @param factor defines the limit velocity value to affect to the specified gradient
  72047. * @returns the current particle system
  72048. */
  72049. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72050. /**
  72051. * Remove a specific limit velocity gradient
  72052. * @param gradient defines the gradient to remove
  72053. * @returns the current particle system
  72054. */
  72055. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72056. /**
  72057. * Adds a new drag gradient
  72058. * @param gradient defines the gradient to use (between 0 and 1)
  72059. * @param factor defines the drag value to affect to the specified gradient
  72060. * @returns the current particle system
  72061. */
  72062. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72063. /**
  72064. * Remove a specific drag gradient
  72065. * @param gradient defines the gradient to remove
  72066. * @returns the current particle system
  72067. */
  72068. removeDragGradient(gradient: number): GPUParticleSystem;
  72069. /**
  72070. * Not supported by GPUParticleSystem
  72071. * @param gradient defines the gradient to use (between 0 and 1)
  72072. * @param factor defines the emit rate value to affect to the specified gradient
  72073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72074. * @returns the current particle system
  72075. */
  72076. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72077. /**
  72078. * Not supported by GPUParticleSystem
  72079. * @param gradient defines the gradient to remove
  72080. * @returns the current particle system
  72081. */
  72082. removeEmitRateGradient(gradient: number): IParticleSystem;
  72083. /**
  72084. * Not supported by GPUParticleSystem
  72085. * @param gradient defines the gradient to use (between 0 and 1)
  72086. * @param factor defines the start size value to affect to the specified gradient
  72087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72088. * @returns the current particle system
  72089. */
  72090. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72091. /**
  72092. * Not supported by GPUParticleSystem
  72093. * @param gradient defines the gradient to remove
  72094. * @returns the current particle system
  72095. */
  72096. removeStartSizeGradient(gradient: number): IParticleSystem;
  72097. /**
  72098. * Not supported by GPUParticleSystem
  72099. * @param gradient defines the gradient to use (between 0 and 1)
  72100. * @param min defines the color remap minimal range
  72101. * @param max defines the color remap maximal range
  72102. * @returns the current particle system
  72103. */
  72104. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72105. /**
  72106. * Not supported by GPUParticleSystem
  72107. * @param gradient defines the gradient to remove
  72108. * @returns the current particle system
  72109. */
  72110. removeColorRemapGradient(): IParticleSystem;
  72111. /**
  72112. * Not supported by GPUParticleSystem
  72113. * @param gradient defines the gradient to use (between 0 and 1)
  72114. * @param min defines the alpha remap minimal range
  72115. * @param max defines the alpha remap maximal range
  72116. * @returns the current particle system
  72117. */
  72118. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72119. /**
  72120. * Not supported by GPUParticleSystem
  72121. * @param gradient defines the gradient to remove
  72122. * @returns the current particle system
  72123. */
  72124. removeAlphaRemapGradient(): IParticleSystem;
  72125. /**
  72126. * Not supported by GPUParticleSystem
  72127. * @param gradient defines the gradient to use (between 0 and 1)
  72128. * @param color defines the color to affect to the specified gradient
  72129. * @returns the current particle system
  72130. */
  72131. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72132. /**
  72133. * Not supported by GPUParticleSystem
  72134. * @param gradient defines the gradient to remove
  72135. * @returns the current particle system
  72136. */
  72137. removeRampGradient(): IParticleSystem;
  72138. /**
  72139. * Not supported by GPUParticleSystem
  72140. * @returns the list of ramp gradients
  72141. */
  72142. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72143. /**
  72144. * Not supported by GPUParticleSystem
  72145. * Gets or sets a boolean indicating that ramp gradients must be used
  72146. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72147. */
  72148. get useRampGradients(): boolean;
  72149. set useRampGradients(value: boolean);
  72150. /**
  72151. * Not supported by GPUParticleSystem
  72152. * @param gradient defines the gradient to use (between 0 and 1)
  72153. * @param factor defines the life time factor to affect to the specified gradient
  72154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72155. * @returns the current particle system
  72156. */
  72157. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72158. /**
  72159. * Not supported by GPUParticleSystem
  72160. * @param gradient defines the gradient to remove
  72161. * @returns the current particle system
  72162. */
  72163. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72164. /**
  72165. * Instantiates a GPU particle system.
  72166. * 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.
  72167. * @param name The name of the particle system
  72168. * @param options The options used to create the system
  72169. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72170. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72171. * @param customEffect a custom effect used to change the way particles are rendered by default
  72172. */
  72173. constructor(name: string, options: Partial<{
  72174. capacity: number;
  72175. randomTextureSize: number;
  72176. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72177. protected _reset(): void;
  72178. private _createUpdateVAO;
  72179. private _createRenderVAO;
  72180. private _initialize;
  72181. /** @hidden */
  72182. _recreateUpdateEffect(): void;
  72183. private _getEffect;
  72184. /**
  72185. * Fill the defines array according to the current settings of the particle system
  72186. * @param defines Array to be updated
  72187. * @param blendMode blend mode to take into account when updating the array
  72188. */
  72189. fillDefines(defines: Array<string>, blendMode?: number): void;
  72190. /**
  72191. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72192. * @param uniforms Uniforms array to fill
  72193. * @param attributes Attributes array to fill
  72194. * @param samplers Samplers array to fill
  72195. */
  72196. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72197. /** @hidden */
  72198. _recreateRenderEffect(): Effect;
  72199. /**
  72200. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72201. * @param preWarm defines if we are in the pre-warmimg phase
  72202. */
  72203. animate(preWarm?: boolean): void;
  72204. private _createFactorGradientTexture;
  72205. private _createSizeGradientTexture;
  72206. private _createAngularSpeedGradientTexture;
  72207. private _createVelocityGradientTexture;
  72208. private _createLimitVelocityGradientTexture;
  72209. private _createDragGradientTexture;
  72210. private _createColorGradientTexture;
  72211. /**
  72212. * Renders the particle system in its current state
  72213. * @param preWarm defines if the system should only update the particles but not render them
  72214. * @returns the current number of particles
  72215. */
  72216. render(preWarm?: boolean): number;
  72217. /**
  72218. * Rebuilds the particle system
  72219. */
  72220. rebuild(): void;
  72221. private _releaseBuffers;
  72222. private _releaseVAOs;
  72223. /**
  72224. * Disposes the particle system and free the associated resources
  72225. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72226. */
  72227. dispose(disposeTexture?: boolean): void;
  72228. /**
  72229. * Clones the particle system.
  72230. * @param name The name of the cloned object
  72231. * @param newEmitter The new emitter to use
  72232. * @returns the cloned particle system
  72233. */
  72234. clone(name: string, newEmitter: any): GPUParticleSystem;
  72235. /**
  72236. * Serializes the particle system to a JSON object
  72237. * @param serializeTexture defines if the texture must be serialized as well
  72238. * @returns the JSON object
  72239. */
  72240. serialize(serializeTexture?: boolean): any;
  72241. /**
  72242. * Parses a JSON object to create a GPU particle system.
  72243. * @param parsedParticleSystem The JSON object to parse
  72244. * @param sceneOrEngine The scene or the engine to create the particle system in
  72245. * @param rootUrl The root url to use to load external dependencies like texture
  72246. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72247. * @returns the parsed GPU particle system
  72248. */
  72249. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72250. }
  72251. }
  72252. declare module "babylonjs/Particles/particleSystemSet" {
  72253. import { Nullable } from "babylonjs/types";
  72254. import { Color3 } from "babylonjs/Maths/math.color";
  72255. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72257. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72258. import { Scene, IDisposable } from "babylonjs/scene";
  72259. /**
  72260. * Represents a set of particle systems working together to create a specific effect
  72261. */
  72262. export class ParticleSystemSet implements IDisposable {
  72263. /**
  72264. * Gets or sets base Assets URL
  72265. */
  72266. static BaseAssetsUrl: string;
  72267. private _emitterCreationOptions;
  72268. private _emitterNode;
  72269. /**
  72270. * Gets the particle system list
  72271. */
  72272. systems: IParticleSystem[];
  72273. /**
  72274. * Gets the emitter node used with this set
  72275. */
  72276. get emitterNode(): Nullable<TransformNode>;
  72277. /**
  72278. * Creates a new emitter mesh as a sphere
  72279. * @param options defines the options used to create the sphere
  72280. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72281. * @param scene defines the hosting scene
  72282. */
  72283. setEmitterAsSphere(options: {
  72284. diameter: number;
  72285. segments: number;
  72286. color: Color3;
  72287. }, renderingGroupId: number, scene: Scene): void;
  72288. /**
  72289. * Starts all particle systems of the set
  72290. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72291. */
  72292. start(emitter?: AbstractMesh): void;
  72293. /**
  72294. * Release all associated resources
  72295. */
  72296. dispose(): void;
  72297. /**
  72298. * Serialize the set into a JSON compatible object
  72299. * @param serializeTexture defines if the texture must be serialized as well
  72300. * @returns a JSON compatible representation of the set
  72301. */
  72302. serialize(serializeTexture?: boolean): any;
  72303. /**
  72304. * Parse a new ParticleSystemSet from a serialized source
  72305. * @param data defines a JSON compatible representation of the set
  72306. * @param scene defines the hosting scene
  72307. * @param gpu defines if we want GPU particles or CPU particles
  72308. * @returns a new ParticleSystemSet
  72309. */
  72310. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72311. }
  72312. }
  72313. declare module "babylonjs/Particles/particleHelper" {
  72314. import { Nullable } from "babylonjs/types";
  72315. import { Scene } from "babylonjs/scene";
  72316. import { Vector3 } from "babylonjs/Maths/math.vector";
  72317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72318. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72319. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72320. /**
  72321. * This class is made for on one-liner static method to help creating particle system set.
  72322. */
  72323. export class ParticleHelper {
  72324. /**
  72325. * Gets or sets base Assets URL
  72326. */
  72327. static BaseAssetsUrl: string;
  72328. /** Define the Url to load snippets */
  72329. static SnippetUrl: string;
  72330. /**
  72331. * Create a default particle system that you can tweak
  72332. * @param emitter defines the emitter to use
  72333. * @param capacity defines the system capacity (default is 500 particles)
  72334. * @param scene defines the hosting scene
  72335. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72336. * @returns the new Particle system
  72337. */
  72338. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72339. /**
  72340. * This is the main static method (one-liner) of this helper to create different particle systems
  72341. * @param type This string represents the type to the particle system to create
  72342. * @param scene The scene where the particle system should live
  72343. * @param gpu If the system will use gpu
  72344. * @returns the ParticleSystemSet created
  72345. */
  72346. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72347. /**
  72348. * Static function used to export a particle system to a ParticleSystemSet variable.
  72349. * Please note that the emitter shape is not exported
  72350. * @param systems defines the particle systems to export
  72351. * @returns the created particle system set
  72352. */
  72353. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72354. /**
  72355. * Creates a particle system from a snippet saved in a remote file
  72356. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72357. * @param url defines the url to load from
  72358. * @param scene defines the hosting scene
  72359. * @param gpu If the system will use gpu
  72360. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72361. * @returns a promise that will resolve to the new particle system
  72362. */
  72363. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72364. /**
  72365. * Creates a particle system from a snippet saved by the particle system editor
  72366. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72367. * @param scene defines the hosting scene
  72368. * @param gpu If the system will use gpu
  72369. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72370. * @returns a promise that will resolve to the new particle system
  72371. */
  72372. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72373. }
  72374. }
  72375. declare module "babylonjs/Particles/particleSystemComponent" {
  72376. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72377. import { Effect } from "babylonjs/Materials/effect";
  72378. import "babylonjs/Shaders/particles.vertex";
  72379. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72380. module "babylonjs/Engines/engine" {
  72381. interface Engine {
  72382. /**
  72383. * Create an effect to use with particle systems.
  72384. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72385. * the particle system for which you want to create a custom effect in the last parameter
  72386. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72387. * @param uniformsNames defines a list of attribute names
  72388. * @param samplers defines an array of string used to represent textures
  72389. * @param defines defines the string containing the defines to use to compile the shaders
  72390. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72391. * @param onCompiled defines a function to call when the effect creation is successful
  72392. * @param onError defines a function to call when the effect creation has failed
  72393. * @param particleSystem the particle system you want to create the effect for
  72394. * @returns the new Effect
  72395. */
  72396. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72397. }
  72398. }
  72399. module "babylonjs/Meshes/mesh" {
  72400. interface Mesh {
  72401. /**
  72402. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72403. * @returns an array of IParticleSystem
  72404. */
  72405. getEmittedParticleSystems(): IParticleSystem[];
  72406. /**
  72407. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72408. * @returns an array of IParticleSystem
  72409. */
  72410. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72411. }
  72412. }
  72413. }
  72414. declare module "babylonjs/Particles/pointsCloudSystem" {
  72415. import { Color4 } from "babylonjs/Maths/math";
  72416. import { Mesh } from "babylonjs/Meshes/mesh";
  72417. import { Scene, IDisposable } from "babylonjs/scene";
  72418. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72419. /** Defines the 4 color options */
  72420. export enum PointColor {
  72421. /** color value */
  72422. Color = 2,
  72423. /** uv value */
  72424. UV = 1,
  72425. /** random value */
  72426. Random = 0,
  72427. /** stated value */
  72428. Stated = 3
  72429. }
  72430. /**
  72431. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72432. * 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.
  72433. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72434. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72435. *
  72436. * Full documentation here : TO BE ENTERED
  72437. */
  72438. export class PointsCloudSystem implements IDisposable {
  72439. /**
  72440. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72441. * Example : var p = SPS.particles[i];
  72442. */
  72443. particles: CloudPoint[];
  72444. /**
  72445. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72446. */
  72447. nbParticles: number;
  72448. /**
  72449. * This a counter for your own usage. It's not set by any SPS functions.
  72450. */
  72451. counter: number;
  72452. /**
  72453. * The PCS name. This name is also given to the underlying mesh.
  72454. */
  72455. name: string;
  72456. /**
  72457. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72458. */
  72459. mesh: Mesh;
  72460. /**
  72461. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72462. * Please read :
  72463. */
  72464. vars: any;
  72465. /**
  72466. * @hidden
  72467. */
  72468. _size: number;
  72469. private _scene;
  72470. private _promises;
  72471. private _positions;
  72472. private _indices;
  72473. private _normals;
  72474. private _colors;
  72475. private _uvs;
  72476. private _indices32;
  72477. private _positions32;
  72478. private _colors32;
  72479. private _uvs32;
  72480. private _updatable;
  72481. private _isVisibilityBoxLocked;
  72482. private _alwaysVisible;
  72483. private _groups;
  72484. private _groupCounter;
  72485. private _computeParticleColor;
  72486. private _computeParticleTexture;
  72487. private _computeParticleRotation;
  72488. private _computeBoundingBox;
  72489. private _isReady;
  72490. /**
  72491. * Creates a PCS (Points Cloud System) object
  72492. * @param name (String) is the PCS name, this will be the underlying mesh name
  72493. * @param pointSize (number) is the size for each point
  72494. * @param scene (Scene) is the scene in which the PCS is added
  72495. * @param options defines the options of the PCS e.g.
  72496. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72497. */
  72498. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72499. updatable?: boolean;
  72500. });
  72501. /**
  72502. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72503. * If no points were added to the PCS, the returned mesh is just a single point.
  72504. * @returns a promise for the created mesh
  72505. */
  72506. buildMeshAsync(): Promise<Mesh>;
  72507. /**
  72508. * @hidden
  72509. */
  72510. private _buildMesh;
  72511. private _addParticle;
  72512. private _randomUnitVector;
  72513. private _getColorIndicesForCoord;
  72514. private _setPointsColorOrUV;
  72515. private _colorFromTexture;
  72516. private _calculateDensity;
  72517. /**
  72518. * Adds points to the PCS in random positions within a unit sphere
  72519. * @param nb (positive integer) the number of particles to be created from this model
  72520. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72521. * @returns the number of groups in the system
  72522. */
  72523. addPoints(nb: number, pointFunction?: any): number;
  72524. /**
  72525. * Adds points to the PCS from the surface of the model shape
  72526. * @param mesh is any Mesh object that will be used as a surface model for the points
  72527. * @param nb (positive integer) the number of particles to be created from this model
  72528. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72529. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72530. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72531. * @returns the number of groups in the system
  72532. */
  72533. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72534. /**
  72535. * Adds points to the PCS inside the model shape
  72536. * @param mesh is any Mesh object that will be used as a surface model for the points
  72537. * @param nb (positive integer) the number of particles to be created from this model
  72538. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72539. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72540. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72541. * @returns the number of groups in the system
  72542. */
  72543. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72544. /**
  72545. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72546. * This method calls `updateParticle()` for each particle of the SPS.
  72547. * For an animated SPS, it is usually called within the render loop.
  72548. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72549. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72550. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72551. * @returns the PCS.
  72552. */
  72553. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72554. /**
  72555. * Disposes the PCS.
  72556. */
  72557. dispose(): void;
  72558. /**
  72559. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72560. * doc :
  72561. * @returns the PCS.
  72562. */
  72563. refreshVisibleSize(): PointsCloudSystem;
  72564. /**
  72565. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72566. * @param size the size (float) of the visibility box
  72567. * note : this doesn't lock the PCS mesh bounding box.
  72568. * doc :
  72569. */
  72570. setVisibilityBox(size: number): void;
  72571. /**
  72572. * Gets whether the PCS is always visible or not
  72573. * doc :
  72574. */
  72575. get isAlwaysVisible(): boolean;
  72576. /**
  72577. * Sets the PCS as always visible or not
  72578. * doc :
  72579. */
  72580. set isAlwaysVisible(val: boolean);
  72581. /**
  72582. * Tells to `setParticles()` to compute the particle rotations or not
  72583. * Default value : false. The PCS is faster when it's set to false
  72584. * Note : particle rotations are only applied to parent particles
  72585. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72586. */
  72587. set computeParticleRotation(val: boolean);
  72588. /**
  72589. * Tells to `setParticles()` to compute the particle colors or not.
  72590. * Default value : true. The PCS is faster when it's set to false.
  72591. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72592. */
  72593. set computeParticleColor(val: boolean);
  72594. set computeParticleTexture(val: boolean);
  72595. /**
  72596. * Gets if `setParticles()` computes the particle colors or not.
  72597. * Default value : false. The PCS is faster when it's set to false.
  72598. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72599. */
  72600. get computeParticleColor(): boolean;
  72601. /**
  72602. * Gets if `setParticles()` computes the particle textures or not.
  72603. * Default value : false. The PCS is faster when it's set to false.
  72604. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72605. */
  72606. get computeParticleTexture(): boolean;
  72607. /**
  72608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72609. */
  72610. set computeBoundingBox(val: boolean);
  72611. /**
  72612. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72613. */
  72614. get computeBoundingBox(): boolean;
  72615. /**
  72616. * This function does nothing. It may be overwritten to set all the particle first values.
  72617. * The PCS doesn't call this function, you may have to call it by your own.
  72618. * doc :
  72619. */
  72620. initParticles(): void;
  72621. /**
  72622. * This function does nothing. It may be overwritten to recycle a particle
  72623. * The PCS doesn't call this function, you can to call it
  72624. * doc :
  72625. * @param particle The particle to recycle
  72626. * @returns the recycled particle
  72627. */
  72628. recycleParticle(particle: CloudPoint): CloudPoint;
  72629. /**
  72630. * Updates a particle : this function should be overwritten by the user.
  72631. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72632. * doc :
  72633. * @example : just set a particle position or velocity and recycle conditions
  72634. * @param particle The particle to update
  72635. * @returns the updated particle
  72636. */
  72637. updateParticle(particle: CloudPoint): CloudPoint;
  72638. /**
  72639. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72640. * This does nothing and may be overwritten by the user.
  72641. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72642. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72643. * @param update the boolean update value actually passed to setParticles()
  72644. */
  72645. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72646. /**
  72647. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72648. * This will be passed three parameters.
  72649. * This does nothing and may be overwritten by the user.
  72650. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72651. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72652. * @param update the boolean update value actually passed to setParticles()
  72653. */
  72654. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72655. }
  72656. }
  72657. declare module "babylonjs/Particles/cloudPoint" {
  72658. import { Nullable } from "babylonjs/types";
  72659. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72660. import { Mesh } from "babylonjs/Meshes/mesh";
  72661. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72662. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72663. /**
  72664. * Represents one particle of a points cloud system.
  72665. */
  72666. export class CloudPoint {
  72667. /**
  72668. * particle global index
  72669. */
  72670. idx: number;
  72671. /**
  72672. * The color of the particle
  72673. */
  72674. color: Nullable<Color4>;
  72675. /**
  72676. * The world space position of the particle.
  72677. */
  72678. position: Vector3;
  72679. /**
  72680. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72681. */
  72682. rotation: Vector3;
  72683. /**
  72684. * The world space rotation quaternion of the particle.
  72685. */
  72686. rotationQuaternion: Nullable<Quaternion>;
  72687. /**
  72688. * The uv of the particle.
  72689. */
  72690. uv: Nullable<Vector2>;
  72691. /**
  72692. * The current speed of the particle.
  72693. */
  72694. velocity: Vector3;
  72695. /**
  72696. * The pivot point in the particle local space.
  72697. */
  72698. pivot: Vector3;
  72699. /**
  72700. * Must the particle be translated from its pivot point in its local space ?
  72701. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72702. * Default : false
  72703. */
  72704. translateFromPivot: boolean;
  72705. /**
  72706. * Index of this particle in the global "positions" array (Internal use)
  72707. * @hidden
  72708. */
  72709. _pos: number;
  72710. /**
  72711. * @hidden Index of this particle in the global "indices" array (Internal use)
  72712. */
  72713. _ind: number;
  72714. /**
  72715. * Group this particle belongs to
  72716. */
  72717. _group: PointsGroup;
  72718. /**
  72719. * Group id of this particle
  72720. */
  72721. groupId: number;
  72722. /**
  72723. * Index of the particle in its group id (Internal use)
  72724. */
  72725. idxInGroup: number;
  72726. /**
  72727. * @hidden Particle BoundingInfo object (Internal use)
  72728. */
  72729. _boundingInfo: BoundingInfo;
  72730. /**
  72731. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72732. */
  72733. _pcs: PointsCloudSystem;
  72734. /**
  72735. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72736. */
  72737. _stillInvisible: boolean;
  72738. /**
  72739. * @hidden Last computed particle rotation matrix
  72740. */
  72741. _rotationMatrix: number[];
  72742. /**
  72743. * Parent particle Id, if any.
  72744. * Default null.
  72745. */
  72746. parentId: Nullable<number>;
  72747. /**
  72748. * @hidden Internal global position in the PCS.
  72749. */
  72750. _globalPosition: Vector3;
  72751. /**
  72752. * Creates a Point Cloud object.
  72753. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72754. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72755. * @param group (PointsGroup) is the group the particle belongs to
  72756. * @param groupId (integer) is the group identifier in the PCS.
  72757. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72758. * @param pcs defines the PCS it is associated to
  72759. */
  72760. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72761. /**
  72762. * get point size
  72763. */
  72764. get size(): Vector3;
  72765. /**
  72766. * Set point size
  72767. */
  72768. set size(scale: Vector3);
  72769. /**
  72770. * Legacy support, changed quaternion to rotationQuaternion
  72771. */
  72772. get quaternion(): Nullable<Quaternion>;
  72773. /**
  72774. * Legacy support, changed quaternion to rotationQuaternion
  72775. */
  72776. set quaternion(q: Nullable<Quaternion>);
  72777. /**
  72778. * Returns a boolean. True if the particle intersects a mesh, else false
  72779. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72780. * @param target is the object (point or mesh) what the intersection is computed against
  72781. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72782. * @returns true if it intersects
  72783. */
  72784. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72785. /**
  72786. * get the rotation matrix of the particle
  72787. * @hidden
  72788. */
  72789. getRotationMatrix(m: Matrix): void;
  72790. }
  72791. /**
  72792. * Represents a group of points in a points cloud system
  72793. * * PCS internal tool, don't use it manually.
  72794. */
  72795. export class PointsGroup {
  72796. /**
  72797. * The group id
  72798. * @hidden
  72799. */
  72800. groupID: number;
  72801. /**
  72802. * image data for group (internal use)
  72803. * @hidden
  72804. */
  72805. _groupImageData: Nullable<ArrayBufferView>;
  72806. /**
  72807. * Image Width (internal use)
  72808. * @hidden
  72809. */
  72810. _groupImgWidth: number;
  72811. /**
  72812. * Image Height (internal use)
  72813. * @hidden
  72814. */
  72815. _groupImgHeight: number;
  72816. /**
  72817. * Custom position function (internal use)
  72818. * @hidden
  72819. */
  72820. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72821. /**
  72822. * density per facet for surface points
  72823. * @hidden
  72824. */
  72825. _groupDensity: number[];
  72826. /**
  72827. * Only when points are colored by texture carries pointer to texture list array
  72828. * @hidden
  72829. */
  72830. _textureNb: number;
  72831. /**
  72832. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72833. * PCS internal tool, don't use it manually.
  72834. * @hidden
  72835. */
  72836. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72837. }
  72838. }
  72839. declare module "babylonjs/Particles/index" {
  72840. export * from "babylonjs/Particles/baseParticleSystem";
  72841. export * from "babylonjs/Particles/EmitterTypes/index";
  72842. export * from "babylonjs/Particles/gpuParticleSystem";
  72843. export * from "babylonjs/Particles/IParticleSystem";
  72844. export * from "babylonjs/Particles/particle";
  72845. export * from "babylonjs/Particles/particleHelper";
  72846. export * from "babylonjs/Particles/particleSystem";
  72847. import "babylonjs/Particles/particleSystemComponent";
  72848. export * from "babylonjs/Particles/particleSystemComponent";
  72849. export * from "babylonjs/Particles/particleSystemSet";
  72850. export * from "babylonjs/Particles/solidParticle";
  72851. export * from "babylonjs/Particles/solidParticleSystem";
  72852. export * from "babylonjs/Particles/cloudPoint";
  72853. export * from "babylonjs/Particles/pointsCloudSystem";
  72854. export * from "babylonjs/Particles/subEmitter";
  72855. }
  72856. declare module "babylonjs/Physics/physicsEngineComponent" {
  72857. import { Nullable } from "babylonjs/types";
  72858. import { Observable, Observer } from "babylonjs/Misc/observable";
  72859. import { Vector3 } from "babylonjs/Maths/math.vector";
  72860. import { Mesh } from "babylonjs/Meshes/mesh";
  72861. import { ISceneComponent } from "babylonjs/sceneComponent";
  72862. import { Scene } from "babylonjs/scene";
  72863. import { Node } from "babylonjs/node";
  72864. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72865. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72866. module "babylonjs/scene" {
  72867. interface Scene {
  72868. /** @hidden (Backing field) */
  72869. _physicsEngine: Nullable<IPhysicsEngine>;
  72870. /** @hidden */
  72871. _physicsTimeAccumulator: number;
  72872. /**
  72873. * Gets the current physics engine
  72874. * @returns a IPhysicsEngine or null if none attached
  72875. */
  72876. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72877. /**
  72878. * Enables physics to the current scene
  72879. * @param gravity defines the scene's gravity for the physics engine
  72880. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72881. * @return a boolean indicating if the physics engine was initialized
  72882. */
  72883. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72884. /**
  72885. * Disables and disposes the physics engine associated with the scene
  72886. */
  72887. disablePhysicsEngine(): void;
  72888. /**
  72889. * Gets a boolean indicating if there is an active physics engine
  72890. * @returns a boolean indicating if there is an active physics engine
  72891. */
  72892. isPhysicsEnabled(): boolean;
  72893. /**
  72894. * Deletes a physics compound impostor
  72895. * @param compound defines the compound to delete
  72896. */
  72897. deleteCompoundImpostor(compound: any): void;
  72898. /**
  72899. * An event triggered when physic simulation is about to be run
  72900. */
  72901. onBeforePhysicsObservable: Observable<Scene>;
  72902. /**
  72903. * An event triggered when physic simulation has been done
  72904. */
  72905. onAfterPhysicsObservable: Observable<Scene>;
  72906. }
  72907. }
  72908. module "babylonjs/Meshes/abstractMesh" {
  72909. interface AbstractMesh {
  72910. /** @hidden */
  72911. _physicsImpostor: Nullable<PhysicsImpostor>;
  72912. /**
  72913. * Gets or sets impostor used for physic simulation
  72914. * @see https://doc.babylonjs.com/features/physics_engine
  72915. */
  72916. physicsImpostor: Nullable<PhysicsImpostor>;
  72917. /**
  72918. * Gets the current physics impostor
  72919. * @see https://doc.babylonjs.com/features/physics_engine
  72920. * @returns a physics impostor or null
  72921. */
  72922. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72923. /** Apply a physic impulse to the mesh
  72924. * @param force defines the force to apply
  72925. * @param contactPoint defines where to apply the force
  72926. * @returns the current mesh
  72927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72928. */
  72929. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72930. /**
  72931. * Creates a physic joint between two meshes
  72932. * @param otherMesh defines the other mesh to use
  72933. * @param pivot1 defines the pivot to use on this mesh
  72934. * @param pivot2 defines the pivot to use on the other mesh
  72935. * @param options defines additional options (can be plugin dependent)
  72936. * @returns the current mesh
  72937. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72938. */
  72939. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72940. /** @hidden */
  72941. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72942. }
  72943. }
  72944. /**
  72945. * Defines the physics engine scene component responsible to manage a physics engine
  72946. */
  72947. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72948. /**
  72949. * The component name helpful to identify the component in the list of scene components.
  72950. */
  72951. readonly name: string;
  72952. /**
  72953. * The scene the component belongs to.
  72954. */
  72955. scene: Scene;
  72956. /**
  72957. * Creates a new instance of the component for the given scene
  72958. * @param scene Defines the scene to register the component in
  72959. */
  72960. constructor(scene: Scene);
  72961. /**
  72962. * Registers the component in a given scene
  72963. */
  72964. register(): void;
  72965. /**
  72966. * Rebuilds the elements related to this component in case of
  72967. * context lost for instance.
  72968. */
  72969. rebuild(): void;
  72970. /**
  72971. * Disposes the component and the associated ressources
  72972. */
  72973. dispose(): void;
  72974. }
  72975. }
  72976. declare module "babylonjs/Physics/physicsHelper" {
  72977. import { Nullable } from "babylonjs/types";
  72978. import { Vector3 } from "babylonjs/Maths/math.vector";
  72979. import { Mesh } from "babylonjs/Meshes/mesh";
  72980. import { Scene } from "babylonjs/scene";
  72981. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72982. /**
  72983. * A helper for physics simulations
  72984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72985. */
  72986. export class PhysicsHelper {
  72987. private _scene;
  72988. private _physicsEngine;
  72989. /**
  72990. * Initializes the Physics helper
  72991. * @param scene Babylon.js scene
  72992. */
  72993. constructor(scene: Scene);
  72994. /**
  72995. * Applies a radial explosion impulse
  72996. * @param origin the origin of the explosion
  72997. * @param radiusOrEventOptions the radius or the options of radial explosion
  72998. * @param strength the explosion strength
  72999. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73000. * @returns A physics radial explosion event, or null
  73001. */
  73002. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73003. /**
  73004. * Applies a radial explosion force
  73005. * @param origin the origin of the explosion
  73006. * @param radiusOrEventOptions the radius or the options of radial explosion
  73007. * @param strength the explosion strength
  73008. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73009. * @returns A physics radial explosion event, or null
  73010. */
  73011. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73012. /**
  73013. * Creates a gravitational field
  73014. * @param origin the origin of the explosion
  73015. * @param radiusOrEventOptions the radius or the options of radial explosion
  73016. * @param strength the explosion strength
  73017. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73018. * @returns A physics gravitational field event, or null
  73019. */
  73020. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73021. /**
  73022. * Creates a physics updraft event
  73023. * @param origin the origin of the updraft
  73024. * @param radiusOrEventOptions the radius or the options of the updraft
  73025. * @param strength the strength of the updraft
  73026. * @param height the height of the updraft
  73027. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73028. * @returns A physics updraft event, or null
  73029. */
  73030. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73031. /**
  73032. * Creates a physics vortex event
  73033. * @param origin the of the vortex
  73034. * @param radiusOrEventOptions the radius or the options of the vortex
  73035. * @param strength the strength of the vortex
  73036. * @param height the height of the vortex
  73037. * @returns a Physics vortex event, or null
  73038. * A physics vortex event or null
  73039. */
  73040. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73041. }
  73042. /**
  73043. * Represents a physics radial explosion event
  73044. */
  73045. class PhysicsRadialExplosionEvent {
  73046. private _scene;
  73047. private _options;
  73048. private _sphere;
  73049. private _dataFetched;
  73050. /**
  73051. * Initializes a radial explosioin event
  73052. * @param _scene BabylonJS scene
  73053. * @param _options The options for the vortex event
  73054. */
  73055. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73056. /**
  73057. * Returns the data related to the radial explosion event (sphere).
  73058. * @returns The radial explosion event data
  73059. */
  73060. getData(): PhysicsRadialExplosionEventData;
  73061. /**
  73062. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73063. * @param impostor A physics imposter
  73064. * @param origin the origin of the explosion
  73065. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73066. */
  73067. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73068. /**
  73069. * Triggers affecterd impostors callbacks
  73070. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73071. */
  73072. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73073. /**
  73074. * Disposes the sphere.
  73075. * @param force Specifies if the sphere should be disposed by force
  73076. */
  73077. dispose(force?: boolean): void;
  73078. /*** Helpers ***/
  73079. private _prepareSphere;
  73080. private _intersectsWithSphere;
  73081. }
  73082. /**
  73083. * Represents a gravitational field event
  73084. */
  73085. class PhysicsGravitationalFieldEvent {
  73086. private _physicsHelper;
  73087. private _scene;
  73088. private _origin;
  73089. private _options;
  73090. private _tickCallback;
  73091. private _sphere;
  73092. private _dataFetched;
  73093. /**
  73094. * Initializes the physics gravitational field event
  73095. * @param _physicsHelper A physics helper
  73096. * @param _scene BabylonJS scene
  73097. * @param _origin The origin position of the gravitational field event
  73098. * @param _options The options for the vortex event
  73099. */
  73100. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73101. /**
  73102. * Returns the data related to the gravitational field event (sphere).
  73103. * @returns A gravitational field event
  73104. */
  73105. getData(): PhysicsGravitationalFieldEventData;
  73106. /**
  73107. * Enables the gravitational field.
  73108. */
  73109. enable(): void;
  73110. /**
  73111. * Disables the gravitational field.
  73112. */
  73113. disable(): void;
  73114. /**
  73115. * Disposes the sphere.
  73116. * @param force The force to dispose from the gravitational field event
  73117. */
  73118. dispose(force?: boolean): void;
  73119. private _tick;
  73120. }
  73121. /**
  73122. * Represents a physics updraft event
  73123. */
  73124. class PhysicsUpdraftEvent {
  73125. private _scene;
  73126. private _origin;
  73127. private _options;
  73128. private _physicsEngine;
  73129. private _originTop;
  73130. private _originDirection;
  73131. private _tickCallback;
  73132. private _cylinder;
  73133. private _cylinderPosition;
  73134. private _dataFetched;
  73135. /**
  73136. * Initializes the physics updraft event
  73137. * @param _scene BabylonJS scene
  73138. * @param _origin The origin position of the updraft
  73139. * @param _options The options for the updraft event
  73140. */
  73141. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73142. /**
  73143. * Returns the data related to the updraft event (cylinder).
  73144. * @returns A physics updraft event
  73145. */
  73146. getData(): PhysicsUpdraftEventData;
  73147. /**
  73148. * Enables the updraft.
  73149. */
  73150. enable(): void;
  73151. /**
  73152. * Disables the updraft.
  73153. */
  73154. disable(): void;
  73155. /**
  73156. * Disposes the cylinder.
  73157. * @param force Specifies if the updraft should be disposed by force
  73158. */
  73159. dispose(force?: boolean): void;
  73160. private getImpostorHitData;
  73161. private _tick;
  73162. /*** Helpers ***/
  73163. private _prepareCylinder;
  73164. private _intersectsWithCylinder;
  73165. }
  73166. /**
  73167. * Represents a physics vortex event
  73168. */
  73169. class PhysicsVortexEvent {
  73170. private _scene;
  73171. private _origin;
  73172. private _options;
  73173. private _physicsEngine;
  73174. private _originTop;
  73175. private _tickCallback;
  73176. private _cylinder;
  73177. private _cylinderPosition;
  73178. private _dataFetched;
  73179. /**
  73180. * Initializes the physics vortex event
  73181. * @param _scene The BabylonJS scene
  73182. * @param _origin The origin position of the vortex
  73183. * @param _options The options for the vortex event
  73184. */
  73185. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73186. /**
  73187. * Returns the data related to the vortex event (cylinder).
  73188. * @returns The physics vortex event data
  73189. */
  73190. getData(): PhysicsVortexEventData;
  73191. /**
  73192. * Enables the vortex.
  73193. */
  73194. enable(): void;
  73195. /**
  73196. * Disables the cortex.
  73197. */
  73198. disable(): void;
  73199. /**
  73200. * Disposes the sphere.
  73201. * @param force
  73202. */
  73203. dispose(force?: boolean): void;
  73204. private getImpostorHitData;
  73205. private _tick;
  73206. /*** Helpers ***/
  73207. private _prepareCylinder;
  73208. private _intersectsWithCylinder;
  73209. }
  73210. /**
  73211. * Options fot the radial explosion event
  73212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73213. */
  73214. export class PhysicsRadialExplosionEventOptions {
  73215. /**
  73216. * The radius of the sphere for the radial explosion.
  73217. */
  73218. radius: number;
  73219. /**
  73220. * The strenth of the explosion.
  73221. */
  73222. strength: number;
  73223. /**
  73224. * The strenght of the force in correspondence to the distance of the affected object
  73225. */
  73226. falloff: PhysicsRadialImpulseFalloff;
  73227. /**
  73228. * Sphere options for the radial explosion.
  73229. */
  73230. sphere: {
  73231. segments: number;
  73232. diameter: number;
  73233. };
  73234. /**
  73235. * Sphere options for the radial explosion.
  73236. */
  73237. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73238. }
  73239. /**
  73240. * Options fot the updraft event
  73241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73242. */
  73243. export class PhysicsUpdraftEventOptions {
  73244. /**
  73245. * The radius of the cylinder for the vortex
  73246. */
  73247. radius: number;
  73248. /**
  73249. * The strenth of the updraft.
  73250. */
  73251. strength: number;
  73252. /**
  73253. * The height of the cylinder for the updraft.
  73254. */
  73255. height: number;
  73256. /**
  73257. * The mode for the the updraft.
  73258. */
  73259. updraftMode: PhysicsUpdraftMode;
  73260. }
  73261. /**
  73262. * Options fot the vortex event
  73263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73264. */
  73265. export class PhysicsVortexEventOptions {
  73266. /**
  73267. * The radius of the cylinder for the vortex
  73268. */
  73269. radius: number;
  73270. /**
  73271. * The strenth of the vortex.
  73272. */
  73273. strength: number;
  73274. /**
  73275. * The height of the cylinder for the vortex.
  73276. */
  73277. height: number;
  73278. /**
  73279. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73280. */
  73281. centripetalForceThreshold: number;
  73282. /**
  73283. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73284. */
  73285. centripetalForceMultiplier: number;
  73286. /**
  73287. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73288. */
  73289. centrifugalForceMultiplier: number;
  73290. /**
  73291. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73292. */
  73293. updraftForceMultiplier: number;
  73294. }
  73295. /**
  73296. * The strenght of the force in correspondence to the distance of the affected object
  73297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73298. */
  73299. export enum PhysicsRadialImpulseFalloff {
  73300. /** Defines that impulse is constant in strength across it's whole radius */
  73301. Constant = 0,
  73302. /** Defines that impulse gets weaker if it's further from the origin */
  73303. Linear = 1
  73304. }
  73305. /**
  73306. * The strength of the force in correspondence to the distance of the affected object
  73307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73308. */
  73309. export enum PhysicsUpdraftMode {
  73310. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73311. Center = 0,
  73312. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73313. Perpendicular = 1
  73314. }
  73315. /**
  73316. * Interface for a physics hit data
  73317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73318. */
  73319. export interface PhysicsHitData {
  73320. /**
  73321. * The force applied at the contact point
  73322. */
  73323. force: Vector3;
  73324. /**
  73325. * The contact point
  73326. */
  73327. contactPoint: Vector3;
  73328. /**
  73329. * The distance from the origin to the contact point
  73330. */
  73331. distanceFromOrigin: number;
  73332. }
  73333. /**
  73334. * Interface for radial explosion event data
  73335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73336. */
  73337. export interface PhysicsRadialExplosionEventData {
  73338. /**
  73339. * A sphere used for the radial explosion event
  73340. */
  73341. sphere: Mesh;
  73342. }
  73343. /**
  73344. * Interface for gravitational field event data
  73345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73346. */
  73347. export interface PhysicsGravitationalFieldEventData {
  73348. /**
  73349. * A sphere mesh used for the gravitational field event
  73350. */
  73351. sphere: Mesh;
  73352. }
  73353. /**
  73354. * Interface for updraft event data
  73355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73356. */
  73357. export interface PhysicsUpdraftEventData {
  73358. /**
  73359. * A cylinder used for the updraft event
  73360. */
  73361. cylinder: Mesh;
  73362. }
  73363. /**
  73364. * Interface for vortex event data
  73365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73366. */
  73367. export interface PhysicsVortexEventData {
  73368. /**
  73369. * A cylinder used for the vortex event
  73370. */
  73371. cylinder: Mesh;
  73372. }
  73373. /**
  73374. * Interface for an affected physics impostor
  73375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73376. */
  73377. export interface PhysicsAffectedImpostorWithData {
  73378. /**
  73379. * The impostor affected by the effect
  73380. */
  73381. impostor: PhysicsImpostor;
  73382. /**
  73383. * The data about the hit/horce from the explosion
  73384. */
  73385. hitData: PhysicsHitData;
  73386. }
  73387. }
  73388. declare module "babylonjs/Physics/Plugins/index" {
  73389. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73390. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73391. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73392. }
  73393. declare module "babylonjs/Physics/index" {
  73394. export * from "babylonjs/Physics/IPhysicsEngine";
  73395. export * from "babylonjs/Physics/physicsEngine";
  73396. export * from "babylonjs/Physics/physicsEngineComponent";
  73397. export * from "babylonjs/Physics/physicsHelper";
  73398. export * from "babylonjs/Physics/physicsImpostor";
  73399. export * from "babylonjs/Physics/physicsJoint";
  73400. export * from "babylonjs/Physics/Plugins/index";
  73401. }
  73402. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73403. /** @hidden */
  73404. export var blackAndWhitePixelShader: {
  73405. name: string;
  73406. shader: string;
  73407. };
  73408. }
  73409. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73410. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73411. import { Camera } from "babylonjs/Cameras/camera";
  73412. import { Engine } from "babylonjs/Engines/engine";
  73413. import "babylonjs/Shaders/blackAndWhite.fragment";
  73414. import { Nullable } from "babylonjs/types";
  73415. import { Scene } from "babylonjs/scene";
  73416. /**
  73417. * Post process used to render in black and white
  73418. */
  73419. export class BlackAndWhitePostProcess extends PostProcess {
  73420. /**
  73421. * Linear about to convert he result to black and white (default: 1)
  73422. */
  73423. degree: number;
  73424. /**
  73425. * Gets a string identifying the name of the class
  73426. * @returns "BlackAndWhitePostProcess" string
  73427. */
  73428. getClassName(): string;
  73429. /**
  73430. * Creates a black and white post process
  73431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73432. * @param name The name of the effect.
  73433. * @param options The required width/height ratio to downsize to before computing the render pass.
  73434. * @param camera The camera to apply the render pass to.
  73435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73436. * @param engine The engine which the post process will be applied. (default: current engine)
  73437. * @param reusable If the post process can be reused on the same frame. (default: false)
  73438. */
  73439. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73440. /** @hidden */
  73441. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73442. }
  73443. }
  73444. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73445. import { Nullable } from "babylonjs/types";
  73446. import { Camera } from "babylonjs/Cameras/camera";
  73447. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73448. import { Engine } from "babylonjs/Engines/engine";
  73449. /**
  73450. * This represents a set of one or more post processes in Babylon.
  73451. * A post process can be used to apply a shader to a texture after it is rendered.
  73452. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73453. */
  73454. export class PostProcessRenderEffect {
  73455. private _postProcesses;
  73456. private _getPostProcesses;
  73457. private _singleInstance;
  73458. private _cameras;
  73459. private _indicesForCamera;
  73460. /**
  73461. * Name of the effect
  73462. * @hidden
  73463. */
  73464. _name: string;
  73465. /**
  73466. * Instantiates a post process render effect.
  73467. * A post process can be used to apply a shader to a texture after it is rendered.
  73468. * @param engine The engine the effect is tied to
  73469. * @param name The name of the effect
  73470. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73471. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73472. */
  73473. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73474. /**
  73475. * Checks if all the post processes in the effect are supported.
  73476. */
  73477. get isSupported(): boolean;
  73478. /**
  73479. * Updates the current state of the effect
  73480. * @hidden
  73481. */
  73482. _update(): void;
  73483. /**
  73484. * Attaches the effect on cameras
  73485. * @param cameras The camera to attach to.
  73486. * @hidden
  73487. */
  73488. _attachCameras(cameras: Camera): void;
  73489. /**
  73490. * Attaches the effect on cameras
  73491. * @param cameras The camera to attach to.
  73492. * @hidden
  73493. */
  73494. _attachCameras(cameras: Camera[]): void;
  73495. /**
  73496. * Detaches the effect on cameras
  73497. * @param cameras The camera to detatch from.
  73498. * @hidden
  73499. */
  73500. _detachCameras(cameras: Camera): void;
  73501. /**
  73502. * Detatches the effect on cameras
  73503. * @param cameras The camera to detatch from.
  73504. * @hidden
  73505. */
  73506. _detachCameras(cameras: Camera[]): void;
  73507. /**
  73508. * Enables the effect on given cameras
  73509. * @param cameras The camera to enable.
  73510. * @hidden
  73511. */
  73512. _enable(cameras: Camera): void;
  73513. /**
  73514. * Enables the effect on given cameras
  73515. * @param cameras The camera to enable.
  73516. * @hidden
  73517. */
  73518. _enable(cameras: Nullable<Camera[]>): void;
  73519. /**
  73520. * Disables the effect on the given cameras
  73521. * @param cameras The camera to disable.
  73522. * @hidden
  73523. */
  73524. _disable(cameras: Camera): void;
  73525. /**
  73526. * Disables the effect on the given cameras
  73527. * @param cameras The camera to disable.
  73528. * @hidden
  73529. */
  73530. _disable(cameras: Nullable<Camera[]>): void;
  73531. /**
  73532. * Gets a list of the post processes contained in the effect.
  73533. * @param camera The camera to get the post processes on.
  73534. * @returns The list of the post processes in the effect.
  73535. */
  73536. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73537. }
  73538. }
  73539. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73540. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73541. /** @hidden */
  73542. export var extractHighlightsPixelShader: {
  73543. name: string;
  73544. shader: string;
  73545. };
  73546. }
  73547. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73548. import { Nullable } from "babylonjs/types";
  73549. import { Camera } from "babylonjs/Cameras/camera";
  73550. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73551. import { Engine } from "babylonjs/Engines/engine";
  73552. import "babylonjs/Shaders/extractHighlights.fragment";
  73553. /**
  73554. * 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.
  73555. */
  73556. export class ExtractHighlightsPostProcess extends PostProcess {
  73557. /**
  73558. * The luminance threshold, pixels below this value will be set to black.
  73559. */
  73560. threshold: number;
  73561. /** @hidden */
  73562. _exposure: number;
  73563. /**
  73564. * Post process which has the input texture to be used when performing highlight extraction
  73565. * @hidden
  73566. */
  73567. _inputPostProcess: Nullable<PostProcess>;
  73568. /**
  73569. * Gets a string identifying the name of the class
  73570. * @returns "ExtractHighlightsPostProcess" string
  73571. */
  73572. getClassName(): string;
  73573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73574. }
  73575. }
  73576. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73577. /** @hidden */
  73578. export var bloomMergePixelShader: {
  73579. name: string;
  73580. shader: string;
  73581. };
  73582. }
  73583. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73584. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73585. import { Nullable } from "babylonjs/types";
  73586. import { Engine } from "babylonjs/Engines/engine";
  73587. import { Camera } from "babylonjs/Cameras/camera";
  73588. import "babylonjs/Shaders/bloomMerge.fragment";
  73589. /**
  73590. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73591. */
  73592. export class BloomMergePostProcess extends PostProcess {
  73593. /** Weight of the bloom to be added to the original input. */
  73594. weight: number;
  73595. /**
  73596. * Gets a string identifying the name of the class
  73597. * @returns "BloomMergePostProcess" string
  73598. */
  73599. getClassName(): string;
  73600. /**
  73601. * Creates a new instance of @see BloomMergePostProcess
  73602. * @param name The name of the effect.
  73603. * @param originalFromInput Post process which's input will be used for the merge.
  73604. * @param blurred Blurred highlights post process which's output will be used.
  73605. * @param weight Weight of the bloom to be added to the original input.
  73606. * @param options The required width/height ratio to downsize to before computing the render pass.
  73607. * @param camera The camera to apply the render pass to.
  73608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73609. * @param engine The engine which the post process will be applied. (default: current engine)
  73610. * @param reusable If the post process can be reused on the same frame. (default: false)
  73611. * @param textureType Type of textures used when performing the post process. (default: 0)
  73612. * @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)
  73613. */
  73614. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73615. /** Weight of the bloom to be added to the original input. */
  73616. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73617. }
  73618. }
  73619. declare module "babylonjs/PostProcesses/bloomEffect" {
  73620. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73621. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73622. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73623. import { Camera } from "babylonjs/Cameras/camera";
  73624. import { Scene } from "babylonjs/scene";
  73625. /**
  73626. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73627. */
  73628. export class BloomEffect extends PostProcessRenderEffect {
  73629. private bloomScale;
  73630. /**
  73631. * @hidden Internal
  73632. */
  73633. _effects: Array<PostProcess>;
  73634. /**
  73635. * @hidden Internal
  73636. */
  73637. _downscale: ExtractHighlightsPostProcess;
  73638. private _blurX;
  73639. private _blurY;
  73640. private _merge;
  73641. /**
  73642. * The luminance threshold to find bright areas of the image to bloom.
  73643. */
  73644. get threshold(): number;
  73645. set threshold(value: number);
  73646. /**
  73647. * The strength of the bloom.
  73648. */
  73649. get weight(): number;
  73650. set weight(value: number);
  73651. /**
  73652. * Specifies the size of the bloom blur kernel, relative to the final output size
  73653. */
  73654. get kernel(): number;
  73655. set kernel(value: number);
  73656. /**
  73657. * Creates a new instance of @see BloomEffect
  73658. * @param scene The scene the effect belongs to.
  73659. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73660. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73661. * @param bloomWeight The the strength of bloom.
  73662. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73663. * @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)
  73664. */
  73665. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73666. /**
  73667. * Disposes each of the internal effects for a given camera.
  73668. * @param camera The camera to dispose the effect on.
  73669. */
  73670. disposeEffects(camera: Camera): void;
  73671. /**
  73672. * @hidden Internal
  73673. */
  73674. _updateEffects(): void;
  73675. /**
  73676. * Internal
  73677. * @returns if all the contained post processes are ready.
  73678. * @hidden
  73679. */
  73680. _isReady(): boolean;
  73681. }
  73682. }
  73683. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73684. /** @hidden */
  73685. export var chromaticAberrationPixelShader: {
  73686. name: string;
  73687. shader: string;
  73688. };
  73689. }
  73690. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73691. import { Vector2 } from "babylonjs/Maths/math.vector";
  73692. import { Nullable } from "babylonjs/types";
  73693. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73694. import { Camera } from "babylonjs/Cameras/camera";
  73695. import { Engine } from "babylonjs/Engines/engine";
  73696. import "babylonjs/Shaders/chromaticAberration.fragment";
  73697. import { Scene } from "babylonjs/scene";
  73698. /**
  73699. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73700. */
  73701. export class ChromaticAberrationPostProcess extends PostProcess {
  73702. /**
  73703. * The amount of seperation of rgb channels (default: 30)
  73704. */
  73705. aberrationAmount: number;
  73706. /**
  73707. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73708. */
  73709. radialIntensity: number;
  73710. /**
  73711. * 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))
  73712. */
  73713. direction: Vector2;
  73714. /**
  73715. * 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))
  73716. */
  73717. centerPosition: Vector2;
  73718. /** The width of the screen to apply the effect on */
  73719. screenWidth: number;
  73720. /** The height of the screen to apply the effect on */
  73721. screenHeight: number;
  73722. /**
  73723. * Gets a string identifying the name of the class
  73724. * @returns "ChromaticAberrationPostProcess" string
  73725. */
  73726. getClassName(): string;
  73727. /**
  73728. * Creates a new instance ChromaticAberrationPostProcess
  73729. * @param name The name of the effect.
  73730. * @param screenWidth The width of the screen to apply the effect on.
  73731. * @param screenHeight The height of the screen to apply the effect on.
  73732. * @param options The required width/height ratio to downsize to before computing the render pass.
  73733. * @param camera The camera to apply the render pass to.
  73734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73735. * @param engine The engine which the post process will be applied. (default: current engine)
  73736. * @param reusable If the post process can be reused on the same frame. (default: false)
  73737. * @param textureType Type of textures used when performing the post process. (default: 0)
  73738. * @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)
  73739. */
  73740. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73741. /** @hidden */
  73742. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73743. }
  73744. }
  73745. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73746. /** @hidden */
  73747. export var circleOfConfusionPixelShader: {
  73748. name: string;
  73749. shader: string;
  73750. };
  73751. }
  73752. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73753. import { Nullable } from "babylonjs/types";
  73754. import { Engine } from "babylonjs/Engines/engine";
  73755. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73756. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73757. import { Camera } from "babylonjs/Cameras/camera";
  73758. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73759. /**
  73760. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73761. */
  73762. export class CircleOfConfusionPostProcess extends PostProcess {
  73763. /**
  73764. * 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.
  73765. */
  73766. lensSize: number;
  73767. /**
  73768. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73769. */
  73770. fStop: number;
  73771. /**
  73772. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73773. */
  73774. focusDistance: number;
  73775. /**
  73776. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73777. */
  73778. focalLength: number;
  73779. /**
  73780. * Gets a string identifying the name of the class
  73781. * @returns "CircleOfConfusionPostProcess" string
  73782. */
  73783. getClassName(): string;
  73784. private _depthTexture;
  73785. /**
  73786. * Creates a new instance CircleOfConfusionPostProcess
  73787. * @param name The name of the effect.
  73788. * @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.
  73789. * @param options The required width/height ratio to downsize to before computing the render pass.
  73790. * @param camera The camera to apply the render pass to.
  73791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73792. * @param engine The engine which the post process will be applied. (default: current engine)
  73793. * @param reusable If the post process can be reused on the same frame. (default: false)
  73794. * @param textureType Type of textures used when performing the post process. (default: 0)
  73795. * @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)
  73796. */
  73797. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73798. /**
  73799. * 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.
  73800. */
  73801. set depthTexture(value: RenderTargetTexture);
  73802. }
  73803. }
  73804. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73805. /** @hidden */
  73806. export var colorCorrectionPixelShader: {
  73807. name: string;
  73808. shader: string;
  73809. };
  73810. }
  73811. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73812. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73813. import { Engine } from "babylonjs/Engines/engine";
  73814. import { Camera } from "babylonjs/Cameras/camera";
  73815. import "babylonjs/Shaders/colorCorrection.fragment";
  73816. import { Nullable } from "babylonjs/types";
  73817. import { Scene } from "babylonjs/scene";
  73818. /**
  73819. *
  73820. * This post-process allows the modification of rendered colors by using
  73821. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73822. *
  73823. * The object needs to be provided an url to a texture containing the color
  73824. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73825. * Use an image editing software to tweak the LUT to match your needs.
  73826. *
  73827. * For an example of a color LUT, see here:
  73828. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73829. * For explanations on color grading, see here:
  73830. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73831. *
  73832. */
  73833. export class ColorCorrectionPostProcess extends PostProcess {
  73834. private _colorTableTexture;
  73835. /**
  73836. * Gets the color table url used to create the LUT texture
  73837. */
  73838. colorTableUrl: string;
  73839. /**
  73840. * Gets a string identifying the name of the class
  73841. * @returns "ColorCorrectionPostProcess" string
  73842. */
  73843. getClassName(): string;
  73844. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73845. /** @hidden */
  73846. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73847. }
  73848. }
  73849. declare module "babylonjs/Shaders/convolution.fragment" {
  73850. /** @hidden */
  73851. export var convolutionPixelShader: {
  73852. name: string;
  73853. shader: string;
  73854. };
  73855. }
  73856. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73857. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73858. import { Nullable } from "babylonjs/types";
  73859. import { Camera } from "babylonjs/Cameras/camera";
  73860. import { Engine } from "babylonjs/Engines/engine";
  73861. import "babylonjs/Shaders/convolution.fragment";
  73862. import { Scene } from "babylonjs/scene";
  73863. /**
  73864. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73865. * input texture to perform effects such as edge detection or sharpening
  73866. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73867. */
  73868. export class ConvolutionPostProcess extends PostProcess {
  73869. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73870. kernel: number[];
  73871. /**
  73872. * Gets a string identifying the name of the class
  73873. * @returns "ConvolutionPostProcess" string
  73874. */
  73875. getClassName(): string;
  73876. /**
  73877. * Creates a new instance ConvolutionPostProcess
  73878. * @param name The name of the effect.
  73879. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73880. * @param options The required width/height ratio to downsize to before computing the render pass.
  73881. * @param camera The camera to apply the render pass to.
  73882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73883. * @param engine The engine which the post process will be applied. (default: current engine)
  73884. * @param reusable If the post process can be reused on the same frame. (default: false)
  73885. * @param textureType Type of textures used when performing the post process. (default: 0)
  73886. */
  73887. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73888. /** @hidden */
  73889. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73890. /**
  73891. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73892. */
  73893. static EdgeDetect0Kernel: number[];
  73894. /**
  73895. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73896. */
  73897. static EdgeDetect1Kernel: number[];
  73898. /**
  73899. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73900. */
  73901. static EdgeDetect2Kernel: number[];
  73902. /**
  73903. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73904. */
  73905. static SharpenKernel: number[];
  73906. /**
  73907. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73908. */
  73909. static EmbossKernel: number[];
  73910. /**
  73911. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73912. */
  73913. static GaussianKernel: number[];
  73914. }
  73915. }
  73916. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73917. import { Nullable } from "babylonjs/types";
  73918. import { Vector2 } from "babylonjs/Maths/math.vector";
  73919. import { Camera } from "babylonjs/Cameras/camera";
  73920. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73921. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73922. import { Engine } from "babylonjs/Engines/engine";
  73923. import { Scene } from "babylonjs/scene";
  73924. /**
  73925. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73926. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73927. * based on samples that have a large difference in distance than the center pixel.
  73928. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73929. */
  73930. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73931. /**
  73932. * The direction the blur should be applied
  73933. */
  73934. direction: Vector2;
  73935. /**
  73936. * Gets a string identifying the name of the class
  73937. * @returns "DepthOfFieldBlurPostProcess" string
  73938. */
  73939. getClassName(): string;
  73940. /**
  73941. * Creates a new instance CircleOfConfusionPostProcess
  73942. * @param name The name of the effect.
  73943. * @param scene The scene the effect belongs to.
  73944. * @param direction The direction the blur should be applied.
  73945. * @param kernel The size of the kernel used to blur.
  73946. * @param options The required width/height ratio to downsize to before computing the render pass.
  73947. * @param camera The camera to apply the render pass to.
  73948. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73949. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73951. * @param engine The engine which the post process will be applied. (default: current engine)
  73952. * @param reusable If the post process can be reused on the same frame. (default: false)
  73953. * @param textureType Type of textures used when performing the post process. (default: 0)
  73954. * @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)
  73955. */
  73956. 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);
  73957. }
  73958. }
  73959. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73960. /** @hidden */
  73961. export var depthOfFieldMergePixelShader: {
  73962. name: string;
  73963. shader: string;
  73964. };
  73965. }
  73966. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73967. import { Nullable } from "babylonjs/types";
  73968. import { Camera } from "babylonjs/Cameras/camera";
  73969. import { Effect } from "babylonjs/Materials/effect";
  73970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73971. import { Engine } from "babylonjs/Engines/engine";
  73972. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73973. /**
  73974. * Options to be set when merging outputs from the default pipeline.
  73975. */
  73976. export class DepthOfFieldMergePostProcessOptions {
  73977. /**
  73978. * The original image to merge on top of
  73979. */
  73980. originalFromInput: PostProcess;
  73981. /**
  73982. * Parameters to perform the merge of the depth of field effect
  73983. */
  73984. depthOfField?: {
  73985. circleOfConfusion: PostProcess;
  73986. blurSteps: Array<PostProcess>;
  73987. };
  73988. /**
  73989. * Parameters to perform the merge of bloom effect
  73990. */
  73991. bloom?: {
  73992. blurred: PostProcess;
  73993. weight: number;
  73994. };
  73995. }
  73996. /**
  73997. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73998. */
  73999. export class DepthOfFieldMergePostProcess extends PostProcess {
  74000. private blurSteps;
  74001. /**
  74002. * Gets a string identifying the name of the class
  74003. * @returns "DepthOfFieldMergePostProcess" string
  74004. */
  74005. getClassName(): string;
  74006. /**
  74007. * Creates a new instance of DepthOfFieldMergePostProcess
  74008. * @param name The name of the effect.
  74009. * @param originalFromInput Post process which's input will be used for the merge.
  74010. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74011. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74012. * @param options The required width/height ratio to downsize to before computing the render pass.
  74013. * @param camera The camera to apply the render pass to.
  74014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74015. * @param engine The engine which the post process will be applied. (default: current engine)
  74016. * @param reusable If the post process can be reused on the same frame. (default: false)
  74017. * @param textureType Type of textures used when performing the post process. (default: 0)
  74018. * @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)
  74019. */
  74020. 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);
  74021. /**
  74022. * Updates the effect with the current post process compile time values and recompiles the shader.
  74023. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74024. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74025. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74026. * @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
  74027. * @param onCompiled Called when the shader has been compiled.
  74028. * @param onError Called if there is an error when compiling a shader.
  74029. */
  74030. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74031. }
  74032. }
  74033. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74034. import { Nullable } from "babylonjs/types";
  74035. import { Camera } from "babylonjs/Cameras/camera";
  74036. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74037. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74038. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74039. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74040. import { Scene } from "babylonjs/scene";
  74041. /**
  74042. * Specifies the level of max blur that should be applied when using the depth of field effect
  74043. */
  74044. export enum DepthOfFieldEffectBlurLevel {
  74045. /**
  74046. * Subtle blur
  74047. */
  74048. Low = 0,
  74049. /**
  74050. * Medium blur
  74051. */
  74052. Medium = 1,
  74053. /**
  74054. * Large blur
  74055. */
  74056. High = 2
  74057. }
  74058. /**
  74059. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74060. */
  74061. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74062. private _circleOfConfusion;
  74063. /**
  74064. * @hidden Internal, blurs from high to low
  74065. */
  74066. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74067. private _depthOfFieldBlurY;
  74068. private _dofMerge;
  74069. /**
  74070. * @hidden Internal post processes in depth of field effect
  74071. */
  74072. _effects: Array<PostProcess>;
  74073. /**
  74074. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74075. */
  74076. set focalLength(value: number);
  74077. get focalLength(): number;
  74078. /**
  74079. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74080. */
  74081. set fStop(value: number);
  74082. get fStop(): number;
  74083. /**
  74084. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74085. */
  74086. set focusDistance(value: number);
  74087. get focusDistance(): number;
  74088. /**
  74089. * 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.
  74090. */
  74091. set lensSize(value: number);
  74092. get lensSize(): number;
  74093. /**
  74094. * Creates a new instance DepthOfFieldEffect
  74095. * @param scene The scene the effect belongs to.
  74096. * @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.
  74097. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74098. * @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)
  74099. */
  74100. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74101. /**
  74102. * Get the current class name of the current effet
  74103. * @returns "DepthOfFieldEffect"
  74104. */
  74105. getClassName(): string;
  74106. /**
  74107. * 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.
  74108. */
  74109. set depthTexture(value: RenderTargetTexture);
  74110. /**
  74111. * Disposes each of the internal effects for a given camera.
  74112. * @param camera The camera to dispose the effect on.
  74113. */
  74114. disposeEffects(camera: Camera): void;
  74115. /**
  74116. * @hidden Internal
  74117. */
  74118. _updateEffects(): void;
  74119. /**
  74120. * Internal
  74121. * @returns if all the contained post processes are ready.
  74122. * @hidden
  74123. */
  74124. _isReady(): boolean;
  74125. }
  74126. }
  74127. declare module "babylonjs/Shaders/displayPass.fragment" {
  74128. /** @hidden */
  74129. export var displayPassPixelShader: {
  74130. name: string;
  74131. shader: string;
  74132. };
  74133. }
  74134. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74135. import { Nullable } from "babylonjs/types";
  74136. import { Camera } from "babylonjs/Cameras/camera";
  74137. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74138. import { Engine } from "babylonjs/Engines/engine";
  74139. import "babylonjs/Shaders/displayPass.fragment";
  74140. import { Scene } from "babylonjs/scene";
  74141. /**
  74142. * DisplayPassPostProcess which produces an output the same as it's input
  74143. */
  74144. export class DisplayPassPostProcess extends PostProcess {
  74145. /**
  74146. * Gets a string identifying the name of the class
  74147. * @returns "DisplayPassPostProcess" string
  74148. */
  74149. getClassName(): string;
  74150. /**
  74151. * Creates the DisplayPassPostProcess
  74152. * @param name The name of the effect.
  74153. * @param options The required width/height ratio to downsize to before computing the render pass.
  74154. * @param camera The camera to apply the render pass to.
  74155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74156. * @param engine The engine which the post process will be applied. (default: current engine)
  74157. * @param reusable If the post process can be reused on the same frame. (default: false)
  74158. */
  74159. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74160. /** @hidden */
  74161. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74162. }
  74163. }
  74164. declare module "babylonjs/Shaders/filter.fragment" {
  74165. /** @hidden */
  74166. export var filterPixelShader: {
  74167. name: string;
  74168. shader: string;
  74169. };
  74170. }
  74171. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74172. import { Nullable } from "babylonjs/types";
  74173. import { Matrix } from "babylonjs/Maths/math.vector";
  74174. import { Camera } from "babylonjs/Cameras/camera";
  74175. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74176. import { Engine } from "babylonjs/Engines/engine";
  74177. import "babylonjs/Shaders/filter.fragment";
  74178. import { Scene } from "babylonjs/scene";
  74179. /**
  74180. * Applies a kernel filter to the image
  74181. */
  74182. export class FilterPostProcess extends PostProcess {
  74183. /** The matrix to be applied to the image */
  74184. kernelMatrix: Matrix;
  74185. /**
  74186. * Gets a string identifying the name of the class
  74187. * @returns "FilterPostProcess" string
  74188. */
  74189. getClassName(): string;
  74190. /**
  74191. *
  74192. * @param name The name of the effect.
  74193. * @param kernelMatrix The matrix to be applied to the image
  74194. * @param options The required width/height ratio to downsize to before computing the render pass.
  74195. * @param camera The camera to apply the render pass to.
  74196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74197. * @param engine The engine which the post process will be applied. (default: current engine)
  74198. * @param reusable If the post process can be reused on the same frame. (default: false)
  74199. */
  74200. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74201. /** @hidden */
  74202. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74203. }
  74204. }
  74205. declare module "babylonjs/Shaders/fxaa.fragment" {
  74206. /** @hidden */
  74207. export var fxaaPixelShader: {
  74208. name: string;
  74209. shader: string;
  74210. };
  74211. }
  74212. declare module "babylonjs/Shaders/fxaa.vertex" {
  74213. /** @hidden */
  74214. export var fxaaVertexShader: {
  74215. name: string;
  74216. shader: string;
  74217. };
  74218. }
  74219. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74220. import { Nullable } from "babylonjs/types";
  74221. import { Camera } from "babylonjs/Cameras/camera";
  74222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74223. import { Engine } from "babylonjs/Engines/engine";
  74224. import "babylonjs/Shaders/fxaa.fragment";
  74225. import "babylonjs/Shaders/fxaa.vertex";
  74226. import { Scene } from "babylonjs/scene";
  74227. /**
  74228. * Fxaa post process
  74229. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74230. */
  74231. export class FxaaPostProcess extends PostProcess {
  74232. /**
  74233. * Gets a string identifying the name of the class
  74234. * @returns "FxaaPostProcess" string
  74235. */
  74236. getClassName(): string;
  74237. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74238. private _getDefines;
  74239. /** @hidden */
  74240. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74241. }
  74242. }
  74243. declare module "babylonjs/Shaders/grain.fragment" {
  74244. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74245. /** @hidden */
  74246. export var grainPixelShader: {
  74247. name: string;
  74248. shader: string;
  74249. };
  74250. }
  74251. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74252. import { Nullable } from "babylonjs/types";
  74253. import { Camera } from "babylonjs/Cameras/camera";
  74254. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74255. import { Engine } from "babylonjs/Engines/engine";
  74256. import "babylonjs/Shaders/grain.fragment";
  74257. import { Scene } from "babylonjs/scene";
  74258. /**
  74259. * The GrainPostProcess adds noise to the image at mid luminance levels
  74260. */
  74261. export class GrainPostProcess extends PostProcess {
  74262. /**
  74263. * The intensity of the grain added (default: 30)
  74264. */
  74265. intensity: number;
  74266. /**
  74267. * If the grain should be randomized on every frame
  74268. */
  74269. animated: boolean;
  74270. /**
  74271. * Gets a string identifying the name of the class
  74272. * @returns "GrainPostProcess" string
  74273. */
  74274. getClassName(): string;
  74275. /**
  74276. * Creates a new instance of @see GrainPostProcess
  74277. * @param name The name of the effect.
  74278. * @param options The required width/height ratio to downsize to before computing the render pass.
  74279. * @param camera The camera to apply the render pass to.
  74280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74281. * @param engine The engine which the post process will be applied. (default: current engine)
  74282. * @param reusable If the post process can be reused on the same frame. (default: false)
  74283. * @param textureType Type of textures used when performing the post process. (default: 0)
  74284. * @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)
  74285. */
  74286. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74287. /** @hidden */
  74288. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74289. }
  74290. }
  74291. declare module "babylonjs/Shaders/highlights.fragment" {
  74292. /** @hidden */
  74293. export var highlightsPixelShader: {
  74294. name: string;
  74295. shader: string;
  74296. };
  74297. }
  74298. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74299. import { Nullable } from "babylonjs/types";
  74300. import { Camera } from "babylonjs/Cameras/camera";
  74301. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74302. import { Engine } from "babylonjs/Engines/engine";
  74303. import "babylonjs/Shaders/highlights.fragment";
  74304. /**
  74305. * Extracts highlights from the image
  74306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74307. */
  74308. export class HighlightsPostProcess extends PostProcess {
  74309. /**
  74310. * Gets a string identifying the name of the class
  74311. * @returns "HighlightsPostProcess" string
  74312. */
  74313. getClassName(): string;
  74314. /**
  74315. * Extracts highlights from the image
  74316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74317. * @param name The name of the effect.
  74318. * @param options The required width/height ratio to downsize to before computing the render pass.
  74319. * @param camera The camera to apply the render pass to.
  74320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74321. * @param engine The engine which the post process will be applied. (default: current engine)
  74322. * @param reusable If the post process can be reused on the same frame. (default: false)
  74323. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74324. */
  74325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74326. }
  74327. }
  74328. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74329. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74330. /**
  74331. * Contains all parameters needed for the prepass to perform
  74332. * motion blur
  74333. */
  74334. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74335. /**
  74336. * Is motion blur enabled
  74337. */
  74338. enabled: boolean;
  74339. /**
  74340. * Name of the configuration
  74341. */
  74342. name: string;
  74343. /**
  74344. * Textures that should be present in the MRT for this effect to work
  74345. */
  74346. readonly texturesRequired: number[];
  74347. }
  74348. }
  74349. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74350. import { Nullable } from "babylonjs/types";
  74351. import { Scene } from "babylonjs/scene";
  74352. import { ISceneComponent } from "babylonjs/sceneComponent";
  74353. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74354. module "babylonjs/scene" {
  74355. interface Scene {
  74356. /** @hidden (Backing field) */
  74357. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74358. /**
  74359. * Gets or Sets the current geometry buffer associated to the scene.
  74360. */
  74361. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74362. /**
  74363. * Enables a GeometryBufferRender and associates it with the scene
  74364. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74365. * @returns the GeometryBufferRenderer
  74366. */
  74367. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74368. /**
  74369. * Disables the GeometryBufferRender associated with the scene
  74370. */
  74371. disableGeometryBufferRenderer(): void;
  74372. }
  74373. }
  74374. /**
  74375. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74376. * in several rendering techniques.
  74377. */
  74378. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74379. /**
  74380. * The component name helpful to identify the component in the list of scene components.
  74381. */
  74382. readonly name: string;
  74383. /**
  74384. * The scene the component belongs to.
  74385. */
  74386. scene: Scene;
  74387. /**
  74388. * Creates a new instance of the component for the given scene
  74389. * @param scene Defines the scene to register the component in
  74390. */
  74391. constructor(scene: Scene);
  74392. /**
  74393. * Registers the component in a given scene
  74394. */
  74395. register(): void;
  74396. /**
  74397. * Rebuilds the elements related to this component in case of
  74398. * context lost for instance.
  74399. */
  74400. rebuild(): void;
  74401. /**
  74402. * Disposes the component and the associated ressources
  74403. */
  74404. dispose(): void;
  74405. private _gatherRenderTargets;
  74406. }
  74407. }
  74408. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74409. /** @hidden */
  74410. export var motionBlurPixelShader: {
  74411. name: string;
  74412. shader: string;
  74413. };
  74414. }
  74415. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74416. import { Nullable } from "babylonjs/types";
  74417. import { Camera } from "babylonjs/Cameras/camera";
  74418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74420. import "babylonjs/Animations/animatable";
  74421. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74422. import "babylonjs/Shaders/motionBlur.fragment";
  74423. import { Engine } from "babylonjs/Engines/engine";
  74424. import { Scene } from "babylonjs/scene";
  74425. /**
  74426. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74427. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74428. * As an example, all you have to do is to create the post-process:
  74429. * var mb = new BABYLON.MotionBlurPostProcess(
  74430. * 'mb', // The name of the effect.
  74431. * scene, // The scene containing the objects to blur according to their velocity.
  74432. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74433. * camera // The camera to apply the render pass to.
  74434. * );
  74435. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74436. */
  74437. export class MotionBlurPostProcess extends PostProcess {
  74438. /**
  74439. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74440. */
  74441. motionStrength: number;
  74442. /**
  74443. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74444. */
  74445. get motionBlurSamples(): number;
  74446. /**
  74447. * Sets the number of iterations to be used for motion blur quality
  74448. */
  74449. set motionBlurSamples(samples: number);
  74450. private _motionBlurSamples;
  74451. private _forceGeometryBuffer;
  74452. private _geometryBufferRenderer;
  74453. private _prePassRenderer;
  74454. /**
  74455. * Gets a string identifying the name of the class
  74456. * @returns "MotionBlurPostProcess" string
  74457. */
  74458. getClassName(): string;
  74459. /**
  74460. * Creates a new instance MotionBlurPostProcess
  74461. * @param name The name of the effect.
  74462. * @param scene The scene containing the objects to blur according to their velocity.
  74463. * @param options The required width/height ratio to downsize to before computing the render pass.
  74464. * @param camera The camera to apply the render pass to.
  74465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74466. * @param engine The engine which the post process will be applied. (default: current engine)
  74467. * @param reusable If the post process can be reused on the same frame. (default: false)
  74468. * @param textureType Type of textures used when performing the post process. (default: 0)
  74469. * @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)
  74470. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74471. */
  74472. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74473. /**
  74474. * Excludes the given skinned mesh from computing bones velocities.
  74475. * 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.
  74476. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74477. */
  74478. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74479. /**
  74480. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74481. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74482. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74483. */
  74484. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74485. /**
  74486. * Disposes the post process.
  74487. * @param camera The camera to dispose the post process on.
  74488. */
  74489. dispose(camera?: Camera): void;
  74490. /** @hidden */
  74491. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74492. }
  74493. }
  74494. declare module "babylonjs/Shaders/refraction.fragment" {
  74495. /** @hidden */
  74496. export var refractionPixelShader: {
  74497. name: string;
  74498. shader: string;
  74499. };
  74500. }
  74501. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74502. import { Color3 } from "babylonjs/Maths/math.color";
  74503. import { Camera } from "babylonjs/Cameras/camera";
  74504. import { Texture } from "babylonjs/Materials/Textures/texture";
  74505. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74506. import { Engine } from "babylonjs/Engines/engine";
  74507. import "babylonjs/Shaders/refraction.fragment";
  74508. import { Scene } from "babylonjs/scene";
  74509. /**
  74510. * Post process which applies a refractin texture
  74511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74512. */
  74513. export class RefractionPostProcess extends PostProcess {
  74514. private _refTexture;
  74515. private _ownRefractionTexture;
  74516. /** the base color of the refraction (used to taint the rendering) */
  74517. color: Color3;
  74518. /** simulated refraction depth */
  74519. depth: number;
  74520. /** the coefficient of the base color (0 to remove base color tainting) */
  74521. colorLevel: number;
  74522. /** Gets the url used to load the refraction texture */
  74523. refractionTextureUrl: string;
  74524. /**
  74525. * Gets or sets the refraction texture
  74526. * Please note that you are responsible for disposing the texture if you set it manually
  74527. */
  74528. get refractionTexture(): Texture;
  74529. set refractionTexture(value: Texture);
  74530. /**
  74531. * Gets a string identifying the name of the class
  74532. * @returns "RefractionPostProcess" string
  74533. */
  74534. getClassName(): string;
  74535. /**
  74536. * Initializes the RefractionPostProcess
  74537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74538. * @param name The name of the effect.
  74539. * @param refractionTextureUrl Url of the refraction texture to use
  74540. * @param color the base color of the refraction (used to taint the rendering)
  74541. * @param depth simulated refraction depth
  74542. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74543. * @param camera The camera to apply the render pass to.
  74544. * @param options The required width/height ratio to downsize to before computing the render pass.
  74545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74546. * @param engine The engine which the post process will be applied. (default: current engine)
  74547. * @param reusable If the post process can be reused on the same frame. (default: false)
  74548. */
  74549. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74550. /**
  74551. * Disposes of the post process
  74552. * @param camera Camera to dispose post process on
  74553. */
  74554. dispose(camera: Camera): void;
  74555. /** @hidden */
  74556. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74557. }
  74558. }
  74559. declare module "babylonjs/Shaders/sharpen.fragment" {
  74560. /** @hidden */
  74561. export var sharpenPixelShader: {
  74562. name: string;
  74563. shader: string;
  74564. };
  74565. }
  74566. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74567. import { Nullable } from "babylonjs/types";
  74568. import { Camera } from "babylonjs/Cameras/camera";
  74569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74570. import "babylonjs/Shaders/sharpen.fragment";
  74571. import { Engine } from "babylonjs/Engines/engine";
  74572. import { Scene } from "babylonjs/scene";
  74573. /**
  74574. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74575. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74576. */
  74577. export class SharpenPostProcess extends PostProcess {
  74578. /**
  74579. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74580. */
  74581. colorAmount: number;
  74582. /**
  74583. * How much sharpness should be applied (default: 0.3)
  74584. */
  74585. edgeAmount: number;
  74586. /**
  74587. * Gets a string identifying the name of the class
  74588. * @returns "SharpenPostProcess" string
  74589. */
  74590. getClassName(): string;
  74591. /**
  74592. * Creates a new instance ConvolutionPostProcess
  74593. * @param name The name of the effect.
  74594. * @param options The required width/height ratio to downsize to before computing the render pass.
  74595. * @param camera The camera to apply the render pass to.
  74596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74597. * @param engine The engine which the post process will be applied. (default: current engine)
  74598. * @param reusable If the post process can be reused on the same frame. (default: false)
  74599. * @param textureType Type of textures used when performing the post process. (default: 0)
  74600. * @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)
  74601. */
  74602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74603. /** @hidden */
  74604. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74605. }
  74606. }
  74607. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74608. import { Nullable } from "babylonjs/types";
  74609. import { Camera } from "babylonjs/Cameras/camera";
  74610. import { Engine } from "babylonjs/Engines/engine";
  74611. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74612. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74613. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74614. /**
  74615. * PostProcessRenderPipeline
  74616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74617. */
  74618. export class PostProcessRenderPipeline {
  74619. private engine;
  74620. private _renderEffects;
  74621. private _renderEffectsForIsolatedPass;
  74622. /**
  74623. * List of inspectable custom properties (used by the Inspector)
  74624. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74625. */
  74626. inspectableCustomProperties: IInspectable[];
  74627. /**
  74628. * @hidden
  74629. */
  74630. protected _cameras: Camera[];
  74631. /** @hidden */
  74632. _name: string;
  74633. /**
  74634. * Gets pipeline name
  74635. */
  74636. get name(): string;
  74637. /** Gets the list of attached cameras */
  74638. get cameras(): Camera[];
  74639. /**
  74640. * Initializes a PostProcessRenderPipeline
  74641. * @param engine engine to add the pipeline to
  74642. * @param name name of the pipeline
  74643. */
  74644. constructor(engine: Engine, name: string);
  74645. /**
  74646. * Gets the class name
  74647. * @returns "PostProcessRenderPipeline"
  74648. */
  74649. getClassName(): string;
  74650. /**
  74651. * If all the render effects in the pipeline are supported
  74652. */
  74653. get isSupported(): boolean;
  74654. /**
  74655. * Adds an effect to the pipeline
  74656. * @param renderEffect the effect to add
  74657. */
  74658. addEffect(renderEffect: PostProcessRenderEffect): void;
  74659. /** @hidden */
  74660. _rebuild(): void;
  74661. /** @hidden */
  74662. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74663. /** @hidden */
  74664. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74665. /** @hidden */
  74666. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74667. /** @hidden */
  74668. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74669. /** @hidden */
  74670. _attachCameras(cameras: Camera, unique: boolean): void;
  74671. /** @hidden */
  74672. _attachCameras(cameras: Camera[], unique: boolean): void;
  74673. /** @hidden */
  74674. _detachCameras(cameras: Camera): void;
  74675. /** @hidden */
  74676. _detachCameras(cameras: Nullable<Camera[]>): void;
  74677. /** @hidden */
  74678. _update(): void;
  74679. /** @hidden */
  74680. _reset(): void;
  74681. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74682. /**
  74683. * Sets the required values to the prepass renderer.
  74684. * @param prePassRenderer defines the prepass renderer to setup.
  74685. * @returns true if the pre pass is needed.
  74686. */
  74687. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74688. /**
  74689. * Disposes of the pipeline
  74690. */
  74691. dispose(): void;
  74692. }
  74693. }
  74694. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74695. import { Camera } from "babylonjs/Cameras/camera";
  74696. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74697. /**
  74698. * PostProcessRenderPipelineManager class
  74699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74700. */
  74701. export class PostProcessRenderPipelineManager {
  74702. private _renderPipelines;
  74703. /**
  74704. * Initializes a PostProcessRenderPipelineManager
  74705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74706. */
  74707. constructor();
  74708. /**
  74709. * Gets the list of supported render pipelines
  74710. */
  74711. get supportedPipelines(): PostProcessRenderPipeline[];
  74712. /**
  74713. * Adds a pipeline to the manager
  74714. * @param renderPipeline The pipeline to add
  74715. */
  74716. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74717. /**
  74718. * Attaches a camera to the pipeline
  74719. * @param renderPipelineName The name of the pipeline to attach to
  74720. * @param cameras the camera to attach
  74721. * @param unique if the camera can be attached multiple times to the pipeline
  74722. */
  74723. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74724. /**
  74725. * Detaches a camera from the pipeline
  74726. * @param renderPipelineName The name of the pipeline to detach from
  74727. * @param cameras the camera to detach
  74728. */
  74729. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74730. /**
  74731. * Enables an effect by name on a pipeline
  74732. * @param renderPipelineName the name of the pipeline to enable the effect in
  74733. * @param renderEffectName the name of the effect to enable
  74734. * @param cameras the cameras that the effect should be enabled on
  74735. */
  74736. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74737. /**
  74738. * Disables an effect by name on a pipeline
  74739. * @param renderPipelineName the name of the pipeline to disable the effect in
  74740. * @param renderEffectName the name of the effect to disable
  74741. * @param cameras the cameras that the effect should be disabled on
  74742. */
  74743. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74744. /**
  74745. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74746. */
  74747. update(): void;
  74748. /** @hidden */
  74749. _rebuild(): void;
  74750. /**
  74751. * Disposes of the manager and pipelines
  74752. */
  74753. dispose(): void;
  74754. }
  74755. }
  74756. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74757. import { ISceneComponent } from "babylonjs/sceneComponent";
  74758. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74759. import { Scene } from "babylonjs/scene";
  74760. module "babylonjs/scene" {
  74761. interface Scene {
  74762. /** @hidden (Backing field) */
  74763. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74764. /**
  74765. * Gets the postprocess render pipeline manager
  74766. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74767. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74768. */
  74769. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74770. }
  74771. }
  74772. /**
  74773. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74774. */
  74775. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74776. /**
  74777. * The component name helpfull to identify the component in the list of scene components.
  74778. */
  74779. readonly name: string;
  74780. /**
  74781. * The scene the component belongs to.
  74782. */
  74783. scene: Scene;
  74784. /**
  74785. * Creates a new instance of the component for the given scene
  74786. * @param scene Defines the scene to register the component in
  74787. */
  74788. constructor(scene: Scene);
  74789. /**
  74790. * Registers the component in a given scene
  74791. */
  74792. register(): void;
  74793. /**
  74794. * Rebuilds the elements related to this component in case of
  74795. * context lost for instance.
  74796. */
  74797. rebuild(): void;
  74798. /**
  74799. * Disposes the component and the associated ressources
  74800. */
  74801. dispose(): void;
  74802. private _gatherRenderTargets;
  74803. }
  74804. }
  74805. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74806. import { Nullable } from "babylonjs/types";
  74807. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74808. import { Camera } from "babylonjs/Cameras/camera";
  74809. import { IDisposable } from "babylonjs/scene";
  74810. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74811. import { Scene } from "babylonjs/scene";
  74812. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74813. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74814. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74815. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74816. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74817. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74818. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74819. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74820. import { Animation } from "babylonjs/Animations/animation";
  74821. /**
  74822. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74823. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74824. */
  74825. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74826. private _scene;
  74827. private _camerasToBeAttached;
  74828. /**
  74829. * ID of the sharpen post process,
  74830. */
  74831. private readonly SharpenPostProcessId;
  74832. /**
  74833. * @ignore
  74834. * ID of the image processing post process;
  74835. */
  74836. readonly ImageProcessingPostProcessId: string;
  74837. /**
  74838. * @ignore
  74839. * ID of the Fast Approximate Anti-Aliasing post process;
  74840. */
  74841. readonly FxaaPostProcessId: string;
  74842. /**
  74843. * ID of the chromatic aberration post process,
  74844. */
  74845. private readonly ChromaticAberrationPostProcessId;
  74846. /**
  74847. * ID of the grain post process
  74848. */
  74849. private readonly GrainPostProcessId;
  74850. /**
  74851. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74852. */
  74853. sharpen: SharpenPostProcess;
  74854. private _sharpenEffect;
  74855. private bloom;
  74856. /**
  74857. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74858. */
  74859. depthOfField: DepthOfFieldEffect;
  74860. /**
  74861. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74862. */
  74863. fxaa: FxaaPostProcess;
  74864. /**
  74865. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74866. */
  74867. imageProcessing: ImageProcessingPostProcess;
  74868. /**
  74869. * Chromatic aberration post process which will shift rgb colors in the image
  74870. */
  74871. chromaticAberration: ChromaticAberrationPostProcess;
  74872. private _chromaticAberrationEffect;
  74873. /**
  74874. * Grain post process which add noise to the image
  74875. */
  74876. grain: GrainPostProcess;
  74877. private _grainEffect;
  74878. /**
  74879. * Glow post process which adds a glow to emissive areas of the image
  74880. */
  74881. private _glowLayer;
  74882. /**
  74883. * Animations which can be used to tweak settings over a period of time
  74884. */
  74885. animations: Animation[];
  74886. private _imageProcessingConfigurationObserver;
  74887. private _sharpenEnabled;
  74888. private _bloomEnabled;
  74889. private _depthOfFieldEnabled;
  74890. private _depthOfFieldBlurLevel;
  74891. private _fxaaEnabled;
  74892. private _imageProcessingEnabled;
  74893. private _defaultPipelineTextureType;
  74894. private _bloomScale;
  74895. private _chromaticAberrationEnabled;
  74896. private _grainEnabled;
  74897. private _buildAllowed;
  74898. /**
  74899. * Gets active scene
  74900. */
  74901. get scene(): Scene;
  74902. /**
  74903. * Enable or disable the sharpen process from the pipeline
  74904. */
  74905. set sharpenEnabled(enabled: boolean);
  74906. get sharpenEnabled(): boolean;
  74907. private _resizeObserver;
  74908. private _hardwareScaleLevel;
  74909. private _bloomKernel;
  74910. /**
  74911. * Specifies the size of the bloom blur kernel, relative to the final output size
  74912. */
  74913. get bloomKernel(): number;
  74914. set bloomKernel(value: number);
  74915. /**
  74916. * Specifies the weight of the bloom in the final rendering
  74917. */
  74918. private _bloomWeight;
  74919. /**
  74920. * Specifies the luma threshold for the area that will be blurred by the bloom
  74921. */
  74922. private _bloomThreshold;
  74923. private _hdr;
  74924. /**
  74925. * The strength of the bloom.
  74926. */
  74927. set bloomWeight(value: number);
  74928. get bloomWeight(): number;
  74929. /**
  74930. * The strength of the bloom.
  74931. */
  74932. set bloomThreshold(value: number);
  74933. get bloomThreshold(): number;
  74934. /**
  74935. * The scale of the bloom, lower value will provide better performance.
  74936. */
  74937. set bloomScale(value: number);
  74938. get bloomScale(): number;
  74939. /**
  74940. * Enable or disable the bloom from the pipeline
  74941. */
  74942. set bloomEnabled(enabled: boolean);
  74943. get bloomEnabled(): boolean;
  74944. private _rebuildBloom;
  74945. /**
  74946. * If the depth of field is enabled.
  74947. */
  74948. get depthOfFieldEnabled(): boolean;
  74949. set depthOfFieldEnabled(enabled: boolean);
  74950. /**
  74951. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74952. */
  74953. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74954. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74955. /**
  74956. * If the anti aliasing is enabled.
  74957. */
  74958. set fxaaEnabled(enabled: boolean);
  74959. get fxaaEnabled(): boolean;
  74960. private _samples;
  74961. /**
  74962. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74963. */
  74964. set samples(sampleCount: number);
  74965. get samples(): number;
  74966. /**
  74967. * If image processing is enabled.
  74968. */
  74969. set imageProcessingEnabled(enabled: boolean);
  74970. get imageProcessingEnabled(): boolean;
  74971. /**
  74972. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74973. */
  74974. set glowLayerEnabled(enabled: boolean);
  74975. get glowLayerEnabled(): boolean;
  74976. /**
  74977. * Gets the glow layer (or null if not defined)
  74978. */
  74979. get glowLayer(): Nullable<GlowLayer>;
  74980. /**
  74981. * Enable or disable the chromaticAberration process from the pipeline
  74982. */
  74983. set chromaticAberrationEnabled(enabled: boolean);
  74984. get chromaticAberrationEnabled(): boolean;
  74985. /**
  74986. * Enable or disable the grain process from the pipeline
  74987. */
  74988. set grainEnabled(enabled: boolean);
  74989. get grainEnabled(): boolean;
  74990. /**
  74991. * @constructor
  74992. * @param name - The rendering pipeline name (default: "")
  74993. * @param hdr - If high dynamic range textures should be used (default: true)
  74994. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74995. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74996. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74997. */
  74998. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74999. /**
  75000. * Get the class name
  75001. * @returns "DefaultRenderingPipeline"
  75002. */
  75003. getClassName(): string;
  75004. /**
  75005. * Force the compilation of the entire pipeline.
  75006. */
  75007. prepare(): void;
  75008. private _hasCleared;
  75009. private _prevPostProcess;
  75010. private _prevPrevPostProcess;
  75011. private _setAutoClearAndTextureSharing;
  75012. private _depthOfFieldSceneObserver;
  75013. private _buildPipeline;
  75014. private _disposePostProcesses;
  75015. /**
  75016. * Adds a camera to the pipeline
  75017. * @param camera the camera to be added
  75018. */
  75019. addCamera(camera: Camera): void;
  75020. /**
  75021. * Removes a camera from the pipeline
  75022. * @param camera the camera to remove
  75023. */
  75024. removeCamera(camera: Camera): void;
  75025. /**
  75026. * Dispose of the pipeline and stop all post processes
  75027. */
  75028. dispose(): void;
  75029. /**
  75030. * Serialize the rendering pipeline (Used when exporting)
  75031. * @returns the serialized object
  75032. */
  75033. serialize(): any;
  75034. /**
  75035. * Parse the serialized pipeline
  75036. * @param source Source pipeline.
  75037. * @param scene The scene to load the pipeline to.
  75038. * @param rootUrl The URL of the serialized pipeline.
  75039. * @returns An instantiated pipeline from the serialized object.
  75040. */
  75041. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75042. }
  75043. }
  75044. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75045. /** @hidden */
  75046. export var lensHighlightsPixelShader: {
  75047. name: string;
  75048. shader: string;
  75049. };
  75050. }
  75051. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75052. /** @hidden */
  75053. export var depthOfFieldPixelShader: {
  75054. name: string;
  75055. shader: string;
  75056. };
  75057. }
  75058. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75059. import { Camera } from "babylonjs/Cameras/camera";
  75060. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75061. import { Scene } from "babylonjs/scene";
  75062. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75063. import "babylonjs/Shaders/chromaticAberration.fragment";
  75064. import "babylonjs/Shaders/lensHighlights.fragment";
  75065. import "babylonjs/Shaders/depthOfField.fragment";
  75066. /**
  75067. * BABYLON.JS Chromatic Aberration GLSL Shader
  75068. * Author: Olivier Guyot
  75069. * Separates very slightly R, G and B colors on the edges of the screen
  75070. * Inspired by Francois Tarlier & Martins Upitis
  75071. */
  75072. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75073. /**
  75074. * @ignore
  75075. * The chromatic aberration PostProcess id in the pipeline
  75076. */
  75077. LensChromaticAberrationEffect: string;
  75078. /**
  75079. * @ignore
  75080. * The highlights enhancing PostProcess id in the pipeline
  75081. */
  75082. HighlightsEnhancingEffect: string;
  75083. /**
  75084. * @ignore
  75085. * The depth-of-field PostProcess id in the pipeline
  75086. */
  75087. LensDepthOfFieldEffect: string;
  75088. private _scene;
  75089. private _depthTexture;
  75090. private _grainTexture;
  75091. private _chromaticAberrationPostProcess;
  75092. private _highlightsPostProcess;
  75093. private _depthOfFieldPostProcess;
  75094. private _edgeBlur;
  75095. private _grainAmount;
  75096. private _chromaticAberration;
  75097. private _distortion;
  75098. private _highlightsGain;
  75099. private _highlightsThreshold;
  75100. private _dofDistance;
  75101. private _dofAperture;
  75102. private _dofDarken;
  75103. private _dofPentagon;
  75104. private _blurNoise;
  75105. /**
  75106. * @constructor
  75107. *
  75108. * Effect parameters are as follow:
  75109. * {
  75110. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75111. * edge_blur: number; // from 0 to x (1 for realism)
  75112. * distortion: number; // from 0 to x (1 for realism)
  75113. * grain_amount: number; // from 0 to 1
  75114. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75115. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75116. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75117. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75118. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75119. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75120. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75121. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75122. * }
  75123. * Note: if an effect parameter is unset, effect is disabled
  75124. *
  75125. * @param name The rendering pipeline name
  75126. * @param parameters - An object containing all parameters (see above)
  75127. * @param scene The scene linked to this pipeline
  75128. * @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)
  75129. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75130. */
  75131. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75132. /**
  75133. * Get the class name
  75134. * @returns "LensRenderingPipeline"
  75135. */
  75136. getClassName(): string;
  75137. /**
  75138. * Gets associated scene
  75139. */
  75140. get scene(): Scene;
  75141. /**
  75142. * Gets or sets the edge blur
  75143. */
  75144. get edgeBlur(): number;
  75145. set edgeBlur(value: number);
  75146. /**
  75147. * Gets or sets the grain amount
  75148. */
  75149. get grainAmount(): number;
  75150. set grainAmount(value: number);
  75151. /**
  75152. * Gets or sets the chromatic aberration amount
  75153. */
  75154. get chromaticAberration(): number;
  75155. set chromaticAberration(value: number);
  75156. /**
  75157. * Gets or sets the depth of field aperture
  75158. */
  75159. get dofAperture(): number;
  75160. set dofAperture(value: number);
  75161. /**
  75162. * Gets or sets the edge distortion
  75163. */
  75164. get edgeDistortion(): number;
  75165. set edgeDistortion(value: number);
  75166. /**
  75167. * Gets or sets the depth of field distortion
  75168. */
  75169. get dofDistortion(): number;
  75170. set dofDistortion(value: number);
  75171. /**
  75172. * Gets or sets the darken out of focus amount
  75173. */
  75174. get darkenOutOfFocus(): number;
  75175. set darkenOutOfFocus(value: number);
  75176. /**
  75177. * Gets or sets a boolean indicating if blur noise is enabled
  75178. */
  75179. get blurNoise(): boolean;
  75180. set blurNoise(value: boolean);
  75181. /**
  75182. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75183. */
  75184. get pentagonBokeh(): boolean;
  75185. set pentagonBokeh(value: boolean);
  75186. /**
  75187. * Gets or sets the highlight grain amount
  75188. */
  75189. get highlightsGain(): number;
  75190. set highlightsGain(value: number);
  75191. /**
  75192. * Gets or sets the highlight threshold
  75193. */
  75194. get highlightsThreshold(): number;
  75195. set highlightsThreshold(value: number);
  75196. /**
  75197. * Sets the amount of blur at the edges
  75198. * @param amount blur amount
  75199. */
  75200. setEdgeBlur(amount: number): void;
  75201. /**
  75202. * Sets edge blur to 0
  75203. */
  75204. disableEdgeBlur(): void;
  75205. /**
  75206. * Sets the amout of grain
  75207. * @param amount Amount of grain
  75208. */
  75209. setGrainAmount(amount: number): void;
  75210. /**
  75211. * Set grain amount to 0
  75212. */
  75213. disableGrain(): void;
  75214. /**
  75215. * Sets the chromatic aberration amount
  75216. * @param amount amount of chromatic aberration
  75217. */
  75218. setChromaticAberration(amount: number): void;
  75219. /**
  75220. * Sets chromatic aberration amount to 0
  75221. */
  75222. disableChromaticAberration(): void;
  75223. /**
  75224. * Sets the EdgeDistortion amount
  75225. * @param amount amount of EdgeDistortion
  75226. */
  75227. setEdgeDistortion(amount: number): void;
  75228. /**
  75229. * Sets edge distortion to 0
  75230. */
  75231. disableEdgeDistortion(): void;
  75232. /**
  75233. * Sets the FocusDistance amount
  75234. * @param amount amount of FocusDistance
  75235. */
  75236. setFocusDistance(amount: number): void;
  75237. /**
  75238. * Disables depth of field
  75239. */
  75240. disableDepthOfField(): void;
  75241. /**
  75242. * Sets the Aperture amount
  75243. * @param amount amount of Aperture
  75244. */
  75245. setAperture(amount: number): void;
  75246. /**
  75247. * Sets the DarkenOutOfFocus amount
  75248. * @param amount amount of DarkenOutOfFocus
  75249. */
  75250. setDarkenOutOfFocus(amount: number): void;
  75251. private _pentagonBokehIsEnabled;
  75252. /**
  75253. * Creates a pentagon bokeh effect
  75254. */
  75255. enablePentagonBokeh(): void;
  75256. /**
  75257. * Disables the pentagon bokeh effect
  75258. */
  75259. disablePentagonBokeh(): void;
  75260. /**
  75261. * Enables noise blur
  75262. */
  75263. enableNoiseBlur(): void;
  75264. /**
  75265. * Disables noise blur
  75266. */
  75267. disableNoiseBlur(): void;
  75268. /**
  75269. * Sets the HighlightsGain amount
  75270. * @param amount amount of HighlightsGain
  75271. */
  75272. setHighlightsGain(amount: number): void;
  75273. /**
  75274. * Sets the HighlightsThreshold amount
  75275. * @param amount amount of HighlightsThreshold
  75276. */
  75277. setHighlightsThreshold(amount: number): void;
  75278. /**
  75279. * Disables highlights
  75280. */
  75281. disableHighlights(): void;
  75282. /**
  75283. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75284. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75285. */
  75286. dispose(disableDepthRender?: boolean): void;
  75287. private _createChromaticAberrationPostProcess;
  75288. private _createHighlightsPostProcess;
  75289. private _createDepthOfFieldPostProcess;
  75290. private _createGrainTexture;
  75291. }
  75292. }
  75293. declare module "babylonjs/Rendering/ssao2Configuration" {
  75294. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75295. /**
  75296. * Contains all parameters needed for the prepass to perform
  75297. * screen space subsurface scattering
  75298. */
  75299. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75300. /**
  75301. * Is subsurface enabled
  75302. */
  75303. enabled: boolean;
  75304. /**
  75305. * Name of the configuration
  75306. */
  75307. name: string;
  75308. /**
  75309. * Textures that should be present in the MRT for this effect to work
  75310. */
  75311. readonly texturesRequired: number[];
  75312. }
  75313. }
  75314. declare module "babylonjs/Shaders/ssao2.fragment" {
  75315. /** @hidden */
  75316. export var ssao2PixelShader: {
  75317. name: string;
  75318. shader: string;
  75319. };
  75320. }
  75321. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75322. /** @hidden */
  75323. export var ssaoCombinePixelShader: {
  75324. name: string;
  75325. shader: string;
  75326. };
  75327. }
  75328. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75329. import { Camera } from "babylonjs/Cameras/camera";
  75330. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75331. import { Scene } from "babylonjs/scene";
  75332. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75333. import "babylonjs/Shaders/ssao2.fragment";
  75334. import "babylonjs/Shaders/ssaoCombine.fragment";
  75335. /**
  75336. * Render pipeline to produce ssao effect
  75337. */
  75338. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75339. /**
  75340. * @ignore
  75341. * The PassPostProcess id in the pipeline that contains the original scene color
  75342. */
  75343. SSAOOriginalSceneColorEffect: string;
  75344. /**
  75345. * @ignore
  75346. * The SSAO PostProcess id in the pipeline
  75347. */
  75348. SSAORenderEffect: string;
  75349. /**
  75350. * @ignore
  75351. * The horizontal blur PostProcess id in the pipeline
  75352. */
  75353. SSAOBlurHRenderEffect: string;
  75354. /**
  75355. * @ignore
  75356. * The vertical blur PostProcess id in the pipeline
  75357. */
  75358. SSAOBlurVRenderEffect: string;
  75359. /**
  75360. * @ignore
  75361. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75362. */
  75363. SSAOCombineRenderEffect: string;
  75364. /**
  75365. * The output strength of the SSAO post-process. Default value is 1.0.
  75366. */
  75367. totalStrength: number;
  75368. /**
  75369. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75370. */
  75371. maxZ: number;
  75372. /**
  75373. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75374. */
  75375. minZAspect: number;
  75376. private _samples;
  75377. /**
  75378. * Number of samples used for the SSAO calculations. Default value is 8
  75379. */
  75380. set samples(n: number);
  75381. get samples(): number;
  75382. private _textureSamples;
  75383. /**
  75384. * Number of samples to use for antialiasing
  75385. */
  75386. set textureSamples(n: number);
  75387. get textureSamples(): number;
  75388. /**
  75389. * Force rendering the geometry through geometry buffer
  75390. */
  75391. private _forceGeometryBuffer;
  75392. /**
  75393. * Ratio object used for SSAO ratio and blur ratio
  75394. */
  75395. private _ratio;
  75396. /**
  75397. * Dynamically generated sphere sampler.
  75398. */
  75399. private _sampleSphere;
  75400. /**
  75401. * Blur filter offsets
  75402. */
  75403. private _samplerOffsets;
  75404. private _expensiveBlur;
  75405. /**
  75406. * If bilateral blur should be used
  75407. */
  75408. set expensiveBlur(b: boolean);
  75409. get expensiveBlur(): boolean;
  75410. /**
  75411. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75412. */
  75413. radius: number;
  75414. /**
  75415. * The base color of the SSAO post-process
  75416. * The final result is "base + ssao" between [0, 1]
  75417. */
  75418. base: number;
  75419. /**
  75420. * Support test.
  75421. */
  75422. static get IsSupported(): boolean;
  75423. private _scene;
  75424. private _randomTexture;
  75425. private _originalColorPostProcess;
  75426. private _ssaoPostProcess;
  75427. private _blurHPostProcess;
  75428. private _blurVPostProcess;
  75429. private _ssaoCombinePostProcess;
  75430. private _prePassRenderer;
  75431. /**
  75432. * Gets active scene
  75433. */
  75434. get scene(): Scene;
  75435. /**
  75436. * @constructor
  75437. * @param name The rendering pipeline name
  75438. * @param scene The scene linked to this pipeline
  75439. * @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 }
  75440. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75441. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75442. */
  75443. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75444. /**
  75445. * Get the class name
  75446. * @returns "SSAO2RenderingPipeline"
  75447. */
  75448. getClassName(): string;
  75449. /**
  75450. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75451. */
  75452. dispose(disableGeometryBufferRenderer?: boolean): void;
  75453. private _createBlurPostProcess;
  75454. /** @hidden */
  75455. _rebuild(): void;
  75456. private _bits;
  75457. private _radicalInverse_VdC;
  75458. private _hammersley;
  75459. private _hemisphereSample_uniform;
  75460. private _generateHemisphere;
  75461. private _getDefinesForSSAO;
  75462. private _createSSAOPostProcess;
  75463. private _createSSAOCombinePostProcess;
  75464. private _createRandomTexture;
  75465. /**
  75466. * Serialize the rendering pipeline (Used when exporting)
  75467. * @returns the serialized object
  75468. */
  75469. serialize(): any;
  75470. /**
  75471. * Parse the serialized pipeline
  75472. * @param source Source pipeline.
  75473. * @param scene The scene to load the pipeline to.
  75474. * @param rootUrl The URL of the serialized pipeline.
  75475. * @returns An instantiated pipeline from the serialized object.
  75476. */
  75477. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75478. }
  75479. }
  75480. declare module "babylonjs/Shaders/ssao.fragment" {
  75481. /** @hidden */
  75482. export var ssaoPixelShader: {
  75483. name: string;
  75484. shader: string;
  75485. };
  75486. }
  75487. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75488. import { Camera } from "babylonjs/Cameras/camera";
  75489. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75490. import { Scene } from "babylonjs/scene";
  75491. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75492. import "babylonjs/Shaders/ssao.fragment";
  75493. import "babylonjs/Shaders/ssaoCombine.fragment";
  75494. /**
  75495. * Render pipeline to produce ssao effect
  75496. */
  75497. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75498. /**
  75499. * @ignore
  75500. * The PassPostProcess id in the pipeline that contains the original scene color
  75501. */
  75502. SSAOOriginalSceneColorEffect: string;
  75503. /**
  75504. * @ignore
  75505. * The SSAO PostProcess id in the pipeline
  75506. */
  75507. SSAORenderEffect: string;
  75508. /**
  75509. * @ignore
  75510. * The horizontal blur PostProcess id in the pipeline
  75511. */
  75512. SSAOBlurHRenderEffect: string;
  75513. /**
  75514. * @ignore
  75515. * The vertical blur PostProcess id in the pipeline
  75516. */
  75517. SSAOBlurVRenderEffect: string;
  75518. /**
  75519. * @ignore
  75520. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75521. */
  75522. SSAOCombineRenderEffect: string;
  75523. /**
  75524. * The output strength of the SSAO post-process. Default value is 1.0.
  75525. */
  75526. totalStrength: number;
  75527. /**
  75528. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75529. */
  75530. radius: number;
  75531. /**
  75532. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75533. * Must not be equal to fallOff and superior to fallOff.
  75534. * Default value is 0.0075
  75535. */
  75536. area: number;
  75537. /**
  75538. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75539. * Must not be equal to area and inferior to area.
  75540. * Default value is 0.000001
  75541. */
  75542. fallOff: number;
  75543. /**
  75544. * The base color of the SSAO post-process
  75545. * The final result is "base + ssao" between [0, 1]
  75546. */
  75547. base: number;
  75548. private _scene;
  75549. private _depthTexture;
  75550. private _randomTexture;
  75551. private _originalColorPostProcess;
  75552. private _ssaoPostProcess;
  75553. private _blurHPostProcess;
  75554. private _blurVPostProcess;
  75555. private _ssaoCombinePostProcess;
  75556. private _firstUpdate;
  75557. /**
  75558. * Gets active scene
  75559. */
  75560. get scene(): Scene;
  75561. /**
  75562. * @constructor
  75563. * @param name - The rendering pipeline name
  75564. * @param scene - The scene linked to this pipeline
  75565. * @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 }
  75566. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75567. */
  75568. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75569. /**
  75570. * Get the class name
  75571. * @returns "SSAORenderingPipeline"
  75572. */
  75573. getClassName(): string;
  75574. /**
  75575. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75576. */
  75577. dispose(disableDepthRender?: boolean): void;
  75578. private _createBlurPostProcess;
  75579. /** @hidden */
  75580. _rebuild(): void;
  75581. private _createSSAOPostProcess;
  75582. private _createSSAOCombinePostProcess;
  75583. private _createRandomTexture;
  75584. }
  75585. }
  75586. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75587. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75588. /**
  75589. * Contains all parameters needed for the prepass to perform
  75590. * screen space reflections
  75591. */
  75592. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75593. /**
  75594. * Is ssr enabled
  75595. */
  75596. enabled: boolean;
  75597. /**
  75598. * Name of the configuration
  75599. */
  75600. name: string;
  75601. /**
  75602. * Textures that should be present in the MRT for this effect to work
  75603. */
  75604. readonly texturesRequired: number[];
  75605. }
  75606. }
  75607. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75608. /** @hidden */
  75609. export var screenSpaceReflectionPixelShader: {
  75610. name: string;
  75611. shader: string;
  75612. };
  75613. }
  75614. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75615. import { Nullable } from "babylonjs/types";
  75616. import { Camera } from "babylonjs/Cameras/camera";
  75617. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75618. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75619. import { Engine } from "babylonjs/Engines/engine";
  75620. import { Scene } from "babylonjs/scene";
  75621. /**
  75622. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75623. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75624. */
  75625. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75626. /**
  75627. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75628. */
  75629. threshold: number;
  75630. /**
  75631. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75632. */
  75633. strength: number;
  75634. /**
  75635. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75636. */
  75637. reflectionSpecularFalloffExponent: number;
  75638. /**
  75639. * 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]
  75640. */
  75641. step: number;
  75642. /**
  75643. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75644. */
  75645. roughnessFactor: number;
  75646. private _forceGeometryBuffer;
  75647. private _geometryBufferRenderer;
  75648. private _prePassRenderer;
  75649. private _enableSmoothReflections;
  75650. private _reflectionSamples;
  75651. private _smoothSteps;
  75652. /**
  75653. * Gets a string identifying the name of the class
  75654. * @returns "ScreenSpaceReflectionPostProcess" string
  75655. */
  75656. getClassName(): string;
  75657. /**
  75658. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75659. * @param name The name of the effect.
  75660. * @param scene The scene containing the objects to calculate reflections.
  75661. * @param options The required width/height ratio to downsize to before computing the render pass.
  75662. * @param camera The camera to apply the render pass to.
  75663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75664. * @param engine The engine which the post process will be applied. (default: current engine)
  75665. * @param reusable If the post process can be reused on the same frame. (default: false)
  75666. * @param textureType Type of textures used when performing the post process. (default: 0)
  75667. * @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)
  75668. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75669. */
  75670. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75671. /**
  75672. * Gets wether or not smoothing reflections is enabled.
  75673. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75674. */
  75675. get enableSmoothReflections(): boolean;
  75676. /**
  75677. * Sets wether or not smoothing reflections is enabled.
  75678. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75679. */
  75680. set enableSmoothReflections(enabled: boolean);
  75681. /**
  75682. * Gets the number of samples taken while computing reflections. More samples count is high,
  75683. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75684. */
  75685. get reflectionSamples(): number;
  75686. /**
  75687. * Sets the number of samples taken while computing reflections. More samples count is high,
  75688. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75689. */
  75690. set reflectionSamples(samples: number);
  75691. /**
  75692. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75693. * more the post-process will require GPU power and can generate a drop in FPS.
  75694. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75695. */
  75696. get smoothSteps(): number;
  75697. set smoothSteps(steps: number);
  75698. private _updateEffectDefines;
  75699. /** @hidden */
  75700. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75701. }
  75702. }
  75703. declare module "babylonjs/Shaders/standard.fragment" {
  75704. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75705. /** @hidden */
  75706. export var standardPixelShader: {
  75707. name: string;
  75708. shader: string;
  75709. };
  75710. }
  75711. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75712. import { Nullable } from "babylonjs/types";
  75713. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75714. import { Camera } from "babylonjs/Cameras/camera";
  75715. import { Texture } from "babylonjs/Materials/Textures/texture";
  75716. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75717. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75718. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75719. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75720. import { IDisposable } from "babylonjs/scene";
  75721. import { SpotLight } from "babylonjs/Lights/spotLight";
  75722. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75723. import { Scene } from "babylonjs/scene";
  75724. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75725. import { Animation } from "babylonjs/Animations/animation";
  75726. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75727. import "babylonjs/Shaders/standard.fragment";
  75728. /**
  75729. * Standard rendering pipeline
  75730. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75731. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75732. */
  75733. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75734. /**
  75735. * Public members
  75736. */
  75737. /**
  75738. * Post-process which contains the original scene color before the pipeline applies all the effects
  75739. */
  75740. originalPostProcess: Nullable<PostProcess>;
  75741. /**
  75742. * Post-process used to down scale an image x4
  75743. */
  75744. downSampleX4PostProcess: Nullable<PostProcess>;
  75745. /**
  75746. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75747. */
  75748. brightPassPostProcess: Nullable<PostProcess>;
  75749. /**
  75750. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75751. */
  75752. blurHPostProcesses: PostProcess[];
  75753. /**
  75754. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75755. */
  75756. blurVPostProcesses: PostProcess[];
  75757. /**
  75758. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75759. */
  75760. textureAdderPostProcess: Nullable<PostProcess>;
  75761. /**
  75762. * Post-process used to create volumetric lighting effect
  75763. */
  75764. volumetricLightPostProcess: Nullable<PostProcess>;
  75765. /**
  75766. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75767. */
  75768. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75769. /**
  75770. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75771. */
  75772. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75773. /**
  75774. * Post-process used to merge the volumetric light effect and the real scene color
  75775. */
  75776. volumetricLightMergePostProces: Nullable<PostProcess>;
  75777. /**
  75778. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75779. */
  75780. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75781. /**
  75782. * Base post-process used to calculate the average luminance of the final image for HDR
  75783. */
  75784. luminancePostProcess: Nullable<PostProcess>;
  75785. /**
  75786. * Post-processes used to create down sample post-processes in order to get
  75787. * the average luminance of the final image for HDR
  75788. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75789. */
  75790. luminanceDownSamplePostProcesses: PostProcess[];
  75791. /**
  75792. * Post-process used to create a HDR effect (light adaptation)
  75793. */
  75794. hdrPostProcess: Nullable<PostProcess>;
  75795. /**
  75796. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75797. */
  75798. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75799. /**
  75800. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75801. */
  75802. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75803. /**
  75804. * Post-process used to merge the final HDR post-process and the real scene color
  75805. */
  75806. hdrFinalPostProcess: Nullable<PostProcess>;
  75807. /**
  75808. * Post-process used to create a lens flare effect
  75809. */
  75810. lensFlarePostProcess: Nullable<PostProcess>;
  75811. /**
  75812. * Post-process that merges the result of the lens flare post-process and the real scene color
  75813. */
  75814. lensFlareComposePostProcess: Nullable<PostProcess>;
  75815. /**
  75816. * Post-process used to create a motion blur effect
  75817. */
  75818. motionBlurPostProcess: Nullable<PostProcess>;
  75819. /**
  75820. * Post-process used to create a depth of field effect
  75821. */
  75822. depthOfFieldPostProcess: Nullable<PostProcess>;
  75823. /**
  75824. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75825. */
  75826. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75827. /**
  75828. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75829. */
  75830. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75831. /**
  75832. * Represents the brightness threshold in order to configure the illuminated surfaces
  75833. */
  75834. brightThreshold: number;
  75835. /**
  75836. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75837. */
  75838. blurWidth: number;
  75839. /**
  75840. * Sets if the blur for highlighted surfaces must be only horizontal
  75841. */
  75842. horizontalBlur: boolean;
  75843. /**
  75844. * Gets the overall exposure used by the pipeline
  75845. */
  75846. get exposure(): number;
  75847. /**
  75848. * Sets the overall exposure used by the pipeline
  75849. */
  75850. set exposure(value: number);
  75851. /**
  75852. * Texture used typically to simulate "dirty" on camera lens
  75853. */
  75854. lensTexture: Nullable<Texture>;
  75855. /**
  75856. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75857. */
  75858. volumetricLightCoefficient: number;
  75859. /**
  75860. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75861. */
  75862. volumetricLightPower: number;
  75863. /**
  75864. * Used the set the blur intensity to smooth the volumetric lights
  75865. */
  75866. volumetricLightBlurScale: number;
  75867. /**
  75868. * Light (spot or directional) used to generate the volumetric lights rays
  75869. * The source light must have a shadow generate so the pipeline can get its
  75870. * depth map
  75871. */
  75872. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75873. /**
  75874. * For eye adaptation, represents the minimum luminance the eye can see
  75875. */
  75876. hdrMinimumLuminance: number;
  75877. /**
  75878. * For eye adaptation, represents the decrease luminance speed
  75879. */
  75880. hdrDecreaseRate: number;
  75881. /**
  75882. * For eye adaptation, represents the increase luminance speed
  75883. */
  75884. hdrIncreaseRate: number;
  75885. /**
  75886. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75887. */
  75888. get hdrAutoExposure(): boolean;
  75889. /**
  75890. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75891. */
  75892. set hdrAutoExposure(value: boolean);
  75893. /**
  75894. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75895. */
  75896. lensColorTexture: Nullable<Texture>;
  75897. /**
  75898. * The overall strengh for the lens flare effect
  75899. */
  75900. lensFlareStrength: number;
  75901. /**
  75902. * Dispersion coefficient for lens flare ghosts
  75903. */
  75904. lensFlareGhostDispersal: number;
  75905. /**
  75906. * Main lens flare halo width
  75907. */
  75908. lensFlareHaloWidth: number;
  75909. /**
  75910. * Based on the lens distortion effect, defines how much the lens flare result
  75911. * is distorted
  75912. */
  75913. lensFlareDistortionStrength: number;
  75914. /**
  75915. * Configures the blur intensity used for for lens flare (halo)
  75916. */
  75917. lensFlareBlurWidth: number;
  75918. /**
  75919. * Lens star texture must be used to simulate rays on the flares and is available
  75920. * in the documentation
  75921. */
  75922. lensStarTexture: Nullable<Texture>;
  75923. /**
  75924. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75925. * flare effect by taking account of the dirt texture
  75926. */
  75927. lensFlareDirtTexture: Nullable<Texture>;
  75928. /**
  75929. * Represents the focal length for the depth of field effect
  75930. */
  75931. depthOfFieldDistance: number;
  75932. /**
  75933. * Represents the blur intensity for the blurred part of the depth of field effect
  75934. */
  75935. depthOfFieldBlurWidth: number;
  75936. /**
  75937. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75938. */
  75939. get motionStrength(): number;
  75940. /**
  75941. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75942. */
  75943. set motionStrength(strength: number);
  75944. /**
  75945. * Gets wether or not the motion blur post-process is object based or screen based.
  75946. */
  75947. get objectBasedMotionBlur(): boolean;
  75948. /**
  75949. * Sets wether or not the motion blur post-process should be object based or screen based
  75950. */
  75951. set objectBasedMotionBlur(value: boolean);
  75952. /**
  75953. * List of animations for the pipeline (IAnimatable implementation)
  75954. */
  75955. animations: Animation[];
  75956. /**
  75957. * Private members
  75958. */
  75959. private _scene;
  75960. private _currentDepthOfFieldSource;
  75961. private _basePostProcess;
  75962. private _fixedExposure;
  75963. private _currentExposure;
  75964. private _hdrAutoExposure;
  75965. private _hdrCurrentLuminance;
  75966. private _motionStrength;
  75967. private _isObjectBasedMotionBlur;
  75968. private _floatTextureType;
  75969. private _camerasToBeAttached;
  75970. private _ratio;
  75971. private _bloomEnabled;
  75972. private _depthOfFieldEnabled;
  75973. private _vlsEnabled;
  75974. private _lensFlareEnabled;
  75975. private _hdrEnabled;
  75976. private _motionBlurEnabled;
  75977. private _fxaaEnabled;
  75978. private _screenSpaceReflectionsEnabled;
  75979. private _motionBlurSamples;
  75980. private _volumetricLightStepsCount;
  75981. private _samples;
  75982. /**
  75983. * @ignore
  75984. * Specifies if the bloom pipeline is enabled
  75985. */
  75986. get BloomEnabled(): boolean;
  75987. set BloomEnabled(enabled: boolean);
  75988. /**
  75989. * @ignore
  75990. * Specifies if the depth of field pipeline is enabed
  75991. */
  75992. get DepthOfFieldEnabled(): boolean;
  75993. set DepthOfFieldEnabled(enabled: boolean);
  75994. /**
  75995. * @ignore
  75996. * Specifies if the lens flare pipeline is enabed
  75997. */
  75998. get LensFlareEnabled(): boolean;
  75999. set LensFlareEnabled(enabled: boolean);
  76000. /**
  76001. * @ignore
  76002. * Specifies if the HDR pipeline is enabled
  76003. */
  76004. get HDREnabled(): boolean;
  76005. set HDREnabled(enabled: boolean);
  76006. /**
  76007. * @ignore
  76008. * Specifies if the volumetric lights scattering effect is enabled
  76009. */
  76010. get VLSEnabled(): boolean;
  76011. set VLSEnabled(enabled: boolean);
  76012. /**
  76013. * @ignore
  76014. * Specifies if the motion blur effect is enabled
  76015. */
  76016. get MotionBlurEnabled(): boolean;
  76017. set MotionBlurEnabled(enabled: boolean);
  76018. /**
  76019. * Specifies if anti-aliasing is enabled
  76020. */
  76021. get fxaaEnabled(): boolean;
  76022. set fxaaEnabled(enabled: boolean);
  76023. /**
  76024. * Specifies if screen space reflections are enabled.
  76025. */
  76026. get screenSpaceReflectionsEnabled(): boolean;
  76027. set screenSpaceReflectionsEnabled(enabled: boolean);
  76028. /**
  76029. * Specifies the number of steps used to calculate the volumetric lights
  76030. * Typically in interval [50, 200]
  76031. */
  76032. get volumetricLightStepsCount(): number;
  76033. set volumetricLightStepsCount(count: number);
  76034. /**
  76035. * Specifies the number of samples used for the motion blur effect
  76036. * Typically in interval [16, 64]
  76037. */
  76038. get motionBlurSamples(): number;
  76039. set motionBlurSamples(samples: number);
  76040. /**
  76041. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76042. */
  76043. get samples(): number;
  76044. set samples(sampleCount: number);
  76045. /**
  76046. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76047. * @constructor
  76048. * @param name The rendering pipeline name
  76049. * @param scene The scene linked to this pipeline
  76050. * @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)
  76051. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76052. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76053. */
  76054. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76055. private _buildPipeline;
  76056. private _createDownSampleX4PostProcess;
  76057. private _createBrightPassPostProcess;
  76058. private _createBlurPostProcesses;
  76059. private _createTextureAdderPostProcess;
  76060. private _createVolumetricLightPostProcess;
  76061. private _createLuminancePostProcesses;
  76062. private _createHdrPostProcess;
  76063. private _createLensFlarePostProcess;
  76064. private _createDepthOfFieldPostProcess;
  76065. private _createMotionBlurPostProcess;
  76066. private _getDepthTexture;
  76067. private _disposePostProcesses;
  76068. /**
  76069. * Dispose of the pipeline and stop all post processes
  76070. */
  76071. dispose(): void;
  76072. /**
  76073. * Serialize the rendering pipeline (Used when exporting)
  76074. * @returns the serialized object
  76075. */
  76076. serialize(): any;
  76077. /**
  76078. * Parse the serialized pipeline
  76079. * @param source Source pipeline.
  76080. * @param scene The scene to load the pipeline to.
  76081. * @param rootUrl The URL of the serialized pipeline.
  76082. * @returns An instantiated pipeline from the serialized object.
  76083. */
  76084. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76085. /**
  76086. * Luminance steps
  76087. */
  76088. static LuminanceSteps: number;
  76089. }
  76090. }
  76091. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76092. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76093. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76094. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76095. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76096. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76097. }
  76098. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76099. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76100. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76101. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76102. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76103. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76104. }
  76105. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76106. /** @hidden */
  76107. export var stereoscopicInterlacePixelShader: {
  76108. name: string;
  76109. shader: string;
  76110. };
  76111. }
  76112. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76113. import { Camera } from "babylonjs/Cameras/camera";
  76114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76115. import { Engine } from "babylonjs/Engines/engine";
  76116. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76117. /**
  76118. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76119. */
  76120. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76121. private _stepSize;
  76122. private _passedProcess;
  76123. /**
  76124. * Gets a string identifying the name of the class
  76125. * @returns "StereoscopicInterlacePostProcessI" string
  76126. */
  76127. getClassName(): string;
  76128. /**
  76129. * Initializes a StereoscopicInterlacePostProcessI
  76130. * @param name The name of the effect.
  76131. * @param rigCameras The rig cameras to be appled to the post process
  76132. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76133. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76135. * @param engine The engine which the post process will be applied. (default: current engine)
  76136. * @param reusable If the post process can be reused on the same frame. (default: false)
  76137. */
  76138. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76139. }
  76140. /**
  76141. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76142. */
  76143. export class StereoscopicInterlacePostProcess extends PostProcess {
  76144. private _stepSize;
  76145. private _passedProcess;
  76146. /**
  76147. * Gets a string identifying the name of the class
  76148. * @returns "StereoscopicInterlacePostProcess" string
  76149. */
  76150. getClassName(): string;
  76151. /**
  76152. * Initializes a StereoscopicInterlacePostProcess
  76153. * @param name The name of the effect.
  76154. * @param rigCameras The rig cameras to be appled to the post process
  76155. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76157. * @param engine The engine which the post process will be applied. (default: current engine)
  76158. * @param reusable If the post process can be reused on the same frame. (default: false)
  76159. */
  76160. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76161. }
  76162. }
  76163. declare module "babylonjs/Shaders/tonemap.fragment" {
  76164. /** @hidden */
  76165. export var tonemapPixelShader: {
  76166. name: string;
  76167. shader: string;
  76168. };
  76169. }
  76170. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76171. import { Camera } from "babylonjs/Cameras/camera";
  76172. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76173. import "babylonjs/Shaders/tonemap.fragment";
  76174. import { Engine } from "babylonjs/Engines/engine";
  76175. /** Defines operator used for tonemapping */
  76176. export enum TonemappingOperator {
  76177. /** Hable */
  76178. Hable = 0,
  76179. /** Reinhard */
  76180. Reinhard = 1,
  76181. /** HejiDawson */
  76182. HejiDawson = 2,
  76183. /** Photographic */
  76184. Photographic = 3
  76185. }
  76186. /**
  76187. * Defines a post process to apply tone mapping
  76188. */
  76189. export class TonemapPostProcess extends PostProcess {
  76190. private _operator;
  76191. /** Defines the required exposure adjustement */
  76192. exposureAdjustment: number;
  76193. /**
  76194. * Gets a string identifying the name of the class
  76195. * @returns "TonemapPostProcess" string
  76196. */
  76197. getClassName(): string;
  76198. /**
  76199. * Creates a new TonemapPostProcess
  76200. * @param name defines the name of the postprocess
  76201. * @param _operator defines the operator to use
  76202. * @param exposureAdjustment defines the required exposure adjustement
  76203. * @param camera defines the camera to use (can be null)
  76204. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76205. * @param engine defines the hosting engine (can be ignore if camera is set)
  76206. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76207. */
  76208. constructor(name: string, _operator: TonemappingOperator,
  76209. /** Defines the required exposure adjustement */
  76210. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76211. }
  76212. }
  76213. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76214. /** @hidden */
  76215. export var volumetricLightScatteringPixelShader: {
  76216. name: string;
  76217. shader: string;
  76218. };
  76219. }
  76220. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76223. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76224. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76226. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76227. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76228. /** @hidden */
  76229. export var volumetricLightScatteringPassVertexShader: {
  76230. name: string;
  76231. shader: string;
  76232. };
  76233. }
  76234. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76235. /** @hidden */
  76236. export var volumetricLightScatteringPassPixelShader: {
  76237. name: string;
  76238. shader: string;
  76239. };
  76240. }
  76241. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76242. import { Vector3 } from "babylonjs/Maths/math.vector";
  76243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76244. import { Mesh } from "babylonjs/Meshes/mesh";
  76245. import { Camera } from "babylonjs/Cameras/camera";
  76246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76248. import { Scene } from "babylonjs/scene";
  76249. import "babylonjs/Meshes/Builders/planeBuilder";
  76250. import "babylonjs/Shaders/depth.vertex";
  76251. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76252. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76253. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76254. import { Engine } from "babylonjs/Engines/engine";
  76255. /**
  76256. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76257. */
  76258. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76259. private _volumetricLightScatteringPass;
  76260. private _volumetricLightScatteringRTT;
  76261. private _viewPort;
  76262. private _screenCoordinates;
  76263. private _cachedDefines;
  76264. /**
  76265. * If not undefined, the mesh position is computed from the attached node position
  76266. */
  76267. attachedNode: {
  76268. position: Vector3;
  76269. };
  76270. /**
  76271. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76272. */
  76273. customMeshPosition: Vector3;
  76274. /**
  76275. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76276. */
  76277. useCustomMeshPosition: boolean;
  76278. /**
  76279. * If the post-process should inverse the light scattering direction
  76280. */
  76281. invert: boolean;
  76282. /**
  76283. * The internal mesh used by the post-process
  76284. */
  76285. mesh: Mesh;
  76286. /**
  76287. * @hidden
  76288. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76289. */
  76290. get useDiffuseColor(): boolean;
  76291. set useDiffuseColor(useDiffuseColor: boolean);
  76292. /**
  76293. * Array containing the excluded meshes not rendered in the internal pass
  76294. */
  76295. excludedMeshes: AbstractMesh[];
  76296. /**
  76297. * Controls the overall intensity of the post-process
  76298. */
  76299. exposure: number;
  76300. /**
  76301. * Dissipates each sample's contribution in range [0, 1]
  76302. */
  76303. decay: number;
  76304. /**
  76305. * Controls the overall intensity of each sample
  76306. */
  76307. weight: number;
  76308. /**
  76309. * Controls the density of each sample
  76310. */
  76311. density: number;
  76312. /**
  76313. * @constructor
  76314. * @param name The post-process name
  76315. * @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)
  76316. * @param camera The camera that the post-process will be attached to
  76317. * @param mesh The mesh used to create the light scattering
  76318. * @param samples The post-process quality, default 100
  76319. * @param samplingModeThe post-process filtering mode
  76320. * @param engine The babylon engine
  76321. * @param reusable If the post-process is reusable
  76322. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76323. */
  76324. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76325. /**
  76326. * Returns the string "VolumetricLightScatteringPostProcess"
  76327. * @returns "VolumetricLightScatteringPostProcess"
  76328. */
  76329. getClassName(): string;
  76330. private _isReady;
  76331. /**
  76332. * Sets the new light position for light scattering effect
  76333. * @param position The new custom light position
  76334. */
  76335. setCustomMeshPosition(position: Vector3): void;
  76336. /**
  76337. * Returns the light position for light scattering effect
  76338. * @return Vector3 The custom light position
  76339. */
  76340. getCustomMeshPosition(): Vector3;
  76341. /**
  76342. * Disposes the internal assets and detaches the post-process from the camera
  76343. */
  76344. dispose(camera: Camera): void;
  76345. /**
  76346. * Returns the render target texture used by the post-process
  76347. * @return the render target texture used by the post-process
  76348. */
  76349. getPass(): RenderTargetTexture;
  76350. private _meshExcluded;
  76351. private _createPass;
  76352. private _updateMeshScreenCoordinates;
  76353. /**
  76354. * Creates a default mesh for the Volumeric Light Scattering post-process
  76355. * @param name The mesh name
  76356. * @param scene The scene where to create the mesh
  76357. * @return the default mesh
  76358. */
  76359. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76360. }
  76361. }
  76362. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76363. /** @hidden */
  76364. export var screenSpaceCurvaturePixelShader: {
  76365. name: string;
  76366. shader: string;
  76367. };
  76368. }
  76369. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76370. import { Nullable } from "babylonjs/types";
  76371. import { Camera } from "babylonjs/Cameras/camera";
  76372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76373. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76374. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76375. import { Engine } from "babylonjs/Engines/engine";
  76376. import { Scene } from "babylonjs/scene";
  76377. /**
  76378. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76379. */
  76380. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76381. /**
  76382. * Defines how much ridge the curvature effect displays.
  76383. */
  76384. ridge: number;
  76385. /**
  76386. * Defines how much valley the curvature effect displays.
  76387. */
  76388. valley: number;
  76389. private _geometryBufferRenderer;
  76390. /**
  76391. * Gets a string identifying the name of the class
  76392. * @returns "ScreenSpaceCurvaturePostProcess" string
  76393. */
  76394. getClassName(): string;
  76395. /**
  76396. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76397. * @param name The name of the effect.
  76398. * @param scene The scene containing the objects to blur according to their velocity.
  76399. * @param options The required width/height ratio to downsize to before computing the render pass.
  76400. * @param camera The camera to apply the render pass to.
  76401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76402. * @param engine The engine which the post process will be applied. (default: current engine)
  76403. * @param reusable If the post process can be reused on the same frame. (default: false)
  76404. * @param textureType Type of textures used when performing the post process. (default: 0)
  76405. * @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)
  76406. */
  76407. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76408. /**
  76409. * Support test.
  76410. */
  76411. static get IsSupported(): boolean;
  76412. /** @hidden */
  76413. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76414. }
  76415. }
  76416. declare module "babylonjs/PostProcesses/index" {
  76417. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76418. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76419. export * from "babylonjs/PostProcesses/bloomEffect";
  76420. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76421. export * from "babylonjs/PostProcesses/blurPostProcess";
  76422. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76423. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76424. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76425. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76426. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76427. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76428. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76429. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76430. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76431. export * from "babylonjs/PostProcesses/filterPostProcess";
  76432. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76433. export * from "babylonjs/PostProcesses/grainPostProcess";
  76434. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76435. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76436. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76437. export * from "babylonjs/PostProcesses/passPostProcess";
  76438. export * from "babylonjs/PostProcesses/postProcess";
  76439. export * from "babylonjs/PostProcesses/postProcessManager";
  76440. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76441. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76442. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76443. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76444. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76445. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76446. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76447. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76448. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76449. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76450. }
  76451. declare module "babylonjs/Probes/index" {
  76452. export * from "babylonjs/Probes/reflectionProbe";
  76453. }
  76454. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76455. import { Scene } from "babylonjs/scene";
  76456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76457. import { SmartArray } from "babylonjs/Misc/smartArray";
  76458. import { ISceneComponent } from "babylonjs/sceneComponent";
  76459. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76460. import "babylonjs/Meshes/Builders/boxBuilder";
  76461. import "babylonjs/Shaders/color.fragment";
  76462. import "babylonjs/Shaders/color.vertex";
  76463. import { Color3 } from "babylonjs/Maths/math.color";
  76464. import { Observable } from "babylonjs/Misc/observable";
  76465. module "babylonjs/scene" {
  76466. interface Scene {
  76467. /** @hidden (Backing field) */
  76468. _boundingBoxRenderer: BoundingBoxRenderer;
  76469. /** @hidden (Backing field) */
  76470. _forceShowBoundingBoxes: boolean;
  76471. /**
  76472. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76473. */
  76474. forceShowBoundingBoxes: boolean;
  76475. /**
  76476. * Gets the bounding box renderer associated with the scene
  76477. * @returns a BoundingBoxRenderer
  76478. */
  76479. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76480. }
  76481. }
  76482. module "babylonjs/Meshes/abstractMesh" {
  76483. interface AbstractMesh {
  76484. /** @hidden (Backing field) */
  76485. _showBoundingBox: boolean;
  76486. /**
  76487. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76488. */
  76489. showBoundingBox: boolean;
  76490. }
  76491. }
  76492. /**
  76493. * Component responsible of rendering the bounding box of the meshes in a scene.
  76494. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76495. */
  76496. export class BoundingBoxRenderer implements ISceneComponent {
  76497. /**
  76498. * The component name helpfull to identify the component in the list of scene components.
  76499. */
  76500. readonly name: string;
  76501. /**
  76502. * The scene the component belongs to.
  76503. */
  76504. scene: Scene;
  76505. /**
  76506. * Color of the bounding box lines placed in front of an object
  76507. */
  76508. frontColor: Color3;
  76509. /**
  76510. * Color of the bounding box lines placed behind an object
  76511. */
  76512. backColor: Color3;
  76513. /**
  76514. * Defines if the renderer should show the back lines or not
  76515. */
  76516. showBackLines: boolean;
  76517. /**
  76518. * Observable raised before rendering a bounding box
  76519. */
  76520. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76521. /**
  76522. * Observable raised after rendering a bounding box
  76523. */
  76524. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76525. /**
  76526. * @hidden
  76527. */
  76528. renderList: SmartArray<BoundingBox>;
  76529. private _colorShader;
  76530. private _vertexBuffers;
  76531. private _indexBuffer;
  76532. private _fillIndexBuffer;
  76533. private _fillIndexData;
  76534. /**
  76535. * Instantiates a new bounding box renderer in a scene.
  76536. * @param scene the scene the renderer renders in
  76537. */
  76538. constructor(scene: Scene);
  76539. /**
  76540. * Registers the component in a given scene
  76541. */
  76542. register(): void;
  76543. private _evaluateSubMesh;
  76544. private _activeMesh;
  76545. private _prepareRessources;
  76546. private _createIndexBuffer;
  76547. /**
  76548. * Rebuilds the elements related to this component in case of
  76549. * context lost for instance.
  76550. */
  76551. rebuild(): void;
  76552. /**
  76553. * @hidden
  76554. */
  76555. reset(): void;
  76556. /**
  76557. * Render the bounding boxes of a specific rendering group
  76558. * @param renderingGroupId defines the rendering group to render
  76559. */
  76560. render(renderingGroupId: number): void;
  76561. /**
  76562. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76563. * @param mesh Define the mesh to render the occlusion bounding box for
  76564. */
  76565. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76566. /**
  76567. * Dispose and release the resources attached to this renderer.
  76568. */
  76569. dispose(): void;
  76570. }
  76571. }
  76572. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76573. import { Nullable } from "babylonjs/types";
  76574. import { Scene } from "babylonjs/scene";
  76575. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76576. import { Camera } from "babylonjs/Cameras/camera";
  76577. import { ISceneComponent } from "babylonjs/sceneComponent";
  76578. module "babylonjs/scene" {
  76579. interface Scene {
  76580. /** @hidden (Backing field) */
  76581. _depthRenderer: {
  76582. [id: string]: DepthRenderer;
  76583. };
  76584. /**
  76585. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76586. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76587. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76588. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76589. * @returns the created depth renderer
  76590. */
  76591. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76592. /**
  76593. * Disables a depth renderer for a given camera
  76594. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76595. */
  76596. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76597. }
  76598. }
  76599. /**
  76600. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76601. * in several rendering techniques.
  76602. */
  76603. export class DepthRendererSceneComponent implements ISceneComponent {
  76604. /**
  76605. * The component name helpfull to identify the component in the list of scene components.
  76606. */
  76607. readonly name: string;
  76608. /**
  76609. * The scene the component belongs to.
  76610. */
  76611. scene: Scene;
  76612. /**
  76613. * Creates a new instance of the component for the given scene
  76614. * @param scene Defines the scene to register the component in
  76615. */
  76616. constructor(scene: Scene);
  76617. /**
  76618. * Registers the component in a given scene
  76619. */
  76620. register(): void;
  76621. /**
  76622. * Rebuilds the elements related to this component in case of
  76623. * context lost for instance.
  76624. */
  76625. rebuild(): void;
  76626. /**
  76627. * Disposes the component and the associated ressources
  76628. */
  76629. dispose(): void;
  76630. private _gatherRenderTargets;
  76631. private _gatherActiveCameraRenderTargets;
  76632. }
  76633. }
  76634. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76635. import { Nullable } from "babylonjs/types";
  76636. import { Scene } from "babylonjs/scene";
  76637. import { ISceneComponent } from "babylonjs/sceneComponent";
  76638. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76639. module "babylonjs/abstractScene" {
  76640. interface AbstractScene {
  76641. /** @hidden (Backing field) */
  76642. _prePassRenderer: Nullable<PrePassRenderer>;
  76643. /**
  76644. * Gets or Sets the current prepass renderer associated to the scene.
  76645. */
  76646. prePassRenderer: Nullable<PrePassRenderer>;
  76647. /**
  76648. * Enables the prepass and associates it with the scene
  76649. * @returns the PrePassRenderer
  76650. */
  76651. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76652. /**
  76653. * Disables the prepass associated with the scene
  76654. */
  76655. disablePrePassRenderer(): void;
  76656. }
  76657. }
  76658. /**
  76659. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76660. * in several rendering techniques.
  76661. */
  76662. export class PrePassRendererSceneComponent implements ISceneComponent {
  76663. /**
  76664. * The component name helpful to identify the component in the list of scene components.
  76665. */
  76666. readonly name: string;
  76667. /**
  76668. * The scene the component belongs to.
  76669. */
  76670. scene: Scene;
  76671. /**
  76672. * Creates a new instance of the component for the given scene
  76673. * @param scene Defines the scene to register the component in
  76674. */
  76675. constructor(scene: Scene);
  76676. /**
  76677. * Registers the component in a given scene
  76678. */
  76679. register(): void;
  76680. private _beforeCameraDraw;
  76681. private _afterCameraDraw;
  76682. private _beforeClearStage;
  76683. /**
  76684. * Rebuilds the elements related to this component in case of
  76685. * context lost for instance.
  76686. */
  76687. rebuild(): void;
  76688. /**
  76689. * Disposes the component and the associated ressources
  76690. */
  76691. dispose(): void;
  76692. }
  76693. }
  76694. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76695. /** @hidden */
  76696. export var fibonacci: {
  76697. name: string;
  76698. shader: string;
  76699. };
  76700. }
  76701. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76702. /** @hidden */
  76703. export var diffusionProfile: {
  76704. name: string;
  76705. shader: string;
  76706. };
  76707. }
  76708. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76709. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76710. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76711. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76712. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76713. /** @hidden */
  76714. export var subSurfaceScatteringPixelShader: {
  76715. name: string;
  76716. shader: string;
  76717. };
  76718. }
  76719. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76720. import { Nullable } from "babylonjs/types";
  76721. import { Camera } from "babylonjs/Cameras/camera";
  76722. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76723. import { Engine } from "babylonjs/Engines/engine";
  76724. import { Scene } from "babylonjs/scene";
  76725. import "babylonjs/Shaders/imageProcessing.fragment";
  76726. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76727. import "babylonjs/Shaders/postprocess.vertex";
  76728. /**
  76729. * Sub surface scattering post process
  76730. */
  76731. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76732. /**
  76733. * Gets a string identifying the name of the class
  76734. * @returns "SubSurfaceScatteringPostProcess" string
  76735. */
  76736. getClassName(): string;
  76737. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76738. }
  76739. }
  76740. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76741. import { Scene } from "babylonjs/scene";
  76742. import { Color3 } from "babylonjs/Maths/math.color";
  76743. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76744. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76745. /**
  76746. * Contains all parameters needed for the prepass to perform
  76747. * screen space subsurface scattering
  76748. */
  76749. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76750. /** @hidden */
  76751. static _SceneComponentInitialization: (scene: Scene) => void;
  76752. private _ssDiffusionS;
  76753. private _ssFilterRadii;
  76754. private _ssDiffusionD;
  76755. /**
  76756. * Post process to attach for screen space subsurface scattering
  76757. */
  76758. postProcess: SubSurfaceScatteringPostProcess;
  76759. /**
  76760. * Diffusion profile color for subsurface scattering
  76761. */
  76762. get ssDiffusionS(): number[];
  76763. /**
  76764. * Diffusion profile max color channel value for subsurface scattering
  76765. */
  76766. get ssDiffusionD(): number[];
  76767. /**
  76768. * Diffusion profile filter radius for subsurface scattering
  76769. */
  76770. get ssFilterRadii(): number[];
  76771. /**
  76772. * Is subsurface enabled
  76773. */
  76774. enabled: boolean;
  76775. /**
  76776. * Name of the configuration
  76777. */
  76778. name: string;
  76779. /**
  76780. * Diffusion profile colors for subsurface scattering
  76781. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76782. * See ...
  76783. * Note that you can only store up to 5 of them
  76784. */
  76785. ssDiffusionProfileColors: Color3[];
  76786. /**
  76787. * Defines the ratio real world => scene units.
  76788. * Used for subsurface scattering
  76789. */
  76790. metersPerUnit: number;
  76791. /**
  76792. * Textures that should be present in the MRT for this effect to work
  76793. */
  76794. readonly texturesRequired: number[];
  76795. private _scene;
  76796. /**
  76797. * Builds a subsurface configuration object
  76798. * @param scene The scene
  76799. */
  76800. constructor(scene: Scene);
  76801. /**
  76802. * Adds a new diffusion profile.
  76803. * Useful for more realistic subsurface scattering on diverse materials.
  76804. * @param color The color of the diffusion profile. Should be the average color of the material.
  76805. * @return The index of the diffusion profile for the material subsurface configuration
  76806. */
  76807. addDiffusionProfile(color: Color3): number;
  76808. /**
  76809. * Creates the sss post process
  76810. * @return The created post process
  76811. */
  76812. createPostProcess(): SubSurfaceScatteringPostProcess;
  76813. /**
  76814. * Deletes all diffusion profiles.
  76815. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76816. */
  76817. clearAllDiffusionProfiles(): void;
  76818. /**
  76819. * Disposes this object
  76820. */
  76821. dispose(): void;
  76822. /**
  76823. * @hidden
  76824. * https://zero-radiance.github.io/post/sampling-diffusion/
  76825. *
  76826. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76827. * ------------------------------------------------------------------------------------
  76828. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76829. * PDF[r, phi, s] = r * R[r, phi, s]
  76830. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76831. * ------------------------------------------------------------------------------------
  76832. * We importance sample the color channel with the widest scattering distance.
  76833. */
  76834. getDiffusionProfileParameters(color: Color3): number;
  76835. /**
  76836. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76837. * 'u' is the random number (the value of the CDF): [0, 1).
  76838. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76839. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76840. */
  76841. private _sampleBurleyDiffusionProfile;
  76842. }
  76843. }
  76844. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76845. import { Nullable } from "babylonjs/types";
  76846. import { Scene } from "babylonjs/scene";
  76847. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76848. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76849. import { AbstractScene } from "babylonjs/abstractScene";
  76850. module "babylonjs/abstractScene" {
  76851. interface AbstractScene {
  76852. /** @hidden (Backing field) */
  76853. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76854. /**
  76855. * Gets or Sets the current prepass renderer associated to the scene.
  76856. */
  76857. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76858. /**
  76859. * Enables the subsurface effect for prepass
  76860. * @returns the SubSurfaceConfiguration
  76861. */
  76862. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76863. /**
  76864. * Disables the subsurface effect for prepass
  76865. */
  76866. disableSubSurfaceForPrePass(): void;
  76867. }
  76868. }
  76869. /**
  76870. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76871. * in several rendering techniques.
  76872. */
  76873. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76874. /**
  76875. * The component name helpful to identify the component in the list of scene components.
  76876. */
  76877. readonly name: string;
  76878. /**
  76879. * The scene the component belongs to.
  76880. */
  76881. scene: Scene;
  76882. /**
  76883. * Creates a new instance of the component for the given scene
  76884. * @param scene Defines the scene to register the component in
  76885. */
  76886. constructor(scene: Scene);
  76887. /**
  76888. * Registers the component in a given scene
  76889. */
  76890. register(): void;
  76891. /**
  76892. * Serializes the component data to the specified json object
  76893. * @param serializationObject The object to serialize to
  76894. */
  76895. serialize(serializationObject: any): void;
  76896. /**
  76897. * Adds all the elements from the container to the scene
  76898. * @param container the container holding the elements
  76899. */
  76900. addFromContainer(container: AbstractScene): void;
  76901. /**
  76902. * Removes all the elements in the container from the scene
  76903. * @param container contains the elements to remove
  76904. * @param dispose if the removed element should be disposed (default: false)
  76905. */
  76906. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76907. /**
  76908. * Rebuilds the elements related to this component in case of
  76909. * context lost for instance.
  76910. */
  76911. rebuild(): void;
  76912. /**
  76913. * Disposes the component and the associated ressources
  76914. */
  76915. dispose(): void;
  76916. }
  76917. }
  76918. declare module "babylonjs/Shaders/outline.fragment" {
  76919. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76920. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76921. /** @hidden */
  76922. export var outlinePixelShader: {
  76923. name: string;
  76924. shader: string;
  76925. };
  76926. }
  76927. declare module "babylonjs/Shaders/outline.vertex" {
  76928. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76929. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76931. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76932. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76933. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76934. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76935. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76936. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76937. /** @hidden */
  76938. export var outlineVertexShader: {
  76939. name: string;
  76940. shader: string;
  76941. };
  76942. }
  76943. declare module "babylonjs/Rendering/outlineRenderer" {
  76944. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76945. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76946. import { Scene } from "babylonjs/scene";
  76947. import { ISceneComponent } from "babylonjs/sceneComponent";
  76948. import "babylonjs/Shaders/outline.fragment";
  76949. import "babylonjs/Shaders/outline.vertex";
  76950. module "babylonjs/scene" {
  76951. interface Scene {
  76952. /** @hidden */
  76953. _outlineRenderer: OutlineRenderer;
  76954. /**
  76955. * Gets the outline renderer associated with the scene
  76956. * @returns a OutlineRenderer
  76957. */
  76958. getOutlineRenderer(): OutlineRenderer;
  76959. }
  76960. }
  76961. module "babylonjs/Meshes/abstractMesh" {
  76962. interface AbstractMesh {
  76963. /** @hidden (Backing field) */
  76964. _renderOutline: boolean;
  76965. /**
  76966. * Gets or sets a boolean indicating if the outline must be rendered as well
  76967. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76968. */
  76969. renderOutline: boolean;
  76970. /** @hidden (Backing field) */
  76971. _renderOverlay: boolean;
  76972. /**
  76973. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76974. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76975. */
  76976. renderOverlay: boolean;
  76977. }
  76978. }
  76979. /**
  76980. * This class is responsible to draw bothe outline/overlay of meshes.
  76981. * It should not be used directly but through the available method on mesh.
  76982. */
  76983. export class OutlineRenderer implements ISceneComponent {
  76984. /**
  76985. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76986. */
  76987. private static _StencilReference;
  76988. /**
  76989. * The name of the component. Each component must have a unique name.
  76990. */
  76991. name: string;
  76992. /**
  76993. * The scene the component belongs to.
  76994. */
  76995. scene: Scene;
  76996. /**
  76997. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76998. */
  76999. zOffset: number;
  77000. private _engine;
  77001. private _effect;
  77002. private _cachedDefines;
  77003. private _savedDepthWrite;
  77004. /**
  77005. * Instantiates a new outline renderer. (There could be only one per scene).
  77006. * @param scene Defines the scene it belongs to
  77007. */
  77008. constructor(scene: Scene);
  77009. /**
  77010. * Register the component to one instance of a scene.
  77011. */
  77012. register(): void;
  77013. /**
  77014. * Rebuilds the elements related to this component in case of
  77015. * context lost for instance.
  77016. */
  77017. rebuild(): void;
  77018. /**
  77019. * Disposes the component and the associated ressources.
  77020. */
  77021. dispose(): void;
  77022. /**
  77023. * Renders the outline in the canvas.
  77024. * @param subMesh Defines the sumesh to render
  77025. * @param batch Defines the batch of meshes in case of instances
  77026. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77027. */
  77028. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77029. /**
  77030. * Returns whether or not the outline renderer is ready for a given submesh.
  77031. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77032. * @param subMesh Defines the submesh to check readyness for
  77033. * @param useInstances Defines wheter wee are trying to render instances or not
  77034. * @returns true if ready otherwise false
  77035. */
  77036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77037. private _beforeRenderingMesh;
  77038. private _afterRenderingMesh;
  77039. }
  77040. }
  77041. declare module "babylonjs/Rendering/index" {
  77042. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77043. export * from "babylonjs/Rendering/depthRenderer";
  77044. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77045. export * from "babylonjs/Rendering/edgesRenderer";
  77046. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77047. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77048. export * from "babylonjs/Rendering/prePassRenderer";
  77049. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77050. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77051. export * from "babylonjs/Rendering/outlineRenderer";
  77052. export * from "babylonjs/Rendering/renderingGroup";
  77053. export * from "babylonjs/Rendering/renderingManager";
  77054. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77055. }
  77056. declare module "babylonjs/Sprites/ISprites" {
  77057. /**
  77058. * Defines the basic options interface of a Sprite Frame Source Size.
  77059. */
  77060. export interface ISpriteJSONSpriteSourceSize {
  77061. /**
  77062. * number of the original width of the Frame
  77063. */
  77064. w: number;
  77065. /**
  77066. * number of the original height of the Frame
  77067. */
  77068. h: number;
  77069. }
  77070. /**
  77071. * Defines the basic options interface of a Sprite Frame Data.
  77072. */
  77073. export interface ISpriteJSONSpriteFrameData {
  77074. /**
  77075. * number of the x offset of the Frame
  77076. */
  77077. x: number;
  77078. /**
  77079. * number of the y offset of the Frame
  77080. */
  77081. y: number;
  77082. /**
  77083. * number of the width of the Frame
  77084. */
  77085. w: number;
  77086. /**
  77087. * number of the height of the Frame
  77088. */
  77089. h: number;
  77090. }
  77091. /**
  77092. * Defines the basic options interface of a JSON Sprite.
  77093. */
  77094. export interface ISpriteJSONSprite {
  77095. /**
  77096. * string name of the Frame
  77097. */
  77098. filename: string;
  77099. /**
  77100. * ISpriteJSONSpriteFrame basic object of the frame data
  77101. */
  77102. frame: ISpriteJSONSpriteFrameData;
  77103. /**
  77104. * boolean to flag is the frame was rotated.
  77105. */
  77106. rotated: boolean;
  77107. /**
  77108. * boolean to flag is the frame was trimmed.
  77109. */
  77110. trimmed: boolean;
  77111. /**
  77112. * ISpriteJSONSpriteFrame basic object of the source data
  77113. */
  77114. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77115. /**
  77116. * ISpriteJSONSpriteFrame basic object of the source data
  77117. */
  77118. sourceSize: ISpriteJSONSpriteSourceSize;
  77119. }
  77120. /**
  77121. * Defines the basic options interface of a JSON atlas.
  77122. */
  77123. export interface ISpriteJSONAtlas {
  77124. /**
  77125. * Array of objects that contain the frame data.
  77126. */
  77127. frames: Array<ISpriteJSONSprite>;
  77128. /**
  77129. * object basic object containing the sprite meta data.
  77130. */
  77131. meta?: object;
  77132. }
  77133. }
  77134. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77135. /** @hidden */
  77136. export var spriteMapPixelShader: {
  77137. name: string;
  77138. shader: string;
  77139. };
  77140. }
  77141. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77142. /** @hidden */
  77143. export var spriteMapVertexShader: {
  77144. name: string;
  77145. shader: string;
  77146. };
  77147. }
  77148. declare module "babylonjs/Sprites/spriteMap" {
  77149. import { IDisposable, Scene } from "babylonjs/scene";
  77150. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77151. import { Texture } from "babylonjs/Materials/Textures/texture";
  77152. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77153. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77154. import "babylonjs/Meshes/Builders/planeBuilder";
  77155. import "babylonjs/Shaders/spriteMap.fragment";
  77156. import "babylonjs/Shaders/spriteMap.vertex";
  77157. /**
  77158. * Defines the basic options interface of a SpriteMap
  77159. */
  77160. export interface ISpriteMapOptions {
  77161. /**
  77162. * Vector2 of the number of cells in the grid.
  77163. */
  77164. stageSize?: Vector2;
  77165. /**
  77166. * Vector2 of the size of the output plane in World Units.
  77167. */
  77168. outputSize?: Vector2;
  77169. /**
  77170. * Vector3 of the position of the output plane in World Units.
  77171. */
  77172. outputPosition?: Vector3;
  77173. /**
  77174. * Vector3 of the rotation of the output plane.
  77175. */
  77176. outputRotation?: Vector3;
  77177. /**
  77178. * number of layers that the system will reserve in resources.
  77179. */
  77180. layerCount?: number;
  77181. /**
  77182. * number of max animation frames a single cell will reserve in resources.
  77183. */
  77184. maxAnimationFrames?: number;
  77185. /**
  77186. * number cell index of the base tile when the system compiles.
  77187. */
  77188. baseTile?: number;
  77189. /**
  77190. * boolean flip the sprite after its been repositioned by the framing data.
  77191. */
  77192. flipU?: boolean;
  77193. /**
  77194. * Vector3 scalar of the global RGB values of the SpriteMap.
  77195. */
  77196. colorMultiply?: Vector3;
  77197. }
  77198. /**
  77199. * Defines the IDisposable interface in order to be cleanable from resources.
  77200. */
  77201. export interface ISpriteMap extends IDisposable {
  77202. /**
  77203. * String name of the SpriteMap.
  77204. */
  77205. name: string;
  77206. /**
  77207. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77208. */
  77209. atlasJSON: ISpriteJSONAtlas;
  77210. /**
  77211. * Texture of the SpriteMap.
  77212. */
  77213. spriteSheet: Texture;
  77214. /**
  77215. * The parameters to initialize the SpriteMap with.
  77216. */
  77217. options: ISpriteMapOptions;
  77218. }
  77219. /**
  77220. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77221. */
  77222. export class SpriteMap implements ISpriteMap {
  77223. /** The Name of the spriteMap */
  77224. name: string;
  77225. /** The JSON file with the frame and meta data */
  77226. atlasJSON: ISpriteJSONAtlas;
  77227. /** The systems Sprite Sheet Texture */
  77228. spriteSheet: Texture;
  77229. /** Arguments passed with the Constructor */
  77230. options: ISpriteMapOptions;
  77231. /** Public Sprite Storage array, parsed from atlasJSON */
  77232. sprites: Array<ISpriteJSONSprite>;
  77233. /** Returns the Number of Sprites in the System */
  77234. get spriteCount(): number;
  77235. /** Returns the Position of Output Plane*/
  77236. get position(): Vector3;
  77237. /** Returns the Position of Output Plane*/
  77238. set position(v: Vector3);
  77239. /** Returns the Rotation of Output Plane*/
  77240. get rotation(): Vector3;
  77241. /** Returns the Rotation of Output Plane*/
  77242. set rotation(v: Vector3);
  77243. /** Sets the AnimationMap*/
  77244. get animationMap(): RawTexture;
  77245. /** Sets the AnimationMap*/
  77246. set animationMap(v: RawTexture);
  77247. /** Scene that the SpriteMap was created in */
  77248. private _scene;
  77249. /** Texture Buffer of Float32 that holds tile frame data*/
  77250. private _frameMap;
  77251. /** Texture Buffers of Float32 that holds tileMap data*/
  77252. private _tileMaps;
  77253. /** Texture Buffer of Float32 that holds Animation Data*/
  77254. private _animationMap;
  77255. /** Custom ShaderMaterial Central to the System*/
  77256. private _material;
  77257. /** Custom ShaderMaterial Central to the System*/
  77258. private _output;
  77259. /** Systems Time Ticker*/
  77260. private _time;
  77261. /**
  77262. * Creates a new SpriteMap
  77263. * @param name defines the SpriteMaps Name
  77264. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77265. * @param spriteSheet is the Texture that the Sprites are on.
  77266. * @param options a basic deployment configuration
  77267. * @param scene The Scene that the map is deployed on
  77268. */
  77269. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77270. /**
  77271. * Returns tileID location
  77272. * @returns Vector2 the cell position ID
  77273. */
  77274. getTileID(): Vector2;
  77275. /**
  77276. * Gets the UV location of the mouse over the SpriteMap.
  77277. * @returns Vector2 the UV position of the mouse interaction
  77278. */
  77279. getMousePosition(): Vector2;
  77280. /**
  77281. * Creates the "frame" texture Buffer
  77282. * -------------------------------------
  77283. * Structure of frames
  77284. * "filename": "Falling-Water-2.png",
  77285. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77286. * "rotated": true,
  77287. * "trimmed": true,
  77288. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77289. * "sourceSize": {"w":32,"h":32}
  77290. * @returns RawTexture of the frameMap
  77291. */
  77292. private _createFrameBuffer;
  77293. /**
  77294. * Creates the tileMap texture Buffer
  77295. * @param buffer normally and array of numbers, or a false to generate from scratch
  77296. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77297. * @returns RawTexture of the tileMap
  77298. */
  77299. private _createTileBuffer;
  77300. /**
  77301. * Modifies the data of the tileMaps
  77302. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77303. * @param pos is the iVector2 Coordinates of the Tile
  77304. * @param tile The SpriteIndex of the new Tile
  77305. */
  77306. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77307. /**
  77308. * Creates the animationMap texture Buffer
  77309. * @param buffer normally and array of numbers, or a false to generate from scratch
  77310. * @returns RawTexture of the animationMap
  77311. */
  77312. private _createTileAnimationBuffer;
  77313. /**
  77314. * Modifies the data of the animationMap
  77315. * @param cellID is the Index of the Sprite
  77316. * @param _frame is the target Animation frame
  77317. * @param toCell is the Target Index of the next frame of the animation
  77318. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77319. * @param speed is a global scalar of the time variable on the map.
  77320. */
  77321. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77322. /**
  77323. * Exports the .tilemaps file
  77324. */
  77325. saveTileMaps(): void;
  77326. /**
  77327. * Imports the .tilemaps file
  77328. * @param url of the .tilemaps file
  77329. */
  77330. loadTileMaps(url: string): void;
  77331. /**
  77332. * Release associated resources
  77333. */
  77334. dispose(): void;
  77335. }
  77336. }
  77337. declare module "babylonjs/Sprites/spritePackedManager" {
  77338. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77339. import { Scene } from "babylonjs/scene";
  77340. /**
  77341. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77342. * @see https://doc.babylonjs.com/babylon101/sprites
  77343. */
  77344. export class SpritePackedManager extends SpriteManager {
  77345. /** defines the packed manager's name */
  77346. name: string;
  77347. /**
  77348. * Creates a new sprite manager from a packed sprite sheet
  77349. * @param name defines the manager's name
  77350. * @param imgUrl defines the sprite sheet url
  77351. * @param capacity defines the maximum allowed number of sprites
  77352. * @param scene defines the hosting scene
  77353. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77354. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77355. * @param samplingMode defines the smapling mode to use with spritesheet
  77356. * @param fromPacked set to true; do not alter
  77357. */
  77358. constructor(
  77359. /** defines the packed manager's name */
  77360. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77361. }
  77362. }
  77363. declare module "babylonjs/Sprites/index" {
  77364. export * from "babylonjs/Sprites/sprite";
  77365. export * from "babylonjs/Sprites/ISprites";
  77366. export * from "babylonjs/Sprites/spriteManager";
  77367. export * from "babylonjs/Sprites/spriteMap";
  77368. export * from "babylonjs/Sprites/spritePackedManager";
  77369. export * from "babylonjs/Sprites/spriteSceneComponent";
  77370. }
  77371. declare module "babylonjs/States/index" {
  77372. export * from "babylonjs/States/alphaCullingState";
  77373. export * from "babylonjs/States/depthCullingState";
  77374. export * from "babylonjs/States/stencilState";
  77375. }
  77376. declare module "babylonjs/Misc/assetsManager" {
  77377. import { Scene } from "babylonjs/scene";
  77378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77379. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77380. import { Skeleton } from "babylonjs/Bones/skeleton";
  77381. import { Observable } from "babylonjs/Misc/observable";
  77382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77383. import { Texture } from "babylonjs/Materials/Textures/texture";
  77384. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77385. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77386. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77387. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77388. import { AssetContainer } from "babylonjs/assetContainer";
  77389. /**
  77390. * Defines the list of states available for a task inside a AssetsManager
  77391. */
  77392. export enum AssetTaskState {
  77393. /**
  77394. * Initialization
  77395. */
  77396. INIT = 0,
  77397. /**
  77398. * Running
  77399. */
  77400. RUNNING = 1,
  77401. /**
  77402. * Done
  77403. */
  77404. DONE = 2,
  77405. /**
  77406. * Error
  77407. */
  77408. ERROR = 3
  77409. }
  77410. /**
  77411. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77412. */
  77413. export abstract class AbstractAssetTask {
  77414. /**
  77415. * Task name
  77416. */ name: string;
  77417. /**
  77418. * Callback called when the task is successful
  77419. */
  77420. onSuccess: (task: any) => void;
  77421. /**
  77422. * Callback called when the task is not successful
  77423. */
  77424. onError: (task: any, message?: string, exception?: any) => void;
  77425. /**
  77426. * Creates a new AssetsManager
  77427. * @param name defines the name of the task
  77428. */
  77429. constructor(
  77430. /**
  77431. * Task name
  77432. */ name: string);
  77433. private _isCompleted;
  77434. private _taskState;
  77435. private _errorObject;
  77436. /**
  77437. * Get if the task is completed
  77438. */
  77439. get isCompleted(): boolean;
  77440. /**
  77441. * Gets the current state of the task
  77442. */
  77443. get taskState(): AssetTaskState;
  77444. /**
  77445. * Gets the current error object (if task is in error)
  77446. */
  77447. get errorObject(): {
  77448. message?: string;
  77449. exception?: any;
  77450. };
  77451. /**
  77452. * Internal only
  77453. * @hidden
  77454. */
  77455. _setErrorObject(message?: string, exception?: any): void;
  77456. /**
  77457. * Execute the current task
  77458. * @param scene defines the scene where you want your assets to be loaded
  77459. * @param onSuccess is a callback called when the task is successfully executed
  77460. * @param onError is a callback called if an error occurs
  77461. */
  77462. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77463. /**
  77464. * Execute the current task
  77465. * @param scene defines the scene where you want your assets to be loaded
  77466. * @param onSuccess is a callback called when the task is successfully executed
  77467. * @param onError is a callback called if an error occurs
  77468. */
  77469. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77470. /**
  77471. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77472. * This can be used with failed tasks that have the reason for failure fixed.
  77473. */
  77474. reset(): void;
  77475. private onErrorCallback;
  77476. private onDoneCallback;
  77477. }
  77478. /**
  77479. * Define the interface used by progress events raised during assets loading
  77480. */
  77481. export interface IAssetsProgressEvent {
  77482. /**
  77483. * Defines the number of remaining tasks to process
  77484. */
  77485. remainingCount: number;
  77486. /**
  77487. * Defines the total number of tasks
  77488. */
  77489. totalCount: number;
  77490. /**
  77491. * Defines the task that was just processed
  77492. */
  77493. task: AbstractAssetTask;
  77494. }
  77495. /**
  77496. * Class used to share progress information about assets loading
  77497. */
  77498. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77499. /**
  77500. * Defines the number of remaining tasks to process
  77501. */
  77502. remainingCount: number;
  77503. /**
  77504. * Defines the total number of tasks
  77505. */
  77506. totalCount: number;
  77507. /**
  77508. * Defines the task that was just processed
  77509. */
  77510. task: AbstractAssetTask;
  77511. /**
  77512. * Creates a AssetsProgressEvent
  77513. * @param remainingCount defines the number of remaining tasks to process
  77514. * @param totalCount defines the total number of tasks
  77515. * @param task defines the task that was just processed
  77516. */
  77517. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77518. }
  77519. /**
  77520. * Define a task used by AssetsManager to load assets into a container
  77521. */
  77522. export class ContainerAssetTask extends AbstractAssetTask {
  77523. /**
  77524. * Defines the name of the task
  77525. */
  77526. name: string;
  77527. /**
  77528. * Defines the list of mesh's names you want to load
  77529. */
  77530. meshesNames: any;
  77531. /**
  77532. * Defines the root url to use as a base to load your meshes and associated resources
  77533. */
  77534. rootUrl: string;
  77535. /**
  77536. * Defines the filename or File of the scene to load from
  77537. */
  77538. sceneFilename: string | File;
  77539. /**
  77540. * Get the loaded asset container
  77541. */
  77542. loadedContainer: AssetContainer;
  77543. /**
  77544. * Gets the list of loaded meshes
  77545. */
  77546. loadedMeshes: Array<AbstractMesh>;
  77547. /**
  77548. * Gets the list of loaded particle systems
  77549. */
  77550. loadedParticleSystems: Array<IParticleSystem>;
  77551. /**
  77552. * Gets the list of loaded skeletons
  77553. */
  77554. loadedSkeletons: Array<Skeleton>;
  77555. /**
  77556. * Gets the list of loaded animation groups
  77557. */
  77558. loadedAnimationGroups: Array<AnimationGroup>;
  77559. /**
  77560. * Callback called when the task is successful
  77561. */
  77562. onSuccess: (task: ContainerAssetTask) => void;
  77563. /**
  77564. * Callback called when the task is successful
  77565. */
  77566. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77567. /**
  77568. * Creates a new ContainerAssetTask
  77569. * @param name defines the name of the task
  77570. * @param meshesNames defines the list of mesh's names you want to load
  77571. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77572. * @param sceneFilename defines the filename or File of the scene to load from
  77573. */
  77574. constructor(
  77575. /**
  77576. * Defines the name of the task
  77577. */
  77578. name: string,
  77579. /**
  77580. * Defines the list of mesh's names you want to load
  77581. */
  77582. meshesNames: any,
  77583. /**
  77584. * Defines the root url to use as a base to load your meshes and associated resources
  77585. */
  77586. rootUrl: string,
  77587. /**
  77588. * Defines the filename or File of the scene to load from
  77589. */
  77590. sceneFilename: string | File);
  77591. /**
  77592. * Execute the current task
  77593. * @param scene defines the scene where you want your assets to be loaded
  77594. * @param onSuccess is a callback called when the task is successfully executed
  77595. * @param onError is a callback called if an error occurs
  77596. */
  77597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77598. }
  77599. /**
  77600. * Define a task used by AssetsManager to load meshes
  77601. */
  77602. export class MeshAssetTask extends AbstractAssetTask {
  77603. /**
  77604. * Defines the name of the task
  77605. */
  77606. name: string;
  77607. /**
  77608. * Defines the list of mesh's names you want to load
  77609. */
  77610. meshesNames: any;
  77611. /**
  77612. * Defines the root url to use as a base to load your meshes and associated resources
  77613. */
  77614. rootUrl: string;
  77615. /**
  77616. * Defines the filename or File of the scene to load from
  77617. */
  77618. sceneFilename: string | File;
  77619. /**
  77620. * Gets the list of loaded meshes
  77621. */
  77622. loadedMeshes: Array<AbstractMesh>;
  77623. /**
  77624. * Gets the list of loaded particle systems
  77625. */
  77626. loadedParticleSystems: Array<IParticleSystem>;
  77627. /**
  77628. * Gets the list of loaded skeletons
  77629. */
  77630. loadedSkeletons: Array<Skeleton>;
  77631. /**
  77632. * Gets the list of loaded animation groups
  77633. */
  77634. loadedAnimationGroups: Array<AnimationGroup>;
  77635. /**
  77636. * Callback called when the task is successful
  77637. */
  77638. onSuccess: (task: MeshAssetTask) => void;
  77639. /**
  77640. * Callback called when the task is successful
  77641. */
  77642. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77643. /**
  77644. * Creates a new MeshAssetTask
  77645. * @param name defines the name of the task
  77646. * @param meshesNames defines the list of mesh's names you want to load
  77647. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77648. * @param sceneFilename defines the filename or File of the scene to load from
  77649. */
  77650. constructor(
  77651. /**
  77652. * Defines the name of the task
  77653. */
  77654. name: string,
  77655. /**
  77656. * Defines the list of mesh's names you want to load
  77657. */
  77658. meshesNames: any,
  77659. /**
  77660. * Defines the root url to use as a base to load your meshes and associated resources
  77661. */
  77662. rootUrl: string,
  77663. /**
  77664. * Defines the filename or File of the scene to load from
  77665. */
  77666. sceneFilename: string | File);
  77667. /**
  77668. * Execute the current task
  77669. * @param scene defines the scene where you want your assets to be loaded
  77670. * @param onSuccess is a callback called when the task is successfully executed
  77671. * @param onError is a callback called if an error occurs
  77672. */
  77673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77674. }
  77675. /**
  77676. * Define a task used by AssetsManager to load text content
  77677. */
  77678. export class TextFileAssetTask extends AbstractAssetTask {
  77679. /**
  77680. * Defines the name of the task
  77681. */
  77682. name: string;
  77683. /**
  77684. * Defines the location of the file to load
  77685. */
  77686. url: string;
  77687. /**
  77688. * Gets the loaded text string
  77689. */
  77690. text: string;
  77691. /**
  77692. * Callback called when the task is successful
  77693. */
  77694. onSuccess: (task: TextFileAssetTask) => void;
  77695. /**
  77696. * Callback called when the task is successful
  77697. */
  77698. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77699. /**
  77700. * Creates a new TextFileAssetTask object
  77701. * @param name defines the name of the task
  77702. * @param url defines the location of the file to load
  77703. */
  77704. constructor(
  77705. /**
  77706. * Defines the name of the task
  77707. */
  77708. name: string,
  77709. /**
  77710. * Defines the location of the file to load
  77711. */
  77712. url: string);
  77713. /**
  77714. * Execute the current task
  77715. * @param scene defines the scene where you want your assets to be loaded
  77716. * @param onSuccess is a callback called when the task is successfully executed
  77717. * @param onError is a callback called if an error occurs
  77718. */
  77719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77720. }
  77721. /**
  77722. * Define a task used by AssetsManager to load binary data
  77723. */
  77724. export class BinaryFileAssetTask extends AbstractAssetTask {
  77725. /**
  77726. * Defines the name of the task
  77727. */
  77728. name: string;
  77729. /**
  77730. * Defines the location of the file to load
  77731. */
  77732. url: string;
  77733. /**
  77734. * Gets the lodaded data (as an array buffer)
  77735. */
  77736. data: ArrayBuffer;
  77737. /**
  77738. * Callback called when the task is successful
  77739. */
  77740. onSuccess: (task: BinaryFileAssetTask) => void;
  77741. /**
  77742. * Callback called when the task is successful
  77743. */
  77744. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77745. /**
  77746. * Creates a new BinaryFileAssetTask object
  77747. * @param name defines the name of the new task
  77748. * @param url defines the location of the file to load
  77749. */
  77750. constructor(
  77751. /**
  77752. * Defines the name of the task
  77753. */
  77754. name: string,
  77755. /**
  77756. * Defines the location of the file to load
  77757. */
  77758. url: string);
  77759. /**
  77760. * Execute the current task
  77761. * @param scene defines the scene where you want your assets to be loaded
  77762. * @param onSuccess is a callback called when the task is successfully executed
  77763. * @param onError is a callback called if an error occurs
  77764. */
  77765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77766. }
  77767. /**
  77768. * Define a task used by AssetsManager to load images
  77769. */
  77770. export class ImageAssetTask extends AbstractAssetTask {
  77771. /**
  77772. * Defines the name of the task
  77773. */
  77774. name: string;
  77775. /**
  77776. * Defines the location of the image to load
  77777. */
  77778. url: string;
  77779. /**
  77780. * Gets the loaded images
  77781. */
  77782. image: HTMLImageElement;
  77783. /**
  77784. * Callback called when the task is successful
  77785. */
  77786. onSuccess: (task: ImageAssetTask) => void;
  77787. /**
  77788. * Callback called when the task is successful
  77789. */
  77790. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77791. /**
  77792. * Creates a new ImageAssetTask
  77793. * @param name defines the name of the task
  77794. * @param url defines the location of the image to load
  77795. */
  77796. constructor(
  77797. /**
  77798. * Defines the name of the task
  77799. */
  77800. name: string,
  77801. /**
  77802. * Defines the location of the image to load
  77803. */
  77804. url: string);
  77805. /**
  77806. * Execute the current task
  77807. * @param scene defines the scene where you want your assets to be loaded
  77808. * @param onSuccess is a callback called when the task is successfully executed
  77809. * @param onError is a callback called if an error occurs
  77810. */
  77811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77812. }
  77813. /**
  77814. * Defines the interface used by texture loading tasks
  77815. */
  77816. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77817. /**
  77818. * Gets the loaded texture
  77819. */
  77820. texture: TEX;
  77821. }
  77822. /**
  77823. * Define a task used by AssetsManager to load 2D textures
  77824. */
  77825. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77826. /**
  77827. * Defines the name of the task
  77828. */
  77829. name: string;
  77830. /**
  77831. * Defines the location of the file to load
  77832. */
  77833. url: string;
  77834. /**
  77835. * Defines if mipmap should not be generated (default is false)
  77836. */
  77837. noMipmap?: boolean | undefined;
  77838. /**
  77839. * Defines if texture must be inverted on Y axis (default is true)
  77840. */
  77841. invertY: boolean;
  77842. /**
  77843. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77844. */
  77845. samplingMode: number;
  77846. /**
  77847. * Gets the loaded texture
  77848. */
  77849. texture: Texture;
  77850. /**
  77851. * Callback called when the task is successful
  77852. */
  77853. onSuccess: (task: TextureAssetTask) => void;
  77854. /**
  77855. * Callback called when the task is successful
  77856. */
  77857. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77858. /**
  77859. * Creates a new TextureAssetTask object
  77860. * @param name defines the name of the task
  77861. * @param url defines the location of the file to load
  77862. * @param noMipmap defines if mipmap should not be generated (default is false)
  77863. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77864. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77865. */
  77866. constructor(
  77867. /**
  77868. * Defines the name of the task
  77869. */
  77870. name: string,
  77871. /**
  77872. * Defines the location of the file to load
  77873. */
  77874. url: string,
  77875. /**
  77876. * Defines if mipmap should not be generated (default is false)
  77877. */
  77878. noMipmap?: boolean | undefined,
  77879. /**
  77880. * Defines if texture must be inverted on Y axis (default is true)
  77881. */
  77882. invertY?: boolean,
  77883. /**
  77884. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77885. */
  77886. samplingMode?: number);
  77887. /**
  77888. * Execute the current task
  77889. * @param scene defines the scene where you want your assets to be loaded
  77890. * @param onSuccess is a callback called when the task is successfully executed
  77891. * @param onError is a callback called if an error occurs
  77892. */
  77893. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77894. }
  77895. /**
  77896. * Define a task used by AssetsManager to load cube textures
  77897. */
  77898. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77899. /**
  77900. * Defines the name of the task
  77901. */
  77902. name: string;
  77903. /**
  77904. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77905. */
  77906. url: string;
  77907. /**
  77908. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77909. */
  77910. extensions?: string[] | undefined;
  77911. /**
  77912. * Defines if mipmaps should not be generated (default is false)
  77913. */
  77914. noMipmap?: boolean | undefined;
  77915. /**
  77916. * Defines the explicit list of files (undefined by default)
  77917. */
  77918. files?: string[] | undefined;
  77919. /**
  77920. * Gets the loaded texture
  77921. */
  77922. texture: CubeTexture;
  77923. /**
  77924. * Callback called when the task is successful
  77925. */
  77926. onSuccess: (task: CubeTextureAssetTask) => void;
  77927. /**
  77928. * Callback called when the task is successful
  77929. */
  77930. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77931. /**
  77932. * Creates a new CubeTextureAssetTask
  77933. * @param name defines the name of the task
  77934. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77935. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77936. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77937. * @param files defines the explicit list of files (undefined by default)
  77938. */
  77939. constructor(
  77940. /**
  77941. * Defines the name of the task
  77942. */
  77943. name: string,
  77944. /**
  77945. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77946. */
  77947. url: string,
  77948. /**
  77949. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77950. */
  77951. extensions?: string[] | undefined,
  77952. /**
  77953. * Defines if mipmaps should not be generated (default is false)
  77954. */
  77955. noMipmap?: boolean | undefined,
  77956. /**
  77957. * Defines the explicit list of files (undefined by default)
  77958. */
  77959. files?: string[] | undefined);
  77960. /**
  77961. * Execute the current task
  77962. * @param scene defines the scene where you want your assets to be loaded
  77963. * @param onSuccess is a callback called when the task is successfully executed
  77964. * @param onError is a callback called if an error occurs
  77965. */
  77966. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77967. }
  77968. /**
  77969. * Define a task used by AssetsManager to load HDR cube textures
  77970. */
  77971. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77972. /**
  77973. * Defines the name of the task
  77974. */
  77975. name: string;
  77976. /**
  77977. * Defines the location of the file to load
  77978. */
  77979. url: string;
  77980. /**
  77981. * Defines the desired size (the more it increases the longer the generation will be)
  77982. */
  77983. size: number;
  77984. /**
  77985. * Defines if mipmaps should not be generated (default is false)
  77986. */
  77987. noMipmap: boolean;
  77988. /**
  77989. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77990. */
  77991. generateHarmonics: boolean;
  77992. /**
  77993. * 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)
  77994. */
  77995. gammaSpace: boolean;
  77996. /**
  77997. * Internal Use Only
  77998. */
  77999. reserved: boolean;
  78000. /**
  78001. * Gets the loaded texture
  78002. */
  78003. texture: HDRCubeTexture;
  78004. /**
  78005. * Callback called when the task is successful
  78006. */
  78007. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78008. /**
  78009. * Callback called when the task is successful
  78010. */
  78011. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78012. /**
  78013. * Creates a new HDRCubeTextureAssetTask object
  78014. * @param name defines the name of the task
  78015. * @param url defines the location of the file to load
  78016. * @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.
  78017. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78018. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78019. * @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)
  78020. * @param reserved Internal use only
  78021. */
  78022. constructor(
  78023. /**
  78024. * Defines the name of the task
  78025. */
  78026. name: string,
  78027. /**
  78028. * Defines the location of the file to load
  78029. */
  78030. url: string,
  78031. /**
  78032. * Defines the desired size (the more it increases the longer the generation will be)
  78033. */
  78034. size: number,
  78035. /**
  78036. * Defines if mipmaps should not be generated (default is false)
  78037. */
  78038. noMipmap?: boolean,
  78039. /**
  78040. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78041. */
  78042. generateHarmonics?: boolean,
  78043. /**
  78044. * 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)
  78045. */
  78046. gammaSpace?: boolean,
  78047. /**
  78048. * Internal Use Only
  78049. */
  78050. reserved?: boolean);
  78051. /**
  78052. * Execute the current task
  78053. * @param scene defines the scene where you want your assets to be loaded
  78054. * @param onSuccess is a callback called when the task is successfully executed
  78055. * @param onError is a callback called if an error occurs
  78056. */
  78057. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78058. }
  78059. /**
  78060. * Define a task used by AssetsManager to load Equirectangular cube textures
  78061. */
  78062. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78063. /**
  78064. * Defines the name of the task
  78065. */
  78066. name: string;
  78067. /**
  78068. * Defines the location of the file to load
  78069. */
  78070. url: string;
  78071. /**
  78072. * Defines the desired size (the more it increases the longer the generation will be)
  78073. */
  78074. size: number;
  78075. /**
  78076. * Defines if mipmaps should not be generated (default is false)
  78077. */
  78078. noMipmap: boolean;
  78079. /**
  78080. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78081. * but the standard material would require them in Gamma space) (default is true)
  78082. */
  78083. gammaSpace: boolean;
  78084. /**
  78085. * Gets the loaded texture
  78086. */
  78087. texture: EquiRectangularCubeTexture;
  78088. /**
  78089. * Callback called when the task is successful
  78090. */
  78091. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78092. /**
  78093. * Callback called when the task is successful
  78094. */
  78095. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78096. /**
  78097. * Creates a new EquiRectangularCubeTextureAssetTask object
  78098. * @param name defines the name of the task
  78099. * @param url defines the location of the file to load
  78100. * @param size defines the desired size (the more it increases the longer the generation will be)
  78101. * If the size is omitted this implies you are using a preprocessed cubemap.
  78102. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78103. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78104. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78105. * (default is true)
  78106. */
  78107. constructor(
  78108. /**
  78109. * Defines the name of the task
  78110. */
  78111. name: string,
  78112. /**
  78113. * Defines the location of the file to load
  78114. */
  78115. url: string,
  78116. /**
  78117. * Defines the desired size (the more it increases the longer the generation will be)
  78118. */
  78119. size: number,
  78120. /**
  78121. * Defines if mipmaps should not be generated (default is false)
  78122. */
  78123. noMipmap?: boolean,
  78124. /**
  78125. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78126. * but the standard material would require them in Gamma space) (default is true)
  78127. */
  78128. gammaSpace?: boolean);
  78129. /**
  78130. * Execute the current task
  78131. * @param scene defines the scene where you want your assets to be loaded
  78132. * @param onSuccess is a callback called when the task is successfully executed
  78133. * @param onError is a callback called if an error occurs
  78134. */
  78135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78136. }
  78137. /**
  78138. * This class can be used to easily import assets into a scene
  78139. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78140. */
  78141. export class AssetsManager {
  78142. private _scene;
  78143. private _isLoading;
  78144. protected _tasks: AbstractAssetTask[];
  78145. protected _waitingTasksCount: number;
  78146. protected _totalTasksCount: number;
  78147. /**
  78148. * Callback called when all tasks are processed
  78149. */
  78150. onFinish: (tasks: AbstractAssetTask[]) => void;
  78151. /**
  78152. * Callback called when a task is successful
  78153. */
  78154. onTaskSuccess: (task: AbstractAssetTask) => void;
  78155. /**
  78156. * Callback called when a task had an error
  78157. */
  78158. onTaskError: (task: AbstractAssetTask) => void;
  78159. /**
  78160. * Callback called when a task is done (whatever the result is)
  78161. */
  78162. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78163. /**
  78164. * Observable called when all tasks are processed
  78165. */
  78166. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78167. /**
  78168. * Observable called when a task had an error
  78169. */
  78170. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78171. /**
  78172. * Observable called when all tasks were executed
  78173. */
  78174. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78175. /**
  78176. * Observable called when a task is done (whatever the result is)
  78177. */
  78178. onProgressObservable: Observable<IAssetsProgressEvent>;
  78179. /**
  78180. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78181. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78182. */
  78183. useDefaultLoadingScreen: boolean;
  78184. /**
  78185. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78186. * when all assets have been downloaded.
  78187. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78188. */
  78189. autoHideLoadingUI: boolean;
  78190. /**
  78191. * Creates a new AssetsManager
  78192. * @param scene defines the scene to work on
  78193. */
  78194. constructor(scene: Scene);
  78195. /**
  78196. * Add a ContainerAssetTask to the list of active tasks
  78197. * @param taskName defines the name of the new task
  78198. * @param meshesNames defines the name of meshes to load
  78199. * @param rootUrl defines the root url to use to locate files
  78200. * @param sceneFilename defines the filename of the scene file
  78201. * @returns a new ContainerAssetTask object
  78202. */
  78203. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78204. /**
  78205. * Add a MeshAssetTask to the list of active tasks
  78206. * @param taskName defines the name of the new task
  78207. * @param meshesNames defines the name of meshes to load
  78208. * @param rootUrl defines the root url to use to locate files
  78209. * @param sceneFilename defines the filename of the scene file
  78210. * @returns a new MeshAssetTask object
  78211. */
  78212. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78213. /**
  78214. * Add a TextFileAssetTask to the list of active tasks
  78215. * @param taskName defines the name of the new task
  78216. * @param url defines the url of the file to load
  78217. * @returns a new TextFileAssetTask object
  78218. */
  78219. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78220. /**
  78221. * Add a BinaryFileAssetTask to the list of active tasks
  78222. * @param taskName defines the name of the new task
  78223. * @param url defines the url of the file to load
  78224. * @returns a new BinaryFileAssetTask object
  78225. */
  78226. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78227. /**
  78228. * Add a ImageAssetTask to the list of active tasks
  78229. * @param taskName defines the name of the new task
  78230. * @param url defines the url of the file to load
  78231. * @returns a new ImageAssetTask object
  78232. */
  78233. addImageTask(taskName: string, url: string): ImageAssetTask;
  78234. /**
  78235. * Add a TextureAssetTask to the list of active tasks
  78236. * @param taskName defines the name of the new task
  78237. * @param url defines the url of the file to load
  78238. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78239. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78240. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78241. * @returns a new TextureAssetTask object
  78242. */
  78243. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78244. /**
  78245. * Add a CubeTextureAssetTask to the list of active tasks
  78246. * @param taskName defines the name of the new task
  78247. * @param url defines the url of the file to load
  78248. * @param extensions defines the extension to use to load the cube map (can be null)
  78249. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78250. * @param files defines the list of files to load (can be null)
  78251. * @returns a new CubeTextureAssetTask object
  78252. */
  78253. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78254. /**
  78255. *
  78256. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78257. * @param taskName defines the name of the new task
  78258. * @param url defines the url of the file to load
  78259. * @param size defines the size you want for the cubemap (can be null)
  78260. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78261. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78262. * @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)
  78263. * @param reserved Internal use only
  78264. * @returns a new HDRCubeTextureAssetTask object
  78265. */
  78266. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78267. /**
  78268. *
  78269. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78270. * @param taskName defines the name of the new task
  78271. * @param url defines the url of the file to load
  78272. * @param size defines the size you want for the cubemap (can be null)
  78273. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78274. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78275. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78276. * @returns a new EquiRectangularCubeTextureAssetTask object
  78277. */
  78278. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78279. /**
  78280. * Remove a task from the assets manager.
  78281. * @param task the task to remove
  78282. */
  78283. removeTask(task: AbstractAssetTask): void;
  78284. private _decreaseWaitingTasksCount;
  78285. private _runTask;
  78286. /**
  78287. * Reset the AssetsManager and remove all tasks
  78288. * @return the current instance of the AssetsManager
  78289. */
  78290. reset(): AssetsManager;
  78291. /**
  78292. * Start the loading process
  78293. * @return the current instance of the AssetsManager
  78294. */
  78295. load(): AssetsManager;
  78296. /**
  78297. * Start the loading process as an async operation
  78298. * @return a promise returning the list of failed tasks
  78299. */
  78300. loadAsync(): Promise<void>;
  78301. }
  78302. }
  78303. declare module "babylonjs/Misc/deferred" {
  78304. /**
  78305. * Wrapper class for promise with external resolve and reject.
  78306. */
  78307. export class Deferred<T> {
  78308. /**
  78309. * The promise associated with this deferred object.
  78310. */
  78311. readonly promise: Promise<T>;
  78312. private _resolve;
  78313. private _reject;
  78314. /**
  78315. * The resolve method of the promise associated with this deferred object.
  78316. */
  78317. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78318. /**
  78319. * The reject method of the promise associated with this deferred object.
  78320. */
  78321. get reject(): (reason?: any) => void;
  78322. /**
  78323. * Constructor for this deferred object.
  78324. */
  78325. constructor();
  78326. }
  78327. }
  78328. declare module "babylonjs/Misc/meshExploder" {
  78329. import { Mesh } from "babylonjs/Meshes/mesh";
  78330. /**
  78331. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78332. */
  78333. export class MeshExploder {
  78334. private _centerMesh;
  78335. private _meshes;
  78336. private _meshesOrigins;
  78337. private _toCenterVectors;
  78338. private _scaledDirection;
  78339. private _newPosition;
  78340. private _centerPosition;
  78341. /**
  78342. * Explodes meshes from a center mesh.
  78343. * @param meshes The meshes to explode.
  78344. * @param centerMesh The mesh to be center of explosion.
  78345. */
  78346. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78347. private _setCenterMesh;
  78348. /**
  78349. * Get class name
  78350. * @returns "MeshExploder"
  78351. */
  78352. getClassName(): string;
  78353. /**
  78354. * "Exploded meshes"
  78355. * @returns Array of meshes with the centerMesh at index 0.
  78356. */
  78357. getMeshes(): Array<Mesh>;
  78358. /**
  78359. * Explodes meshes giving a specific direction
  78360. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78361. */
  78362. explode(direction?: number): void;
  78363. }
  78364. }
  78365. declare module "babylonjs/Misc/filesInput" {
  78366. import { Engine } from "babylonjs/Engines/engine";
  78367. import { Scene } from "babylonjs/scene";
  78368. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78369. import { Nullable } from "babylonjs/types";
  78370. /**
  78371. * Class used to help managing file picking and drag'n'drop
  78372. */
  78373. export class FilesInput {
  78374. /**
  78375. * List of files ready to be loaded
  78376. */
  78377. static get FilesToLoad(): {
  78378. [key: string]: File;
  78379. };
  78380. /**
  78381. * Callback called when a file is processed
  78382. */
  78383. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78384. private _engine;
  78385. private _currentScene;
  78386. private _sceneLoadedCallback;
  78387. private _progressCallback;
  78388. private _additionalRenderLoopLogicCallback;
  78389. private _textureLoadingCallback;
  78390. private _startingProcessingFilesCallback;
  78391. private _onReloadCallback;
  78392. private _errorCallback;
  78393. private _elementToMonitor;
  78394. private _sceneFileToLoad;
  78395. private _filesToLoad;
  78396. /**
  78397. * Creates a new FilesInput
  78398. * @param engine defines the rendering engine
  78399. * @param scene defines the hosting scene
  78400. * @param sceneLoadedCallback callback called when scene is loaded
  78401. * @param progressCallback callback called to track progress
  78402. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78403. * @param textureLoadingCallback callback called when a texture is loading
  78404. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78405. * @param onReloadCallback callback called when a reload is requested
  78406. * @param errorCallback callback call if an error occurs
  78407. */
  78408. 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>);
  78409. private _dragEnterHandler;
  78410. private _dragOverHandler;
  78411. private _dropHandler;
  78412. /**
  78413. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78414. * @param elementToMonitor defines the DOM element to track
  78415. */
  78416. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78417. /** Gets the current list of files to load */
  78418. get filesToLoad(): File[];
  78419. /**
  78420. * Release all associated resources
  78421. */
  78422. dispose(): void;
  78423. private renderFunction;
  78424. private drag;
  78425. private drop;
  78426. private _traverseFolder;
  78427. private _processFiles;
  78428. /**
  78429. * Load files from a drop event
  78430. * @param event defines the drop event to use as source
  78431. */
  78432. loadFiles(event: any): void;
  78433. private _processReload;
  78434. /**
  78435. * Reload the current scene from the loaded files
  78436. */
  78437. reload(): void;
  78438. }
  78439. }
  78440. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78441. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78442. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78443. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78444. }
  78445. declare module "babylonjs/Misc/sceneOptimizer" {
  78446. import { Scene, IDisposable } from "babylonjs/scene";
  78447. import { Observable } from "babylonjs/Misc/observable";
  78448. /**
  78449. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78450. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78451. */
  78452. export class SceneOptimization {
  78453. /**
  78454. * Defines the priority of this optimization (0 by default which means first in the list)
  78455. */
  78456. priority: number;
  78457. /**
  78458. * Gets a string describing the action executed by the current optimization
  78459. * @returns description string
  78460. */
  78461. getDescription(): string;
  78462. /**
  78463. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78464. * @param scene defines the current scene where to apply this optimization
  78465. * @param optimizer defines the current optimizer
  78466. * @returns true if everything that can be done was applied
  78467. */
  78468. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78469. /**
  78470. * Creates the SceneOptimization object
  78471. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78472. * @param desc defines the description associated with the optimization
  78473. */
  78474. constructor(
  78475. /**
  78476. * Defines the priority of this optimization (0 by default which means first in the list)
  78477. */
  78478. priority?: number);
  78479. }
  78480. /**
  78481. * Defines an optimization used to reduce the size of render target textures
  78482. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78483. */
  78484. export class TextureOptimization extends SceneOptimization {
  78485. /**
  78486. * Defines the priority of this optimization (0 by default which means first in the list)
  78487. */
  78488. priority: number;
  78489. /**
  78490. * 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
  78491. */
  78492. maximumSize: number;
  78493. /**
  78494. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78495. */
  78496. step: number;
  78497. /**
  78498. * Gets a string describing the action executed by the current optimization
  78499. * @returns description string
  78500. */
  78501. getDescription(): string;
  78502. /**
  78503. * Creates the TextureOptimization object
  78504. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78505. * @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
  78506. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78507. */
  78508. constructor(
  78509. /**
  78510. * Defines the priority of this optimization (0 by default which means first in the list)
  78511. */
  78512. priority?: number,
  78513. /**
  78514. * 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
  78515. */
  78516. maximumSize?: number,
  78517. /**
  78518. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78519. */
  78520. step?: number);
  78521. /**
  78522. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78523. * @param scene defines the current scene where to apply this optimization
  78524. * @param optimizer defines the current optimizer
  78525. * @returns true if everything that can be done was applied
  78526. */
  78527. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78528. }
  78529. /**
  78530. * Defines an optimization used to increase or decrease the rendering resolution
  78531. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78532. */
  78533. export class HardwareScalingOptimization extends SceneOptimization {
  78534. /**
  78535. * Defines the priority of this optimization (0 by default which means first in the list)
  78536. */
  78537. priority: number;
  78538. /**
  78539. * Defines the maximum scale to use (2 by default)
  78540. */
  78541. maximumScale: number;
  78542. /**
  78543. * Defines the step to use between two passes (0.5 by default)
  78544. */
  78545. step: number;
  78546. private _currentScale;
  78547. private _directionOffset;
  78548. /**
  78549. * Gets a string describing the action executed by the current optimization
  78550. * @return description string
  78551. */
  78552. getDescription(): string;
  78553. /**
  78554. * Creates the HardwareScalingOptimization object
  78555. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78556. * @param maximumScale defines the maximum scale to use (2 by default)
  78557. * @param step defines the step to use between two passes (0.5 by default)
  78558. */
  78559. constructor(
  78560. /**
  78561. * Defines the priority of this optimization (0 by default which means first in the list)
  78562. */
  78563. priority?: number,
  78564. /**
  78565. * Defines the maximum scale to use (2 by default)
  78566. */
  78567. maximumScale?: number,
  78568. /**
  78569. * Defines the step to use between two passes (0.5 by default)
  78570. */
  78571. step?: number);
  78572. /**
  78573. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78574. * @param scene defines the current scene where to apply this optimization
  78575. * @param optimizer defines the current optimizer
  78576. * @returns true if everything that can be done was applied
  78577. */
  78578. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78579. }
  78580. /**
  78581. * Defines an optimization used to remove shadows
  78582. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78583. */
  78584. export class ShadowsOptimization extends SceneOptimization {
  78585. /**
  78586. * Gets a string describing the action executed by the current optimization
  78587. * @return description string
  78588. */
  78589. getDescription(): string;
  78590. /**
  78591. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78592. * @param scene defines the current scene where to apply this optimization
  78593. * @param optimizer defines the current optimizer
  78594. * @returns true if everything that can be done was applied
  78595. */
  78596. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78597. }
  78598. /**
  78599. * Defines an optimization used to turn post-processes off
  78600. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78601. */
  78602. export class PostProcessesOptimization extends SceneOptimization {
  78603. /**
  78604. * Gets a string describing the action executed by the current optimization
  78605. * @return description string
  78606. */
  78607. getDescription(): string;
  78608. /**
  78609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78610. * @param scene defines the current scene where to apply this optimization
  78611. * @param optimizer defines the current optimizer
  78612. * @returns true if everything that can be done was applied
  78613. */
  78614. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78615. }
  78616. /**
  78617. * Defines an optimization used to turn lens flares off
  78618. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78619. */
  78620. export class LensFlaresOptimization extends SceneOptimization {
  78621. /**
  78622. * Gets a string describing the action executed by the current optimization
  78623. * @return description string
  78624. */
  78625. getDescription(): string;
  78626. /**
  78627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78628. * @param scene defines the current scene where to apply this optimization
  78629. * @param optimizer defines the current optimizer
  78630. * @returns true if everything that can be done was applied
  78631. */
  78632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78633. }
  78634. /**
  78635. * Defines an optimization based on user defined callback.
  78636. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78637. */
  78638. export class CustomOptimization extends SceneOptimization {
  78639. /**
  78640. * Callback called to apply the custom optimization.
  78641. */
  78642. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78643. /**
  78644. * Callback called to get custom description
  78645. */
  78646. onGetDescription: () => string;
  78647. /**
  78648. * Gets a string describing the action executed by the current optimization
  78649. * @returns description string
  78650. */
  78651. getDescription(): string;
  78652. /**
  78653. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78654. * @param scene defines the current scene where to apply this optimization
  78655. * @param optimizer defines the current optimizer
  78656. * @returns true if everything that can be done was applied
  78657. */
  78658. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78659. }
  78660. /**
  78661. * Defines an optimization used to turn particles off
  78662. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78663. */
  78664. export class ParticlesOptimization extends SceneOptimization {
  78665. /**
  78666. * Gets a string describing the action executed by the current optimization
  78667. * @return description string
  78668. */
  78669. getDescription(): string;
  78670. /**
  78671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78672. * @param scene defines the current scene where to apply this optimization
  78673. * @param optimizer defines the current optimizer
  78674. * @returns true if everything that can be done was applied
  78675. */
  78676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78677. }
  78678. /**
  78679. * Defines an optimization used to turn render targets off
  78680. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78681. */
  78682. export class RenderTargetsOptimization extends SceneOptimization {
  78683. /**
  78684. * Gets a string describing the action executed by the current optimization
  78685. * @return description string
  78686. */
  78687. getDescription(): string;
  78688. /**
  78689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78690. * @param scene defines the current scene where to apply this optimization
  78691. * @param optimizer defines the current optimizer
  78692. * @returns true if everything that can be done was applied
  78693. */
  78694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78695. }
  78696. /**
  78697. * Defines an optimization used to merge meshes with compatible materials
  78698. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78699. */
  78700. export class MergeMeshesOptimization extends SceneOptimization {
  78701. private static _UpdateSelectionTree;
  78702. /**
  78703. * Gets or sets a boolean which defines if optimization octree has to be updated
  78704. */
  78705. static get UpdateSelectionTree(): boolean;
  78706. /**
  78707. * Gets or sets a boolean which defines if optimization octree has to be updated
  78708. */
  78709. static set UpdateSelectionTree(value: boolean);
  78710. /**
  78711. * Gets a string describing the action executed by the current optimization
  78712. * @return description string
  78713. */
  78714. getDescription(): string;
  78715. private _canBeMerged;
  78716. /**
  78717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78718. * @param scene defines the current scene where to apply this optimization
  78719. * @param optimizer defines the current optimizer
  78720. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78721. * @returns true if everything that can be done was applied
  78722. */
  78723. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78724. }
  78725. /**
  78726. * Defines a list of options used by SceneOptimizer
  78727. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78728. */
  78729. export class SceneOptimizerOptions {
  78730. /**
  78731. * Defines the target frame rate to reach (60 by default)
  78732. */
  78733. targetFrameRate: number;
  78734. /**
  78735. * Defines the interval between two checkes (2000ms by default)
  78736. */
  78737. trackerDuration: number;
  78738. /**
  78739. * Gets the list of optimizations to apply
  78740. */
  78741. optimizations: SceneOptimization[];
  78742. /**
  78743. * Creates a new list of options used by SceneOptimizer
  78744. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78745. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78746. */
  78747. constructor(
  78748. /**
  78749. * Defines the target frame rate to reach (60 by default)
  78750. */
  78751. targetFrameRate?: number,
  78752. /**
  78753. * Defines the interval between two checkes (2000ms by default)
  78754. */
  78755. trackerDuration?: number);
  78756. /**
  78757. * Add a new optimization
  78758. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78759. * @returns the current SceneOptimizerOptions
  78760. */
  78761. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78762. /**
  78763. * Add a new custom optimization
  78764. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78765. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78766. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78767. * @returns the current SceneOptimizerOptions
  78768. */
  78769. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78770. /**
  78771. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78772. * @param targetFrameRate defines the target frame rate (60 by default)
  78773. * @returns a SceneOptimizerOptions object
  78774. */
  78775. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78776. /**
  78777. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78778. * @param targetFrameRate defines the target frame rate (60 by default)
  78779. * @returns a SceneOptimizerOptions object
  78780. */
  78781. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78782. /**
  78783. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78784. * @param targetFrameRate defines the target frame rate (60 by default)
  78785. * @returns a SceneOptimizerOptions object
  78786. */
  78787. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78788. }
  78789. /**
  78790. * Class used to run optimizations in order to reach a target frame rate
  78791. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78792. */
  78793. export class SceneOptimizer implements IDisposable {
  78794. private _isRunning;
  78795. private _options;
  78796. private _scene;
  78797. private _currentPriorityLevel;
  78798. private _targetFrameRate;
  78799. private _trackerDuration;
  78800. private _currentFrameRate;
  78801. private _sceneDisposeObserver;
  78802. private _improvementMode;
  78803. /**
  78804. * Defines an observable called when the optimizer reaches the target frame rate
  78805. */
  78806. onSuccessObservable: Observable<SceneOptimizer>;
  78807. /**
  78808. * Defines an observable called when the optimizer enables an optimization
  78809. */
  78810. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78811. /**
  78812. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78813. */
  78814. onFailureObservable: Observable<SceneOptimizer>;
  78815. /**
  78816. * Gets a boolean indicating if the optimizer is in improvement mode
  78817. */
  78818. get isInImprovementMode(): boolean;
  78819. /**
  78820. * Gets the current priority level (0 at start)
  78821. */
  78822. get currentPriorityLevel(): number;
  78823. /**
  78824. * Gets the current frame rate checked by the SceneOptimizer
  78825. */
  78826. get currentFrameRate(): number;
  78827. /**
  78828. * Gets or sets the current target frame rate (60 by default)
  78829. */
  78830. get targetFrameRate(): number;
  78831. /**
  78832. * Gets or sets the current target frame rate (60 by default)
  78833. */
  78834. set targetFrameRate(value: number);
  78835. /**
  78836. * Gets or sets the current interval between two checks (every 2000ms by default)
  78837. */
  78838. get trackerDuration(): number;
  78839. /**
  78840. * Gets or sets the current interval between two checks (every 2000ms by default)
  78841. */
  78842. set trackerDuration(value: number);
  78843. /**
  78844. * Gets the list of active optimizations
  78845. */
  78846. get optimizations(): SceneOptimization[];
  78847. /**
  78848. * Creates a new SceneOptimizer
  78849. * @param scene defines the scene to work on
  78850. * @param options defines the options to use with the SceneOptimizer
  78851. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78852. * @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)
  78853. */
  78854. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78855. /**
  78856. * Stops the current optimizer
  78857. */
  78858. stop(): void;
  78859. /**
  78860. * Reset the optimizer to initial step (current priority level = 0)
  78861. */
  78862. reset(): void;
  78863. /**
  78864. * Start the optimizer. By default it will try to reach a specific framerate
  78865. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78866. */
  78867. start(): void;
  78868. private _checkCurrentState;
  78869. /**
  78870. * Release all resources
  78871. */
  78872. dispose(): void;
  78873. /**
  78874. * Helper function to create a SceneOptimizer with one single line of code
  78875. * @param scene defines the scene to work on
  78876. * @param options defines the options to use with the SceneOptimizer
  78877. * @param onSuccess defines a callback to call on success
  78878. * @param onFailure defines a callback to call on failure
  78879. * @returns the new SceneOptimizer object
  78880. */
  78881. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78882. }
  78883. }
  78884. declare module "babylonjs/Misc/sceneSerializer" {
  78885. import { Scene } from "babylonjs/scene";
  78886. /**
  78887. * Class used to serialize a scene into a string
  78888. */
  78889. export class SceneSerializer {
  78890. /**
  78891. * Clear cache used by a previous serialization
  78892. */
  78893. static ClearCache(): void;
  78894. /**
  78895. * Serialize a scene into a JSON compatible object
  78896. * @param scene defines the scene to serialize
  78897. * @returns a JSON compatible object
  78898. */
  78899. static Serialize(scene: Scene): any;
  78900. /**
  78901. * Serialize a mesh into a JSON compatible object
  78902. * @param toSerialize defines the mesh to serialize
  78903. * @param withParents defines if parents must be serialized as well
  78904. * @param withChildren defines if children must be serialized as well
  78905. * @returns a JSON compatible object
  78906. */
  78907. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78908. }
  78909. }
  78910. declare module "babylonjs/Misc/textureTools" {
  78911. import { Texture } from "babylonjs/Materials/Textures/texture";
  78912. /**
  78913. * Class used to host texture specific utilities
  78914. */
  78915. export class TextureTools {
  78916. /**
  78917. * Uses the GPU to create a copy texture rescaled at a given size
  78918. * @param texture Texture to copy from
  78919. * @param width defines the desired width
  78920. * @param height defines the desired height
  78921. * @param useBilinearMode defines if bilinear mode has to be used
  78922. * @return the generated texture
  78923. */
  78924. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78925. }
  78926. }
  78927. declare module "babylonjs/Misc/videoRecorder" {
  78928. import { Nullable } from "babylonjs/types";
  78929. import { Engine } from "babylonjs/Engines/engine";
  78930. /**
  78931. * This represents the different options available for the video capture.
  78932. */
  78933. export interface VideoRecorderOptions {
  78934. /** Defines the mime type of the video. */
  78935. mimeType: string;
  78936. /** Defines the FPS the video should be recorded at. */
  78937. fps: number;
  78938. /** Defines the chunk size for the recording data. */
  78939. recordChunckSize: number;
  78940. /** The audio tracks to attach to the recording. */
  78941. audioTracks?: MediaStreamTrack[];
  78942. }
  78943. /**
  78944. * This can help with recording videos from BabylonJS.
  78945. * This is based on the available WebRTC functionalities of the browser.
  78946. *
  78947. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78948. */
  78949. export class VideoRecorder {
  78950. private static readonly _defaultOptions;
  78951. /**
  78952. * Returns whether or not the VideoRecorder is available in your browser.
  78953. * @param engine Defines the Babylon Engine.
  78954. * @returns true if supported otherwise false.
  78955. */
  78956. static IsSupported(engine: Engine): boolean;
  78957. private readonly _options;
  78958. private _canvas;
  78959. private _mediaRecorder;
  78960. private _recordedChunks;
  78961. private _fileName;
  78962. private _resolve;
  78963. private _reject;
  78964. /**
  78965. * True when a recording is already in progress.
  78966. */
  78967. get isRecording(): boolean;
  78968. /**
  78969. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78970. * @param engine Defines the BabylonJS Engine you wish to record.
  78971. * @param options Defines options that can be used to customize the capture.
  78972. */
  78973. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78974. /**
  78975. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78976. */
  78977. stopRecording(): void;
  78978. /**
  78979. * Starts recording the canvas for a max duration specified in parameters.
  78980. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78981. * If null no automatic download will start and you can rely on the promise to get the data back.
  78982. * @param maxDuration Defines the maximum recording time in seconds.
  78983. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78984. * @return A promise callback at the end of the recording with the video data in Blob.
  78985. */
  78986. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78987. /**
  78988. * Releases internal resources used during the recording.
  78989. */
  78990. dispose(): void;
  78991. private _handleDataAvailable;
  78992. private _handleError;
  78993. private _handleStop;
  78994. }
  78995. }
  78996. declare module "babylonjs/Misc/screenshotTools" {
  78997. import { Camera } from "babylonjs/Cameras/camera";
  78998. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78999. import { Engine } from "babylonjs/Engines/engine";
  79000. /**
  79001. * Class containing a set of static utilities functions for screenshots
  79002. */
  79003. export class ScreenshotTools {
  79004. /**
  79005. * Captures a screenshot of the current rendering
  79006. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79007. * @param engine defines the rendering engine
  79008. * @param camera defines the source camera
  79009. * @param size This parameter can be set to a single number or to an object with the
  79010. * following (optional) properties: precision, width, height. If a single number is passed,
  79011. * it will be used for both width and height. If an object is passed, the screenshot size
  79012. * will be derived from the parameters. The precision property is a multiplier allowing
  79013. * rendering at a higher or lower resolution
  79014. * @param successCallback defines the callback receives a single parameter which contains the
  79015. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79016. * src parameter of an <img> to display it
  79017. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79018. * Check your browser for supported MIME types
  79019. */
  79020. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79021. /**
  79022. * Captures a screenshot of the current rendering
  79023. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79024. * @param engine defines the rendering engine
  79025. * @param camera defines the source camera
  79026. * @param size This parameter can be set to a single number or to an object with the
  79027. * following (optional) properties: precision, width, height. If a single number is passed,
  79028. * it will be used for both width and height. If an object is passed, the screenshot size
  79029. * will be derived from the parameters. The precision property is a multiplier allowing
  79030. * rendering at a higher or lower resolution
  79031. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79032. * Check your browser for supported MIME types
  79033. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79034. * to the src parameter of an <img> to display it
  79035. */
  79036. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79037. /**
  79038. * Generates an image screenshot from the specified camera.
  79039. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79040. * @param engine The engine to use for rendering
  79041. * @param camera The camera to use for rendering
  79042. * @param size This parameter can be set to a single number or to an object with the
  79043. * following (optional) properties: precision, width, height. If a single number is passed,
  79044. * it will be used for both width and height. If an object is passed, the screenshot size
  79045. * will be derived from the parameters. The precision property is a multiplier allowing
  79046. * rendering at a higher or lower resolution
  79047. * @param successCallback The callback receives a single parameter which contains the
  79048. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79049. * src parameter of an <img> to display it
  79050. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79051. * Check your browser for supported MIME types
  79052. * @param samples Texture samples (default: 1)
  79053. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79054. * @param fileName A name for for the downloaded file.
  79055. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79056. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79057. */
  79058. 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;
  79059. /**
  79060. * Generates an image screenshot from the specified camera.
  79061. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79062. * @param engine The engine to use for rendering
  79063. * @param camera The camera to use for rendering
  79064. * @param size This parameter can be set to a single number or to an object with the
  79065. * following (optional) properties: precision, width, height. If a single number is passed,
  79066. * it will be used for both width and height. If an object is passed, the screenshot size
  79067. * will be derived from the parameters. The precision property is a multiplier allowing
  79068. * rendering at a higher or lower resolution
  79069. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79070. * Check your browser for supported MIME types
  79071. * @param samples Texture samples (default: 1)
  79072. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79073. * @param fileName A name for for the downloaded file.
  79074. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79075. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79076. * to the src parameter of an <img> to display it
  79077. */
  79078. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79079. /**
  79080. * Gets height and width for screenshot size
  79081. * @private
  79082. */
  79083. private static _getScreenshotSize;
  79084. }
  79085. }
  79086. declare module "babylonjs/Misc/dataReader" {
  79087. /**
  79088. * Interface for a data buffer
  79089. */
  79090. export interface IDataBuffer {
  79091. /**
  79092. * Reads bytes from the data buffer.
  79093. * @param byteOffset The byte offset to read
  79094. * @param byteLength The byte length to read
  79095. * @returns A promise that resolves when the bytes are read
  79096. */
  79097. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79098. /**
  79099. * The byte length of the buffer.
  79100. */
  79101. readonly byteLength: number;
  79102. }
  79103. /**
  79104. * Utility class for reading from a data buffer
  79105. */
  79106. export class DataReader {
  79107. /**
  79108. * The data buffer associated with this data reader.
  79109. */
  79110. readonly buffer: IDataBuffer;
  79111. /**
  79112. * The current byte offset from the beginning of the data buffer.
  79113. */
  79114. byteOffset: number;
  79115. private _dataView;
  79116. private _dataByteOffset;
  79117. /**
  79118. * Constructor
  79119. * @param buffer The buffer to read
  79120. */
  79121. constructor(buffer: IDataBuffer);
  79122. /**
  79123. * Loads the given byte length.
  79124. * @param byteLength The byte length to load
  79125. * @returns A promise that resolves when the load is complete
  79126. */
  79127. loadAsync(byteLength: number): Promise<void>;
  79128. /**
  79129. * Read a unsigned 32-bit integer from the currently loaded data range.
  79130. * @returns The 32-bit integer read
  79131. */
  79132. readUint32(): number;
  79133. /**
  79134. * Read a byte array from the currently loaded data range.
  79135. * @param byteLength The byte length to read
  79136. * @returns The byte array read
  79137. */
  79138. readUint8Array(byteLength: number): Uint8Array;
  79139. /**
  79140. * Read a string from the currently loaded data range.
  79141. * @param byteLength The byte length to read
  79142. * @returns The string read
  79143. */
  79144. readString(byteLength: number): string;
  79145. /**
  79146. * Skips the given byte length the currently loaded data range.
  79147. * @param byteLength The byte length to skip
  79148. */
  79149. skipBytes(byteLength: number): void;
  79150. }
  79151. }
  79152. declare module "babylonjs/Misc/dataStorage" {
  79153. /**
  79154. * Class for storing data to local storage if available or in-memory storage otherwise
  79155. */
  79156. export class DataStorage {
  79157. private static _Storage;
  79158. private static _GetStorage;
  79159. /**
  79160. * Reads a string from the data storage
  79161. * @param key The key to read
  79162. * @param defaultValue The value if the key doesn't exist
  79163. * @returns The string value
  79164. */
  79165. static ReadString(key: string, defaultValue: string): string;
  79166. /**
  79167. * Writes a string to the data storage
  79168. * @param key The key to write
  79169. * @param value The value to write
  79170. */
  79171. static WriteString(key: string, value: string): void;
  79172. /**
  79173. * Reads a boolean from the data storage
  79174. * @param key The key to read
  79175. * @param defaultValue The value if the key doesn't exist
  79176. * @returns The boolean value
  79177. */
  79178. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79179. /**
  79180. * Writes a boolean to the data storage
  79181. * @param key The key to write
  79182. * @param value The value to write
  79183. */
  79184. static WriteBoolean(key: string, value: boolean): void;
  79185. /**
  79186. * Reads a number from the data storage
  79187. * @param key The key to read
  79188. * @param defaultValue The value if the key doesn't exist
  79189. * @returns The number value
  79190. */
  79191. static ReadNumber(key: string, defaultValue: number): number;
  79192. /**
  79193. * Writes a number to the data storage
  79194. * @param key The key to write
  79195. * @param value The value to write
  79196. */
  79197. static WriteNumber(key: string, value: number): void;
  79198. }
  79199. }
  79200. declare module "babylonjs/Misc/sceneRecorder" {
  79201. import { Scene } from "babylonjs/scene";
  79202. /**
  79203. * Class used to record delta files between 2 scene states
  79204. */
  79205. export class SceneRecorder {
  79206. private _trackedScene;
  79207. private _savedJSON;
  79208. /**
  79209. * Track a given scene. This means the current scene state will be considered the original state
  79210. * @param scene defines the scene to track
  79211. */
  79212. track(scene: Scene): void;
  79213. /**
  79214. * Get the delta between current state and original state
  79215. * @returns a string containing the delta
  79216. */
  79217. getDelta(): any;
  79218. private _compareArray;
  79219. private _compareObjects;
  79220. private _compareCollections;
  79221. private static GetShadowGeneratorById;
  79222. /**
  79223. * Apply a given delta to a given scene
  79224. * @param deltaJSON defines the JSON containing the delta
  79225. * @param scene defines the scene to apply the delta to
  79226. */
  79227. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79228. private static _ApplyPropertiesToEntity;
  79229. private static _ApplyDeltaForEntity;
  79230. }
  79231. }
  79232. declare module "babylonjs/Misc/trajectoryClassifier" {
  79233. import { DeepImmutable, Nullable } from "babylonjs/types";
  79234. import { Vector3 } from "babylonjs/Maths/math.vector";
  79235. /**
  79236. * A 3D trajectory consisting of an order list of vectors describing a
  79237. * path of motion through 3D space.
  79238. */
  79239. export class Trajectory {
  79240. private _points;
  79241. private readonly _segmentLength;
  79242. /**
  79243. * Serialize to JSON.
  79244. * @returns serialized JSON string
  79245. */
  79246. serialize(): string;
  79247. /**
  79248. * Deserialize from JSON.
  79249. * @param json serialized JSON string
  79250. * @returns deserialized Trajectory
  79251. */
  79252. static Deserialize(json: string): Trajectory;
  79253. /**
  79254. * Create a new empty Trajectory.
  79255. * @param segmentLength radius of discretization for Trajectory points
  79256. */
  79257. constructor(segmentLength?: number);
  79258. /**
  79259. * Get the length of the Trajectory.
  79260. * @returns length of the Trajectory
  79261. */
  79262. getLength(): number;
  79263. /**
  79264. * Append a new point to the Trajectory.
  79265. * NOTE: This implementation has many allocations.
  79266. * @param point point to append to the Trajectory
  79267. */
  79268. add(point: DeepImmutable<Vector3>): void;
  79269. /**
  79270. * Create a new Trajectory with a segment length chosen to make it
  79271. * probable that the new Trajectory will have a specified number of
  79272. * segments. This operation is imprecise.
  79273. * @param targetResolution number of segments desired
  79274. * @returns new Trajectory with approximately the requested number of segments
  79275. */
  79276. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79277. /**
  79278. * Convert Trajectory segments into tokenized representation. This
  79279. * representation is an array of numbers where each nth number is the
  79280. * index of the token which is most similar to the nth segment of the
  79281. * Trajectory.
  79282. * @param tokens list of vectors which serve as discrete tokens
  79283. * @returns list of indices of most similar token per segment
  79284. */
  79285. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79286. private static _forwardDir;
  79287. private static _inverseFromVec;
  79288. private static _upDir;
  79289. private static _fromToVec;
  79290. private static _lookMatrix;
  79291. /**
  79292. * Transform the rotation (i.e., direction) of a segment to isolate
  79293. * the relative transformation represented by the segment. This operation
  79294. * may or may not succeed due to singularities in the equations that define
  79295. * motion relativity in this context.
  79296. * @param priorVec the origin of the prior segment
  79297. * @param fromVec the origin of the current segment
  79298. * @param toVec the destination of the current segment
  79299. * @param result reference to output variable
  79300. * @returns whether or not transformation was successful
  79301. */
  79302. private static _transformSegmentDirToRef;
  79303. private static _bestMatch;
  79304. private static _score;
  79305. private static _bestScore;
  79306. /**
  79307. * Determine which token vector is most similar to the
  79308. * segment vector.
  79309. * @param segment segment vector
  79310. * @param tokens token vector list
  79311. * @returns index of the most similar token to the segment
  79312. */
  79313. private static _tokenizeSegment;
  79314. }
  79315. /**
  79316. * Class representing a set of known, named trajectories to which Trajectories can be
  79317. * added and using which Trajectories can be recognized.
  79318. */
  79319. export class TrajectoryClassifier {
  79320. private _maximumAllowableMatchCost;
  79321. private _vector3Alphabet;
  79322. private _levenshteinAlphabet;
  79323. private _nameToDescribedTrajectory;
  79324. /**
  79325. * Serialize to JSON.
  79326. * @returns JSON serialization
  79327. */
  79328. serialize(): string;
  79329. /**
  79330. * Deserialize from JSON.
  79331. * @param json JSON serialization
  79332. * @returns deserialized TrajectorySet
  79333. */
  79334. static Deserialize(json: string): TrajectoryClassifier;
  79335. /**
  79336. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79337. * VERY naive, need to be generating these things from known
  79338. * sets. Better version later, probably eliminating this one.
  79339. * @returns auto-generated TrajectorySet
  79340. */
  79341. static Generate(): TrajectoryClassifier;
  79342. private constructor();
  79343. /**
  79344. * Add a new Trajectory to the set with a given name.
  79345. * @param trajectory new Trajectory to be added
  79346. * @param classification name to which to add the Trajectory
  79347. */
  79348. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79349. /**
  79350. * Remove a known named trajectory and all Trajectories associated with it.
  79351. * @param classification name to remove
  79352. * @returns whether anything was removed
  79353. */
  79354. deleteClassification(classification: string): boolean;
  79355. /**
  79356. * Attempt to recognize a Trajectory from among all the classifications
  79357. * already known to the classifier.
  79358. * @param trajectory Trajectory to be recognized
  79359. * @returns classification of Trajectory if recognized, null otherwise
  79360. */
  79361. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79362. }
  79363. }
  79364. declare module "babylonjs/Misc/index" {
  79365. export * from "babylonjs/Misc/andOrNotEvaluator";
  79366. export * from "babylonjs/Misc/assetsManager";
  79367. export * from "babylonjs/Misc/basis";
  79368. export * from "babylonjs/Misc/dds";
  79369. export * from "babylonjs/Misc/decorators";
  79370. export * from "babylonjs/Misc/deferred";
  79371. export * from "babylonjs/Misc/environmentTextureTools";
  79372. export * from "babylonjs/Misc/meshExploder";
  79373. export * from "babylonjs/Misc/filesInput";
  79374. export * from "babylonjs/Misc/HighDynamicRange/index";
  79375. export * from "babylonjs/Misc/khronosTextureContainer";
  79376. export * from "babylonjs/Misc/observable";
  79377. export * from "babylonjs/Misc/performanceMonitor";
  79378. export * from "babylonjs/Misc/promise";
  79379. export * from "babylonjs/Misc/sceneOptimizer";
  79380. export * from "babylonjs/Misc/sceneSerializer";
  79381. export * from "babylonjs/Misc/smartArray";
  79382. export * from "babylonjs/Misc/stringDictionary";
  79383. export * from "babylonjs/Misc/tags";
  79384. export * from "babylonjs/Misc/textureTools";
  79385. export * from "babylonjs/Misc/tga";
  79386. export * from "babylonjs/Misc/tools";
  79387. export * from "babylonjs/Misc/videoRecorder";
  79388. export * from "babylonjs/Misc/virtualJoystick";
  79389. export * from "babylonjs/Misc/workerPool";
  79390. export * from "babylonjs/Misc/logger";
  79391. export * from "babylonjs/Misc/typeStore";
  79392. export * from "babylonjs/Misc/filesInputStore";
  79393. export * from "babylonjs/Misc/deepCopier";
  79394. export * from "babylonjs/Misc/pivotTools";
  79395. export * from "babylonjs/Misc/precisionDate";
  79396. export * from "babylonjs/Misc/screenshotTools";
  79397. export * from "babylonjs/Misc/typeStore";
  79398. export * from "babylonjs/Misc/webRequest";
  79399. export * from "babylonjs/Misc/iInspectable";
  79400. export * from "babylonjs/Misc/brdfTextureTools";
  79401. export * from "babylonjs/Misc/rgbdTextureTools";
  79402. export * from "babylonjs/Misc/gradients";
  79403. export * from "babylonjs/Misc/perfCounter";
  79404. export * from "babylonjs/Misc/fileRequest";
  79405. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79406. export * from "babylonjs/Misc/retryStrategy";
  79407. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79408. export * from "babylonjs/Misc/canvasGenerator";
  79409. export * from "babylonjs/Misc/fileTools";
  79410. export * from "babylonjs/Misc/stringTools";
  79411. export * from "babylonjs/Misc/dataReader";
  79412. export * from "babylonjs/Misc/minMaxReducer";
  79413. export * from "babylonjs/Misc/depthReducer";
  79414. export * from "babylonjs/Misc/dataStorage";
  79415. export * from "babylonjs/Misc/sceneRecorder";
  79416. export * from "babylonjs/Misc/khronosTextureContainer2";
  79417. export * from "babylonjs/Misc/trajectoryClassifier";
  79418. export * from "babylonjs/Misc/timer";
  79419. }
  79420. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79421. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79422. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79423. import { Observable } from "babylonjs/Misc/observable";
  79424. import { Matrix } from "babylonjs/Maths/math.vector";
  79425. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79426. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79427. /**
  79428. * An interface for all Hit test features
  79429. */
  79430. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79431. /**
  79432. * Triggered when new babylon (transformed) hit test results are available
  79433. */
  79434. onHitTestResultObservable: Observable<T[]>;
  79435. }
  79436. /**
  79437. * Options used for hit testing
  79438. */
  79439. export interface IWebXRLegacyHitTestOptions {
  79440. /**
  79441. * Only test when user interacted with the scene. Default - hit test every frame
  79442. */
  79443. testOnPointerDownOnly?: boolean;
  79444. /**
  79445. * The node to use to transform the local results to world coordinates
  79446. */
  79447. worldParentNode?: TransformNode;
  79448. }
  79449. /**
  79450. * Interface defining the babylon result of raycasting/hit-test
  79451. */
  79452. export interface IWebXRLegacyHitResult {
  79453. /**
  79454. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79455. */
  79456. transformationMatrix: Matrix;
  79457. /**
  79458. * The native hit test result
  79459. */
  79460. xrHitResult: XRHitResult | XRHitTestResult;
  79461. }
  79462. /**
  79463. * The currently-working hit-test module.
  79464. * Hit test (or Ray-casting) is used to interact with the real world.
  79465. * For further information read here - https://github.com/immersive-web/hit-test
  79466. */
  79467. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79468. /**
  79469. * options to use when constructing this feature
  79470. */
  79471. readonly options: IWebXRLegacyHitTestOptions;
  79472. private _direction;
  79473. private _mat;
  79474. private _onSelectEnabled;
  79475. private _origin;
  79476. /**
  79477. * The module's name
  79478. */
  79479. static readonly Name: string;
  79480. /**
  79481. * The (Babylon) version of this module.
  79482. * This is an integer representing the implementation version.
  79483. * This number does not correspond to the WebXR specs version
  79484. */
  79485. static readonly Version: number;
  79486. /**
  79487. * Populated with the last native XR Hit Results
  79488. */
  79489. lastNativeXRHitResults: XRHitResult[];
  79490. /**
  79491. * Triggered when new babylon (transformed) hit test results are available
  79492. */
  79493. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79494. /**
  79495. * Creates a new instance of the (legacy version) hit test feature
  79496. * @param _xrSessionManager an instance of WebXRSessionManager
  79497. * @param options options to use when constructing this feature
  79498. */
  79499. constructor(_xrSessionManager: WebXRSessionManager,
  79500. /**
  79501. * options to use when constructing this feature
  79502. */
  79503. options?: IWebXRLegacyHitTestOptions);
  79504. /**
  79505. * execute a hit test with an XR Ray
  79506. *
  79507. * @param xrSession a native xrSession that will execute this hit test
  79508. * @param xrRay the ray (position and direction) to use for ray-casting
  79509. * @param referenceSpace native XR reference space to use for the hit-test
  79510. * @param filter filter function that will filter the results
  79511. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79512. */
  79513. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79514. /**
  79515. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79516. * @param event the (select) event to use to select with
  79517. * @param referenceSpace the reference space to use for this hit test
  79518. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79519. */
  79520. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79521. /**
  79522. * attach this feature
  79523. * Will usually be called by the features manager
  79524. *
  79525. * @returns true if successful.
  79526. */
  79527. attach(): boolean;
  79528. /**
  79529. * detach this feature.
  79530. * Will usually be called by the features manager
  79531. *
  79532. * @returns true if successful.
  79533. */
  79534. detach(): boolean;
  79535. /**
  79536. * Dispose this feature and all of the resources attached
  79537. */
  79538. dispose(): void;
  79539. protected _onXRFrame(frame: XRFrame): void;
  79540. private _onHitTestResults;
  79541. private _onSelect;
  79542. }
  79543. }
  79544. declare module "babylonjs/XR/features/WebXRHitTest" {
  79545. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79546. import { Observable } from "babylonjs/Misc/observable";
  79547. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79548. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79549. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79550. /**
  79551. * Options used for hit testing (version 2)
  79552. */
  79553. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79554. /**
  79555. * Do not create a permanent hit test. Will usually be used when only
  79556. * transient inputs are needed.
  79557. */
  79558. disablePermanentHitTest?: boolean;
  79559. /**
  79560. * Enable transient (for example touch-based) hit test inspections
  79561. */
  79562. enableTransientHitTest?: boolean;
  79563. /**
  79564. * Offset ray for the permanent hit test
  79565. */
  79566. offsetRay?: Vector3;
  79567. /**
  79568. * Offset ray for the transient hit test
  79569. */
  79570. transientOffsetRay?: Vector3;
  79571. /**
  79572. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79573. */
  79574. useReferenceSpace?: boolean;
  79575. /**
  79576. * Override the default entity type(s) of the hit-test result
  79577. */
  79578. entityTypes?: XRHitTestTrackableType[];
  79579. }
  79580. /**
  79581. * Interface defining the babylon result of hit-test
  79582. */
  79583. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79584. /**
  79585. * The input source that generated this hit test (if transient)
  79586. */
  79587. inputSource?: XRInputSource;
  79588. /**
  79589. * Is this a transient hit test
  79590. */
  79591. isTransient?: boolean;
  79592. /**
  79593. * Position of the hit test result
  79594. */
  79595. position: Vector3;
  79596. /**
  79597. * Rotation of the hit test result
  79598. */
  79599. rotationQuaternion: Quaternion;
  79600. /**
  79601. * The native hit test result
  79602. */
  79603. xrHitResult: XRHitTestResult;
  79604. }
  79605. /**
  79606. * The currently-working hit-test module.
  79607. * Hit test (or Ray-casting) is used to interact with the real world.
  79608. * For further information read here - https://github.com/immersive-web/hit-test
  79609. *
  79610. * Tested on chrome (mobile) 80.
  79611. */
  79612. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79613. /**
  79614. * options to use when constructing this feature
  79615. */
  79616. readonly options: IWebXRHitTestOptions;
  79617. private _tmpMat;
  79618. private _tmpPos;
  79619. private _tmpQuat;
  79620. private _transientXrHitTestSource;
  79621. private _xrHitTestSource;
  79622. private initHitTestSource;
  79623. /**
  79624. * The module's name
  79625. */
  79626. static readonly Name: string;
  79627. /**
  79628. * The (Babylon) version of this module.
  79629. * This is an integer representing the implementation version.
  79630. * This number does not correspond to the WebXR specs version
  79631. */
  79632. static readonly Version: number;
  79633. /**
  79634. * When set to true, each hit test will have its own position/rotation objects
  79635. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79636. * the developers will clone them or copy them as they see fit.
  79637. */
  79638. autoCloneTransformation: boolean;
  79639. /**
  79640. * Triggered when new babylon (transformed) hit test results are available
  79641. * Note - this will be called when results come back from the device. It can be an empty array!!
  79642. */
  79643. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79644. /**
  79645. * Use this to temporarily pause hit test checks.
  79646. */
  79647. paused: boolean;
  79648. /**
  79649. * Creates a new instance of the hit test feature
  79650. * @param _xrSessionManager an instance of WebXRSessionManager
  79651. * @param options options to use when constructing this feature
  79652. */
  79653. constructor(_xrSessionManager: WebXRSessionManager,
  79654. /**
  79655. * options to use when constructing this feature
  79656. */
  79657. options?: IWebXRHitTestOptions);
  79658. /**
  79659. * attach this feature
  79660. * Will usually be called by the features manager
  79661. *
  79662. * @returns true if successful.
  79663. */
  79664. attach(): boolean;
  79665. /**
  79666. * detach this feature.
  79667. * Will usually be called by the features manager
  79668. *
  79669. * @returns true if successful.
  79670. */
  79671. detach(): boolean;
  79672. /**
  79673. * Dispose this feature and all of the resources attached
  79674. */
  79675. dispose(): void;
  79676. protected _onXRFrame(frame: XRFrame): void;
  79677. private _processWebXRHitTestResult;
  79678. }
  79679. }
  79680. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79681. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79682. import { Observable } from "babylonjs/Misc/observable";
  79683. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79684. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79685. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79686. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79687. /**
  79688. * Configuration options of the anchor system
  79689. */
  79690. export interface IWebXRAnchorSystemOptions {
  79691. /**
  79692. * a node that will be used to convert local to world coordinates
  79693. */
  79694. worldParentNode?: TransformNode;
  79695. /**
  79696. * If set to true a reference of the created anchors will be kept until the next session starts
  79697. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79698. */
  79699. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79700. }
  79701. /**
  79702. * A babylon container for an XR Anchor
  79703. */
  79704. export interface IWebXRAnchor {
  79705. /**
  79706. * A babylon-assigned ID for this anchor
  79707. */
  79708. id: number;
  79709. /**
  79710. * Transformation matrix to apply to an object attached to this anchor
  79711. */
  79712. transformationMatrix: Matrix;
  79713. /**
  79714. * The native anchor object
  79715. */
  79716. xrAnchor: XRAnchor;
  79717. /**
  79718. * if defined, this object will be constantly updated by the anchor's position and rotation
  79719. */
  79720. attachedNode?: TransformNode;
  79721. }
  79722. /**
  79723. * An implementation of the anchor system for WebXR.
  79724. * For further information see https://github.com/immersive-web/anchors/
  79725. */
  79726. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79727. private _options;
  79728. private _lastFrameDetected;
  79729. private _trackedAnchors;
  79730. private _referenceSpaceForFrameAnchors;
  79731. private _futureAnchors;
  79732. /**
  79733. * The module's name
  79734. */
  79735. static readonly Name: string;
  79736. /**
  79737. * The (Babylon) version of this module.
  79738. * This is an integer representing the implementation version.
  79739. * This number does not correspond to the WebXR specs version
  79740. */
  79741. static readonly Version: number;
  79742. /**
  79743. * Observers registered here will be executed when a new anchor was added to the session
  79744. */
  79745. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79746. /**
  79747. * Observers registered here will be executed when an anchor was removed from the session
  79748. */
  79749. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79750. /**
  79751. * Observers registered here will be executed when an existing anchor updates
  79752. * This can execute N times every frame
  79753. */
  79754. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79755. /**
  79756. * Set the reference space to use for anchor creation, when not using a hit test.
  79757. * Will default to the session's reference space if not defined
  79758. */
  79759. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79760. /**
  79761. * constructs a new anchor system
  79762. * @param _xrSessionManager an instance of WebXRSessionManager
  79763. * @param _options configuration object for this feature
  79764. */
  79765. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79766. private _tmpVector;
  79767. private _tmpQuaternion;
  79768. private _populateTmpTransformation;
  79769. /**
  79770. * Create a new anchor point using a hit test result at a specific point in the scene
  79771. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79772. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79773. *
  79774. * @param hitTestResult The hit test result to use for this anchor creation
  79775. * @param position an optional position offset for this anchor
  79776. * @param rotationQuaternion an optional rotation offset for this anchor
  79777. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79778. */
  79779. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79780. /**
  79781. * Add a new anchor at a specific position and rotation
  79782. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79783. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79784. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79785. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79786. *
  79787. * @param position the position in which to add an anchor
  79788. * @param rotationQuaternion an optional rotation for the anchor transformation
  79789. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79790. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79791. */
  79792. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79793. /**
  79794. * detach this feature.
  79795. * Will usually be called by the features manager
  79796. *
  79797. * @returns true if successful.
  79798. */
  79799. detach(): boolean;
  79800. /**
  79801. * Dispose this feature and all of the resources attached
  79802. */
  79803. dispose(): void;
  79804. protected _onXRFrame(frame: XRFrame): void;
  79805. /**
  79806. * avoiding using Array.find for global support.
  79807. * @param xrAnchor the plane to find in the array
  79808. */
  79809. private _findIndexInAnchorArray;
  79810. private _updateAnchorWithXRFrame;
  79811. private _createAnchorAtTransformation;
  79812. }
  79813. }
  79814. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79815. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79816. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79817. import { Observable } from "babylonjs/Misc/observable";
  79818. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79819. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79820. /**
  79821. * Options used in the plane detector module
  79822. */
  79823. export interface IWebXRPlaneDetectorOptions {
  79824. /**
  79825. * The node to use to transform the local results to world coordinates
  79826. */
  79827. worldParentNode?: TransformNode;
  79828. /**
  79829. * If set to true a reference of the created planes will be kept until the next session starts
  79830. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79831. */
  79832. doNotRemovePlanesOnSessionEnded?: boolean;
  79833. }
  79834. /**
  79835. * A babylon interface for a WebXR plane.
  79836. * A Plane is actually a polygon, built from N points in space
  79837. *
  79838. * Supported in chrome 79, not supported in canary 81 ATM
  79839. */
  79840. export interface IWebXRPlane {
  79841. /**
  79842. * a babylon-assigned ID for this polygon
  79843. */
  79844. id: number;
  79845. /**
  79846. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79847. */
  79848. polygonDefinition: Array<Vector3>;
  79849. /**
  79850. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79851. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79852. */
  79853. transformationMatrix: Matrix;
  79854. /**
  79855. * the native xr-plane object
  79856. */
  79857. xrPlane: XRPlane;
  79858. }
  79859. /**
  79860. * The plane detector is used to detect planes in the real world when in AR
  79861. * For more information see https://github.com/immersive-web/real-world-geometry/
  79862. */
  79863. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79864. private _options;
  79865. private _detectedPlanes;
  79866. private _enabled;
  79867. private _lastFrameDetected;
  79868. /**
  79869. * The module's name
  79870. */
  79871. static readonly Name: string;
  79872. /**
  79873. * The (Babylon) version of this module.
  79874. * This is an integer representing the implementation version.
  79875. * This number does not correspond to the WebXR specs version
  79876. */
  79877. static readonly Version: number;
  79878. /**
  79879. * Observers registered here will be executed when a new plane was added to the session
  79880. */
  79881. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79882. /**
  79883. * Observers registered here will be executed when a plane is no longer detected in the session
  79884. */
  79885. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79886. /**
  79887. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79888. * This can execute N times every frame
  79889. */
  79890. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79891. /**
  79892. * construct a new Plane Detector
  79893. * @param _xrSessionManager an instance of xr Session manager
  79894. * @param _options configuration to use when constructing this feature
  79895. */
  79896. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79897. /**
  79898. * detach this feature.
  79899. * Will usually be called by the features manager
  79900. *
  79901. * @returns true if successful.
  79902. */
  79903. detach(): boolean;
  79904. /**
  79905. * Dispose this feature and all of the resources attached
  79906. */
  79907. dispose(): void;
  79908. protected _onXRFrame(frame: XRFrame): void;
  79909. private _init;
  79910. private _updatePlaneWithXRPlane;
  79911. /**
  79912. * avoiding using Array.find for global support.
  79913. * @param xrPlane the plane to find in the array
  79914. */
  79915. private findIndexInPlaneArray;
  79916. }
  79917. }
  79918. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79919. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79921. import { Observable } from "babylonjs/Misc/observable";
  79922. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79923. /**
  79924. * Options interface for the background remover plugin
  79925. */
  79926. export interface IWebXRBackgroundRemoverOptions {
  79927. /**
  79928. * Further background meshes to disable when entering AR
  79929. */
  79930. backgroundMeshes?: AbstractMesh[];
  79931. /**
  79932. * flags to configure the removal of the environment helper.
  79933. * If not set, the entire background will be removed. If set, flags should be set as well.
  79934. */
  79935. environmentHelperRemovalFlags?: {
  79936. /**
  79937. * Should the skybox be removed (default false)
  79938. */
  79939. skyBox?: boolean;
  79940. /**
  79941. * Should the ground be removed (default false)
  79942. */
  79943. ground?: boolean;
  79944. };
  79945. /**
  79946. * don't disable the environment helper
  79947. */
  79948. ignoreEnvironmentHelper?: boolean;
  79949. }
  79950. /**
  79951. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79952. */
  79953. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79954. /**
  79955. * read-only options to be used in this module
  79956. */
  79957. readonly options: IWebXRBackgroundRemoverOptions;
  79958. /**
  79959. * The module's name
  79960. */
  79961. static readonly Name: string;
  79962. /**
  79963. * The (Babylon) version of this module.
  79964. * This is an integer representing the implementation version.
  79965. * This number does not correspond to the WebXR specs version
  79966. */
  79967. static readonly Version: number;
  79968. /**
  79969. * registered observers will be triggered when the background state changes
  79970. */
  79971. onBackgroundStateChangedObservable: Observable<boolean>;
  79972. /**
  79973. * constructs a new background remover module
  79974. * @param _xrSessionManager the session manager for this module
  79975. * @param options read-only options to be used in this module
  79976. */
  79977. constructor(_xrSessionManager: WebXRSessionManager,
  79978. /**
  79979. * read-only options to be used in this module
  79980. */
  79981. options?: IWebXRBackgroundRemoverOptions);
  79982. /**
  79983. * attach this feature
  79984. * Will usually be called by the features manager
  79985. *
  79986. * @returns true if successful.
  79987. */
  79988. attach(): boolean;
  79989. /**
  79990. * detach this feature.
  79991. * Will usually be called by the features manager
  79992. *
  79993. * @returns true if successful.
  79994. */
  79995. detach(): boolean;
  79996. /**
  79997. * Dispose this feature and all of the resources attached
  79998. */
  79999. dispose(): void;
  80000. protected _onXRFrame(_xrFrame: XRFrame): void;
  80001. private _setBackgroundState;
  80002. }
  80003. }
  80004. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80005. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80006. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80007. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80008. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80009. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80010. import { Nullable } from "babylonjs/types";
  80011. /**
  80012. * Options for the controller physics feature
  80013. */
  80014. export class IWebXRControllerPhysicsOptions {
  80015. /**
  80016. * Should the headset get its own impostor
  80017. */
  80018. enableHeadsetImpostor?: boolean;
  80019. /**
  80020. * Optional parameters for the headset impostor
  80021. */
  80022. headsetImpostorParams?: {
  80023. /**
  80024. * The type of impostor to create. Default is sphere
  80025. */
  80026. impostorType: number;
  80027. /**
  80028. * the size of the impostor. Defaults to 10cm
  80029. */
  80030. impostorSize?: number | {
  80031. width: number;
  80032. height: number;
  80033. depth: number;
  80034. };
  80035. /**
  80036. * Friction definitions
  80037. */
  80038. friction?: number;
  80039. /**
  80040. * Restitution
  80041. */
  80042. restitution?: number;
  80043. };
  80044. /**
  80045. * The physics properties of the future impostors
  80046. */
  80047. physicsProperties?: {
  80048. /**
  80049. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80050. * Note that this requires a physics engine that supports mesh impostors!
  80051. */
  80052. useControllerMesh?: boolean;
  80053. /**
  80054. * The type of impostor to create. Default is sphere
  80055. */
  80056. impostorType?: number;
  80057. /**
  80058. * the size of the impostor. Defaults to 10cm
  80059. */
  80060. impostorSize?: number | {
  80061. width: number;
  80062. height: number;
  80063. depth: number;
  80064. };
  80065. /**
  80066. * Friction definitions
  80067. */
  80068. friction?: number;
  80069. /**
  80070. * Restitution
  80071. */
  80072. restitution?: number;
  80073. };
  80074. /**
  80075. * the xr input to use with this pointer selection
  80076. */
  80077. xrInput: WebXRInput;
  80078. }
  80079. /**
  80080. * Add physics impostor to your webxr controllers,
  80081. * including naive calculation of their linear and angular velocity
  80082. */
  80083. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80084. private readonly _options;
  80085. private _attachController;
  80086. private _controllers;
  80087. private _debugMode;
  80088. private _delta;
  80089. private _headsetImpostor?;
  80090. private _headsetMesh?;
  80091. private _lastTimestamp;
  80092. private _tmpQuaternion;
  80093. private _tmpVector;
  80094. /**
  80095. * The module's name
  80096. */
  80097. static readonly Name: string;
  80098. /**
  80099. * The (Babylon) version of this module.
  80100. * This is an integer representing the implementation version.
  80101. * This number does not correspond to the webxr specs version
  80102. */
  80103. static readonly Version: number;
  80104. /**
  80105. * Construct a new Controller Physics Feature
  80106. * @param _xrSessionManager the corresponding xr session manager
  80107. * @param _options options to create this feature with
  80108. */
  80109. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80110. /**
  80111. * @hidden
  80112. * enable debugging - will show console outputs and the impostor mesh
  80113. */
  80114. _enablePhysicsDebug(): void;
  80115. /**
  80116. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80117. * @param xrController the controller to add
  80118. */
  80119. addController(xrController: WebXRInputSource): void;
  80120. /**
  80121. * attach this feature
  80122. * Will usually be called by the features manager
  80123. *
  80124. * @returns true if successful.
  80125. */
  80126. attach(): boolean;
  80127. /**
  80128. * detach this feature.
  80129. * Will usually be called by the features manager
  80130. *
  80131. * @returns true if successful.
  80132. */
  80133. detach(): boolean;
  80134. /**
  80135. * Get the headset impostor, if enabled
  80136. * @returns the impostor
  80137. */
  80138. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80139. /**
  80140. * Get the physics impostor of a specific controller.
  80141. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80142. * @param controller the controller or the controller id of which to get the impostor
  80143. * @returns the impostor or null
  80144. */
  80145. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80146. /**
  80147. * Update the physics properties provided in the constructor
  80148. * @param newProperties the new properties object
  80149. */
  80150. setPhysicsProperties(newProperties: {
  80151. impostorType?: number;
  80152. impostorSize?: number | {
  80153. width: number;
  80154. height: number;
  80155. depth: number;
  80156. };
  80157. friction?: number;
  80158. restitution?: number;
  80159. }): void;
  80160. protected _onXRFrame(_xrFrame: any): void;
  80161. private _detachController;
  80162. }
  80163. }
  80164. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80165. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80166. import { Observable } from "babylonjs/Misc/observable";
  80167. import { Vector3 } from "babylonjs/Maths/math.vector";
  80168. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80169. /**
  80170. * A babylon interface for a "WebXR" feature point.
  80171. * Represents the position and confidence value of a given feature point.
  80172. */
  80173. export interface IWebXRFeaturePoint {
  80174. /**
  80175. * Represents the position of the feature point in world space.
  80176. */
  80177. position: Vector3;
  80178. /**
  80179. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80180. */
  80181. confidenceValue: number;
  80182. }
  80183. /**
  80184. * The feature point system is used to detect feature points from real world geometry.
  80185. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80186. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80187. */
  80188. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80189. private _enabled;
  80190. private _featurePointCloud;
  80191. /**
  80192. * The module's name
  80193. */
  80194. static readonly Name: string;
  80195. /**
  80196. * The (Babylon) version of this module.
  80197. * This is an integer representing the implementation version.
  80198. * This number does not correspond to the WebXR specs version
  80199. */
  80200. static readonly Version: number;
  80201. /**
  80202. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80203. * Will notify the observers about which feature points have been added.
  80204. */
  80205. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80206. /**
  80207. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80208. * Will notify the observers about which feature points have been updated.
  80209. */
  80210. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80211. /**
  80212. * The current feature point cloud maintained across frames.
  80213. */
  80214. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80215. /**
  80216. * construct the feature point system
  80217. * @param _xrSessionManager an instance of xr Session manager
  80218. */
  80219. constructor(_xrSessionManager: WebXRSessionManager);
  80220. /**
  80221. * Detach this feature.
  80222. * Will usually be called by the features manager
  80223. *
  80224. * @returns true if successful.
  80225. */
  80226. detach(): boolean;
  80227. /**
  80228. * Dispose this feature and all of the resources attached
  80229. */
  80230. dispose(): void;
  80231. /**
  80232. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80233. */
  80234. protected _onXRFrame(frame: XRFrame): void;
  80235. /**
  80236. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80237. */
  80238. private _init;
  80239. }
  80240. }
  80241. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80242. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80243. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80245. import { Mesh } from "babylonjs/Meshes/mesh";
  80246. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80247. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80248. import { Nullable } from "babylonjs/types";
  80249. import { IDisposable } from "babylonjs/scene";
  80250. import { Observable } from "babylonjs/Misc/observable";
  80251. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80252. /**
  80253. * Configuration interface for the hand tracking feature
  80254. */
  80255. export interface IWebXRHandTrackingOptions {
  80256. /**
  80257. * The xrInput that will be used as source for new hands
  80258. */
  80259. xrInput: WebXRInput;
  80260. /**
  80261. * Configuration object for the joint meshes
  80262. */
  80263. jointMeshes?: {
  80264. /**
  80265. * Should the meshes created be invisible (defaults to false)
  80266. */
  80267. invisible?: boolean;
  80268. /**
  80269. * A source mesh to be used to create instances. Defaults to a sphere.
  80270. * This mesh will be the source for all other (25) meshes.
  80271. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80272. */
  80273. sourceMesh?: Mesh;
  80274. /**
  80275. * This function will be called after a mesh was created for a specific joint.
  80276. * Using this function you can either manipulate the instance or return a new mesh.
  80277. * When returning a new mesh the instance created before will be disposed
  80278. */
  80279. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80280. /**
  80281. * Should the source mesh stay visible. Defaults to false
  80282. */
  80283. keepOriginalVisible?: boolean;
  80284. /**
  80285. * Scale factor for all instances (defaults to 2)
  80286. */
  80287. scaleFactor?: number;
  80288. /**
  80289. * Should each instance have its own physics impostor
  80290. */
  80291. enablePhysics?: boolean;
  80292. /**
  80293. * If enabled, override default physics properties
  80294. */
  80295. physicsProps?: {
  80296. friction?: number;
  80297. restitution?: number;
  80298. impostorType?: number;
  80299. };
  80300. /**
  80301. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80302. */
  80303. handMesh?: AbstractMesh;
  80304. };
  80305. }
  80306. /**
  80307. * Parts of the hands divided to writs and finger names
  80308. */
  80309. export const enum HandPart {
  80310. /**
  80311. * HandPart - Wrist
  80312. */
  80313. WRIST = "wrist",
  80314. /**
  80315. * HandPart - The THumb
  80316. */
  80317. THUMB = "thumb",
  80318. /**
  80319. * HandPart - Index finger
  80320. */
  80321. INDEX = "index",
  80322. /**
  80323. * HandPart - Middle finger
  80324. */
  80325. MIDDLE = "middle",
  80326. /**
  80327. * HandPart - Ring finger
  80328. */
  80329. RING = "ring",
  80330. /**
  80331. * HandPart - Little finger
  80332. */
  80333. LITTLE = "little"
  80334. }
  80335. /**
  80336. * Representing a single hand (with its corresponding native XRHand object)
  80337. */
  80338. export class WebXRHand implements IDisposable {
  80339. /** the controller to which the hand correlates */
  80340. readonly xrController: WebXRInputSource;
  80341. /** the meshes to be used to track the hand joints */
  80342. readonly trackedMeshes: AbstractMesh[];
  80343. /**
  80344. * Hand-parts definition (key is HandPart)
  80345. */
  80346. handPartsDefinition: {
  80347. [key: string]: number[];
  80348. };
  80349. /**
  80350. * Populate the HandPartsDefinition object.
  80351. * This is called as a side effect since certain browsers don't have XRHand defined.
  80352. */
  80353. private generateHandPartsDefinition;
  80354. /**
  80355. * Construct a new hand object
  80356. * @param xrController the controller to which the hand correlates
  80357. * @param trackedMeshes the meshes to be used to track the hand joints
  80358. */
  80359. constructor(
  80360. /** the controller to which the hand correlates */
  80361. xrController: WebXRInputSource,
  80362. /** the meshes to be used to track the hand joints */
  80363. trackedMeshes: AbstractMesh[]);
  80364. /**
  80365. * Update this hand from the latest xr frame
  80366. * @param xrFrame xrFrame to update from
  80367. * @param referenceSpace The current viewer reference space
  80368. * @param scaleFactor optional scale factor for the meshes
  80369. */
  80370. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80371. /**
  80372. * Get meshes of part of the hand
  80373. * @param part the part of hand to get
  80374. * @returns An array of meshes that correlate to the hand part requested
  80375. */
  80376. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80377. /**
  80378. * Dispose this Hand object
  80379. */
  80380. dispose(): void;
  80381. }
  80382. /**
  80383. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80384. */
  80385. export class WebXRHandTracking extends WebXRAbstractFeature {
  80386. /**
  80387. * options to use when constructing this feature
  80388. */
  80389. readonly options: IWebXRHandTrackingOptions;
  80390. private static _idCounter;
  80391. /**
  80392. * The module's name
  80393. */
  80394. static readonly Name: string;
  80395. /**
  80396. * The (Babylon) version of this module.
  80397. * This is an integer representing the implementation version.
  80398. * This number does not correspond to the WebXR specs version
  80399. */
  80400. static readonly Version: number;
  80401. /**
  80402. * This observable will notify registered observers when a new hand object was added and initialized
  80403. */
  80404. onHandAddedObservable: Observable<WebXRHand>;
  80405. /**
  80406. * This observable will notify its observers right before the hand object is disposed
  80407. */
  80408. onHandRemovedObservable: Observable<WebXRHand>;
  80409. private _hands;
  80410. /**
  80411. * Creates a new instance of the hit test feature
  80412. * @param _xrSessionManager an instance of WebXRSessionManager
  80413. * @param options options to use when constructing this feature
  80414. */
  80415. constructor(_xrSessionManager: WebXRSessionManager,
  80416. /**
  80417. * options to use when constructing this feature
  80418. */
  80419. options: IWebXRHandTrackingOptions);
  80420. /**
  80421. * Check if the needed objects are defined.
  80422. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80423. */
  80424. isCompatible(): boolean;
  80425. /**
  80426. * attach this feature
  80427. * Will usually be called by the features manager
  80428. *
  80429. * @returns true if successful.
  80430. */
  80431. attach(): boolean;
  80432. /**
  80433. * detach this feature.
  80434. * Will usually be called by the features manager
  80435. *
  80436. * @returns true if successful.
  80437. */
  80438. detach(): boolean;
  80439. /**
  80440. * Dispose this feature and all of the resources attached
  80441. */
  80442. dispose(): void;
  80443. /**
  80444. * Get the hand object according to the controller id
  80445. * @param controllerId the controller id to which we want to get the hand
  80446. * @returns null if not found or the WebXRHand object if found
  80447. */
  80448. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80449. /**
  80450. * Get a hand object according to the requested handedness
  80451. * @param handedness the handedness to request
  80452. * @returns null if not found or the WebXRHand object if found
  80453. */
  80454. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80455. protected _onXRFrame(_xrFrame: XRFrame): void;
  80456. private _attachHand;
  80457. private _detachHand;
  80458. }
  80459. }
  80460. declare module "babylonjs/XR/features/index" {
  80461. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80462. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80463. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80464. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80465. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80466. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80467. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80468. export * from "babylonjs/XR/features/WebXRHitTest";
  80469. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80470. export * from "babylonjs/XR/features/WebXRHandTracking";
  80471. }
  80472. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80473. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80475. import { Scene } from "babylonjs/scene";
  80476. /**
  80477. * The motion controller class for all microsoft mixed reality controllers
  80478. */
  80479. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80480. protected readonly _mapping: {
  80481. defaultButton: {
  80482. valueNodeName: string;
  80483. unpressedNodeName: string;
  80484. pressedNodeName: string;
  80485. };
  80486. defaultAxis: {
  80487. valueNodeName: string;
  80488. minNodeName: string;
  80489. maxNodeName: string;
  80490. };
  80491. buttons: {
  80492. "xr-standard-trigger": {
  80493. rootNodeName: string;
  80494. componentProperty: string;
  80495. states: string[];
  80496. };
  80497. "xr-standard-squeeze": {
  80498. rootNodeName: string;
  80499. componentProperty: string;
  80500. states: string[];
  80501. };
  80502. "xr-standard-touchpad": {
  80503. rootNodeName: string;
  80504. labelAnchorNodeName: string;
  80505. touchPointNodeName: string;
  80506. };
  80507. "xr-standard-thumbstick": {
  80508. rootNodeName: string;
  80509. componentProperty: string;
  80510. states: string[];
  80511. };
  80512. };
  80513. axes: {
  80514. "xr-standard-touchpad": {
  80515. "x-axis": {
  80516. rootNodeName: string;
  80517. };
  80518. "y-axis": {
  80519. rootNodeName: string;
  80520. };
  80521. };
  80522. "xr-standard-thumbstick": {
  80523. "x-axis": {
  80524. rootNodeName: string;
  80525. };
  80526. "y-axis": {
  80527. rootNodeName: string;
  80528. };
  80529. };
  80530. };
  80531. };
  80532. /**
  80533. * The base url used to load the left and right controller models
  80534. */
  80535. static MODEL_BASE_URL: string;
  80536. /**
  80537. * The name of the left controller model file
  80538. */
  80539. static MODEL_LEFT_FILENAME: string;
  80540. /**
  80541. * The name of the right controller model file
  80542. */
  80543. static MODEL_RIGHT_FILENAME: string;
  80544. profileId: string;
  80545. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80546. protected _getFilenameAndPath(): {
  80547. filename: string;
  80548. path: string;
  80549. };
  80550. protected _getModelLoadingConstraints(): boolean;
  80551. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80552. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80553. protected _updateModel(): void;
  80554. }
  80555. }
  80556. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80557. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80559. import { Scene } from "babylonjs/scene";
  80560. /**
  80561. * The motion controller class for oculus touch (quest, rift).
  80562. * This class supports legacy mapping as well the standard xr mapping
  80563. */
  80564. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80565. private _forceLegacyControllers;
  80566. private _modelRootNode;
  80567. /**
  80568. * The base url used to load the left and right controller models
  80569. */
  80570. static MODEL_BASE_URL: string;
  80571. /**
  80572. * The name of the left controller model file
  80573. */
  80574. static MODEL_LEFT_FILENAME: string;
  80575. /**
  80576. * The name of the right controller model file
  80577. */
  80578. static MODEL_RIGHT_FILENAME: string;
  80579. /**
  80580. * Base Url for the Quest controller model.
  80581. */
  80582. static QUEST_MODEL_BASE_URL: string;
  80583. profileId: string;
  80584. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80585. protected _getFilenameAndPath(): {
  80586. filename: string;
  80587. path: string;
  80588. };
  80589. protected _getModelLoadingConstraints(): boolean;
  80590. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80591. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80592. protected _updateModel(): void;
  80593. /**
  80594. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80595. * between the touch and touch 2.
  80596. */
  80597. private _isQuest;
  80598. }
  80599. }
  80600. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80601. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80602. import { Scene } from "babylonjs/scene";
  80603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80604. /**
  80605. * The motion controller class for the standard HTC-Vive controllers
  80606. */
  80607. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80608. private _modelRootNode;
  80609. /**
  80610. * The base url used to load the left and right controller models
  80611. */
  80612. static MODEL_BASE_URL: string;
  80613. /**
  80614. * File name for the controller model.
  80615. */
  80616. static MODEL_FILENAME: string;
  80617. profileId: string;
  80618. /**
  80619. * Create a new Vive motion controller object
  80620. * @param scene the scene to use to create this controller
  80621. * @param gamepadObject the corresponding gamepad object
  80622. * @param handedness the handedness of the controller
  80623. */
  80624. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80625. protected _getFilenameAndPath(): {
  80626. filename: string;
  80627. path: string;
  80628. };
  80629. protected _getModelLoadingConstraints(): boolean;
  80630. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80631. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80632. protected _updateModel(): void;
  80633. }
  80634. }
  80635. declare module "babylonjs/XR/motionController/index" {
  80636. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80637. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80638. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80639. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80640. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80641. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80642. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80643. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80644. }
  80645. declare module "babylonjs/XR/index" {
  80646. export * from "babylonjs/XR/webXRCamera";
  80647. export * from "babylonjs/XR/webXREnterExitUI";
  80648. export * from "babylonjs/XR/webXRExperienceHelper";
  80649. export * from "babylonjs/XR/webXRInput";
  80650. export * from "babylonjs/XR/webXRInputSource";
  80651. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80652. export * from "babylonjs/XR/webXRTypes";
  80653. export * from "babylonjs/XR/webXRSessionManager";
  80654. export * from "babylonjs/XR/webXRDefaultExperience";
  80655. export * from "babylonjs/XR/webXRFeaturesManager";
  80656. export * from "babylonjs/XR/features/index";
  80657. export * from "babylonjs/XR/motionController/index";
  80658. }
  80659. declare module "babylonjs/index" {
  80660. export * from "babylonjs/abstractScene";
  80661. export * from "babylonjs/Actions/index";
  80662. export * from "babylonjs/Animations/index";
  80663. export * from "babylonjs/assetContainer";
  80664. export * from "babylonjs/Audio/index";
  80665. export * from "babylonjs/Behaviors/index";
  80666. export * from "babylonjs/Bones/index";
  80667. export * from "babylonjs/Cameras/index";
  80668. export * from "babylonjs/Collisions/index";
  80669. export * from "babylonjs/Culling/index";
  80670. export * from "babylonjs/Debug/index";
  80671. export * from "babylonjs/DeviceInput/index";
  80672. export * from "babylonjs/Engines/index";
  80673. export * from "babylonjs/Events/index";
  80674. export * from "babylonjs/Gamepads/index";
  80675. export * from "babylonjs/Gizmos/index";
  80676. export * from "babylonjs/Helpers/index";
  80677. export * from "babylonjs/Instrumentation/index";
  80678. export * from "babylonjs/Layers/index";
  80679. export * from "babylonjs/LensFlares/index";
  80680. export * from "babylonjs/Lights/index";
  80681. export * from "babylonjs/Loading/index";
  80682. export * from "babylonjs/Materials/index";
  80683. export * from "babylonjs/Maths/index";
  80684. export * from "babylonjs/Meshes/index";
  80685. export * from "babylonjs/Morph/index";
  80686. export * from "babylonjs/Navigation/index";
  80687. export * from "babylonjs/node";
  80688. export * from "babylonjs/Offline/index";
  80689. export * from "babylonjs/Particles/index";
  80690. export * from "babylonjs/Physics/index";
  80691. export * from "babylonjs/PostProcesses/index";
  80692. export * from "babylonjs/Probes/index";
  80693. export * from "babylonjs/Rendering/index";
  80694. export * from "babylonjs/scene";
  80695. export * from "babylonjs/sceneComponent";
  80696. export * from "babylonjs/Sprites/index";
  80697. export * from "babylonjs/States/index";
  80698. export * from "babylonjs/Misc/index";
  80699. export * from "babylonjs/XR/index";
  80700. export * from "babylonjs/types";
  80701. }
  80702. declare module "babylonjs/Animations/pathCursor" {
  80703. import { Vector3 } from "babylonjs/Maths/math.vector";
  80704. import { Path2 } from "babylonjs/Maths/math.path";
  80705. /**
  80706. * A cursor which tracks a point on a path
  80707. */
  80708. export class PathCursor {
  80709. private path;
  80710. /**
  80711. * Stores path cursor callbacks for when an onchange event is triggered
  80712. */
  80713. private _onchange;
  80714. /**
  80715. * The value of the path cursor
  80716. */
  80717. value: number;
  80718. /**
  80719. * The animation array of the path cursor
  80720. */
  80721. animations: Animation[];
  80722. /**
  80723. * Initializes the path cursor
  80724. * @param path The path to track
  80725. */
  80726. constructor(path: Path2);
  80727. /**
  80728. * Gets the cursor point on the path
  80729. * @returns A point on the path cursor at the cursor location
  80730. */
  80731. getPoint(): Vector3;
  80732. /**
  80733. * Moves the cursor ahead by the step amount
  80734. * @param step The amount to move the cursor forward
  80735. * @returns This path cursor
  80736. */
  80737. moveAhead(step?: number): PathCursor;
  80738. /**
  80739. * Moves the cursor behind by the step amount
  80740. * @param step The amount to move the cursor back
  80741. * @returns This path cursor
  80742. */
  80743. moveBack(step?: number): PathCursor;
  80744. /**
  80745. * Moves the cursor by the step amount
  80746. * If the step amount is greater than one, an exception is thrown
  80747. * @param step The amount to move the cursor
  80748. * @returns This path cursor
  80749. */
  80750. move(step: number): PathCursor;
  80751. /**
  80752. * Ensures that the value is limited between zero and one
  80753. * @returns This path cursor
  80754. */
  80755. private ensureLimits;
  80756. /**
  80757. * Runs onchange callbacks on change (used by the animation engine)
  80758. * @returns This path cursor
  80759. */
  80760. private raiseOnChange;
  80761. /**
  80762. * Executes a function on change
  80763. * @param f A path cursor onchange callback
  80764. * @returns This path cursor
  80765. */
  80766. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80767. }
  80768. }
  80769. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80770. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80771. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80772. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80773. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80774. }
  80775. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80776. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80777. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80778. }
  80779. declare module "babylonjs/Engines/Processors/index" {
  80780. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80781. export * from "babylonjs/Engines/Processors/Expressions/index";
  80782. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80783. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80784. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80785. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80786. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80787. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80788. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80789. }
  80790. declare module "babylonjs/Legacy/legacy" {
  80791. import * as Babylon from "babylonjs/index";
  80792. export * from "babylonjs/index";
  80793. }
  80794. declare module "babylonjs/Shaders/blur.fragment" {
  80795. /** @hidden */
  80796. export var blurPixelShader: {
  80797. name: string;
  80798. shader: string;
  80799. };
  80800. }
  80801. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80802. /** @hidden */
  80803. export var pointCloudVertexDeclaration: {
  80804. name: string;
  80805. shader: string;
  80806. };
  80807. }
  80808. declare module "babylonjs" {
  80809. export * from "babylonjs/Legacy/legacy";
  80810. }
  80811. declare module BABYLON {
  80812. /** Alias type for value that can be null */
  80813. export type Nullable<T> = T | null;
  80814. /**
  80815. * Alias type for number that are floats
  80816. * @ignorenaming
  80817. */
  80818. export type float = number;
  80819. /**
  80820. * Alias type for number that are doubles.
  80821. * @ignorenaming
  80822. */
  80823. export type double = number;
  80824. /**
  80825. * Alias type for number that are integer
  80826. * @ignorenaming
  80827. */
  80828. export type int = number;
  80829. /** Alias type for number array or Float32Array */
  80830. export type FloatArray = number[] | Float32Array;
  80831. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80832. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80833. /**
  80834. * Alias for types that can be used by a Buffer or VertexBuffer.
  80835. */
  80836. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80837. /**
  80838. * Alias type for primitive types
  80839. * @ignorenaming
  80840. */
  80841. type Primitive = undefined | null | boolean | string | number | Function;
  80842. /**
  80843. * Type modifier to make all the properties of an object Readonly
  80844. */
  80845. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80846. /**
  80847. * Type modifier to make all the properties of an object Readonly recursively
  80848. */
  80849. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80850. /**
  80851. * Type modifier to make object properties readonly.
  80852. */
  80853. export type DeepImmutableObject<T> = {
  80854. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80855. };
  80856. /** @hidden */
  80857. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80858. }
  80859. }
  80860. declare module BABYLON {
  80861. /**
  80862. * A class serves as a medium between the observable and its observers
  80863. */
  80864. export class EventState {
  80865. /**
  80866. * Create a new EventState
  80867. * @param mask defines the mask associated with this state
  80868. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80869. * @param target defines the original target of the state
  80870. * @param currentTarget defines the current target of the state
  80871. */
  80872. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80873. /**
  80874. * Initialize the current event state
  80875. * @param mask defines the mask associated with this state
  80876. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80877. * @param target defines the original target of the state
  80878. * @param currentTarget defines the current target of the state
  80879. * @returns the current event state
  80880. */
  80881. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80882. /**
  80883. * An Observer can set this property to true to prevent subsequent observers of being notified
  80884. */
  80885. skipNextObservers: boolean;
  80886. /**
  80887. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80888. */
  80889. mask: number;
  80890. /**
  80891. * The object that originally notified the event
  80892. */
  80893. target?: any;
  80894. /**
  80895. * The current object in the bubbling phase
  80896. */
  80897. currentTarget?: any;
  80898. /**
  80899. * This will be populated with the return value of the last function that was executed.
  80900. * If it is the first function in the callback chain it will be the event data.
  80901. */
  80902. lastReturnValue?: any;
  80903. /**
  80904. * User defined information that will be sent to observers
  80905. */
  80906. userInfo?: any;
  80907. }
  80908. /**
  80909. * Represent an Observer registered to a given Observable object.
  80910. */
  80911. export class Observer<T> {
  80912. /**
  80913. * Defines the callback to call when the observer is notified
  80914. */
  80915. callback: (eventData: T, eventState: EventState) => void;
  80916. /**
  80917. * Defines the mask of the observer (used to filter notifications)
  80918. */
  80919. mask: number;
  80920. /**
  80921. * Defines the current scope used to restore the JS context
  80922. */
  80923. scope: any;
  80924. /** @hidden */
  80925. _willBeUnregistered: boolean;
  80926. /**
  80927. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80928. */
  80929. unregisterOnNextCall: boolean;
  80930. /**
  80931. * Creates a new observer
  80932. * @param callback defines the callback to call when the observer is notified
  80933. * @param mask defines the mask of the observer (used to filter notifications)
  80934. * @param scope defines the current scope used to restore the JS context
  80935. */
  80936. constructor(
  80937. /**
  80938. * Defines the callback to call when the observer is notified
  80939. */
  80940. callback: (eventData: T, eventState: EventState) => void,
  80941. /**
  80942. * Defines the mask of the observer (used to filter notifications)
  80943. */
  80944. mask: number,
  80945. /**
  80946. * Defines the current scope used to restore the JS context
  80947. */
  80948. scope?: any);
  80949. }
  80950. /**
  80951. * Represent a list of observers registered to multiple Observables object.
  80952. */
  80953. export class MultiObserver<T> {
  80954. private _observers;
  80955. private _observables;
  80956. /**
  80957. * Release associated resources
  80958. */
  80959. dispose(): void;
  80960. /**
  80961. * Raise a callback when one of the observable will notify
  80962. * @param observables defines a list of observables to watch
  80963. * @param callback defines the callback to call on notification
  80964. * @param mask defines the mask used to filter notifications
  80965. * @param scope defines the current scope used to restore the JS context
  80966. * @returns the new MultiObserver
  80967. */
  80968. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80969. }
  80970. /**
  80971. * The Observable class is a simple implementation of the Observable pattern.
  80972. *
  80973. * 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.
  80974. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80975. * 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).
  80976. * 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.
  80977. */
  80978. export class Observable<T> {
  80979. private _observers;
  80980. private _eventState;
  80981. private _onObserverAdded;
  80982. /**
  80983. * Gets the list of observers
  80984. */
  80985. get observers(): Array<Observer<T>>;
  80986. /**
  80987. * Creates a new observable
  80988. * @param onObserverAdded defines a callback to call when a new observer is added
  80989. */
  80990. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80991. /**
  80992. * Create a new Observer with the specified callback
  80993. * @param callback the callback that will be executed for that Observer
  80994. * @param mask the mask used to filter observers
  80995. * @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.
  80996. * @param scope optional scope for the callback to be called from
  80997. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80998. * @returns the new observer created for the callback
  80999. */
  81000. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81001. /**
  81002. * Create a new Observer with the specified callback and unregisters after the next notification
  81003. * @param callback the callback that will be executed for that Observer
  81004. * @returns the new observer created for the callback
  81005. */
  81006. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81007. /**
  81008. * Remove an Observer from the Observable object
  81009. * @param observer the instance of the Observer to remove
  81010. * @returns false if it doesn't belong to this Observable
  81011. */
  81012. remove(observer: Nullable<Observer<T>>): boolean;
  81013. /**
  81014. * Remove a callback from the Observable object
  81015. * @param callback the callback to remove
  81016. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81017. * @returns false if it doesn't belong to this Observable
  81018. */
  81019. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81020. private _deferUnregister;
  81021. private _remove;
  81022. /**
  81023. * Moves the observable to the top of the observer list making it get called first when notified
  81024. * @param observer the observer to move
  81025. */
  81026. makeObserverTopPriority(observer: Observer<T>): void;
  81027. /**
  81028. * Moves the observable to the bottom of the observer list making it get called last when notified
  81029. * @param observer the observer to move
  81030. */
  81031. makeObserverBottomPriority(observer: Observer<T>): void;
  81032. /**
  81033. * Notify all Observers by calling their respective callback with the given data
  81034. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81035. * @param eventData defines the data to send to all observers
  81036. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81037. * @param target defines the original target of the state
  81038. * @param currentTarget defines the current target of the state
  81039. * @param userInfo defines any user info to send to observers
  81040. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81041. */
  81042. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81043. /**
  81044. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81045. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81046. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81047. * and it is crucial that all callbacks will be executed.
  81048. * The order of the callbacks is kept, callbacks are not executed parallel.
  81049. *
  81050. * @param eventData The data to be sent to each callback
  81051. * @param mask is used to filter observers defaults to -1
  81052. * @param target defines the callback target (see EventState)
  81053. * @param currentTarget defines he current object in the bubbling phase
  81054. * @param userInfo defines any user info to send to observers
  81055. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81056. */
  81057. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81058. /**
  81059. * Notify a specific observer
  81060. * @param observer defines the observer to notify
  81061. * @param eventData defines the data to be sent to each callback
  81062. * @param mask is used to filter observers defaults to -1
  81063. */
  81064. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81065. /**
  81066. * Gets a boolean indicating if the observable has at least one observer
  81067. * @returns true is the Observable has at least one Observer registered
  81068. */
  81069. hasObservers(): boolean;
  81070. /**
  81071. * Clear the list of observers
  81072. */
  81073. clear(): void;
  81074. /**
  81075. * Clone the current observable
  81076. * @returns a new observable
  81077. */
  81078. clone(): Observable<T>;
  81079. /**
  81080. * Does this observable handles observer registered with a given mask
  81081. * @param mask defines the mask to be tested
  81082. * @return whether or not one observer registered with the given mask is handeled
  81083. **/
  81084. hasSpecificMask(mask?: number): boolean;
  81085. }
  81086. }
  81087. declare module BABYLON {
  81088. /**
  81089. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81090. * Babylon.js
  81091. */
  81092. export class DomManagement {
  81093. /**
  81094. * Checks if the window object exists
  81095. * @returns true if the window object exists
  81096. */
  81097. static IsWindowObjectExist(): boolean;
  81098. /**
  81099. * Checks if the navigator object exists
  81100. * @returns true if the navigator object exists
  81101. */
  81102. static IsNavigatorAvailable(): boolean;
  81103. /**
  81104. * Check if the document object exists
  81105. * @returns true if the document object exists
  81106. */
  81107. static IsDocumentAvailable(): boolean;
  81108. /**
  81109. * Extracts text content from a DOM element hierarchy
  81110. * @param element defines the root element
  81111. * @returns a string
  81112. */
  81113. static GetDOMTextContent(element: HTMLElement): string;
  81114. }
  81115. }
  81116. declare module BABYLON {
  81117. /**
  81118. * Logger used througouht the application to allow configuration of
  81119. * the log level required for the messages.
  81120. */
  81121. export class Logger {
  81122. /**
  81123. * No log
  81124. */
  81125. static readonly NoneLogLevel: number;
  81126. /**
  81127. * Only message logs
  81128. */
  81129. static readonly MessageLogLevel: number;
  81130. /**
  81131. * Only warning logs
  81132. */
  81133. static readonly WarningLogLevel: number;
  81134. /**
  81135. * Only error logs
  81136. */
  81137. static readonly ErrorLogLevel: number;
  81138. /**
  81139. * All logs
  81140. */
  81141. static readonly AllLogLevel: number;
  81142. private static _LogCache;
  81143. /**
  81144. * Gets a value indicating the number of loading errors
  81145. * @ignorenaming
  81146. */
  81147. static errorsCount: number;
  81148. /**
  81149. * Callback called when a new log is added
  81150. */
  81151. static OnNewCacheEntry: (entry: string) => void;
  81152. private static _AddLogEntry;
  81153. private static _FormatMessage;
  81154. private static _LogDisabled;
  81155. private static _LogEnabled;
  81156. private static _WarnDisabled;
  81157. private static _WarnEnabled;
  81158. private static _ErrorDisabled;
  81159. private static _ErrorEnabled;
  81160. /**
  81161. * Log a message to the console
  81162. */
  81163. static Log: (message: string) => void;
  81164. /**
  81165. * Write a warning message to the console
  81166. */
  81167. static Warn: (message: string) => void;
  81168. /**
  81169. * Write an error message to the console
  81170. */
  81171. static Error: (message: string) => void;
  81172. /**
  81173. * Gets current log cache (list of logs)
  81174. */
  81175. static get LogCache(): string;
  81176. /**
  81177. * Clears the log cache
  81178. */
  81179. static ClearLogCache(): void;
  81180. /**
  81181. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81182. */
  81183. static set LogLevels(level: number);
  81184. }
  81185. }
  81186. declare module BABYLON {
  81187. /** @hidden */
  81188. export class _TypeStore {
  81189. /** @hidden */
  81190. static RegisteredTypes: {
  81191. [key: string]: Object;
  81192. };
  81193. /** @hidden */
  81194. static GetClass(fqdn: string): any;
  81195. }
  81196. }
  81197. declare module BABYLON {
  81198. /**
  81199. * Helper to manipulate strings
  81200. */
  81201. export class StringTools {
  81202. /**
  81203. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81204. * @param str Source string
  81205. * @param suffix Suffix to search for in the source string
  81206. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81207. */
  81208. static EndsWith(str: string, suffix: string): boolean;
  81209. /**
  81210. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81211. * @param str Source string
  81212. * @param suffix Suffix to search for in the source string
  81213. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81214. */
  81215. static StartsWith(str: string, suffix: string): boolean;
  81216. /**
  81217. * Decodes a buffer into a string
  81218. * @param buffer The buffer to decode
  81219. * @returns The decoded string
  81220. */
  81221. static Decode(buffer: Uint8Array | Uint16Array): string;
  81222. /**
  81223. * Encode a buffer to a base64 string
  81224. * @param buffer defines the buffer to encode
  81225. * @returns the encoded string
  81226. */
  81227. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81228. /**
  81229. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81230. * @param num the number to convert and pad
  81231. * @param length the expected length of the string
  81232. * @returns the padded string
  81233. */
  81234. static PadNumber(num: number, length: number): string;
  81235. }
  81236. }
  81237. declare module BABYLON {
  81238. /**
  81239. * Class containing a set of static utilities functions for deep copy.
  81240. */
  81241. export class DeepCopier {
  81242. /**
  81243. * Tries to copy an object by duplicating every property
  81244. * @param source defines the source object
  81245. * @param destination defines the target object
  81246. * @param doNotCopyList defines a list of properties to avoid
  81247. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81248. */
  81249. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81250. }
  81251. }
  81252. declare module BABYLON {
  81253. /**
  81254. * Class containing a set of static utilities functions for precision date
  81255. */
  81256. export class PrecisionDate {
  81257. /**
  81258. * Gets either window.performance.now() if supported or Date.now() else
  81259. */
  81260. static get Now(): number;
  81261. }
  81262. }
  81263. declare module BABYLON {
  81264. /** @hidden */
  81265. export class _DevTools {
  81266. static WarnImport(name: string): string;
  81267. }
  81268. }
  81269. declare module BABYLON {
  81270. /**
  81271. * Interface used to define the mechanism to get data from the network
  81272. */
  81273. export interface IWebRequest {
  81274. /**
  81275. * Returns client's response url
  81276. */
  81277. responseURL: string;
  81278. /**
  81279. * Returns client's status
  81280. */
  81281. status: number;
  81282. /**
  81283. * Returns client's status as a text
  81284. */
  81285. statusText: string;
  81286. }
  81287. }
  81288. declare module BABYLON {
  81289. /**
  81290. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81291. */
  81292. export class WebRequest implements IWebRequest {
  81293. private _xhr;
  81294. /**
  81295. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81296. * i.e. when loading files, where the server/service expects an Authorization header
  81297. */
  81298. static CustomRequestHeaders: {
  81299. [key: string]: string;
  81300. };
  81301. /**
  81302. * Add callback functions in this array to update all the requests before they get sent to the network
  81303. */
  81304. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81305. private _injectCustomRequestHeaders;
  81306. /**
  81307. * Gets or sets a function to be called when loading progress changes
  81308. */
  81309. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81310. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81311. /**
  81312. * Returns client's state
  81313. */
  81314. get readyState(): number;
  81315. /**
  81316. * Returns client's status
  81317. */
  81318. get status(): number;
  81319. /**
  81320. * Returns client's status as a text
  81321. */
  81322. get statusText(): string;
  81323. /**
  81324. * Returns client's response
  81325. */
  81326. get response(): any;
  81327. /**
  81328. * Returns client's response url
  81329. */
  81330. get responseURL(): string;
  81331. /**
  81332. * Returns client's response as text
  81333. */
  81334. get responseText(): string;
  81335. /**
  81336. * Gets or sets the expected response type
  81337. */
  81338. get responseType(): XMLHttpRequestResponseType;
  81339. set responseType(value: XMLHttpRequestResponseType);
  81340. /** @hidden */
  81341. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81342. /** @hidden */
  81343. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81344. /**
  81345. * Cancels any network activity
  81346. */
  81347. abort(): void;
  81348. /**
  81349. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81350. * @param body defines an optional request body
  81351. */
  81352. send(body?: Document | BodyInit | null): void;
  81353. /**
  81354. * Sets the request method, request URL
  81355. * @param method defines the method to use (GET, POST, etc..)
  81356. * @param url defines the url to connect with
  81357. */
  81358. open(method: string, url: string): void;
  81359. /**
  81360. * Sets the value of a request header.
  81361. * @param name The name of the header whose value is to be set
  81362. * @param value The value to set as the body of the header
  81363. */
  81364. setRequestHeader(name: string, value: string): void;
  81365. /**
  81366. * Get the string containing the text of a particular header's value.
  81367. * @param name The name of the header
  81368. * @returns The string containing the text of the given header name
  81369. */
  81370. getResponseHeader(name: string): Nullable<string>;
  81371. }
  81372. }
  81373. declare module BABYLON {
  81374. /**
  81375. * File request interface
  81376. */
  81377. export interface IFileRequest {
  81378. /**
  81379. * Raised when the request is complete (success or error).
  81380. */
  81381. onCompleteObservable: Observable<IFileRequest>;
  81382. /**
  81383. * Aborts the request for a file.
  81384. */
  81385. abort: () => void;
  81386. }
  81387. }
  81388. declare module BABYLON {
  81389. /**
  81390. * Define options used to create a render target texture
  81391. */
  81392. export class RenderTargetCreationOptions {
  81393. /**
  81394. * Specifies is mipmaps must be generated
  81395. */
  81396. generateMipMaps?: boolean;
  81397. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81398. generateDepthBuffer?: boolean;
  81399. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81400. generateStencilBuffer?: boolean;
  81401. /** Defines texture type (int by default) */
  81402. type?: number;
  81403. /** Defines sampling mode (trilinear by default) */
  81404. samplingMode?: number;
  81405. /** Defines format (RGBA by default) */
  81406. format?: number;
  81407. }
  81408. }
  81409. declare module BABYLON {
  81410. /** Defines the cross module used constants to avoid circular dependncies */
  81411. export class Constants {
  81412. /** Defines that alpha blending is disabled */
  81413. static readonly ALPHA_DISABLE: number;
  81414. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81415. static readonly ALPHA_ADD: number;
  81416. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81417. static readonly ALPHA_COMBINE: number;
  81418. /** Defines that alpha blending is DEST - SRC * DEST */
  81419. static readonly ALPHA_SUBTRACT: number;
  81420. /** Defines that alpha blending is SRC * DEST */
  81421. static readonly ALPHA_MULTIPLY: number;
  81422. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81423. static readonly ALPHA_MAXIMIZED: number;
  81424. /** Defines that alpha blending is SRC + DEST */
  81425. static readonly ALPHA_ONEONE: number;
  81426. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81427. static readonly ALPHA_PREMULTIPLIED: number;
  81428. /**
  81429. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81430. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81431. */
  81432. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81433. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81434. static readonly ALPHA_INTERPOLATE: number;
  81435. /**
  81436. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81437. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81438. */
  81439. static readonly ALPHA_SCREENMODE: number;
  81440. /**
  81441. * Defines that alpha blending is SRC + DST
  81442. * Alpha will be set to SRC ALPHA + DST ALPHA
  81443. */
  81444. static readonly ALPHA_ONEONE_ONEONE: number;
  81445. /**
  81446. * Defines that alpha blending is SRC * DST ALPHA + DST
  81447. * Alpha will be set to 0
  81448. */
  81449. static readonly ALPHA_ALPHATOCOLOR: number;
  81450. /**
  81451. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81452. */
  81453. static readonly ALPHA_REVERSEONEMINUS: number;
  81454. /**
  81455. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81456. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81457. */
  81458. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81459. /**
  81460. * Defines that alpha blending is SRC + DST
  81461. * Alpha will be set to SRC ALPHA
  81462. */
  81463. static readonly ALPHA_ONEONE_ONEZERO: number;
  81464. /**
  81465. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81466. * Alpha will be set to DST ALPHA
  81467. */
  81468. static readonly ALPHA_EXCLUSION: number;
  81469. /** Defines that alpha blending equation a SUM */
  81470. static readonly ALPHA_EQUATION_ADD: number;
  81471. /** Defines that alpha blending equation a SUBSTRACTION */
  81472. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81473. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81474. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81475. /** Defines that alpha blending equation a MAX operation */
  81476. static readonly ALPHA_EQUATION_MAX: number;
  81477. /** Defines that alpha blending equation a MIN operation */
  81478. static readonly ALPHA_EQUATION_MIN: number;
  81479. /**
  81480. * Defines that alpha blending equation a DARKEN operation:
  81481. * It takes the min of the src and sums the alpha channels.
  81482. */
  81483. static readonly ALPHA_EQUATION_DARKEN: number;
  81484. /** Defines that the ressource is not delayed*/
  81485. static readonly DELAYLOADSTATE_NONE: number;
  81486. /** Defines that the ressource was successfully delay loaded */
  81487. static readonly DELAYLOADSTATE_LOADED: number;
  81488. /** Defines that the ressource is currently delay loading */
  81489. static readonly DELAYLOADSTATE_LOADING: number;
  81490. /** Defines that the ressource is delayed and has not started loading */
  81491. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81492. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81493. static readonly NEVER: number;
  81494. /** 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 */
  81495. static readonly ALWAYS: number;
  81496. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81497. static readonly LESS: number;
  81498. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81499. static readonly EQUAL: number;
  81500. /** 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 */
  81501. static readonly LEQUAL: number;
  81502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81503. static readonly GREATER: number;
  81504. /** 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 */
  81505. static readonly GEQUAL: number;
  81506. /** 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 */
  81507. static readonly NOTEQUAL: number;
  81508. /** Passed to stencilOperation to specify that stencil value must be kept */
  81509. static readonly KEEP: number;
  81510. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81511. static readonly REPLACE: number;
  81512. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81513. static readonly INCR: number;
  81514. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81515. static readonly DECR: number;
  81516. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81517. static readonly INVERT: number;
  81518. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81519. static readonly INCR_WRAP: number;
  81520. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81521. static readonly DECR_WRAP: number;
  81522. /** Texture is not repeating outside of 0..1 UVs */
  81523. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81524. /** Texture is repeating outside of 0..1 UVs */
  81525. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81526. /** Texture is repeating and mirrored */
  81527. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81528. /** ALPHA */
  81529. static readonly TEXTUREFORMAT_ALPHA: number;
  81530. /** LUMINANCE */
  81531. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81532. /** LUMINANCE_ALPHA */
  81533. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81534. /** RGB */
  81535. static readonly TEXTUREFORMAT_RGB: number;
  81536. /** RGBA */
  81537. static readonly TEXTUREFORMAT_RGBA: number;
  81538. /** RED */
  81539. static readonly TEXTUREFORMAT_RED: number;
  81540. /** RED (2nd reference) */
  81541. static readonly TEXTUREFORMAT_R: number;
  81542. /** RG */
  81543. static readonly TEXTUREFORMAT_RG: number;
  81544. /** RED_INTEGER */
  81545. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81546. /** RED_INTEGER (2nd reference) */
  81547. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81548. /** RG_INTEGER */
  81549. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81550. /** RGB_INTEGER */
  81551. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81552. /** RGBA_INTEGER */
  81553. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81554. /** UNSIGNED_BYTE */
  81555. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81556. /** UNSIGNED_BYTE (2nd reference) */
  81557. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81558. /** FLOAT */
  81559. static readonly TEXTURETYPE_FLOAT: number;
  81560. /** HALF_FLOAT */
  81561. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81562. /** BYTE */
  81563. static readonly TEXTURETYPE_BYTE: number;
  81564. /** SHORT */
  81565. static readonly TEXTURETYPE_SHORT: number;
  81566. /** UNSIGNED_SHORT */
  81567. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81568. /** INT */
  81569. static readonly TEXTURETYPE_INT: number;
  81570. /** UNSIGNED_INT */
  81571. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81572. /** UNSIGNED_SHORT_4_4_4_4 */
  81573. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81574. /** UNSIGNED_SHORT_5_5_5_1 */
  81575. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81576. /** UNSIGNED_SHORT_5_6_5 */
  81577. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81578. /** UNSIGNED_INT_2_10_10_10_REV */
  81579. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81580. /** UNSIGNED_INT_24_8 */
  81581. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81582. /** UNSIGNED_INT_10F_11F_11F_REV */
  81583. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81584. /** UNSIGNED_INT_5_9_9_9_REV */
  81585. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81586. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81587. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81588. /** nearest is mag = nearest and min = nearest and no mip */
  81589. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81590. /** mag = nearest and min = nearest and mip = none */
  81591. static readonly TEXTURE_NEAREST_NEAREST: number;
  81592. /** Bilinear is mag = linear and min = linear and no mip */
  81593. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81594. /** mag = linear and min = linear and mip = none */
  81595. static readonly TEXTURE_LINEAR_LINEAR: number;
  81596. /** Trilinear is mag = linear and min = linear and mip = linear */
  81597. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81598. /** Trilinear is mag = linear and min = linear and mip = linear */
  81599. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81600. /** mag = nearest and min = nearest and mip = nearest */
  81601. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81602. /** mag = nearest and min = linear and mip = nearest */
  81603. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81604. /** mag = nearest and min = linear and mip = linear */
  81605. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81606. /** mag = nearest and min = linear and mip = none */
  81607. static readonly TEXTURE_NEAREST_LINEAR: number;
  81608. /** nearest is mag = nearest and min = nearest and mip = linear */
  81609. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81610. /** mag = linear and min = nearest and mip = nearest */
  81611. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81612. /** mag = linear and min = nearest and mip = linear */
  81613. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81616. /** mag = linear and min = nearest and mip = none */
  81617. static readonly TEXTURE_LINEAR_NEAREST: number;
  81618. /** Explicit coordinates mode */
  81619. static readonly TEXTURE_EXPLICIT_MODE: number;
  81620. /** Spherical coordinates mode */
  81621. static readonly TEXTURE_SPHERICAL_MODE: number;
  81622. /** Planar coordinates mode */
  81623. static readonly TEXTURE_PLANAR_MODE: number;
  81624. /** Cubic coordinates mode */
  81625. static readonly TEXTURE_CUBIC_MODE: number;
  81626. /** Projection coordinates mode */
  81627. static readonly TEXTURE_PROJECTION_MODE: number;
  81628. /** Skybox coordinates mode */
  81629. static readonly TEXTURE_SKYBOX_MODE: number;
  81630. /** Inverse Cubic coordinates mode */
  81631. static readonly TEXTURE_INVCUBIC_MODE: number;
  81632. /** Equirectangular coordinates mode */
  81633. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81634. /** Equirectangular Fixed coordinates mode */
  81635. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81636. /** Equirectangular Fixed Mirrored coordinates mode */
  81637. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81638. /** Offline (baking) quality for texture filtering */
  81639. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81640. /** High quality for texture filtering */
  81641. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81642. /** Medium quality for texture filtering */
  81643. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81644. /** Low quality for texture filtering */
  81645. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81646. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81647. static readonly SCALEMODE_FLOOR: number;
  81648. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81649. static readonly SCALEMODE_NEAREST: number;
  81650. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81651. static readonly SCALEMODE_CEILING: number;
  81652. /**
  81653. * The dirty texture flag value
  81654. */
  81655. static readonly MATERIAL_TextureDirtyFlag: number;
  81656. /**
  81657. * The dirty light flag value
  81658. */
  81659. static readonly MATERIAL_LightDirtyFlag: number;
  81660. /**
  81661. * The dirty fresnel flag value
  81662. */
  81663. static readonly MATERIAL_FresnelDirtyFlag: number;
  81664. /**
  81665. * The dirty attribute flag value
  81666. */
  81667. static readonly MATERIAL_AttributesDirtyFlag: number;
  81668. /**
  81669. * The dirty misc flag value
  81670. */
  81671. static readonly MATERIAL_MiscDirtyFlag: number;
  81672. /**
  81673. * The dirty prepass flag value
  81674. */
  81675. static readonly MATERIAL_PrePassDirtyFlag: number;
  81676. /**
  81677. * The all dirty flag value
  81678. */
  81679. static readonly MATERIAL_AllDirtyFlag: number;
  81680. /**
  81681. * Returns the triangle fill mode
  81682. */
  81683. static readonly MATERIAL_TriangleFillMode: number;
  81684. /**
  81685. * Returns the wireframe mode
  81686. */
  81687. static readonly MATERIAL_WireFrameFillMode: number;
  81688. /**
  81689. * Returns the point fill mode
  81690. */
  81691. static readonly MATERIAL_PointFillMode: number;
  81692. /**
  81693. * Returns the point list draw mode
  81694. */
  81695. static readonly MATERIAL_PointListDrawMode: number;
  81696. /**
  81697. * Returns the line list draw mode
  81698. */
  81699. static readonly MATERIAL_LineListDrawMode: number;
  81700. /**
  81701. * Returns the line loop draw mode
  81702. */
  81703. static readonly MATERIAL_LineLoopDrawMode: number;
  81704. /**
  81705. * Returns the line strip draw mode
  81706. */
  81707. static readonly MATERIAL_LineStripDrawMode: number;
  81708. /**
  81709. * Returns the triangle strip draw mode
  81710. */
  81711. static readonly MATERIAL_TriangleStripDrawMode: number;
  81712. /**
  81713. * Returns the triangle fan draw mode
  81714. */
  81715. static readonly MATERIAL_TriangleFanDrawMode: number;
  81716. /**
  81717. * Stores the clock-wise side orientation
  81718. */
  81719. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81720. /**
  81721. * Stores the counter clock-wise side orientation
  81722. */
  81723. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81724. /**
  81725. * Nothing
  81726. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81727. */
  81728. static readonly ACTION_NothingTrigger: number;
  81729. /**
  81730. * On pick
  81731. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81732. */
  81733. static readonly ACTION_OnPickTrigger: number;
  81734. /**
  81735. * On left pick
  81736. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81737. */
  81738. static readonly ACTION_OnLeftPickTrigger: number;
  81739. /**
  81740. * On right pick
  81741. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81742. */
  81743. static readonly ACTION_OnRightPickTrigger: number;
  81744. /**
  81745. * On center pick
  81746. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81747. */
  81748. static readonly ACTION_OnCenterPickTrigger: number;
  81749. /**
  81750. * On pick down
  81751. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81752. */
  81753. static readonly ACTION_OnPickDownTrigger: number;
  81754. /**
  81755. * On double pick
  81756. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81757. */
  81758. static readonly ACTION_OnDoublePickTrigger: number;
  81759. /**
  81760. * On pick up
  81761. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81762. */
  81763. static readonly ACTION_OnPickUpTrigger: number;
  81764. /**
  81765. * On pick out.
  81766. * This trigger will only be raised if you also declared a OnPickDown
  81767. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81768. */
  81769. static readonly ACTION_OnPickOutTrigger: number;
  81770. /**
  81771. * On long press
  81772. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81773. */
  81774. static readonly ACTION_OnLongPressTrigger: number;
  81775. /**
  81776. * On pointer over
  81777. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81778. */
  81779. static readonly ACTION_OnPointerOverTrigger: number;
  81780. /**
  81781. * On pointer out
  81782. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81783. */
  81784. static readonly ACTION_OnPointerOutTrigger: number;
  81785. /**
  81786. * On every frame
  81787. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81788. */
  81789. static readonly ACTION_OnEveryFrameTrigger: number;
  81790. /**
  81791. * On intersection enter
  81792. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81793. */
  81794. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81795. /**
  81796. * On intersection exit
  81797. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81798. */
  81799. static readonly ACTION_OnIntersectionExitTrigger: number;
  81800. /**
  81801. * On key down
  81802. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81803. */
  81804. static readonly ACTION_OnKeyDownTrigger: number;
  81805. /**
  81806. * On key up
  81807. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81808. */
  81809. static readonly ACTION_OnKeyUpTrigger: number;
  81810. /**
  81811. * Billboard mode will only apply to Y axis
  81812. */
  81813. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81814. /**
  81815. * Billboard mode will apply to all axes
  81816. */
  81817. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81818. /**
  81819. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81820. */
  81821. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81822. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81823. * Test order :
  81824. * Is the bounding sphere outside the frustum ?
  81825. * If not, are the bounding box vertices outside the frustum ?
  81826. * It not, then the cullable object is in the frustum.
  81827. */
  81828. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81829. /** Culling strategy : Bounding Sphere Only.
  81830. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81831. * It's also less accurate than the standard because some not visible objects can still be selected.
  81832. * Test : is the bounding sphere outside the frustum ?
  81833. * If not, then the cullable object is in the frustum.
  81834. */
  81835. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81836. /** Culling strategy : Optimistic Inclusion.
  81837. * This in an inclusion test first, then the standard exclusion test.
  81838. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81839. * 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.
  81840. * Anyway, it's as accurate as the standard strategy.
  81841. * Test :
  81842. * Is the cullable object bounding sphere center in the frustum ?
  81843. * If not, apply the default culling strategy.
  81844. */
  81845. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81846. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81847. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81848. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81849. * 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.
  81850. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81851. * Test :
  81852. * Is the cullable object bounding sphere center in the frustum ?
  81853. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81854. */
  81855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81856. /**
  81857. * No logging while loading
  81858. */
  81859. static readonly SCENELOADER_NO_LOGGING: number;
  81860. /**
  81861. * Minimal logging while loading
  81862. */
  81863. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81864. /**
  81865. * Summary logging while loading
  81866. */
  81867. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81868. /**
  81869. * Detailled logging while loading
  81870. */
  81871. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81872. /**
  81873. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81874. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81875. */
  81876. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81877. /**
  81878. * Constant used to retrieve the position texture index in the textures array in the prepass
  81879. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81880. */
  81881. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81882. /**
  81883. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81884. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81885. */
  81886. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81887. /**
  81888. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81889. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81890. */
  81891. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81892. /**
  81893. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81894. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81895. */
  81896. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81897. /**
  81898. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81899. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81900. */
  81901. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81902. /**
  81903. * Constant used to retrieve albedo index in the textures array in the prepass
  81904. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81905. */
  81906. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81907. }
  81908. }
  81909. declare module BABYLON {
  81910. /**
  81911. * This represents the required contract to create a new type of texture loader.
  81912. */
  81913. export interface IInternalTextureLoader {
  81914. /**
  81915. * Defines wether the loader supports cascade loading the different faces.
  81916. */
  81917. supportCascades: boolean;
  81918. /**
  81919. * This returns if the loader support the current file information.
  81920. * @param extension defines the file extension of the file being loaded
  81921. * @param mimeType defines the optional mime type of the file being loaded
  81922. * @returns true if the loader can load the specified file
  81923. */
  81924. canLoad(extension: string, mimeType?: string): boolean;
  81925. /**
  81926. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81927. * @param data contains the texture data
  81928. * @param texture defines the BabylonJS internal texture
  81929. * @param createPolynomials will be true if polynomials have been requested
  81930. * @param onLoad defines the callback to trigger once the texture is ready
  81931. * @param onError defines the callback to trigger in case of error
  81932. * @param options options to be passed to the loader
  81933. */
  81934. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  81935. /**
  81936. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81937. * @param data contains the texture data
  81938. * @param texture defines the BabylonJS internal texture
  81939. * @param callback defines the method to call once ready to upload
  81940. * @param options options to be passed to the loader
  81941. */
  81942. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  81943. }
  81944. }
  81945. declare module BABYLON {
  81946. /**
  81947. * Class used to store and describe the pipeline context associated with an effect
  81948. */
  81949. export interface IPipelineContext {
  81950. /**
  81951. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81952. */
  81953. isAsync: boolean;
  81954. /**
  81955. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81956. */
  81957. isReady: boolean;
  81958. /** @hidden */
  81959. _getVertexShaderCode(): string | null;
  81960. /** @hidden */
  81961. _getFragmentShaderCode(): string | null;
  81962. /** @hidden */
  81963. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81964. }
  81965. }
  81966. declare module BABYLON {
  81967. /**
  81968. * Class used to store gfx data (like WebGLBuffer)
  81969. */
  81970. export class DataBuffer {
  81971. /**
  81972. * Gets or sets the number of objects referencing this buffer
  81973. */
  81974. references: number;
  81975. /** Gets or sets the size of the underlying buffer */
  81976. capacity: number;
  81977. /**
  81978. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81979. */
  81980. is32Bits: boolean;
  81981. /**
  81982. * Gets the underlying buffer
  81983. */
  81984. get underlyingResource(): any;
  81985. }
  81986. }
  81987. declare module BABYLON {
  81988. /** @hidden */
  81989. export interface IShaderProcessor {
  81990. attributeProcessor?: (attribute: string) => string;
  81991. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81992. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81993. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81994. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81995. lineProcessor?: (line: string, isFragment: boolean) => string;
  81996. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81997. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81998. }
  81999. }
  82000. declare module BABYLON {
  82001. /** @hidden */
  82002. export interface ProcessingOptions {
  82003. defines: string[];
  82004. indexParameters: any;
  82005. isFragment: boolean;
  82006. shouldUseHighPrecisionShader: boolean;
  82007. supportsUniformBuffers: boolean;
  82008. shadersRepository: string;
  82009. includesShadersStore: {
  82010. [key: string]: string;
  82011. };
  82012. processor?: IShaderProcessor;
  82013. version: string;
  82014. platformName: string;
  82015. lookForClosingBracketForUniformBuffer?: boolean;
  82016. }
  82017. }
  82018. declare module BABYLON {
  82019. /** @hidden */
  82020. export class ShaderCodeNode {
  82021. line: string;
  82022. children: ShaderCodeNode[];
  82023. additionalDefineKey?: string;
  82024. additionalDefineValue?: string;
  82025. isValid(preprocessors: {
  82026. [key: string]: string;
  82027. }): boolean;
  82028. process(preprocessors: {
  82029. [key: string]: string;
  82030. }, options: ProcessingOptions): string;
  82031. }
  82032. }
  82033. declare module BABYLON {
  82034. /** @hidden */
  82035. export class ShaderCodeCursor {
  82036. private _lines;
  82037. lineIndex: number;
  82038. get currentLine(): string;
  82039. get canRead(): boolean;
  82040. set lines(value: string[]);
  82041. }
  82042. }
  82043. declare module BABYLON {
  82044. /** @hidden */
  82045. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82046. process(preprocessors: {
  82047. [key: string]: string;
  82048. }, options: ProcessingOptions): string;
  82049. }
  82050. }
  82051. declare module BABYLON {
  82052. /** @hidden */
  82053. export class ShaderDefineExpression {
  82054. isTrue(preprocessors: {
  82055. [key: string]: string;
  82056. }): boolean;
  82057. private static _OperatorPriority;
  82058. private static _Stack;
  82059. static postfixToInfix(postfix: string[]): string;
  82060. static infixToPostfix(infix: string): string[];
  82061. }
  82062. }
  82063. declare module BABYLON {
  82064. /** @hidden */
  82065. export class ShaderCodeTestNode extends ShaderCodeNode {
  82066. testExpression: ShaderDefineExpression;
  82067. isValid(preprocessors: {
  82068. [key: string]: string;
  82069. }): boolean;
  82070. }
  82071. }
  82072. declare module BABYLON {
  82073. /** @hidden */
  82074. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82075. define: string;
  82076. not: boolean;
  82077. constructor(define: string, not?: boolean);
  82078. isTrue(preprocessors: {
  82079. [key: string]: string;
  82080. }): boolean;
  82081. }
  82082. }
  82083. declare module BABYLON {
  82084. /** @hidden */
  82085. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82086. leftOperand: ShaderDefineExpression;
  82087. rightOperand: ShaderDefineExpression;
  82088. isTrue(preprocessors: {
  82089. [key: string]: string;
  82090. }): boolean;
  82091. }
  82092. }
  82093. declare module BABYLON {
  82094. /** @hidden */
  82095. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82096. leftOperand: ShaderDefineExpression;
  82097. rightOperand: ShaderDefineExpression;
  82098. isTrue(preprocessors: {
  82099. [key: string]: string;
  82100. }): boolean;
  82101. }
  82102. }
  82103. declare module BABYLON {
  82104. /** @hidden */
  82105. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82106. define: string;
  82107. operand: string;
  82108. testValue: string;
  82109. constructor(define: string, operand: string, testValue: string);
  82110. isTrue(preprocessors: {
  82111. [key: string]: string;
  82112. }): boolean;
  82113. }
  82114. }
  82115. declare module BABYLON {
  82116. /**
  82117. * Class used to enable access to offline support
  82118. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82119. */
  82120. export interface IOfflineProvider {
  82121. /**
  82122. * Gets a boolean indicating if scene must be saved in the database
  82123. */
  82124. enableSceneOffline: boolean;
  82125. /**
  82126. * Gets a boolean indicating if textures must be saved in the database
  82127. */
  82128. enableTexturesOffline: boolean;
  82129. /**
  82130. * Open the offline support and make it available
  82131. * @param successCallback defines the callback to call on success
  82132. * @param errorCallback defines the callback to call on error
  82133. */
  82134. open(successCallback: () => void, errorCallback: () => void): void;
  82135. /**
  82136. * Loads an image from the offline support
  82137. * @param url defines the url to load from
  82138. * @param image defines the target DOM image
  82139. */
  82140. loadImage(url: string, image: HTMLImageElement): void;
  82141. /**
  82142. * Loads a file from offline support
  82143. * @param url defines the URL to load from
  82144. * @param sceneLoaded defines a callback to call on success
  82145. * @param progressCallBack defines a callback to call when progress changed
  82146. * @param errorCallback defines a callback to call on error
  82147. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82148. */
  82149. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82150. }
  82151. }
  82152. declare module BABYLON {
  82153. /**
  82154. * Class used to help managing file picking and drag'n'drop
  82155. * File Storage
  82156. */
  82157. export class FilesInputStore {
  82158. /**
  82159. * List of files ready to be loaded
  82160. */
  82161. static FilesToLoad: {
  82162. [key: string]: File;
  82163. };
  82164. }
  82165. }
  82166. declare module BABYLON {
  82167. /**
  82168. * Class used to define a retry strategy when error happens while loading assets
  82169. */
  82170. export class RetryStrategy {
  82171. /**
  82172. * Function used to defines an exponential back off strategy
  82173. * @param maxRetries defines the maximum number of retries (3 by default)
  82174. * @param baseInterval defines the interval between retries
  82175. * @returns the strategy function to use
  82176. */
  82177. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82178. }
  82179. }
  82180. declare module BABYLON {
  82181. /**
  82182. * @ignore
  82183. * Application error to support additional information when loading a file
  82184. */
  82185. export abstract class BaseError extends Error {
  82186. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82187. }
  82188. }
  82189. declare module BABYLON {
  82190. /** @ignore */
  82191. export class LoadFileError extends BaseError {
  82192. request?: WebRequest;
  82193. file?: File;
  82194. /**
  82195. * Creates a new LoadFileError
  82196. * @param message defines the message of the error
  82197. * @param request defines the optional web request
  82198. * @param file defines the optional file
  82199. */
  82200. constructor(message: string, object?: WebRequest | File);
  82201. }
  82202. /** @ignore */
  82203. export class RequestFileError extends BaseError {
  82204. request: WebRequest;
  82205. /**
  82206. * Creates a new LoadFileError
  82207. * @param message defines the message of the error
  82208. * @param request defines the optional web request
  82209. */
  82210. constructor(message: string, request: WebRequest);
  82211. }
  82212. /** @ignore */
  82213. export class ReadFileError extends BaseError {
  82214. file: File;
  82215. /**
  82216. * Creates a new ReadFileError
  82217. * @param message defines the message of the error
  82218. * @param file defines the optional file
  82219. */
  82220. constructor(message: string, file: File);
  82221. }
  82222. /**
  82223. * @hidden
  82224. */
  82225. export class FileTools {
  82226. /**
  82227. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82228. */
  82229. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82230. /**
  82231. * Gets or sets the base URL to use to load assets
  82232. */
  82233. static BaseUrl: string;
  82234. /**
  82235. * Default behaviour for cors in the application.
  82236. * It can be a string if the expected behavior is identical in the entire app.
  82237. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82238. */
  82239. static CorsBehavior: string | ((url: string | string[]) => string);
  82240. /**
  82241. * Gets or sets a function used to pre-process url before using them to load assets
  82242. */
  82243. static PreprocessUrl: (url: string) => string;
  82244. /**
  82245. * Removes unwanted characters from an url
  82246. * @param url defines the url to clean
  82247. * @returns the cleaned url
  82248. */
  82249. private static _CleanUrl;
  82250. /**
  82251. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82252. * @param url define the url we are trying
  82253. * @param element define the dom element where to configure the cors policy
  82254. */
  82255. static SetCorsBehavior(url: string | string[], element: {
  82256. crossOrigin: string | null;
  82257. }): void;
  82258. /**
  82259. * Loads an image as an HTMLImageElement.
  82260. * @param input url string, ArrayBuffer, or Blob to load
  82261. * @param onLoad callback called when the image successfully loads
  82262. * @param onError callback called when the image fails to load
  82263. * @param offlineProvider offline provider for caching
  82264. * @param mimeType optional mime type
  82265. * @returns the HTMLImageElement of the loaded image
  82266. */
  82267. 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>;
  82268. /**
  82269. * Reads a file from a File object
  82270. * @param file defines the file to load
  82271. * @param onSuccess defines the callback to call when data is loaded
  82272. * @param onProgress defines the callback to call during loading process
  82273. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82274. * @param onError defines the callback to call when an error occurs
  82275. * @returns a file request object
  82276. */
  82277. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82278. /**
  82279. * Loads a file from a url
  82280. * @param url url to load
  82281. * @param onSuccess callback called when the file successfully loads
  82282. * @param onProgress callback called while file is loading (if the server supports this mode)
  82283. * @param offlineProvider defines the offline provider for caching
  82284. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82285. * @param onError callback called when the file fails to load
  82286. * @returns a file request object
  82287. */
  82288. 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;
  82289. /**
  82290. * Loads a file
  82291. * @param url url to load
  82292. * @param onSuccess callback called when the file successfully loads
  82293. * @param onProgress callback called while file is loading (if the server supports this mode)
  82294. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82295. * @param onError callback called when the file fails to load
  82296. * @param onOpened callback called when the web request is opened
  82297. * @returns a file request object
  82298. */
  82299. 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;
  82300. /**
  82301. * Checks if the loaded document was accessed via `file:`-Protocol.
  82302. * @returns boolean
  82303. */
  82304. static IsFileURL(): boolean;
  82305. }
  82306. }
  82307. declare module BABYLON {
  82308. /** @hidden */
  82309. export class ShaderProcessor {
  82310. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82311. private static _ProcessPrecision;
  82312. private static _ExtractOperation;
  82313. private static _BuildSubExpression;
  82314. private static _BuildExpression;
  82315. private static _MoveCursorWithinIf;
  82316. private static _MoveCursor;
  82317. private static _EvaluatePreProcessors;
  82318. private static _PreparePreProcessors;
  82319. private static _ProcessShaderConversion;
  82320. private static _ProcessIncludes;
  82321. /**
  82322. * Loads a file from a url
  82323. * @param url url to load
  82324. * @param onSuccess callback called when the file successfully loads
  82325. * @param onProgress callback called while file is loading (if the server supports this mode)
  82326. * @param offlineProvider defines the offline provider for caching
  82327. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82328. * @param onError callback called when the file fails to load
  82329. * @returns a file request object
  82330. * @hidden
  82331. */
  82332. 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;
  82333. }
  82334. }
  82335. declare module BABYLON {
  82336. /**
  82337. * @hidden
  82338. */
  82339. export interface IColor4Like {
  82340. r: float;
  82341. g: float;
  82342. b: float;
  82343. a: float;
  82344. }
  82345. /**
  82346. * @hidden
  82347. */
  82348. export interface IColor3Like {
  82349. r: float;
  82350. g: float;
  82351. b: float;
  82352. }
  82353. /**
  82354. * @hidden
  82355. */
  82356. export interface IVector4Like {
  82357. x: float;
  82358. y: float;
  82359. z: float;
  82360. w: float;
  82361. }
  82362. /**
  82363. * @hidden
  82364. */
  82365. export interface IVector3Like {
  82366. x: float;
  82367. y: float;
  82368. z: float;
  82369. }
  82370. /**
  82371. * @hidden
  82372. */
  82373. export interface IVector2Like {
  82374. x: float;
  82375. y: float;
  82376. }
  82377. /**
  82378. * @hidden
  82379. */
  82380. export interface IMatrixLike {
  82381. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82382. updateFlag: int;
  82383. }
  82384. /**
  82385. * @hidden
  82386. */
  82387. export interface IViewportLike {
  82388. x: float;
  82389. y: float;
  82390. width: float;
  82391. height: float;
  82392. }
  82393. /**
  82394. * @hidden
  82395. */
  82396. export interface IPlaneLike {
  82397. normal: IVector3Like;
  82398. d: float;
  82399. normalize(): void;
  82400. }
  82401. }
  82402. declare module BABYLON {
  82403. /**
  82404. * Interface used to define common properties for effect fallbacks
  82405. */
  82406. export interface IEffectFallbacks {
  82407. /**
  82408. * Removes the defines that should be removed when falling back.
  82409. * @param currentDefines defines the current define statements for the shader.
  82410. * @param effect defines the current effect we try to compile
  82411. * @returns The resulting defines with defines of the current rank removed.
  82412. */
  82413. reduce(currentDefines: string, effect: Effect): string;
  82414. /**
  82415. * Removes the fallback from the bound mesh.
  82416. */
  82417. unBindMesh(): void;
  82418. /**
  82419. * Checks to see if more fallbacks are still availible.
  82420. */
  82421. hasMoreFallbacks: boolean;
  82422. }
  82423. }
  82424. declare module BABYLON {
  82425. /**
  82426. * Class used to evalaute queries containing `and` and `or` operators
  82427. */
  82428. export class AndOrNotEvaluator {
  82429. /**
  82430. * Evaluate a query
  82431. * @param query defines the query to evaluate
  82432. * @param evaluateCallback defines the callback used to filter result
  82433. * @returns true if the query matches
  82434. */
  82435. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82436. private static _HandleParenthesisContent;
  82437. private static _SimplifyNegation;
  82438. }
  82439. }
  82440. declare module BABYLON {
  82441. /**
  82442. * Class used to store custom tags
  82443. */
  82444. export class Tags {
  82445. /**
  82446. * Adds support for tags on the given object
  82447. * @param obj defines the object to use
  82448. */
  82449. static EnableFor(obj: any): void;
  82450. /**
  82451. * Removes tags support
  82452. * @param obj defines the object to use
  82453. */
  82454. static DisableFor(obj: any): void;
  82455. /**
  82456. * Gets a boolean indicating if the given object has tags
  82457. * @param obj defines the object to use
  82458. * @returns a boolean
  82459. */
  82460. static HasTags(obj: any): boolean;
  82461. /**
  82462. * Gets the tags available on a given object
  82463. * @param obj defines the object to use
  82464. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82465. * @returns the tags
  82466. */
  82467. static GetTags(obj: any, asString?: boolean): any;
  82468. /**
  82469. * Adds tags to an object
  82470. * @param obj defines the object to use
  82471. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82472. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82473. */
  82474. static AddTagsTo(obj: any, tagsString: string): void;
  82475. /**
  82476. * @hidden
  82477. */
  82478. static _AddTagTo(obj: any, tag: string): void;
  82479. /**
  82480. * Removes specific tags from a specific object
  82481. * @param obj defines the object to use
  82482. * @param tagsString defines the tags to remove
  82483. */
  82484. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82485. /**
  82486. * @hidden
  82487. */
  82488. static _RemoveTagFrom(obj: any, tag: string): void;
  82489. /**
  82490. * Defines if tags hosted on an object match a given query
  82491. * @param obj defines the object to use
  82492. * @param tagsQuery defines the tag query
  82493. * @returns a boolean
  82494. */
  82495. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82496. }
  82497. }
  82498. declare module BABYLON {
  82499. /**
  82500. * Scalar computation library
  82501. */
  82502. export class Scalar {
  82503. /**
  82504. * Two pi constants convenient for computation.
  82505. */
  82506. static TwoPi: number;
  82507. /**
  82508. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82509. * @param a number
  82510. * @param b number
  82511. * @param epsilon (default = 1.401298E-45)
  82512. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82513. */
  82514. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82515. /**
  82516. * Returns a string : the upper case translation of the number i to hexadecimal.
  82517. * @param i number
  82518. * @returns the upper case translation of the number i to hexadecimal.
  82519. */
  82520. static ToHex(i: number): string;
  82521. /**
  82522. * Returns -1 if value is negative and +1 is value is positive.
  82523. * @param value the value
  82524. * @returns the value itself if it's equal to zero.
  82525. */
  82526. static Sign(value: number): number;
  82527. /**
  82528. * Returns the value itself if it's between min and max.
  82529. * Returns min if the value is lower than min.
  82530. * Returns max if the value is greater than max.
  82531. * @param value the value to clmap
  82532. * @param min the min value to clamp to (default: 0)
  82533. * @param max the max value to clamp to (default: 1)
  82534. * @returns the clamped value
  82535. */
  82536. static Clamp(value: number, min?: number, max?: number): number;
  82537. /**
  82538. * the log2 of value.
  82539. * @param value the value to compute log2 of
  82540. * @returns the log2 of value.
  82541. */
  82542. static Log2(value: number): number;
  82543. /**
  82544. * Loops the value, so that it is never larger than length and never smaller than 0.
  82545. *
  82546. * This is similar to the modulo operator but it works with floating point numbers.
  82547. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82548. * With t = 5 and length = 2.5, the result would be 0.0.
  82549. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82550. * @param value the value
  82551. * @param length the length
  82552. * @returns the looped value
  82553. */
  82554. static Repeat(value: number, length: number): number;
  82555. /**
  82556. * Normalize the value between 0.0 and 1.0 using min and max values
  82557. * @param value value to normalize
  82558. * @param min max to normalize between
  82559. * @param max min to normalize between
  82560. * @returns the normalized value
  82561. */
  82562. static Normalize(value: number, min: number, max: number): number;
  82563. /**
  82564. * Denormalize the value from 0.0 and 1.0 using min and max values
  82565. * @param normalized value to denormalize
  82566. * @param min max to denormalize between
  82567. * @param max min to denormalize between
  82568. * @returns the denormalized value
  82569. */
  82570. static Denormalize(normalized: number, min: number, max: number): number;
  82571. /**
  82572. * Calculates the shortest difference between two given angles given in degrees.
  82573. * @param current current angle in degrees
  82574. * @param target target angle in degrees
  82575. * @returns the delta
  82576. */
  82577. static DeltaAngle(current: number, target: number): number;
  82578. /**
  82579. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82580. * @param tx value
  82581. * @param length length
  82582. * @returns The returned value will move back and forth between 0 and length
  82583. */
  82584. static PingPong(tx: number, length: number): number;
  82585. /**
  82586. * Interpolates between min and max with smoothing at the limits.
  82587. *
  82588. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82589. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82590. * @param from from
  82591. * @param to to
  82592. * @param tx value
  82593. * @returns the smooth stepped value
  82594. */
  82595. static SmoothStep(from: number, to: number, tx: number): number;
  82596. /**
  82597. * Moves a value current towards target.
  82598. *
  82599. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82600. * Negative values of maxDelta pushes the value away from target.
  82601. * @param current current value
  82602. * @param target target value
  82603. * @param maxDelta max distance to move
  82604. * @returns resulting value
  82605. */
  82606. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82607. /**
  82608. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82609. *
  82610. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82611. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82612. * @param current current value
  82613. * @param target target value
  82614. * @param maxDelta max distance to move
  82615. * @returns resulting angle
  82616. */
  82617. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82618. /**
  82619. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82620. * @param start start value
  82621. * @param end target value
  82622. * @param amount amount to lerp between
  82623. * @returns the lerped value
  82624. */
  82625. static Lerp(start: number, end: number, amount: number): number;
  82626. /**
  82627. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82628. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82629. * @param start start value
  82630. * @param end target value
  82631. * @param amount amount to lerp between
  82632. * @returns the lerped value
  82633. */
  82634. static LerpAngle(start: number, end: number, amount: number): number;
  82635. /**
  82636. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82637. * @param a start value
  82638. * @param b target value
  82639. * @param value value between a and b
  82640. * @returns the inverseLerp value
  82641. */
  82642. static InverseLerp(a: number, b: number, value: number): number;
  82643. /**
  82644. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82645. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82646. * @param value1 spline value
  82647. * @param tangent1 spline value
  82648. * @param value2 spline value
  82649. * @param tangent2 spline value
  82650. * @param amount input value
  82651. * @returns hermite result
  82652. */
  82653. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82654. /**
  82655. * Returns a random float number between and min and max values
  82656. * @param min min value of random
  82657. * @param max max value of random
  82658. * @returns random value
  82659. */
  82660. static RandomRange(min: number, max: number): number;
  82661. /**
  82662. * This function returns percentage of a number in a given range.
  82663. *
  82664. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82665. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82666. * @param number to convert to percentage
  82667. * @param min min range
  82668. * @param max max range
  82669. * @returns the percentage
  82670. */
  82671. static RangeToPercent(number: number, min: number, max: number): number;
  82672. /**
  82673. * This function returns number that corresponds to the percentage in a given range.
  82674. *
  82675. * PercentToRange(0.34,0,100) will return 34.
  82676. * @param percent to convert to number
  82677. * @param min min range
  82678. * @param max max range
  82679. * @returns the number
  82680. */
  82681. static PercentToRange(percent: number, min: number, max: number): number;
  82682. /**
  82683. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82684. * @param angle The angle to normalize in radian.
  82685. * @return The converted angle.
  82686. */
  82687. static NormalizeRadians(angle: number): number;
  82688. }
  82689. }
  82690. declare module BABYLON {
  82691. /**
  82692. * Constant used to convert a value to gamma space
  82693. * @ignorenaming
  82694. */
  82695. export const ToGammaSpace: number;
  82696. /**
  82697. * Constant used to convert a value to linear space
  82698. * @ignorenaming
  82699. */
  82700. export const ToLinearSpace = 2.2;
  82701. /**
  82702. * Constant used to define the minimal number value in Babylon.js
  82703. * @ignorenaming
  82704. */
  82705. let Epsilon: number;
  82706. }
  82707. declare module BABYLON {
  82708. /**
  82709. * Class used to represent a viewport on screen
  82710. */
  82711. export class Viewport {
  82712. /** viewport left coordinate */
  82713. x: number;
  82714. /** viewport top coordinate */
  82715. y: number;
  82716. /**viewport width */
  82717. width: number;
  82718. /** viewport height */
  82719. height: number;
  82720. /**
  82721. * Creates a Viewport object located at (x, y) and sized (width, height)
  82722. * @param x defines viewport left coordinate
  82723. * @param y defines viewport top coordinate
  82724. * @param width defines the viewport width
  82725. * @param height defines the viewport height
  82726. */
  82727. constructor(
  82728. /** viewport left coordinate */
  82729. x: number,
  82730. /** viewport top coordinate */
  82731. y: number,
  82732. /**viewport width */
  82733. width: number,
  82734. /** viewport height */
  82735. height: number);
  82736. /**
  82737. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82738. * @param renderWidth defines the rendering width
  82739. * @param renderHeight defines the rendering height
  82740. * @returns a new Viewport
  82741. */
  82742. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82743. /**
  82744. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82745. * @param renderWidth defines the rendering width
  82746. * @param renderHeight defines the rendering height
  82747. * @param ref defines the target viewport
  82748. * @returns the current viewport
  82749. */
  82750. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82751. /**
  82752. * Returns a new Viewport copied from the current one
  82753. * @returns a new Viewport
  82754. */
  82755. clone(): Viewport;
  82756. }
  82757. }
  82758. declare module BABYLON {
  82759. /**
  82760. * Class containing a set of static utilities functions for arrays.
  82761. */
  82762. export class ArrayTools {
  82763. /**
  82764. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82765. * @param size the number of element to construct and put in the array
  82766. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82767. * @returns a new array filled with new objects
  82768. */
  82769. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82770. }
  82771. }
  82772. declare module BABYLON {
  82773. /**
  82774. * Represents a plane by the equation ax + by + cz + d = 0
  82775. */
  82776. export class Plane {
  82777. private static _TmpMatrix;
  82778. /**
  82779. * Normal of the plane (a,b,c)
  82780. */
  82781. normal: Vector3;
  82782. /**
  82783. * d component of the plane
  82784. */
  82785. d: number;
  82786. /**
  82787. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82788. * @param a a component of the plane
  82789. * @param b b component of the plane
  82790. * @param c c component of the plane
  82791. * @param d d component of the plane
  82792. */
  82793. constructor(a: number, b: number, c: number, d: number);
  82794. /**
  82795. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82796. */
  82797. asArray(): number[];
  82798. /**
  82799. * @returns a new plane copied from the current Plane.
  82800. */
  82801. clone(): Plane;
  82802. /**
  82803. * @returns the string "Plane".
  82804. */
  82805. getClassName(): string;
  82806. /**
  82807. * @returns the Plane hash code.
  82808. */
  82809. getHashCode(): number;
  82810. /**
  82811. * Normalize the current Plane in place.
  82812. * @returns the updated Plane.
  82813. */
  82814. normalize(): Plane;
  82815. /**
  82816. * Applies a transformation the plane and returns the result
  82817. * @param transformation the transformation matrix to be applied to the plane
  82818. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82819. */
  82820. transform(transformation: DeepImmutable<Matrix>): Plane;
  82821. /**
  82822. * Compute the dot product between the point and the plane normal
  82823. * @param point point to calculate the dot product with
  82824. * @returns the dot product (float) of the point coordinates and the plane normal.
  82825. */
  82826. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82827. /**
  82828. * Updates the current Plane from the plane defined by the three given points.
  82829. * @param point1 one of the points used to contruct the plane
  82830. * @param point2 one of the points used to contruct the plane
  82831. * @param point3 one of the points used to contruct the plane
  82832. * @returns the updated Plane.
  82833. */
  82834. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82835. /**
  82836. * Checks if the plane is facing a given direction
  82837. * @param direction the direction to check if the plane is facing
  82838. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82839. * @returns True is the vector "direction" is the same side than the plane normal.
  82840. */
  82841. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82842. /**
  82843. * Calculates the distance to a point
  82844. * @param point point to calculate distance to
  82845. * @returns the signed distance (float) from the given point to the Plane.
  82846. */
  82847. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82848. /**
  82849. * Creates a plane from an array
  82850. * @param array the array to create a plane from
  82851. * @returns a new Plane from the given array.
  82852. */
  82853. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82854. /**
  82855. * Creates a plane from three points
  82856. * @param point1 point used to create the plane
  82857. * @param point2 point used to create the plane
  82858. * @param point3 point used to create the plane
  82859. * @returns a new Plane defined by the three given points.
  82860. */
  82861. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82862. /**
  82863. * Creates a plane from an origin point and a normal
  82864. * @param origin origin of the plane to be constructed
  82865. * @param normal normal of the plane to be constructed
  82866. * @returns a new Plane the normal vector to this plane at the given origin point.
  82867. * Note : the vector "normal" is updated because normalized.
  82868. */
  82869. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82870. /**
  82871. * Calculates the distance from a plane and a point
  82872. * @param origin origin of the plane to be constructed
  82873. * @param normal normal of the plane to be constructed
  82874. * @param point point to calculate distance to
  82875. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82876. */
  82877. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82878. }
  82879. }
  82880. declare module BABYLON {
  82881. /** @hidden */
  82882. export class PerformanceConfigurator {
  82883. /** @hidden */
  82884. static MatrixUse64Bits: boolean;
  82885. /** @hidden */
  82886. static MatrixTrackPrecisionChange: boolean;
  82887. /** @hidden */
  82888. static MatrixCurrentType: any;
  82889. /** @hidden */
  82890. static MatrixTrackedMatrices: Array<any> | null;
  82891. /** @hidden */
  82892. static SetMatrixPrecision(use64bits: boolean): void;
  82893. }
  82894. }
  82895. declare module BABYLON {
  82896. /**
  82897. * Class representing a vector containing 2 coordinates
  82898. */
  82899. export class Vector2 {
  82900. /** defines the first coordinate */
  82901. x: number;
  82902. /** defines the second coordinate */
  82903. y: number;
  82904. /**
  82905. * Creates a new Vector2 from the given x and y coordinates
  82906. * @param x defines the first coordinate
  82907. * @param y defines the second coordinate
  82908. */
  82909. constructor(
  82910. /** defines the first coordinate */
  82911. x?: number,
  82912. /** defines the second coordinate */
  82913. y?: number);
  82914. /**
  82915. * Gets a string with the Vector2 coordinates
  82916. * @returns a string with the Vector2 coordinates
  82917. */
  82918. toString(): string;
  82919. /**
  82920. * Gets class name
  82921. * @returns the string "Vector2"
  82922. */
  82923. getClassName(): string;
  82924. /**
  82925. * Gets current vector hash code
  82926. * @returns the Vector2 hash code as a number
  82927. */
  82928. getHashCode(): number;
  82929. /**
  82930. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82931. * @param array defines the source array
  82932. * @param index defines the offset in source array
  82933. * @returns the current Vector2
  82934. */
  82935. toArray(array: FloatArray, index?: number): Vector2;
  82936. /**
  82937. * Update the current vector from an array
  82938. * @param array defines the destination array
  82939. * @param index defines the offset in the destination array
  82940. * @returns the current Vector3
  82941. */
  82942. fromArray(array: FloatArray, index?: number): Vector2;
  82943. /**
  82944. * Copy the current vector to an array
  82945. * @returns a new array with 2 elements: the Vector2 coordinates.
  82946. */
  82947. asArray(): number[];
  82948. /**
  82949. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82950. * @param source defines the source Vector2
  82951. * @returns the current updated Vector2
  82952. */
  82953. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82954. /**
  82955. * Sets the Vector2 coordinates with the given floats
  82956. * @param x defines the first coordinate
  82957. * @param y defines the second coordinate
  82958. * @returns the current updated Vector2
  82959. */
  82960. copyFromFloats(x: number, y: number): Vector2;
  82961. /**
  82962. * Sets the Vector2 coordinates with the given floats
  82963. * @param x defines the first coordinate
  82964. * @param y defines the second coordinate
  82965. * @returns the current updated Vector2
  82966. */
  82967. set(x: number, y: number): Vector2;
  82968. /**
  82969. * Add another vector with the current one
  82970. * @param otherVector defines the other vector
  82971. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82972. */
  82973. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82974. /**
  82975. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82976. * @param otherVector defines the other vector
  82977. * @param result defines the target vector
  82978. * @returns the unmodified current Vector2
  82979. */
  82980. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82981. /**
  82982. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82983. * @param otherVector defines the other vector
  82984. * @returns the current updated Vector2
  82985. */
  82986. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82987. /**
  82988. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82989. * @param otherVector defines the other vector
  82990. * @returns a new Vector2
  82991. */
  82992. addVector3(otherVector: Vector3): Vector2;
  82993. /**
  82994. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82995. * @param otherVector defines the other vector
  82996. * @returns a new Vector2
  82997. */
  82998. subtract(otherVector: Vector2): Vector2;
  82999. /**
  83000. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  83001. * @param otherVector defines the other vector
  83002. * @param result defines the target vector
  83003. * @returns the unmodified current Vector2
  83004. */
  83005. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83006. /**
  83007. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  83008. * @param otherVector defines the other vector
  83009. * @returns the current updated Vector2
  83010. */
  83011. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83012. /**
  83013. * Multiplies in place the current Vector2 coordinates by the given ones
  83014. * @param otherVector defines the other vector
  83015. * @returns the current updated Vector2
  83016. */
  83017. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83018. /**
  83019. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  83020. * @param otherVector defines the other vector
  83021. * @returns a new Vector2
  83022. */
  83023. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  83024. /**
  83025. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83026. * @param otherVector defines the other vector
  83027. * @param result defines the target vector
  83028. * @returns the unmodified current Vector2
  83029. */
  83030. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83031. /**
  83032. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83033. * @param x defines the first coordinate
  83034. * @param y defines the second coordinate
  83035. * @returns a new Vector2
  83036. */
  83037. multiplyByFloats(x: number, y: number): Vector2;
  83038. /**
  83039. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83040. * @param otherVector defines the other vector
  83041. * @returns a new Vector2
  83042. */
  83043. divide(otherVector: Vector2): Vector2;
  83044. /**
  83045. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83046. * @param otherVector defines the other vector
  83047. * @param result defines the target vector
  83048. * @returns the unmodified current Vector2
  83049. */
  83050. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83051. /**
  83052. * Divides the current Vector2 coordinates by the given ones
  83053. * @param otherVector defines the other vector
  83054. * @returns the current updated Vector2
  83055. */
  83056. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83057. /**
  83058. * Gets a new Vector2 with current Vector2 negated coordinates
  83059. * @returns a new Vector2
  83060. */
  83061. negate(): Vector2;
  83062. /**
  83063. * Negate this vector in place
  83064. * @returns this
  83065. */
  83066. negateInPlace(): Vector2;
  83067. /**
  83068. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83069. * @param result defines the Vector3 object where to store the result
  83070. * @returns the current Vector2
  83071. */
  83072. negateToRef(result: Vector2): Vector2;
  83073. /**
  83074. * Multiply the Vector2 coordinates by scale
  83075. * @param scale defines the scaling factor
  83076. * @returns the current updated Vector2
  83077. */
  83078. scaleInPlace(scale: number): Vector2;
  83079. /**
  83080. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83081. * @param scale defines the scaling factor
  83082. * @returns a new Vector2
  83083. */
  83084. scale(scale: number): Vector2;
  83085. /**
  83086. * Scale the current Vector2 values by a factor to a given Vector2
  83087. * @param scale defines the scale factor
  83088. * @param result defines the Vector2 object where to store the result
  83089. * @returns the unmodified current Vector2
  83090. */
  83091. scaleToRef(scale: number, result: Vector2): Vector2;
  83092. /**
  83093. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83094. * @param scale defines the scale factor
  83095. * @param result defines the Vector2 object where to store the result
  83096. * @returns the unmodified current Vector2
  83097. */
  83098. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83099. /**
  83100. * Gets a boolean if two vectors are equals
  83101. * @param otherVector defines the other vector
  83102. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83103. */
  83104. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83105. /**
  83106. * Gets a boolean if two vectors are equals (using an epsilon value)
  83107. * @param otherVector defines the other vector
  83108. * @param epsilon defines the minimal distance to consider equality
  83109. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83110. */
  83111. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83112. /**
  83113. * Gets a new Vector2 from current Vector2 floored values
  83114. * @returns a new Vector2
  83115. */
  83116. floor(): Vector2;
  83117. /**
  83118. * Gets a new Vector2 from current Vector2 floored values
  83119. * @returns a new Vector2
  83120. */
  83121. fract(): Vector2;
  83122. /**
  83123. * Gets the length of the vector
  83124. * @returns the vector length (float)
  83125. */
  83126. length(): number;
  83127. /**
  83128. * Gets the vector squared length
  83129. * @returns the vector squared length (float)
  83130. */
  83131. lengthSquared(): number;
  83132. /**
  83133. * Normalize the vector
  83134. * @returns the current updated Vector2
  83135. */
  83136. normalize(): Vector2;
  83137. /**
  83138. * Gets a new Vector2 copied from the Vector2
  83139. * @returns a new Vector2
  83140. */
  83141. clone(): Vector2;
  83142. /**
  83143. * Gets a new Vector2(0, 0)
  83144. * @returns a new Vector2
  83145. */
  83146. static Zero(): Vector2;
  83147. /**
  83148. * Gets a new Vector2(1, 1)
  83149. * @returns a new Vector2
  83150. */
  83151. static One(): Vector2;
  83152. /**
  83153. * Gets a new Vector2 set from the given index element of the given array
  83154. * @param array defines the data source
  83155. * @param offset defines the offset in the data source
  83156. * @returns a new Vector2
  83157. */
  83158. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83159. /**
  83160. * Sets "result" from the given index element of the given array
  83161. * @param array defines the data source
  83162. * @param offset defines the offset in the data source
  83163. * @param result defines the target vector
  83164. */
  83165. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83166. /**
  83167. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83168. * @param value1 defines 1st point of control
  83169. * @param value2 defines 2nd point of control
  83170. * @param value3 defines 3rd point of control
  83171. * @param value4 defines 4th point of control
  83172. * @param amount defines the interpolation factor
  83173. * @returns a new Vector2
  83174. */
  83175. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83176. /**
  83177. * 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".
  83178. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83179. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83180. * @param value defines the value to clamp
  83181. * @param min defines the lower limit
  83182. * @param max defines the upper limit
  83183. * @returns a new Vector2
  83184. */
  83185. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83186. /**
  83187. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83188. * @param value1 defines the 1st control point
  83189. * @param tangent1 defines the outgoing tangent
  83190. * @param value2 defines the 2nd control point
  83191. * @param tangent2 defines the incoming tangent
  83192. * @param amount defines the interpolation factor
  83193. * @returns a new Vector2
  83194. */
  83195. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83196. /**
  83197. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83198. * @param start defines the start vector
  83199. * @param end defines the end vector
  83200. * @param amount defines the interpolation factor
  83201. * @returns a new Vector2
  83202. */
  83203. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83204. /**
  83205. * Gets the dot product of the vector "left" and the vector "right"
  83206. * @param left defines first vector
  83207. * @param right defines second vector
  83208. * @returns the dot product (float)
  83209. */
  83210. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83211. /**
  83212. * Returns a new Vector2 equal to the normalized given vector
  83213. * @param vector defines the vector to normalize
  83214. * @returns a new Vector2
  83215. */
  83216. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83217. /**
  83218. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83219. * @param left defines 1st vector
  83220. * @param right defines 2nd vector
  83221. * @returns a new Vector2
  83222. */
  83223. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83224. /**
  83225. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83226. * @param left defines 1st vector
  83227. * @param right defines 2nd vector
  83228. * @returns a new Vector2
  83229. */
  83230. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83231. /**
  83232. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83233. * @param vector defines the vector to transform
  83234. * @param transformation defines the matrix to apply
  83235. * @returns a new Vector2
  83236. */
  83237. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83238. /**
  83239. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83240. * @param vector defines the vector to transform
  83241. * @param transformation defines the matrix to apply
  83242. * @param result defines the target vector
  83243. */
  83244. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83245. /**
  83246. * Determines if a given vector is included in a triangle
  83247. * @param p defines the vector to test
  83248. * @param p0 defines 1st triangle point
  83249. * @param p1 defines 2nd triangle point
  83250. * @param p2 defines 3rd triangle point
  83251. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83252. */
  83253. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83254. /**
  83255. * Gets the distance between the vectors "value1" and "value2"
  83256. * @param value1 defines first vector
  83257. * @param value2 defines second vector
  83258. * @returns the distance between vectors
  83259. */
  83260. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83261. /**
  83262. * Returns the squared distance between the vectors "value1" and "value2"
  83263. * @param value1 defines first vector
  83264. * @param value2 defines second vector
  83265. * @returns the squared distance between vectors
  83266. */
  83267. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83268. /**
  83269. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83270. * @param value1 defines first vector
  83271. * @param value2 defines second vector
  83272. * @returns a new Vector2
  83273. */
  83274. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83275. /**
  83276. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83277. * @param p defines the middle point
  83278. * @param segA defines one point of the segment
  83279. * @param segB defines the other point of the segment
  83280. * @returns the shortest distance
  83281. */
  83282. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83283. }
  83284. /**
  83285. * Class used to store (x,y,z) vector representation
  83286. * A Vector3 is the main object used in 3D geometry
  83287. * It can represent etiher the coordinates of a point the space, either a direction
  83288. * Reminder: js uses a left handed forward facing system
  83289. */
  83290. export class Vector3 {
  83291. private static _UpReadOnly;
  83292. private static _ZeroReadOnly;
  83293. /** @hidden */
  83294. _x: number;
  83295. /** @hidden */
  83296. _y: number;
  83297. /** @hidden */
  83298. _z: number;
  83299. /** @hidden */
  83300. _isDirty: boolean;
  83301. /** Gets or sets the x coordinate */
  83302. get x(): number;
  83303. set x(value: number);
  83304. /** Gets or sets the y coordinate */
  83305. get y(): number;
  83306. set y(value: number);
  83307. /** Gets or sets the z coordinate */
  83308. get z(): number;
  83309. set z(value: number);
  83310. /**
  83311. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83312. * @param x defines the first coordinates (on X axis)
  83313. * @param y defines the second coordinates (on Y axis)
  83314. * @param z defines the third coordinates (on Z axis)
  83315. */
  83316. constructor(x?: number, y?: number, z?: number);
  83317. /**
  83318. * Creates a string representation of the Vector3
  83319. * @returns a string with the Vector3 coordinates.
  83320. */
  83321. toString(): string;
  83322. /**
  83323. * Gets the class name
  83324. * @returns the string "Vector3"
  83325. */
  83326. getClassName(): string;
  83327. /**
  83328. * Creates the Vector3 hash code
  83329. * @returns a number which tends to be unique between Vector3 instances
  83330. */
  83331. getHashCode(): number;
  83332. /**
  83333. * Creates an array containing three elements : the coordinates of the Vector3
  83334. * @returns a new array of numbers
  83335. */
  83336. asArray(): number[];
  83337. /**
  83338. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83339. * @param array defines the destination array
  83340. * @param index defines the offset in the destination array
  83341. * @returns the current Vector3
  83342. */
  83343. toArray(array: FloatArray, index?: number): Vector3;
  83344. /**
  83345. * Update the current vector from an array
  83346. * @param array defines the destination array
  83347. * @param index defines the offset in the destination array
  83348. * @returns the current Vector3
  83349. */
  83350. fromArray(array: FloatArray, index?: number): Vector3;
  83351. /**
  83352. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83353. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83354. */
  83355. toQuaternion(): Quaternion;
  83356. /**
  83357. * Adds the given vector to the current Vector3
  83358. * @param otherVector defines the second operand
  83359. * @returns the current updated Vector3
  83360. */
  83361. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83362. /**
  83363. * Adds the given coordinates to the current Vector3
  83364. * @param x defines the x coordinate of the operand
  83365. * @param y defines the y coordinate of the operand
  83366. * @param z defines the z coordinate of the operand
  83367. * @returns the current updated Vector3
  83368. */
  83369. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83370. /**
  83371. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83372. * @param otherVector defines the second operand
  83373. * @returns the resulting Vector3
  83374. */
  83375. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83376. /**
  83377. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83378. * @param otherVector defines the second operand
  83379. * @param result defines the Vector3 object where to store the result
  83380. * @returns the current Vector3
  83381. */
  83382. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83383. /**
  83384. * Subtract the given vector from the current Vector3
  83385. * @param otherVector defines the second operand
  83386. * @returns the current updated Vector3
  83387. */
  83388. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83389. /**
  83390. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83391. * @param otherVector defines the second operand
  83392. * @returns the resulting Vector3
  83393. */
  83394. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83395. /**
  83396. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83397. * @param otherVector defines the second operand
  83398. * @param result defines the Vector3 object where to store the result
  83399. * @returns the current Vector3
  83400. */
  83401. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83402. /**
  83403. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83404. * @param x defines the x coordinate of the operand
  83405. * @param y defines the y coordinate of the operand
  83406. * @param z defines the z coordinate of the operand
  83407. * @returns the resulting Vector3
  83408. */
  83409. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83410. /**
  83411. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83412. * @param x defines the x coordinate of the operand
  83413. * @param y defines the y coordinate of the operand
  83414. * @param z defines the z coordinate of the operand
  83415. * @param result defines the Vector3 object where to store the result
  83416. * @returns the current Vector3
  83417. */
  83418. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83419. /**
  83420. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83421. * @returns a new Vector3
  83422. */
  83423. negate(): Vector3;
  83424. /**
  83425. * Negate this vector in place
  83426. * @returns this
  83427. */
  83428. negateInPlace(): Vector3;
  83429. /**
  83430. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83431. * @param result defines the Vector3 object where to store the result
  83432. * @returns the current Vector3
  83433. */
  83434. negateToRef(result: Vector3): Vector3;
  83435. /**
  83436. * Multiplies the Vector3 coordinates by the float "scale"
  83437. * @param scale defines the multiplier factor
  83438. * @returns the current updated Vector3
  83439. */
  83440. scaleInPlace(scale: number): Vector3;
  83441. /**
  83442. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83443. * @param scale defines the multiplier factor
  83444. * @returns a new Vector3
  83445. */
  83446. scale(scale: number): Vector3;
  83447. /**
  83448. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83449. * @param scale defines the multiplier factor
  83450. * @param result defines the Vector3 object where to store the result
  83451. * @returns the current Vector3
  83452. */
  83453. scaleToRef(scale: number, result: Vector3): Vector3;
  83454. /**
  83455. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83456. * @param scale defines the scale factor
  83457. * @param result defines the Vector3 object where to store the result
  83458. * @returns the unmodified current Vector3
  83459. */
  83460. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83461. /**
  83462. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83463. * @param origin defines the origin of the projection ray
  83464. * @param plane defines the plane to project to
  83465. * @returns the projected vector3
  83466. */
  83467. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83468. /**
  83469. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83470. * @param origin defines the origin of the projection ray
  83471. * @param plane defines the plane to project to
  83472. * @param result defines the Vector3 where to store the result
  83473. */
  83474. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83475. /**
  83476. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83477. * @param otherVector defines the second operand
  83478. * @returns true if both vectors are equals
  83479. */
  83480. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83481. /**
  83482. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83483. * @param otherVector defines the second operand
  83484. * @param epsilon defines the minimal distance to define values as equals
  83485. * @returns true if both vectors are distant less than epsilon
  83486. */
  83487. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83488. /**
  83489. * Returns true if the current Vector3 coordinates equals the given floats
  83490. * @param x defines the x coordinate of the operand
  83491. * @param y defines the y coordinate of the operand
  83492. * @param z defines the z coordinate of the operand
  83493. * @returns true if both vectors are equals
  83494. */
  83495. equalsToFloats(x: number, y: number, z: number): boolean;
  83496. /**
  83497. * Multiplies the current Vector3 coordinates by the given ones
  83498. * @param otherVector defines the second operand
  83499. * @returns the current updated Vector3
  83500. */
  83501. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83502. /**
  83503. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83504. * @param otherVector defines the second operand
  83505. * @returns the new Vector3
  83506. */
  83507. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83508. /**
  83509. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83510. * @param otherVector defines the second operand
  83511. * @param result defines the Vector3 object where to store the result
  83512. * @returns the current Vector3
  83513. */
  83514. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83515. /**
  83516. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83517. * @param x defines the x coordinate of the operand
  83518. * @param y defines the y coordinate of the operand
  83519. * @param z defines the z coordinate of the operand
  83520. * @returns the new Vector3
  83521. */
  83522. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83523. /**
  83524. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83525. * @param otherVector defines the second operand
  83526. * @returns the new Vector3
  83527. */
  83528. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83529. /**
  83530. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83531. * @param otherVector defines the second operand
  83532. * @param result defines the Vector3 object where to store the result
  83533. * @returns the current Vector3
  83534. */
  83535. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83536. /**
  83537. * Divides the current Vector3 coordinates by the given ones.
  83538. * @param otherVector defines the second operand
  83539. * @returns the current updated Vector3
  83540. */
  83541. divideInPlace(otherVector: Vector3): Vector3;
  83542. /**
  83543. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83544. * @param other defines the second operand
  83545. * @returns the current updated Vector3
  83546. */
  83547. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83548. /**
  83549. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83550. * @param other defines the second operand
  83551. * @returns the current updated Vector3
  83552. */
  83553. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83554. /**
  83555. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83556. * @param x defines the x coordinate of the operand
  83557. * @param y defines the y coordinate of the operand
  83558. * @param z defines the z coordinate of the operand
  83559. * @returns the current updated Vector3
  83560. */
  83561. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83562. /**
  83563. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83564. * @param x defines the x coordinate of the operand
  83565. * @param y defines the y coordinate of the operand
  83566. * @param z defines the z coordinate of the operand
  83567. * @returns the current updated Vector3
  83568. */
  83569. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83570. /**
  83571. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83572. * Check if is non uniform within a certain amount of decimal places to account for this
  83573. * @param epsilon the amount the values can differ
  83574. * @returns if the the vector is non uniform to a certain number of decimal places
  83575. */
  83576. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83577. /**
  83578. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83579. */
  83580. get isNonUniform(): boolean;
  83581. /**
  83582. * Gets a new Vector3 from current Vector3 floored values
  83583. * @returns a new Vector3
  83584. */
  83585. floor(): Vector3;
  83586. /**
  83587. * Gets a new Vector3 from current Vector3 floored values
  83588. * @returns a new Vector3
  83589. */
  83590. fract(): Vector3;
  83591. /**
  83592. * Gets the length of the Vector3
  83593. * @returns the length of the Vector3
  83594. */
  83595. length(): number;
  83596. /**
  83597. * Gets the squared length of the Vector3
  83598. * @returns squared length of the Vector3
  83599. */
  83600. lengthSquared(): number;
  83601. /**
  83602. * Normalize the current Vector3.
  83603. * Please note that this is an in place operation.
  83604. * @returns the current updated Vector3
  83605. */
  83606. normalize(): Vector3;
  83607. /**
  83608. * Reorders the x y z properties of the vector in place
  83609. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83610. * @returns the current updated vector
  83611. */
  83612. reorderInPlace(order: string): this;
  83613. /**
  83614. * Rotates the vector around 0,0,0 by a quaternion
  83615. * @param quaternion the rotation quaternion
  83616. * @param result vector to store the result
  83617. * @returns the resulting vector
  83618. */
  83619. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83620. /**
  83621. * Rotates a vector around a given point
  83622. * @param quaternion the rotation quaternion
  83623. * @param point the point to rotate around
  83624. * @param result vector to store the result
  83625. * @returns the resulting vector
  83626. */
  83627. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83628. /**
  83629. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83630. * The cross product is then orthogonal to both current and "other"
  83631. * @param other defines the right operand
  83632. * @returns the cross product
  83633. */
  83634. cross(other: Vector3): Vector3;
  83635. /**
  83636. * Normalize the current Vector3 with the given input length.
  83637. * Please note that this is an in place operation.
  83638. * @param len the length of the vector
  83639. * @returns the current updated Vector3
  83640. */
  83641. normalizeFromLength(len: number): Vector3;
  83642. /**
  83643. * Normalize the current Vector3 to a new vector
  83644. * @returns the new Vector3
  83645. */
  83646. normalizeToNew(): Vector3;
  83647. /**
  83648. * Normalize the current Vector3 to the reference
  83649. * @param reference define the Vector3 to update
  83650. * @returns the updated Vector3
  83651. */
  83652. normalizeToRef(reference: Vector3): Vector3;
  83653. /**
  83654. * Creates a new Vector3 copied from the current Vector3
  83655. * @returns the new Vector3
  83656. */
  83657. clone(): Vector3;
  83658. /**
  83659. * Copies the given vector coordinates to the current Vector3 ones
  83660. * @param source defines the source Vector3
  83661. * @returns the current updated Vector3
  83662. */
  83663. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83664. /**
  83665. * Copies the given floats to the current Vector3 coordinates
  83666. * @param x defines the x coordinate of the operand
  83667. * @param y defines the y coordinate of the operand
  83668. * @param z defines the z coordinate of the operand
  83669. * @returns the current updated Vector3
  83670. */
  83671. copyFromFloats(x: number, y: number, z: number): Vector3;
  83672. /**
  83673. * Copies the given floats to the current Vector3 coordinates
  83674. * @param x defines the x coordinate of the operand
  83675. * @param y defines the y coordinate of the operand
  83676. * @param z defines the z coordinate of the operand
  83677. * @returns the current updated Vector3
  83678. */
  83679. set(x: number, y: number, z: number): Vector3;
  83680. /**
  83681. * Copies the given float to the current Vector3 coordinates
  83682. * @param v defines the x, y and z coordinates of the operand
  83683. * @returns the current updated Vector3
  83684. */
  83685. setAll(v: number): Vector3;
  83686. /**
  83687. * Get the clip factor between two vectors
  83688. * @param vector0 defines the first operand
  83689. * @param vector1 defines the second operand
  83690. * @param axis defines the axis to use
  83691. * @param size defines the size along the axis
  83692. * @returns the clip factor
  83693. */
  83694. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83695. /**
  83696. * Get angle between two vectors
  83697. * @param vector0 angle between vector0 and vector1
  83698. * @param vector1 angle between vector0 and vector1
  83699. * @param normal direction of the normal
  83700. * @return the angle between vector0 and vector1
  83701. */
  83702. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83703. /**
  83704. * Returns a new Vector3 set from the index "offset" of the given array
  83705. * @param array defines the source array
  83706. * @param offset defines the offset in the source array
  83707. * @returns the new Vector3
  83708. */
  83709. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83710. /**
  83711. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83712. * @param array defines the source array
  83713. * @param offset defines the offset in the source array
  83714. * @returns the new Vector3
  83715. * @deprecated Please use FromArray instead.
  83716. */
  83717. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83718. /**
  83719. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83720. * @param array defines the source array
  83721. * @param offset defines the offset in the source array
  83722. * @param result defines the Vector3 where to store the result
  83723. */
  83724. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83725. /**
  83726. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83727. * @param array defines the source array
  83728. * @param offset defines the offset in the source array
  83729. * @param result defines the Vector3 where to store the result
  83730. * @deprecated Please use FromArrayToRef instead.
  83731. */
  83732. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83733. /**
  83734. * Sets the given vector "result" with the given floats.
  83735. * @param x defines the x coordinate of the source
  83736. * @param y defines the y coordinate of the source
  83737. * @param z defines the z coordinate of the source
  83738. * @param result defines the Vector3 where to store the result
  83739. */
  83740. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83741. /**
  83742. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83743. * @returns a new empty Vector3
  83744. */
  83745. static Zero(): Vector3;
  83746. /**
  83747. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83748. * @returns a new unit Vector3
  83749. */
  83750. static One(): Vector3;
  83751. /**
  83752. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83753. * @returns a new up Vector3
  83754. */
  83755. static Up(): Vector3;
  83756. /**
  83757. * Gets a up Vector3 that must not be updated
  83758. */
  83759. static get UpReadOnly(): DeepImmutable<Vector3>;
  83760. /**
  83761. * Gets a zero Vector3 that must not be updated
  83762. */
  83763. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83764. /**
  83765. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83766. * @returns a new down Vector3
  83767. */
  83768. static Down(): Vector3;
  83769. /**
  83770. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83771. * @param rightHandedSystem is the scene right-handed (negative z)
  83772. * @returns a new forward Vector3
  83773. */
  83774. static Forward(rightHandedSystem?: boolean): Vector3;
  83775. /**
  83776. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83777. * @param rightHandedSystem is the scene right-handed (negative-z)
  83778. * @returns a new forward Vector3
  83779. */
  83780. static Backward(rightHandedSystem?: boolean): Vector3;
  83781. /**
  83782. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83783. * @returns a new right Vector3
  83784. */
  83785. static Right(): Vector3;
  83786. /**
  83787. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83788. * @returns a new left Vector3
  83789. */
  83790. static Left(): Vector3;
  83791. /**
  83792. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83793. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83794. * @param vector defines the Vector3 to transform
  83795. * @param transformation defines the transformation matrix
  83796. * @returns the transformed Vector3
  83797. */
  83798. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83799. /**
  83800. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83801. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83802. * @param vector defines the Vector3 to transform
  83803. * @param transformation defines the transformation matrix
  83804. * @param result defines the Vector3 where to store the result
  83805. */
  83806. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83807. /**
  83808. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83809. * This method computes tranformed coordinates only, not transformed direction vectors
  83810. * @param x define the x coordinate of the source vector
  83811. * @param y define the y coordinate of the source vector
  83812. * @param z define the z coordinate of the source vector
  83813. * @param transformation defines the transformation matrix
  83814. * @param result defines the Vector3 where to store the result
  83815. */
  83816. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83817. /**
  83818. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83819. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83820. * @param vector defines the Vector3 to transform
  83821. * @param transformation defines the transformation matrix
  83822. * @returns the new Vector3
  83823. */
  83824. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83825. /**
  83826. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83827. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83828. * @param vector defines the Vector3 to transform
  83829. * @param transformation defines the transformation matrix
  83830. * @param result defines the Vector3 where to store the result
  83831. */
  83832. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83833. /**
  83834. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83835. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83836. * @param x define the x coordinate of the source vector
  83837. * @param y define the y coordinate of the source vector
  83838. * @param z define the z coordinate of the source vector
  83839. * @param transformation defines the transformation matrix
  83840. * @param result defines the Vector3 where to store the result
  83841. */
  83842. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83843. /**
  83844. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83845. * @param value1 defines the first control point
  83846. * @param value2 defines the second control point
  83847. * @param value3 defines the third control point
  83848. * @param value4 defines the fourth control point
  83849. * @param amount defines the amount on the spline to use
  83850. * @returns the new Vector3
  83851. */
  83852. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83853. /**
  83854. * 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"
  83855. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83856. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83857. * @param value defines the current value
  83858. * @param min defines the lower range value
  83859. * @param max defines the upper range value
  83860. * @returns the new Vector3
  83861. */
  83862. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83863. /**
  83864. * 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"
  83865. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83866. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83867. * @param value defines the current value
  83868. * @param min defines the lower range value
  83869. * @param max defines the upper range value
  83870. * @param result defines the Vector3 where to store the result
  83871. */
  83872. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83873. /**
  83874. * Checks if a given vector is inside a specific range
  83875. * @param v defines the vector to test
  83876. * @param min defines the minimum range
  83877. * @param max defines the maximum range
  83878. */
  83879. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83880. /**
  83881. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83882. * @param value1 defines the first control point
  83883. * @param tangent1 defines the first tangent vector
  83884. * @param value2 defines the second control point
  83885. * @param tangent2 defines the second tangent vector
  83886. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83887. * @returns the new Vector3
  83888. */
  83889. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83890. /**
  83891. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83892. * @param start defines the start value
  83893. * @param end defines the end value
  83894. * @param amount max defines amount between both (between 0 and 1)
  83895. * @returns the new Vector3
  83896. */
  83897. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83898. /**
  83899. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83900. * @param start defines the start value
  83901. * @param end defines the end value
  83902. * @param amount max defines amount between both (between 0 and 1)
  83903. * @param result defines the Vector3 where to store the result
  83904. */
  83905. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83906. /**
  83907. * Returns the dot product (float) between the vectors "left" and "right"
  83908. * @param left defines the left operand
  83909. * @param right defines the right operand
  83910. * @returns the dot product
  83911. */
  83912. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83913. /**
  83914. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83915. * The cross product is then orthogonal to both "left" and "right"
  83916. * @param left defines the left operand
  83917. * @param right defines the right operand
  83918. * @returns the cross product
  83919. */
  83920. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83921. /**
  83922. * Sets the given vector "result" with the cross product of "left" and "right"
  83923. * The cross product is then orthogonal to both "left" and "right"
  83924. * @param left defines the left operand
  83925. * @param right defines the right operand
  83926. * @param result defines the Vector3 where to store the result
  83927. */
  83928. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83929. /**
  83930. * Returns a new Vector3 as the normalization of the given vector
  83931. * @param vector defines the Vector3 to normalize
  83932. * @returns the new Vector3
  83933. */
  83934. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83935. /**
  83936. * Sets the given vector "result" with the normalization of the given first vector
  83937. * @param vector defines the Vector3 to normalize
  83938. * @param result defines the Vector3 where to store the result
  83939. */
  83940. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83941. /**
  83942. * Project a Vector3 onto screen space
  83943. * @param vector defines the Vector3 to project
  83944. * @param world defines the world matrix to use
  83945. * @param transform defines the transform (view x projection) matrix to use
  83946. * @param viewport defines the screen viewport to use
  83947. * @returns the new Vector3
  83948. */
  83949. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83950. /**
  83951. * Project a Vector3 onto screen space to reference
  83952. * @param vector defines the Vector3 to project
  83953. * @param world defines the world matrix to use
  83954. * @param transform defines the transform (view x projection) matrix to use
  83955. * @param viewport defines the screen viewport to use
  83956. * @param result the vector in which the screen space will be stored
  83957. * @returns the new Vector3
  83958. */
  83959. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  83960. /** @hidden */
  83961. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83962. /**
  83963. * Unproject from screen space to object space
  83964. * @param source defines the screen space Vector3 to use
  83965. * @param viewportWidth defines the current width of the viewport
  83966. * @param viewportHeight defines the current height of the viewport
  83967. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83968. * @param transform defines the transform (view x projection) matrix to use
  83969. * @returns the new Vector3
  83970. */
  83971. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83972. /**
  83973. * Unproject from screen space to object space
  83974. * @param source defines the screen space Vector3 to use
  83975. * @param viewportWidth defines the current width of the viewport
  83976. * @param viewportHeight defines the current height of the viewport
  83977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83978. * @param view defines the view matrix to use
  83979. * @param projection defines the projection matrix to use
  83980. * @returns the new Vector3
  83981. */
  83982. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83983. /**
  83984. * Unproject from screen space to object space
  83985. * @param source defines the screen space Vector3 to use
  83986. * @param viewportWidth defines the current width of the viewport
  83987. * @param viewportHeight defines the current height of the viewport
  83988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83989. * @param view defines the view matrix to use
  83990. * @param projection defines the projection matrix to use
  83991. * @param result defines the Vector3 where to store the result
  83992. */
  83993. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83994. /**
  83995. * Unproject from screen space to object space
  83996. * @param sourceX defines the screen space x coordinate to use
  83997. * @param sourceY defines the screen space y coordinate to use
  83998. * @param sourceZ defines the screen space z coordinate to use
  83999. * @param viewportWidth defines the current width of the viewport
  84000. * @param viewportHeight defines the current height of the viewport
  84001. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84002. * @param view defines the view matrix to use
  84003. * @param projection defines the projection matrix to use
  84004. * @param result defines the Vector3 where to store the result
  84005. */
  84006. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84007. /**
  84008. * Gets the minimal coordinate values between two Vector3
  84009. * @param left defines the first operand
  84010. * @param right defines the second operand
  84011. * @returns the new Vector3
  84012. */
  84013. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84014. /**
  84015. * Gets the maximal coordinate values between two Vector3
  84016. * @param left defines the first operand
  84017. * @param right defines the second operand
  84018. * @returns the new Vector3
  84019. */
  84020. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84021. /**
  84022. * Returns the distance between the vectors "value1" and "value2"
  84023. * @param value1 defines the first operand
  84024. * @param value2 defines the second operand
  84025. * @returns the distance
  84026. */
  84027. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84028. /**
  84029. * Returns the squared distance between the vectors "value1" and "value2"
  84030. * @param value1 defines the first operand
  84031. * @param value2 defines the second operand
  84032. * @returns the squared distance
  84033. */
  84034. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84035. /**
  84036. * Returns a new Vector3 located at the center between "value1" and "value2"
  84037. * @param value1 defines the first operand
  84038. * @param value2 defines the second operand
  84039. * @returns the new Vector3
  84040. */
  84041. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84042. /**
  84043. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84044. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84045. * to something in order to rotate it from its local system to the given target system
  84046. * Note: axis1, axis2 and axis3 are normalized during this operation
  84047. * @param axis1 defines the first axis
  84048. * @param axis2 defines the second axis
  84049. * @param axis3 defines the third axis
  84050. * @returns a new Vector3
  84051. */
  84052. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84053. /**
  84054. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84055. * @param axis1 defines the first axis
  84056. * @param axis2 defines the second axis
  84057. * @param axis3 defines the third axis
  84058. * @param ref defines the Vector3 where to store the result
  84059. */
  84060. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84061. }
  84062. /**
  84063. * Vector4 class created for EulerAngle class conversion to Quaternion
  84064. */
  84065. export class Vector4 {
  84066. /** x value of the vector */
  84067. x: number;
  84068. /** y value of the vector */
  84069. y: number;
  84070. /** z value of the vector */
  84071. z: number;
  84072. /** w value of the vector */
  84073. w: number;
  84074. /**
  84075. * Creates a Vector4 object from the given floats.
  84076. * @param x x value of the vector
  84077. * @param y y value of the vector
  84078. * @param z z value of the vector
  84079. * @param w w value of the vector
  84080. */
  84081. constructor(
  84082. /** x value of the vector */
  84083. x: number,
  84084. /** y value of the vector */
  84085. y: number,
  84086. /** z value of the vector */
  84087. z: number,
  84088. /** w value of the vector */
  84089. w: number);
  84090. /**
  84091. * Returns the string with the Vector4 coordinates.
  84092. * @returns a string containing all the vector values
  84093. */
  84094. toString(): string;
  84095. /**
  84096. * Returns the string "Vector4".
  84097. * @returns "Vector4"
  84098. */
  84099. getClassName(): string;
  84100. /**
  84101. * Returns the Vector4 hash code.
  84102. * @returns a unique hash code
  84103. */
  84104. getHashCode(): number;
  84105. /**
  84106. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84107. * @returns the resulting array
  84108. */
  84109. asArray(): number[];
  84110. /**
  84111. * Populates the given array from the given index with the Vector4 coordinates.
  84112. * @param array array to populate
  84113. * @param index index of the array to start at (default: 0)
  84114. * @returns the Vector4.
  84115. */
  84116. toArray(array: FloatArray, index?: number): Vector4;
  84117. /**
  84118. * Update the current vector from an array
  84119. * @param array defines the destination array
  84120. * @param index defines the offset in the destination array
  84121. * @returns the current Vector3
  84122. */
  84123. fromArray(array: FloatArray, index?: number): Vector4;
  84124. /**
  84125. * Adds the given vector to the current Vector4.
  84126. * @param otherVector the vector to add
  84127. * @returns the updated Vector4.
  84128. */
  84129. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84130. /**
  84131. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84132. * @param otherVector the vector to add
  84133. * @returns the resulting vector
  84134. */
  84135. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84136. /**
  84137. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84138. * @param otherVector the vector to add
  84139. * @param result the vector to store the result
  84140. * @returns the current Vector4.
  84141. */
  84142. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84143. /**
  84144. * Subtract in place the given vector from the current Vector4.
  84145. * @param otherVector the vector to subtract
  84146. * @returns the updated Vector4.
  84147. */
  84148. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84149. /**
  84150. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84151. * @param otherVector the vector to add
  84152. * @returns the new vector with the result
  84153. */
  84154. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84155. /**
  84156. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84157. * @param otherVector the vector to subtract
  84158. * @param result the vector to store the result
  84159. * @returns the current Vector4.
  84160. */
  84161. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84162. /**
  84163. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84164. */
  84165. /**
  84166. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84167. * @param x value to subtract
  84168. * @param y value to subtract
  84169. * @param z value to subtract
  84170. * @param w value to subtract
  84171. * @returns new vector containing the result
  84172. */
  84173. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84174. /**
  84175. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84176. * @param x value to subtract
  84177. * @param y value to subtract
  84178. * @param z value to subtract
  84179. * @param w value to subtract
  84180. * @param result the vector to store the result in
  84181. * @returns the current Vector4.
  84182. */
  84183. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84184. /**
  84185. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84186. * @returns a new vector with the negated values
  84187. */
  84188. negate(): Vector4;
  84189. /**
  84190. * Negate this vector in place
  84191. * @returns this
  84192. */
  84193. negateInPlace(): Vector4;
  84194. /**
  84195. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84196. * @param result defines the Vector3 object where to store the result
  84197. * @returns the current Vector4
  84198. */
  84199. negateToRef(result: Vector4): Vector4;
  84200. /**
  84201. * Multiplies the current Vector4 coordinates by scale (float).
  84202. * @param scale the number to scale with
  84203. * @returns the updated Vector4.
  84204. */
  84205. scaleInPlace(scale: number): Vector4;
  84206. /**
  84207. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84208. * @param scale the number to scale with
  84209. * @returns a new vector with the result
  84210. */
  84211. scale(scale: number): Vector4;
  84212. /**
  84213. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84214. * @param scale the number to scale with
  84215. * @param result a vector to store the result in
  84216. * @returns the current Vector4.
  84217. */
  84218. scaleToRef(scale: number, result: Vector4): Vector4;
  84219. /**
  84220. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84221. * @param scale defines the scale factor
  84222. * @param result defines the Vector4 object where to store the result
  84223. * @returns the unmodified current Vector4
  84224. */
  84225. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84226. /**
  84227. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84228. * @param otherVector the vector to compare against
  84229. * @returns true if they are equal
  84230. */
  84231. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84232. /**
  84233. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84234. * @param otherVector vector to compare against
  84235. * @param epsilon (Default: very small number)
  84236. * @returns true if they are equal
  84237. */
  84238. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84239. /**
  84240. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84241. * @param x x value to compare against
  84242. * @param y y value to compare against
  84243. * @param z z value to compare against
  84244. * @param w w value to compare against
  84245. * @returns true if equal
  84246. */
  84247. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84248. /**
  84249. * Multiplies in place the current Vector4 by the given one.
  84250. * @param otherVector vector to multiple with
  84251. * @returns the updated Vector4.
  84252. */
  84253. multiplyInPlace(otherVector: Vector4): Vector4;
  84254. /**
  84255. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84256. * @param otherVector vector to multiple with
  84257. * @returns resulting new vector
  84258. */
  84259. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84260. /**
  84261. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84262. * @param otherVector vector to multiple with
  84263. * @param result vector to store the result
  84264. * @returns the current Vector4.
  84265. */
  84266. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84267. /**
  84268. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84269. * @param x x value multiply with
  84270. * @param y y value multiply with
  84271. * @param z z value multiply with
  84272. * @param w w value multiply with
  84273. * @returns resulting new vector
  84274. */
  84275. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84276. /**
  84277. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84278. * @param otherVector vector to devide with
  84279. * @returns resulting new vector
  84280. */
  84281. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84282. /**
  84283. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84284. * @param otherVector vector to devide with
  84285. * @param result vector to store the result
  84286. * @returns the current Vector4.
  84287. */
  84288. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84289. /**
  84290. * Divides the current Vector3 coordinates by the given ones.
  84291. * @param otherVector vector to devide with
  84292. * @returns the updated Vector3.
  84293. */
  84294. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84295. /**
  84296. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84297. * @param other defines the second operand
  84298. * @returns the current updated Vector4
  84299. */
  84300. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84301. /**
  84302. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84303. * @param other defines the second operand
  84304. * @returns the current updated Vector4
  84305. */
  84306. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84307. /**
  84308. * Gets a new Vector4 from current Vector4 floored values
  84309. * @returns a new Vector4
  84310. */
  84311. floor(): Vector4;
  84312. /**
  84313. * Gets a new Vector4 from current Vector3 floored values
  84314. * @returns a new Vector4
  84315. */
  84316. fract(): Vector4;
  84317. /**
  84318. * Returns the Vector4 length (float).
  84319. * @returns the length
  84320. */
  84321. length(): number;
  84322. /**
  84323. * Returns the Vector4 squared length (float).
  84324. * @returns the length squared
  84325. */
  84326. lengthSquared(): number;
  84327. /**
  84328. * Normalizes in place the Vector4.
  84329. * @returns the updated Vector4.
  84330. */
  84331. normalize(): Vector4;
  84332. /**
  84333. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84334. * @returns this converted to a new vector3
  84335. */
  84336. toVector3(): Vector3;
  84337. /**
  84338. * Returns a new Vector4 copied from the current one.
  84339. * @returns the new cloned vector
  84340. */
  84341. clone(): Vector4;
  84342. /**
  84343. * Updates the current Vector4 with the given one coordinates.
  84344. * @param source the source vector to copy from
  84345. * @returns the updated Vector4.
  84346. */
  84347. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84348. /**
  84349. * Updates the current Vector4 coordinates with the given floats.
  84350. * @param x float to copy from
  84351. * @param y float to copy from
  84352. * @param z float to copy from
  84353. * @param w float to copy from
  84354. * @returns the updated Vector4.
  84355. */
  84356. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84357. /**
  84358. * Updates the current Vector4 coordinates with the given floats.
  84359. * @param x float to set from
  84360. * @param y float to set from
  84361. * @param z float to set from
  84362. * @param w float to set from
  84363. * @returns the updated Vector4.
  84364. */
  84365. set(x: number, y: number, z: number, w: number): Vector4;
  84366. /**
  84367. * Copies the given float to the current Vector3 coordinates
  84368. * @param v defines the x, y, z and w coordinates of the operand
  84369. * @returns the current updated Vector3
  84370. */
  84371. setAll(v: number): Vector4;
  84372. /**
  84373. * Returns a new Vector4 set from the starting index of the given array.
  84374. * @param array the array to pull values from
  84375. * @param offset the offset into the array to start at
  84376. * @returns the new vector
  84377. */
  84378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84379. /**
  84380. * Updates the given vector "result" from the starting index of the given array.
  84381. * @param array the array to pull values from
  84382. * @param offset the offset into the array to start at
  84383. * @param result the vector to store the result in
  84384. */
  84385. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84386. /**
  84387. * Updates the given vector "result" from the starting index of the given Float32Array.
  84388. * @param array the array to pull values from
  84389. * @param offset the offset into the array to start at
  84390. * @param result the vector to store the result in
  84391. */
  84392. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84393. /**
  84394. * Updates the given vector "result" coordinates from the given floats.
  84395. * @param x float to set from
  84396. * @param y float to set from
  84397. * @param z float to set from
  84398. * @param w float to set from
  84399. * @param result the vector to the floats in
  84400. */
  84401. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84402. /**
  84403. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84404. * @returns the new vector
  84405. */
  84406. static Zero(): Vector4;
  84407. /**
  84408. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84409. * @returns the new vector
  84410. */
  84411. static One(): Vector4;
  84412. /**
  84413. * Returns a new normalized Vector4 from the given one.
  84414. * @param vector the vector to normalize
  84415. * @returns the vector
  84416. */
  84417. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84418. /**
  84419. * Updates the given vector "result" from the normalization of the given one.
  84420. * @param vector the vector to normalize
  84421. * @param result the vector to store the result in
  84422. */
  84423. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84424. /**
  84425. * Returns a vector with the minimum values from the left and right vectors
  84426. * @param left left vector to minimize
  84427. * @param right right vector to minimize
  84428. * @returns a new vector with the minimum of the left and right vector values
  84429. */
  84430. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84431. /**
  84432. * Returns a vector with the maximum values from the left and right vectors
  84433. * @param left left vector to maximize
  84434. * @param right right vector to maximize
  84435. * @returns a new vector with the maximum of the left and right vector values
  84436. */
  84437. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84438. /**
  84439. * Returns the distance (float) between the vectors "value1" and "value2".
  84440. * @param value1 value to calulate the distance between
  84441. * @param value2 value to calulate the distance between
  84442. * @return the distance between the two vectors
  84443. */
  84444. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84445. /**
  84446. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84447. * @param value1 value to calulate the distance between
  84448. * @param value2 value to calulate the distance between
  84449. * @return the distance between the two vectors squared
  84450. */
  84451. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84452. /**
  84453. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84454. * @param value1 value to calulate the center between
  84455. * @param value2 value to calulate the center between
  84456. * @return the center between the two vectors
  84457. */
  84458. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84459. /**
  84460. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84461. * This methods computes transformed normalized direction vectors only.
  84462. * @param vector the vector to transform
  84463. * @param transformation the transformation matrix to apply
  84464. * @returns the new vector
  84465. */
  84466. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84467. /**
  84468. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84469. * This methods computes transformed normalized direction vectors only.
  84470. * @param vector the vector to transform
  84471. * @param transformation the transformation matrix to apply
  84472. * @param result the vector to store the result in
  84473. */
  84474. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84475. /**
  84476. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84477. * This methods computes transformed normalized direction vectors only.
  84478. * @param x value to transform
  84479. * @param y value to transform
  84480. * @param z value to transform
  84481. * @param w value to transform
  84482. * @param transformation the transformation matrix to apply
  84483. * @param result the vector to store the results in
  84484. */
  84485. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84486. /**
  84487. * Creates a new Vector4 from a Vector3
  84488. * @param source defines the source data
  84489. * @param w defines the 4th component (default is 0)
  84490. * @returns a new Vector4
  84491. */
  84492. static FromVector3(source: Vector3, w?: number): Vector4;
  84493. }
  84494. /**
  84495. * Class used to store quaternion data
  84496. * @see https://en.wikipedia.org/wiki/Quaternion
  84497. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84498. */
  84499. export class Quaternion {
  84500. /** @hidden */
  84501. _x: number;
  84502. /** @hidden */
  84503. _y: number;
  84504. /** @hidden */
  84505. _z: number;
  84506. /** @hidden */
  84507. _w: number;
  84508. /** @hidden */
  84509. _isDirty: boolean;
  84510. /** Gets or sets the x coordinate */
  84511. get x(): number;
  84512. set x(value: number);
  84513. /** Gets or sets the y coordinate */
  84514. get y(): number;
  84515. set y(value: number);
  84516. /** Gets or sets the z coordinate */
  84517. get z(): number;
  84518. set z(value: number);
  84519. /** Gets or sets the w coordinate */
  84520. get w(): number;
  84521. set w(value: number);
  84522. /**
  84523. * Creates a new Quaternion from the given floats
  84524. * @param x defines the first component (0 by default)
  84525. * @param y defines the second component (0 by default)
  84526. * @param z defines the third component (0 by default)
  84527. * @param w defines the fourth component (1.0 by default)
  84528. */
  84529. constructor(x?: number, y?: number, z?: number, w?: number);
  84530. /**
  84531. * Gets a string representation for the current quaternion
  84532. * @returns a string with the Quaternion coordinates
  84533. */
  84534. toString(): string;
  84535. /**
  84536. * Gets the class name of the quaternion
  84537. * @returns the string "Quaternion"
  84538. */
  84539. getClassName(): string;
  84540. /**
  84541. * Gets a hash code for this quaternion
  84542. * @returns the quaternion hash code
  84543. */
  84544. getHashCode(): number;
  84545. /**
  84546. * Copy the quaternion to an array
  84547. * @returns a new array populated with 4 elements from the quaternion coordinates
  84548. */
  84549. asArray(): number[];
  84550. /**
  84551. * Check if two quaternions are equals
  84552. * @param otherQuaternion defines the second operand
  84553. * @return true if the current quaternion and the given one coordinates are strictly equals
  84554. */
  84555. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84556. /**
  84557. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84558. * @param otherQuaternion defines the other quaternion
  84559. * @param epsilon defines the minimal distance to consider equality
  84560. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84561. */
  84562. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84563. /**
  84564. * Clone the current quaternion
  84565. * @returns a new quaternion copied from the current one
  84566. */
  84567. clone(): Quaternion;
  84568. /**
  84569. * Copy a quaternion to the current one
  84570. * @param other defines the other quaternion
  84571. * @returns the updated current quaternion
  84572. */
  84573. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84574. /**
  84575. * Updates the current quaternion with the given float coordinates
  84576. * @param x defines the x coordinate
  84577. * @param y defines the y coordinate
  84578. * @param z defines the z coordinate
  84579. * @param w defines the w coordinate
  84580. * @returns the updated current quaternion
  84581. */
  84582. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84583. /**
  84584. * Updates the current quaternion from the given float coordinates
  84585. * @param x defines the x coordinate
  84586. * @param y defines the y coordinate
  84587. * @param z defines the z coordinate
  84588. * @param w defines the w coordinate
  84589. * @returns the updated current quaternion
  84590. */
  84591. set(x: number, y: number, z: number, w: number): Quaternion;
  84592. /**
  84593. * Adds two quaternions
  84594. * @param other defines the second operand
  84595. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84596. */
  84597. add(other: DeepImmutable<Quaternion>): Quaternion;
  84598. /**
  84599. * Add a quaternion to the current one
  84600. * @param other defines the quaternion to add
  84601. * @returns the current quaternion
  84602. */
  84603. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84604. /**
  84605. * Subtract two quaternions
  84606. * @param other defines the second operand
  84607. * @returns a new quaternion as the subtraction result of the given one from the current one
  84608. */
  84609. subtract(other: Quaternion): Quaternion;
  84610. /**
  84611. * Multiplies the current quaternion by a scale factor
  84612. * @param value defines the scale factor
  84613. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84614. */
  84615. scale(value: number): Quaternion;
  84616. /**
  84617. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84618. * @param scale defines the scale factor
  84619. * @param result defines the Quaternion object where to store the result
  84620. * @returns the unmodified current quaternion
  84621. */
  84622. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84623. /**
  84624. * Multiplies in place the current quaternion by a scale factor
  84625. * @param value defines the scale factor
  84626. * @returns the current modified quaternion
  84627. */
  84628. scaleInPlace(value: number): Quaternion;
  84629. /**
  84630. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84631. * @param scale defines the scale factor
  84632. * @param result defines the Quaternion object where to store the result
  84633. * @returns the unmodified current quaternion
  84634. */
  84635. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84636. /**
  84637. * Multiplies two quaternions
  84638. * @param q1 defines the second operand
  84639. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84640. */
  84641. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84642. /**
  84643. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84644. * @param q1 defines the second operand
  84645. * @param result defines the target quaternion
  84646. * @returns the current quaternion
  84647. */
  84648. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84649. /**
  84650. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84651. * @param q1 defines the second operand
  84652. * @returns the currentupdated quaternion
  84653. */
  84654. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84655. /**
  84656. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84657. * @param ref defines the target quaternion
  84658. * @returns the current quaternion
  84659. */
  84660. conjugateToRef(ref: Quaternion): Quaternion;
  84661. /**
  84662. * Conjugates in place (1-q) the current quaternion
  84663. * @returns the current updated quaternion
  84664. */
  84665. conjugateInPlace(): Quaternion;
  84666. /**
  84667. * Conjugates in place (1-q) the current quaternion
  84668. * @returns a new quaternion
  84669. */
  84670. conjugate(): Quaternion;
  84671. /**
  84672. * Gets length of current quaternion
  84673. * @returns the quaternion length (float)
  84674. */
  84675. length(): number;
  84676. /**
  84677. * Normalize in place the current quaternion
  84678. * @returns the current updated quaternion
  84679. */
  84680. normalize(): Quaternion;
  84681. /**
  84682. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84683. * @param order is a reserved parameter and is ignored for now
  84684. * @returns a new Vector3 containing the Euler angles
  84685. */
  84686. toEulerAngles(order?: string): Vector3;
  84687. /**
  84688. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84689. * @param result defines the vector which will be filled with the Euler angles
  84690. * @returns the current unchanged quaternion
  84691. */
  84692. toEulerAnglesToRef(result: Vector3): Quaternion;
  84693. /**
  84694. * Updates the given rotation matrix with the current quaternion values
  84695. * @param result defines the target matrix
  84696. * @returns the current unchanged quaternion
  84697. */
  84698. toRotationMatrix(result: Matrix): Quaternion;
  84699. /**
  84700. * Updates the current quaternion from the given rotation matrix values
  84701. * @param matrix defines the source matrix
  84702. * @returns the current updated quaternion
  84703. */
  84704. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84705. /**
  84706. * Creates a new quaternion from a rotation matrix
  84707. * @param matrix defines the source matrix
  84708. * @returns a new quaternion created from the given rotation matrix values
  84709. */
  84710. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84711. /**
  84712. * Updates the given quaternion with the given rotation matrix values
  84713. * @param matrix defines the source matrix
  84714. * @param result defines the target quaternion
  84715. */
  84716. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84717. /**
  84718. * Returns the dot product (float) between the quaternions "left" and "right"
  84719. * @param left defines the left operand
  84720. * @param right defines the right operand
  84721. * @returns the dot product
  84722. */
  84723. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84724. /**
  84725. * Checks if the two quaternions are close to each other
  84726. * @param quat0 defines the first quaternion to check
  84727. * @param quat1 defines the second quaternion to check
  84728. * @returns true if the two quaternions are close to each other
  84729. */
  84730. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84731. /**
  84732. * Creates an empty quaternion
  84733. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84734. */
  84735. static Zero(): Quaternion;
  84736. /**
  84737. * Inverse a given quaternion
  84738. * @param q defines the source quaternion
  84739. * @returns a new quaternion as the inverted current quaternion
  84740. */
  84741. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84742. /**
  84743. * Inverse a given quaternion
  84744. * @param q defines the source quaternion
  84745. * @param result the quaternion the result will be stored in
  84746. * @returns the result quaternion
  84747. */
  84748. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84749. /**
  84750. * Creates an identity quaternion
  84751. * @returns the identity quaternion
  84752. */
  84753. static Identity(): Quaternion;
  84754. /**
  84755. * Gets a boolean indicating if the given quaternion is identity
  84756. * @param quaternion defines the quaternion to check
  84757. * @returns true if the quaternion is identity
  84758. */
  84759. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84760. /**
  84761. * Creates a quaternion from a rotation around an axis
  84762. * @param axis defines the axis to use
  84763. * @param angle defines the angle to use
  84764. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84765. */
  84766. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84767. /**
  84768. * Creates a rotation around an axis and stores it into the given quaternion
  84769. * @param axis defines the axis to use
  84770. * @param angle defines the angle to use
  84771. * @param result defines the target quaternion
  84772. * @returns the target quaternion
  84773. */
  84774. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84775. /**
  84776. * Creates a new quaternion from data stored into an array
  84777. * @param array defines the data source
  84778. * @param offset defines the offset in the source array where the data starts
  84779. * @returns a new quaternion
  84780. */
  84781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84782. /**
  84783. * Updates the given quaternion "result" from the starting index of the given array.
  84784. * @param array the array to pull values from
  84785. * @param offset the offset into the array to start at
  84786. * @param result the quaternion to store the result in
  84787. */
  84788. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84789. /**
  84790. * Create a quaternion from Euler rotation angles
  84791. * @param x Pitch
  84792. * @param y Yaw
  84793. * @param z Roll
  84794. * @returns the new Quaternion
  84795. */
  84796. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84797. /**
  84798. * Updates a quaternion from Euler rotation angles
  84799. * @param x Pitch
  84800. * @param y Yaw
  84801. * @param z Roll
  84802. * @param result the quaternion to store the result
  84803. * @returns the updated quaternion
  84804. */
  84805. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84806. /**
  84807. * Create a quaternion from Euler rotation vector
  84808. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84809. * @returns the new Quaternion
  84810. */
  84811. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84812. /**
  84813. * Updates a quaternion from Euler rotation vector
  84814. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84815. * @param result the quaternion to store the result
  84816. * @returns the updated quaternion
  84817. */
  84818. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84819. /**
  84820. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84821. * @param yaw defines the rotation around Y axis
  84822. * @param pitch defines the rotation around X axis
  84823. * @param roll defines the rotation around Z axis
  84824. * @returns the new quaternion
  84825. */
  84826. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84827. /**
  84828. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84829. * @param yaw defines the rotation around Y axis
  84830. * @param pitch defines the rotation around X axis
  84831. * @param roll defines the rotation around Z axis
  84832. * @param result defines the target quaternion
  84833. */
  84834. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84835. /**
  84836. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84837. * @param alpha defines the rotation around first axis
  84838. * @param beta defines the rotation around second axis
  84839. * @param gamma defines the rotation around third axis
  84840. * @returns the new quaternion
  84841. */
  84842. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84843. /**
  84844. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84845. * @param alpha defines the rotation around first axis
  84846. * @param beta defines the rotation around second axis
  84847. * @param gamma defines the rotation around third axis
  84848. * @param result defines the target quaternion
  84849. */
  84850. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84851. /**
  84852. * 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)
  84853. * @param axis1 defines the first axis
  84854. * @param axis2 defines the second axis
  84855. * @param axis3 defines the third axis
  84856. * @returns the new quaternion
  84857. */
  84858. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84859. /**
  84860. * 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
  84861. * @param axis1 defines the first axis
  84862. * @param axis2 defines the second axis
  84863. * @param axis3 defines the third axis
  84864. * @param ref defines the target quaternion
  84865. */
  84866. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84867. /**
  84868. * Interpolates between two quaternions
  84869. * @param left defines first quaternion
  84870. * @param right defines second quaternion
  84871. * @param amount defines the gradient to use
  84872. * @returns the new interpolated quaternion
  84873. */
  84874. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84875. /**
  84876. * Interpolates between two quaternions and stores it into a target quaternion
  84877. * @param left defines first quaternion
  84878. * @param right defines second quaternion
  84879. * @param amount defines the gradient to use
  84880. * @param result defines the target quaternion
  84881. */
  84882. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84883. /**
  84884. * Interpolate between two quaternions using Hermite interpolation
  84885. * @param value1 defines first quaternion
  84886. * @param tangent1 defines the incoming tangent
  84887. * @param value2 defines second quaternion
  84888. * @param tangent2 defines the outgoing tangent
  84889. * @param amount defines the target quaternion
  84890. * @returns the new interpolated quaternion
  84891. */
  84892. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84893. }
  84894. /**
  84895. * Class used to store matrix data (4x4)
  84896. */
  84897. export class Matrix {
  84898. /**
  84899. * Gets the precision of matrix computations
  84900. */
  84901. static get Use64Bits(): boolean;
  84902. private static _updateFlagSeed;
  84903. private static _identityReadOnly;
  84904. private _isIdentity;
  84905. private _isIdentityDirty;
  84906. private _isIdentity3x2;
  84907. private _isIdentity3x2Dirty;
  84908. /**
  84909. * Gets the update flag of the matrix which is an unique number for the matrix.
  84910. * It will be incremented every time the matrix data change.
  84911. * You can use it to speed the comparison between two versions of the same matrix.
  84912. */
  84913. updateFlag: number;
  84914. private readonly _m;
  84915. /**
  84916. * Gets the internal data of the matrix
  84917. */
  84918. get m(): DeepImmutable<Float32Array | Array<number>>;
  84919. /** @hidden */
  84920. _markAsUpdated(): void;
  84921. /** @hidden */
  84922. private _updateIdentityStatus;
  84923. /**
  84924. * Creates an empty matrix (filled with zeros)
  84925. */
  84926. constructor();
  84927. /**
  84928. * Check if the current matrix is identity
  84929. * @returns true is the matrix is the identity matrix
  84930. */
  84931. isIdentity(): boolean;
  84932. /**
  84933. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84934. * @returns true is the matrix is the identity matrix
  84935. */
  84936. isIdentityAs3x2(): boolean;
  84937. /**
  84938. * Gets the determinant of the matrix
  84939. * @returns the matrix determinant
  84940. */
  84941. determinant(): number;
  84942. /**
  84943. * Returns the matrix as a Float32Array or Array<number>
  84944. * @returns the matrix underlying array
  84945. */
  84946. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84947. /**
  84948. * Returns the matrix as a Float32Array or Array<number>
  84949. * @returns the matrix underlying array.
  84950. */
  84951. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84952. /**
  84953. * Inverts the current matrix in place
  84954. * @returns the current inverted matrix
  84955. */
  84956. invert(): Matrix;
  84957. /**
  84958. * Sets all the matrix elements to zero
  84959. * @returns the current matrix
  84960. */
  84961. reset(): Matrix;
  84962. /**
  84963. * Adds the current matrix with a second one
  84964. * @param other defines the matrix to add
  84965. * @returns a new matrix as the addition of the current matrix and the given one
  84966. */
  84967. add(other: DeepImmutable<Matrix>): Matrix;
  84968. /**
  84969. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84970. * @param other defines the matrix to add
  84971. * @param result defines the target matrix
  84972. * @returns the current matrix
  84973. */
  84974. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84975. /**
  84976. * Adds in place the given matrix to the current matrix
  84977. * @param other defines the second operand
  84978. * @returns the current updated matrix
  84979. */
  84980. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84981. /**
  84982. * Sets the given matrix to the current inverted Matrix
  84983. * @param other defines the target matrix
  84984. * @returns the unmodified current matrix
  84985. */
  84986. invertToRef(other: Matrix): Matrix;
  84987. /**
  84988. * add a value at the specified position in the current Matrix
  84989. * @param index the index of the value within the matrix. between 0 and 15.
  84990. * @param value the value to be added
  84991. * @returns the current updated matrix
  84992. */
  84993. addAtIndex(index: number, value: number): Matrix;
  84994. /**
  84995. * mutiply the specified position in the current Matrix by a value
  84996. * @param index the index of the value within the matrix. between 0 and 15.
  84997. * @param value the value to be added
  84998. * @returns the current updated matrix
  84999. */
  85000. multiplyAtIndex(index: number, value: number): Matrix;
  85001. /**
  85002. * Inserts the translation vector (using 3 floats) in the current matrix
  85003. * @param x defines the 1st component of the translation
  85004. * @param y defines the 2nd component of the translation
  85005. * @param z defines the 3rd component of the translation
  85006. * @returns the current updated matrix
  85007. */
  85008. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85009. /**
  85010. * Adds the translation vector (using 3 floats) in the current matrix
  85011. * @param x defines the 1st component of the translation
  85012. * @param y defines the 2nd component of the translation
  85013. * @param z defines the 3rd component of the translation
  85014. * @returns the current updated matrix
  85015. */
  85016. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85017. /**
  85018. * Inserts the translation vector in the current matrix
  85019. * @param vector3 defines the translation to insert
  85020. * @returns the current updated matrix
  85021. */
  85022. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  85023. /**
  85024. * Gets the translation value of the current matrix
  85025. * @returns a new Vector3 as the extracted translation from the matrix
  85026. */
  85027. getTranslation(): Vector3;
  85028. /**
  85029. * Fill a Vector3 with the extracted translation from the matrix
  85030. * @param result defines the Vector3 where to store the translation
  85031. * @returns the current matrix
  85032. */
  85033. getTranslationToRef(result: Vector3): Matrix;
  85034. /**
  85035. * Remove rotation and scaling part from the matrix
  85036. * @returns the updated matrix
  85037. */
  85038. removeRotationAndScaling(): Matrix;
  85039. /**
  85040. * Multiply two matrices
  85041. * @param other defines the second operand
  85042. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85043. */
  85044. multiply(other: DeepImmutable<Matrix>): Matrix;
  85045. /**
  85046. * Copy the current matrix from the given one
  85047. * @param other defines the source matrix
  85048. * @returns the current updated matrix
  85049. */
  85050. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85051. /**
  85052. * Populates the given array from the starting index with the current matrix values
  85053. * @param array defines the target array
  85054. * @param offset defines the offset in the target array where to start storing values
  85055. * @returns the current matrix
  85056. */
  85057. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85058. /**
  85059. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85060. * @param other defines the second operand
  85061. * @param result defines the matrix where to store the multiplication
  85062. * @returns the current matrix
  85063. */
  85064. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85065. /**
  85066. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85067. * @param other defines the second operand
  85068. * @param result defines the array where to store the multiplication
  85069. * @param offset defines the offset in the target array where to start storing values
  85070. * @returns the current matrix
  85071. */
  85072. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85073. /**
  85074. * Check equality between this matrix and a second one
  85075. * @param value defines the second matrix to compare
  85076. * @returns true is the current matrix and the given one values are strictly equal
  85077. */
  85078. equals(value: DeepImmutable<Matrix>): boolean;
  85079. /**
  85080. * Clone the current matrix
  85081. * @returns a new matrix from the current matrix
  85082. */
  85083. clone(): Matrix;
  85084. /**
  85085. * Returns the name of the current matrix class
  85086. * @returns the string "Matrix"
  85087. */
  85088. getClassName(): string;
  85089. /**
  85090. * Gets the hash code of the current matrix
  85091. * @returns the hash code
  85092. */
  85093. getHashCode(): number;
  85094. /**
  85095. * Decomposes the current Matrix into a translation, rotation and scaling components
  85096. * @param scale defines the scale vector3 given as a reference to update
  85097. * @param rotation defines the rotation quaternion given as a reference to update
  85098. * @param translation defines the translation vector3 given as a reference to update
  85099. * @returns true if operation was successful
  85100. */
  85101. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85102. /**
  85103. * Gets specific row of the matrix
  85104. * @param index defines the number of the row to get
  85105. * @returns the index-th row of the current matrix as a new Vector4
  85106. */
  85107. getRow(index: number): Nullable<Vector4>;
  85108. /**
  85109. * Sets the index-th row of the current matrix to the vector4 values
  85110. * @param index defines the number of the row to set
  85111. * @param row defines the target vector4
  85112. * @returns the updated current matrix
  85113. */
  85114. setRow(index: number, row: Vector4): Matrix;
  85115. /**
  85116. * Compute the transpose of the matrix
  85117. * @returns the new transposed matrix
  85118. */
  85119. transpose(): Matrix;
  85120. /**
  85121. * Compute the transpose of the matrix and store it in a given matrix
  85122. * @param result defines the target matrix
  85123. * @returns the current matrix
  85124. */
  85125. transposeToRef(result: Matrix): Matrix;
  85126. /**
  85127. * Sets the index-th row of the current matrix with the given 4 x float values
  85128. * @param index defines the row index
  85129. * @param x defines the x component to set
  85130. * @param y defines the y component to set
  85131. * @param z defines the z component to set
  85132. * @param w defines the w component to set
  85133. * @returns the updated current matrix
  85134. */
  85135. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85136. /**
  85137. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85138. * @param scale defines the scale factor
  85139. * @returns a new matrix
  85140. */
  85141. scale(scale: number): Matrix;
  85142. /**
  85143. * Scale the current matrix values by a factor to a given result matrix
  85144. * @param scale defines the scale factor
  85145. * @param result defines the matrix to store the result
  85146. * @returns the current matrix
  85147. */
  85148. scaleToRef(scale: number, result: Matrix): Matrix;
  85149. /**
  85150. * Scale the current matrix values by a factor and add the result to a given matrix
  85151. * @param scale defines the scale factor
  85152. * @param result defines the Matrix to store the result
  85153. * @returns the current matrix
  85154. */
  85155. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85156. /**
  85157. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85158. * @param ref matrix to store the result
  85159. */
  85160. toNormalMatrix(ref: Matrix): void;
  85161. /**
  85162. * Gets only rotation part of the current matrix
  85163. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85164. */
  85165. getRotationMatrix(): Matrix;
  85166. /**
  85167. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85168. * @param result defines the target matrix to store data to
  85169. * @returns the current matrix
  85170. */
  85171. getRotationMatrixToRef(result: Matrix): Matrix;
  85172. /**
  85173. * Toggles model matrix from being right handed to left handed in place and vice versa
  85174. */
  85175. toggleModelMatrixHandInPlace(): void;
  85176. /**
  85177. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85178. */
  85179. toggleProjectionMatrixHandInPlace(): void;
  85180. /**
  85181. * Creates a matrix from an array
  85182. * @param array defines the source array
  85183. * @param offset defines an offset in the source array
  85184. * @returns a new Matrix set from the starting index of the given array
  85185. */
  85186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85187. /**
  85188. * Copy the content of an array into a given matrix
  85189. * @param array defines the source array
  85190. * @param offset defines an offset in the source array
  85191. * @param result defines the target matrix
  85192. */
  85193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85194. /**
  85195. * Stores an array into a matrix after having multiplied each component by a given factor
  85196. * @param array defines the source array
  85197. * @param offset defines the offset in the source array
  85198. * @param scale defines the scaling factor
  85199. * @param result defines the target matrix
  85200. */
  85201. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85202. /**
  85203. * Gets an identity matrix that must not be updated
  85204. */
  85205. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85206. /**
  85207. * Stores a list of values (16) inside a given matrix
  85208. * @param initialM11 defines 1st value of 1st row
  85209. * @param initialM12 defines 2nd value of 1st row
  85210. * @param initialM13 defines 3rd value of 1st row
  85211. * @param initialM14 defines 4th value of 1st row
  85212. * @param initialM21 defines 1st value of 2nd row
  85213. * @param initialM22 defines 2nd value of 2nd row
  85214. * @param initialM23 defines 3rd value of 2nd row
  85215. * @param initialM24 defines 4th value of 2nd row
  85216. * @param initialM31 defines 1st value of 3rd row
  85217. * @param initialM32 defines 2nd value of 3rd row
  85218. * @param initialM33 defines 3rd value of 3rd row
  85219. * @param initialM34 defines 4th value of 3rd row
  85220. * @param initialM41 defines 1st value of 4th row
  85221. * @param initialM42 defines 2nd value of 4th row
  85222. * @param initialM43 defines 3rd value of 4th row
  85223. * @param initialM44 defines 4th value of 4th row
  85224. * @param result defines the target matrix
  85225. */
  85226. 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;
  85227. /**
  85228. * Creates new matrix from a list of values (16)
  85229. * @param initialM11 defines 1st value of 1st row
  85230. * @param initialM12 defines 2nd value of 1st row
  85231. * @param initialM13 defines 3rd value of 1st row
  85232. * @param initialM14 defines 4th value of 1st row
  85233. * @param initialM21 defines 1st value of 2nd row
  85234. * @param initialM22 defines 2nd value of 2nd row
  85235. * @param initialM23 defines 3rd value of 2nd row
  85236. * @param initialM24 defines 4th value of 2nd row
  85237. * @param initialM31 defines 1st value of 3rd row
  85238. * @param initialM32 defines 2nd value of 3rd row
  85239. * @param initialM33 defines 3rd value of 3rd row
  85240. * @param initialM34 defines 4th value of 3rd row
  85241. * @param initialM41 defines 1st value of 4th row
  85242. * @param initialM42 defines 2nd value of 4th row
  85243. * @param initialM43 defines 3rd value of 4th row
  85244. * @param initialM44 defines 4th value of 4th row
  85245. * @returns the new matrix
  85246. */
  85247. 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;
  85248. /**
  85249. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85250. * @param scale defines the scale vector3
  85251. * @param rotation defines the rotation quaternion
  85252. * @param translation defines the translation vector3
  85253. * @returns a new matrix
  85254. */
  85255. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85256. /**
  85257. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85258. * @param scale defines the scale vector3
  85259. * @param rotation defines the rotation quaternion
  85260. * @param translation defines the translation vector3
  85261. * @param result defines the target matrix
  85262. */
  85263. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85264. /**
  85265. * Creates a new identity matrix
  85266. * @returns a new identity matrix
  85267. */
  85268. static Identity(): Matrix;
  85269. /**
  85270. * Creates a new identity matrix and stores the result in a given matrix
  85271. * @param result defines the target matrix
  85272. */
  85273. static IdentityToRef(result: Matrix): void;
  85274. /**
  85275. * Creates a new zero matrix
  85276. * @returns a new zero matrix
  85277. */
  85278. static Zero(): Matrix;
  85279. /**
  85280. * Creates a new rotation matrix for "angle" radians around the X axis
  85281. * @param angle defines the angle (in radians) to use
  85282. * @return the new matrix
  85283. */
  85284. static RotationX(angle: number): Matrix;
  85285. /**
  85286. * Creates a new matrix as the invert of a given matrix
  85287. * @param source defines the source matrix
  85288. * @returns the new matrix
  85289. */
  85290. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85291. /**
  85292. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85293. * @param angle defines the angle (in radians) to use
  85294. * @param result defines the target matrix
  85295. */
  85296. static RotationXToRef(angle: number, result: Matrix): void;
  85297. /**
  85298. * Creates a new rotation matrix for "angle" radians around the Y axis
  85299. * @param angle defines the angle (in radians) to use
  85300. * @return the new matrix
  85301. */
  85302. static RotationY(angle: number): Matrix;
  85303. /**
  85304. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85305. * @param angle defines the angle (in radians) to use
  85306. * @param result defines the target matrix
  85307. */
  85308. static RotationYToRef(angle: number, result: Matrix): void;
  85309. /**
  85310. * Creates a new rotation matrix for "angle" radians around the Z axis
  85311. * @param angle defines the angle (in radians) to use
  85312. * @return the new matrix
  85313. */
  85314. static RotationZ(angle: number): Matrix;
  85315. /**
  85316. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85317. * @param angle defines the angle (in radians) to use
  85318. * @param result defines the target matrix
  85319. */
  85320. static RotationZToRef(angle: number, result: Matrix): void;
  85321. /**
  85322. * Creates a new rotation matrix for "angle" radians around the given axis
  85323. * @param axis defines the axis to use
  85324. * @param angle defines the angle (in radians) to use
  85325. * @return the new matrix
  85326. */
  85327. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85328. /**
  85329. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85330. * @param axis defines the axis to use
  85331. * @param angle defines the angle (in radians) to use
  85332. * @param result defines the target matrix
  85333. */
  85334. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85335. /**
  85336. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85337. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85338. * @param from defines the vector to align
  85339. * @param to defines the vector to align to
  85340. * @param result defines the target matrix
  85341. */
  85342. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85343. /**
  85344. * Creates a rotation matrix
  85345. * @param yaw defines the yaw angle in radians (Y axis)
  85346. * @param pitch defines the pitch angle in radians (X axis)
  85347. * @param roll defines the roll angle in radians (Z axis)
  85348. * @returns the new rotation matrix
  85349. */
  85350. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85351. /**
  85352. * Creates a rotation matrix and stores it in a given matrix
  85353. * @param yaw defines the yaw angle in radians (Y axis)
  85354. * @param pitch defines the pitch angle in radians (X axis)
  85355. * @param roll defines the roll angle in radians (Z axis)
  85356. * @param result defines the target matrix
  85357. */
  85358. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85359. /**
  85360. * Creates a scaling matrix
  85361. * @param x defines the scale factor on X axis
  85362. * @param y defines the scale factor on Y axis
  85363. * @param z defines the scale factor on Z axis
  85364. * @returns the new matrix
  85365. */
  85366. static Scaling(x: number, y: number, z: number): Matrix;
  85367. /**
  85368. * Creates a scaling matrix and stores it in a given matrix
  85369. * @param x defines the scale factor on X axis
  85370. * @param y defines the scale factor on Y axis
  85371. * @param z defines the scale factor on Z axis
  85372. * @param result defines the target matrix
  85373. */
  85374. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85375. /**
  85376. * Creates a translation matrix
  85377. * @param x defines the translation on X axis
  85378. * @param y defines the translation on Y axis
  85379. * @param z defines the translationon Z axis
  85380. * @returns the new matrix
  85381. */
  85382. static Translation(x: number, y: number, z: number): Matrix;
  85383. /**
  85384. * Creates a translation matrix and stores it in a given matrix
  85385. * @param x defines the translation on X axis
  85386. * @param y defines the translation on Y axis
  85387. * @param z defines the translationon Z axis
  85388. * @param result defines the target matrix
  85389. */
  85390. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85391. /**
  85392. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85393. * @param startValue defines the start value
  85394. * @param endValue defines the end value
  85395. * @param gradient defines the gradient factor
  85396. * @returns the new matrix
  85397. */
  85398. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85399. /**
  85400. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85401. * @param startValue defines the start value
  85402. * @param endValue defines the end value
  85403. * @param gradient defines the gradient factor
  85404. * @param result defines the Matrix object where to store data
  85405. */
  85406. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85407. /**
  85408. * Builds a new matrix whose values are computed by:
  85409. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85410. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85411. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85412. * @param startValue defines the first matrix
  85413. * @param endValue defines the second matrix
  85414. * @param gradient defines the gradient between the two matrices
  85415. * @returns the new matrix
  85416. */
  85417. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85418. /**
  85419. * Update a matrix to values which are computed by:
  85420. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85421. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85422. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85423. * @param startValue defines the first matrix
  85424. * @param endValue defines the second matrix
  85425. * @param gradient defines the gradient between the two matrices
  85426. * @param result defines the target matrix
  85427. */
  85428. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85429. /**
  85430. * 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"
  85431. * This function works in left handed mode
  85432. * @param eye defines the final position of the entity
  85433. * @param target defines where the entity should look at
  85434. * @param up defines the up vector for the entity
  85435. * @returns the new matrix
  85436. */
  85437. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85438. /**
  85439. * 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".
  85440. * This function works in left handed mode
  85441. * @param eye defines the final position of the entity
  85442. * @param target defines where the entity should look at
  85443. * @param up defines the up vector for the entity
  85444. * @param result defines the target matrix
  85445. */
  85446. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85447. /**
  85448. * 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"
  85449. * This function works in right handed mode
  85450. * @param eye defines the final position of the entity
  85451. * @param target defines where the entity should look at
  85452. * @param up defines the up vector for the entity
  85453. * @returns the new matrix
  85454. */
  85455. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85456. /**
  85457. * 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".
  85458. * This function works in right handed mode
  85459. * @param eye defines the final position of the entity
  85460. * @param target defines where the entity should look at
  85461. * @param up defines the up vector for the entity
  85462. * @param result defines the target matrix
  85463. */
  85464. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85465. /**
  85466. * Create a left-handed orthographic projection matrix
  85467. * @param width defines the viewport width
  85468. * @param height defines the viewport height
  85469. * @param znear defines the near clip plane
  85470. * @param zfar defines the far clip plane
  85471. * @returns a new matrix as a left-handed orthographic projection matrix
  85472. */
  85473. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85474. /**
  85475. * Store a left-handed orthographic projection to a given matrix
  85476. * @param width defines the viewport width
  85477. * @param height defines the viewport height
  85478. * @param znear defines the near clip plane
  85479. * @param zfar defines the far clip plane
  85480. * @param result defines the target matrix
  85481. */
  85482. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85483. /**
  85484. * Create a left-handed orthographic projection matrix
  85485. * @param left defines the viewport left coordinate
  85486. * @param right defines the viewport right coordinate
  85487. * @param bottom defines the viewport bottom coordinate
  85488. * @param top defines the viewport top coordinate
  85489. * @param znear defines the near clip plane
  85490. * @param zfar defines the far clip plane
  85491. * @returns a new matrix as a left-handed orthographic projection matrix
  85492. */
  85493. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85494. /**
  85495. * Stores a left-handed orthographic projection into a given matrix
  85496. * @param left defines the viewport left coordinate
  85497. * @param right defines the viewport right coordinate
  85498. * @param bottom defines the viewport bottom coordinate
  85499. * @param top defines the viewport top coordinate
  85500. * @param znear defines the near clip plane
  85501. * @param zfar defines the far clip plane
  85502. * @param result defines the target matrix
  85503. */
  85504. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85505. /**
  85506. * Creates a right-handed orthographic projection matrix
  85507. * @param left defines the viewport left coordinate
  85508. * @param right defines the viewport right coordinate
  85509. * @param bottom defines the viewport bottom coordinate
  85510. * @param top defines the viewport top coordinate
  85511. * @param znear defines the near clip plane
  85512. * @param zfar defines the far clip plane
  85513. * @returns a new matrix as a right-handed orthographic projection matrix
  85514. */
  85515. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85516. /**
  85517. * Stores a right-handed orthographic projection into a given matrix
  85518. * @param left defines the viewport left coordinate
  85519. * @param right defines the viewport right coordinate
  85520. * @param bottom defines the viewport bottom coordinate
  85521. * @param top defines the viewport top coordinate
  85522. * @param znear defines the near clip plane
  85523. * @param zfar defines the far clip plane
  85524. * @param result defines the target matrix
  85525. */
  85526. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85527. /**
  85528. * Creates a left-handed perspective projection matrix
  85529. * @param width defines the viewport width
  85530. * @param height defines the viewport height
  85531. * @param znear defines the near clip plane
  85532. * @param zfar defines the far clip plane
  85533. * @returns a new matrix as a left-handed perspective projection matrix
  85534. */
  85535. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85536. /**
  85537. * Creates a left-handed perspective projection matrix
  85538. * @param fov defines the horizontal field of view
  85539. * @param aspect defines the aspect ratio
  85540. * @param znear defines the near clip plane
  85541. * @param zfar defines the far clip plane
  85542. * @returns a new matrix as a left-handed perspective projection matrix
  85543. */
  85544. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85545. /**
  85546. * Stores a left-handed perspective projection into a given matrix
  85547. * @param fov defines the horizontal field of view
  85548. * @param aspect defines the aspect ratio
  85549. * @param znear defines the near clip plane
  85550. * @param zfar defines the far clip plane
  85551. * @param result defines the target matrix
  85552. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85553. */
  85554. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85555. /**
  85556. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85557. * @param fov defines the horizontal field of view
  85558. * @param aspect defines the aspect ratio
  85559. * @param znear defines the near clip plane
  85560. * @param zfar not used as infinity is used as far clip
  85561. * @param result defines the target matrix
  85562. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85563. */
  85564. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85565. /**
  85566. * Creates a right-handed perspective projection matrix
  85567. * @param fov defines the horizontal field of view
  85568. * @param aspect defines the aspect ratio
  85569. * @param znear defines the near clip plane
  85570. * @param zfar defines the far clip plane
  85571. * @returns a new matrix as a right-handed perspective projection matrix
  85572. */
  85573. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85574. /**
  85575. * Stores a right-handed perspective projection into a given matrix
  85576. * @param fov defines the horizontal field of view
  85577. * @param aspect defines the aspect ratio
  85578. * @param znear defines the near clip plane
  85579. * @param zfar defines the far clip plane
  85580. * @param result defines the target matrix
  85581. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85582. */
  85583. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85584. /**
  85585. * Stores a right-handed perspective projection into a given matrix
  85586. * @param fov defines the horizontal field of view
  85587. * @param aspect defines the aspect ratio
  85588. * @param znear defines the near clip plane
  85589. * @param zfar not used as infinity is used as far clip
  85590. * @param result defines the target matrix
  85591. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85592. */
  85593. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85594. /**
  85595. * Stores a perspective projection for WebVR info a given matrix
  85596. * @param fov defines the field of view
  85597. * @param znear defines the near clip plane
  85598. * @param zfar defines the far clip plane
  85599. * @param result defines the target matrix
  85600. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85601. */
  85602. static PerspectiveFovWebVRToRef(fov: {
  85603. upDegrees: number;
  85604. downDegrees: number;
  85605. leftDegrees: number;
  85606. rightDegrees: number;
  85607. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85608. /**
  85609. * Computes a complete transformation matrix
  85610. * @param viewport defines the viewport to use
  85611. * @param world defines the world matrix
  85612. * @param view defines the view matrix
  85613. * @param projection defines the projection matrix
  85614. * @param zmin defines the near clip plane
  85615. * @param zmax defines the far clip plane
  85616. * @returns the transformation matrix
  85617. */
  85618. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85619. /**
  85620. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85621. * @param matrix defines the matrix to use
  85622. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85623. */
  85624. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85625. /**
  85626. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85627. * @param matrix defines the matrix to use
  85628. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85629. */
  85630. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85631. /**
  85632. * Compute the transpose of a given matrix
  85633. * @param matrix defines the matrix to transpose
  85634. * @returns the new matrix
  85635. */
  85636. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85637. /**
  85638. * Compute the transpose of a matrix and store it in a target matrix
  85639. * @param matrix defines the matrix to transpose
  85640. * @param result defines the target matrix
  85641. */
  85642. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85643. /**
  85644. * Computes a reflection matrix from a plane
  85645. * @param plane defines the reflection plane
  85646. * @returns a new matrix
  85647. */
  85648. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85649. /**
  85650. * Computes a reflection matrix from a plane
  85651. * @param plane defines the reflection plane
  85652. * @param result defines the target matrix
  85653. */
  85654. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85655. /**
  85656. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85657. * @param xaxis defines the value of the 1st axis
  85658. * @param yaxis defines the value of the 2nd axis
  85659. * @param zaxis defines the value of the 3rd axis
  85660. * @param result defines the target matrix
  85661. */
  85662. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85663. /**
  85664. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85665. * @param quat defines the quaternion to use
  85666. * @param result defines the target matrix
  85667. */
  85668. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85669. }
  85670. /**
  85671. * @hidden
  85672. */
  85673. export class TmpVectors {
  85674. static Vector2: Vector2[];
  85675. static Vector3: Vector3[];
  85676. static Vector4: Vector4[];
  85677. static Quaternion: Quaternion[];
  85678. static Matrix: Matrix[];
  85679. }
  85680. }
  85681. declare module BABYLON {
  85682. /**
  85683. * Defines potential orientation for back face culling
  85684. */
  85685. export enum Orientation {
  85686. /**
  85687. * Clockwise
  85688. */
  85689. CW = 0,
  85690. /** Counter clockwise */
  85691. CCW = 1
  85692. }
  85693. /** Class used to represent a Bezier curve */
  85694. export class BezierCurve {
  85695. /**
  85696. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85697. * @param t defines the time
  85698. * @param x1 defines the left coordinate on X axis
  85699. * @param y1 defines the left coordinate on Y axis
  85700. * @param x2 defines the right coordinate on X axis
  85701. * @param y2 defines the right coordinate on Y axis
  85702. * @returns the interpolated value
  85703. */
  85704. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85705. }
  85706. /**
  85707. * Defines angle representation
  85708. */
  85709. export class Angle {
  85710. private _radians;
  85711. /**
  85712. * Creates an Angle object of "radians" radians (float).
  85713. * @param radians the angle in radians
  85714. */
  85715. constructor(radians: number);
  85716. /**
  85717. * Get value in degrees
  85718. * @returns the Angle value in degrees (float)
  85719. */
  85720. degrees(): number;
  85721. /**
  85722. * Get value in radians
  85723. * @returns the Angle value in radians (float)
  85724. */
  85725. radians(): number;
  85726. /**
  85727. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85728. * @param a defines first point as the origin
  85729. * @param b defines point
  85730. * @returns a new Angle
  85731. */
  85732. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85733. /**
  85734. * Gets a new Angle object from the given float in radians
  85735. * @param radians defines the angle value in radians
  85736. * @returns a new Angle
  85737. */
  85738. static FromRadians(radians: number): Angle;
  85739. /**
  85740. * Gets a new Angle object from the given float in degrees
  85741. * @param degrees defines the angle value in degrees
  85742. * @returns a new Angle
  85743. */
  85744. static FromDegrees(degrees: number): Angle;
  85745. }
  85746. /**
  85747. * This represents an arc in a 2d space.
  85748. */
  85749. export class Arc2 {
  85750. /** Defines the start point of the arc */
  85751. startPoint: Vector2;
  85752. /** Defines the mid point of the arc */
  85753. midPoint: Vector2;
  85754. /** Defines the end point of the arc */
  85755. endPoint: Vector2;
  85756. /**
  85757. * Defines the center point of the arc.
  85758. */
  85759. centerPoint: Vector2;
  85760. /**
  85761. * Defines the radius of the arc.
  85762. */
  85763. radius: number;
  85764. /**
  85765. * Defines the angle of the arc (from mid point to end point).
  85766. */
  85767. angle: Angle;
  85768. /**
  85769. * Defines the start angle of the arc (from start point to middle point).
  85770. */
  85771. startAngle: Angle;
  85772. /**
  85773. * Defines the orientation of the arc (clock wise/counter clock wise).
  85774. */
  85775. orientation: Orientation;
  85776. /**
  85777. * Creates an Arc object from the three given points : start, middle and end.
  85778. * @param startPoint Defines the start point of the arc
  85779. * @param midPoint Defines the midlle point of the arc
  85780. * @param endPoint Defines the end point of the arc
  85781. */
  85782. constructor(
  85783. /** Defines the start point of the arc */
  85784. startPoint: Vector2,
  85785. /** Defines the mid point of the arc */
  85786. midPoint: Vector2,
  85787. /** Defines the end point of the arc */
  85788. endPoint: Vector2);
  85789. }
  85790. /**
  85791. * Represents a 2D path made up of multiple 2D points
  85792. */
  85793. export class Path2 {
  85794. private _points;
  85795. private _length;
  85796. /**
  85797. * If the path start and end point are the same
  85798. */
  85799. closed: boolean;
  85800. /**
  85801. * Creates a Path2 object from the starting 2D coordinates x and y.
  85802. * @param x the starting points x value
  85803. * @param y the starting points y value
  85804. */
  85805. constructor(x: number, y: number);
  85806. /**
  85807. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85808. * @param x the added points x value
  85809. * @param y the added points y value
  85810. * @returns the updated Path2.
  85811. */
  85812. addLineTo(x: number, y: number): Path2;
  85813. /**
  85814. * 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.
  85815. * @param midX middle point x value
  85816. * @param midY middle point y value
  85817. * @param endX end point x value
  85818. * @param endY end point y value
  85819. * @param numberOfSegments (default: 36)
  85820. * @returns the updated Path2.
  85821. */
  85822. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85823. /**
  85824. * Closes the Path2.
  85825. * @returns the Path2.
  85826. */
  85827. close(): Path2;
  85828. /**
  85829. * Gets the sum of the distance between each sequential point in the path
  85830. * @returns the Path2 total length (float).
  85831. */
  85832. length(): number;
  85833. /**
  85834. * Gets the points which construct the path
  85835. * @returns the Path2 internal array of points.
  85836. */
  85837. getPoints(): Vector2[];
  85838. /**
  85839. * Retreives the point at the distance aways from the starting point
  85840. * @param normalizedLengthPosition the length along the path to retreive the point from
  85841. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85842. */
  85843. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85844. /**
  85845. * Creates a new path starting from an x and y position
  85846. * @param x starting x value
  85847. * @param y starting y value
  85848. * @returns a new Path2 starting at the coordinates (x, y).
  85849. */
  85850. static StartingAt(x: number, y: number): Path2;
  85851. }
  85852. /**
  85853. * Represents a 3D path made up of multiple 3D points
  85854. */
  85855. export class Path3D {
  85856. /**
  85857. * an array of Vector3, the curve axis of the Path3D
  85858. */
  85859. path: Vector3[];
  85860. private _curve;
  85861. private _distances;
  85862. private _tangents;
  85863. private _normals;
  85864. private _binormals;
  85865. private _raw;
  85866. private _alignTangentsWithPath;
  85867. private readonly _pointAtData;
  85868. /**
  85869. * new Path3D(path, normal, raw)
  85870. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85871. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85872. * @param path an array of Vector3, the curve axis of the Path3D
  85873. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85874. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85875. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85876. */
  85877. constructor(
  85878. /**
  85879. * an array of Vector3, the curve axis of the Path3D
  85880. */
  85881. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85882. /**
  85883. * Returns the Path3D array of successive Vector3 designing its curve.
  85884. * @returns the Path3D array of successive Vector3 designing its curve.
  85885. */
  85886. getCurve(): Vector3[];
  85887. /**
  85888. * Returns the Path3D array of successive Vector3 designing its curve.
  85889. * @returns the Path3D array of successive Vector3 designing its curve.
  85890. */
  85891. getPoints(): Vector3[];
  85892. /**
  85893. * @returns the computed length (float) of the path.
  85894. */
  85895. length(): number;
  85896. /**
  85897. * Returns an array populated with tangent vectors on each Path3D curve point.
  85898. * @returns an array populated with tangent vectors on each Path3D curve point.
  85899. */
  85900. getTangents(): Vector3[];
  85901. /**
  85902. * Returns an array populated with normal vectors on each Path3D curve point.
  85903. * @returns an array populated with normal vectors on each Path3D curve point.
  85904. */
  85905. getNormals(): Vector3[];
  85906. /**
  85907. * Returns an array populated with binormal vectors on each Path3D curve point.
  85908. * @returns an array populated with binormal vectors on each Path3D curve point.
  85909. */
  85910. getBinormals(): Vector3[];
  85911. /**
  85912. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85913. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85914. */
  85915. getDistances(): number[];
  85916. /**
  85917. * Returns an interpolated point along this path
  85918. * @param position the position of the point along this path, from 0.0 to 1.0
  85919. * @returns a new Vector3 as the point
  85920. */
  85921. getPointAt(position: number): Vector3;
  85922. /**
  85923. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85924. * @param position the position of the point along this path, from 0.0 to 1.0
  85925. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85926. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85927. */
  85928. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85929. /**
  85930. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85931. * @param position the position of the point along this path, from 0.0 to 1.0
  85932. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85933. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85934. */
  85935. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85936. /**
  85937. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85938. * @param position the position of the point along this path, from 0.0 to 1.0
  85939. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85940. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85941. */
  85942. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85943. /**
  85944. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85945. * @param position the position of the point along this path, from 0.0 to 1.0
  85946. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85947. */
  85948. getDistanceAt(position: number): number;
  85949. /**
  85950. * Returns the array index of the previous point of an interpolated point along this path
  85951. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85952. * @returns the array index
  85953. */
  85954. getPreviousPointIndexAt(position: number): number;
  85955. /**
  85956. * 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)
  85957. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85958. * @returns the sub position
  85959. */
  85960. getSubPositionAt(position: number): number;
  85961. /**
  85962. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85963. * @param target the vector of which to get the closest position to
  85964. * @returns the position of the closest virtual point on this path to the target vector
  85965. */
  85966. getClosestPositionTo(target: Vector3): number;
  85967. /**
  85968. * Returns a sub path (slice) of this path
  85969. * @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
  85970. * @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
  85971. * @returns a sub path (slice) of this path
  85972. */
  85973. slice(start?: number, end?: number): Path3D;
  85974. /**
  85975. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85976. * @param path path which all values are copied into the curves points
  85977. * @param firstNormal which should be projected onto the curve
  85978. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85979. * @returns the same object updated.
  85980. */
  85981. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85982. private _compute;
  85983. private _getFirstNonNullVector;
  85984. private _getLastNonNullVector;
  85985. private _normalVector;
  85986. /**
  85987. * Updates the point at data for an interpolated point along this curve
  85988. * @param position the position of the point along this curve, from 0.0 to 1.0
  85989. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85990. * @returns the (updated) point at data
  85991. */
  85992. private _updatePointAtData;
  85993. /**
  85994. * Updates the point at data from the specified parameters
  85995. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85996. * @param point the interpolated point
  85997. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85998. */
  85999. private _setPointAtData;
  86000. /**
  86001. * Updates the point at interpolation matrix for the tangents, normals and binormals
  86002. */
  86003. private _updateInterpolationMatrix;
  86004. }
  86005. /**
  86006. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86007. * A Curve3 is designed from a series of successive Vector3.
  86008. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  86009. */
  86010. export class Curve3 {
  86011. private _points;
  86012. private _length;
  86013. /**
  86014. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  86015. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  86016. * @param v1 (Vector3) the control point
  86017. * @param v2 (Vector3) the end point of the Quadratic Bezier
  86018. * @param nbPoints (integer) the wanted number of points in the curve
  86019. * @returns the created Curve3
  86020. */
  86021. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86022. /**
  86023. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  86024. * @param v0 (Vector3) the origin point of the Cubic Bezier
  86025. * @param v1 (Vector3) the first control point
  86026. * @param v2 (Vector3) the second control point
  86027. * @param v3 (Vector3) the end point of the Cubic Bezier
  86028. * @param nbPoints (integer) the wanted number of points in the curve
  86029. * @returns the created Curve3
  86030. */
  86031. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86032. /**
  86033. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86034. * @param p1 (Vector3) the origin point of the Hermite Spline
  86035. * @param t1 (Vector3) the tangent vector at the origin point
  86036. * @param p2 (Vector3) the end point of the Hermite Spline
  86037. * @param t2 (Vector3) the tangent vector at the end point
  86038. * @param nbPoints (integer) the wanted number of points in the curve
  86039. * @returns the created Curve3
  86040. */
  86041. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86042. /**
  86043. * Returns a Curve3 object along a CatmullRom Spline curve :
  86044. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86045. * @param nbPoints (integer) the wanted number of points between each curve control points
  86046. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86047. * @returns the created Curve3
  86048. */
  86049. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86050. /**
  86051. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86052. * A Curve3 is designed from a series of successive Vector3.
  86053. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86054. * @param points points which make up the curve
  86055. */
  86056. constructor(points: Vector3[]);
  86057. /**
  86058. * @returns the Curve3 stored array of successive Vector3
  86059. */
  86060. getPoints(): Vector3[];
  86061. /**
  86062. * @returns the computed length (float) of the curve.
  86063. */
  86064. length(): number;
  86065. /**
  86066. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86067. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86068. * curveA and curveB keep unchanged.
  86069. * @param curve the curve to continue from this curve
  86070. * @returns the newly constructed curve
  86071. */
  86072. continue(curve: DeepImmutable<Curve3>): Curve3;
  86073. private _computeLength;
  86074. }
  86075. }
  86076. declare module BABYLON {
  86077. /**
  86078. * This represents the main contract an easing function should follow.
  86079. * Easing functions are used throughout the animation system.
  86080. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86081. */
  86082. export interface IEasingFunction {
  86083. /**
  86084. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86085. * of the easing function.
  86086. * The link below provides some of the most common examples of easing functions.
  86087. * @see https://easings.net/
  86088. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86089. * @returns the corresponding value on the curve defined by the easing function
  86090. */
  86091. ease(gradient: number): number;
  86092. }
  86093. /**
  86094. * Base class used for every default easing function.
  86095. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86096. */
  86097. export class EasingFunction implements IEasingFunction {
  86098. /**
  86099. * Interpolation follows the mathematical formula associated with the easing function.
  86100. */
  86101. static readonly EASINGMODE_EASEIN: number;
  86102. /**
  86103. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86104. */
  86105. static readonly EASINGMODE_EASEOUT: number;
  86106. /**
  86107. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86108. */
  86109. static readonly EASINGMODE_EASEINOUT: number;
  86110. private _easingMode;
  86111. /**
  86112. * Sets the easing mode of the current function.
  86113. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86114. */
  86115. setEasingMode(easingMode: number): void;
  86116. /**
  86117. * Gets the current easing mode.
  86118. * @returns the easing mode
  86119. */
  86120. getEasingMode(): number;
  86121. /**
  86122. * @hidden
  86123. */
  86124. easeInCore(gradient: number): number;
  86125. /**
  86126. * Given an input gradient between 0 and 1, this returns the corresponding value
  86127. * of the easing function.
  86128. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86129. * @returns the corresponding value on the curve defined by the easing function
  86130. */
  86131. ease(gradient: number): number;
  86132. }
  86133. /**
  86134. * Easing function with a circle shape (see link below).
  86135. * @see https://easings.net/#easeInCirc
  86136. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86137. */
  86138. export class CircleEase extends EasingFunction implements IEasingFunction {
  86139. /** @hidden */
  86140. easeInCore(gradient: number): number;
  86141. }
  86142. /**
  86143. * Easing function with a ease back shape (see link below).
  86144. * @see https://easings.net/#easeInBack
  86145. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86146. */
  86147. export class BackEase extends EasingFunction implements IEasingFunction {
  86148. /** Defines the amplitude of the function */
  86149. amplitude: number;
  86150. /**
  86151. * Instantiates a back ease easing
  86152. * @see https://easings.net/#easeInBack
  86153. * @param amplitude Defines the amplitude of the function
  86154. */
  86155. constructor(
  86156. /** Defines the amplitude of the function */
  86157. amplitude?: number);
  86158. /** @hidden */
  86159. easeInCore(gradient: number): number;
  86160. }
  86161. /**
  86162. * Easing function with a bouncing shape (see link below).
  86163. * @see https://easings.net/#easeInBounce
  86164. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86165. */
  86166. export class BounceEase extends EasingFunction implements IEasingFunction {
  86167. /** Defines the number of bounces */
  86168. bounces: number;
  86169. /** Defines the amplitude of the bounce */
  86170. bounciness: number;
  86171. /**
  86172. * Instantiates a bounce easing
  86173. * @see https://easings.net/#easeInBounce
  86174. * @param bounces Defines the number of bounces
  86175. * @param bounciness Defines the amplitude of the bounce
  86176. */
  86177. constructor(
  86178. /** Defines the number of bounces */
  86179. bounces?: number,
  86180. /** Defines the amplitude of the bounce */
  86181. bounciness?: number);
  86182. /** @hidden */
  86183. easeInCore(gradient: number): number;
  86184. }
  86185. /**
  86186. * Easing function with a power of 3 shape (see link below).
  86187. * @see https://easings.net/#easeInCubic
  86188. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86189. */
  86190. export class CubicEase extends EasingFunction implements IEasingFunction {
  86191. /** @hidden */
  86192. easeInCore(gradient: number): number;
  86193. }
  86194. /**
  86195. * Easing function with an elastic shape (see link below).
  86196. * @see https://easings.net/#easeInElastic
  86197. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86198. */
  86199. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86200. /** Defines the number of oscillations*/
  86201. oscillations: number;
  86202. /** Defines the amplitude of the oscillations*/
  86203. springiness: number;
  86204. /**
  86205. * Instantiates an elastic easing function
  86206. * @see https://easings.net/#easeInElastic
  86207. * @param oscillations Defines the number of oscillations
  86208. * @param springiness Defines the amplitude of the oscillations
  86209. */
  86210. constructor(
  86211. /** Defines the number of oscillations*/
  86212. oscillations?: number,
  86213. /** Defines the amplitude of the oscillations*/
  86214. springiness?: number);
  86215. /** @hidden */
  86216. easeInCore(gradient: number): number;
  86217. }
  86218. /**
  86219. * Easing function with an exponential shape (see link below).
  86220. * @see https://easings.net/#easeInExpo
  86221. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86222. */
  86223. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86224. /** Defines the exponent of the function */
  86225. exponent: number;
  86226. /**
  86227. * Instantiates an exponential easing function
  86228. * @see https://easings.net/#easeInExpo
  86229. * @param exponent Defines the exponent of the function
  86230. */
  86231. constructor(
  86232. /** Defines the exponent of the function */
  86233. exponent?: number);
  86234. /** @hidden */
  86235. easeInCore(gradient: number): number;
  86236. }
  86237. /**
  86238. * Easing function with a power shape (see link below).
  86239. * @see https://easings.net/#easeInQuad
  86240. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86241. */
  86242. export class PowerEase extends EasingFunction implements IEasingFunction {
  86243. /** Defines the power of the function */
  86244. power: number;
  86245. /**
  86246. * Instantiates an power base easing function
  86247. * @see https://easings.net/#easeInQuad
  86248. * @param power Defines the power of the function
  86249. */
  86250. constructor(
  86251. /** Defines the power of the function */
  86252. power?: number);
  86253. /** @hidden */
  86254. easeInCore(gradient: number): number;
  86255. }
  86256. /**
  86257. * Easing function with a power of 2 shape (see link below).
  86258. * @see https://easings.net/#easeInQuad
  86259. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86260. */
  86261. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86262. /** @hidden */
  86263. easeInCore(gradient: number): number;
  86264. }
  86265. /**
  86266. * Easing function with a power of 4 shape (see link below).
  86267. * @see https://easings.net/#easeInQuart
  86268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86269. */
  86270. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86271. /** @hidden */
  86272. easeInCore(gradient: number): number;
  86273. }
  86274. /**
  86275. * Easing function with a power of 5 shape (see link below).
  86276. * @see https://easings.net/#easeInQuint
  86277. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86278. */
  86279. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86280. /** @hidden */
  86281. easeInCore(gradient: number): number;
  86282. }
  86283. /**
  86284. * Easing function with a sin shape (see link below).
  86285. * @see https://easings.net/#easeInSine
  86286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86287. */
  86288. export class SineEase extends EasingFunction implements IEasingFunction {
  86289. /** @hidden */
  86290. easeInCore(gradient: number): number;
  86291. }
  86292. /**
  86293. * Easing function with a bezier shape (see link below).
  86294. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86296. */
  86297. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86298. /** Defines the x component of the start tangent in the bezier curve */
  86299. x1: number;
  86300. /** Defines the y component of the start tangent in the bezier curve */
  86301. y1: number;
  86302. /** Defines the x component of the end tangent in the bezier curve */
  86303. x2: number;
  86304. /** Defines the y component of the end tangent in the bezier curve */
  86305. y2: number;
  86306. /**
  86307. * Instantiates a bezier function
  86308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86309. * @param x1 Defines the x component of the start tangent in the bezier curve
  86310. * @param y1 Defines the y component of the start tangent in the bezier curve
  86311. * @param x2 Defines the x component of the end tangent in the bezier curve
  86312. * @param y2 Defines the y component of the end tangent in the bezier curve
  86313. */
  86314. constructor(
  86315. /** Defines the x component of the start tangent in the bezier curve */
  86316. x1?: number,
  86317. /** Defines the y component of the start tangent in the bezier curve */
  86318. y1?: number,
  86319. /** Defines the x component of the end tangent in the bezier curve */
  86320. x2?: number,
  86321. /** Defines the y component of the end tangent in the bezier curve */
  86322. y2?: number);
  86323. /** @hidden */
  86324. easeInCore(gradient: number): number;
  86325. }
  86326. }
  86327. declare module BABYLON {
  86328. /**
  86329. * Class used to hold a RBG color
  86330. */
  86331. export class Color3 {
  86332. /**
  86333. * Defines the red component (between 0 and 1, default is 0)
  86334. */
  86335. r: number;
  86336. /**
  86337. * Defines the green component (between 0 and 1, default is 0)
  86338. */
  86339. g: number;
  86340. /**
  86341. * Defines the blue component (between 0 and 1, default is 0)
  86342. */
  86343. b: number;
  86344. /**
  86345. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86346. * @param r defines the red component (between 0 and 1, default is 0)
  86347. * @param g defines the green component (between 0 and 1, default is 0)
  86348. * @param b defines the blue component (between 0 and 1, default is 0)
  86349. */
  86350. constructor(
  86351. /**
  86352. * Defines the red component (between 0 and 1, default is 0)
  86353. */
  86354. r?: number,
  86355. /**
  86356. * Defines the green component (between 0 and 1, default is 0)
  86357. */
  86358. g?: number,
  86359. /**
  86360. * Defines the blue component (between 0 and 1, default is 0)
  86361. */
  86362. b?: number);
  86363. /**
  86364. * Creates a string with the Color3 current values
  86365. * @returns the string representation of the Color3 object
  86366. */
  86367. toString(): string;
  86368. /**
  86369. * Returns the string "Color3"
  86370. * @returns "Color3"
  86371. */
  86372. getClassName(): string;
  86373. /**
  86374. * Compute the Color3 hash code
  86375. * @returns an unique number that can be used to hash Color3 objects
  86376. */
  86377. getHashCode(): number;
  86378. /**
  86379. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86380. * @param array defines the array where to store the r,g,b components
  86381. * @param index defines an optional index in the target array to define where to start storing values
  86382. * @returns the current Color3 object
  86383. */
  86384. toArray(array: FloatArray, index?: number): Color3;
  86385. /**
  86386. * Update the current color with values stored in an array from the starting index of the given array
  86387. * @param array defines the source array
  86388. * @param offset defines an offset in the source array
  86389. * @returns the current Color3 object
  86390. */
  86391. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86392. /**
  86393. * Returns a new Color4 object from the current Color3 and the given alpha
  86394. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86395. * @returns a new Color4 object
  86396. */
  86397. toColor4(alpha?: number): Color4;
  86398. /**
  86399. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86400. * @returns the new array
  86401. */
  86402. asArray(): number[];
  86403. /**
  86404. * Returns the luminance value
  86405. * @returns a float value
  86406. */
  86407. toLuminance(): number;
  86408. /**
  86409. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86410. * @param otherColor defines the second operand
  86411. * @returns the new Color3 object
  86412. */
  86413. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86414. /**
  86415. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86416. * @param otherColor defines the second operand
  86417. * @param result defines the Color3 object where to store the result
  86418. * @returns the current Color3
  86419. */
  86420. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86421. /**
  86422. * Determines equality between Color3 objects
  86423. * @param otherColor defines the second operand
  86424. * @returns true if the rgb values are equal to the given ones
  86425. */
  86426. equals(otherColor: DeepImmutable<Color3>): boolean;
  86427. /**
  86428. * Determines equality between the current Color3 object and a set of r,b,g values
  86429. * @param r defines the red component to check
  86430. * @param g defines the green component to check
  86431. * @param b defines the blue component to check
  86432. * @returns true if the rgb values are equal to the given ones
  86433. */
  86434. equalsFloats(r: number, g: number, b: number): boolean;
  86435. /**
  86436. * Multiplies in place each rgb value by scale
  86437. * @param scale defines the scaling factor
  86438. * @returns the updated Color3
  86439. */
  86440. scale(scale: number): Color3;
  86441. /**
  86442. * Multiplies the rgb values by scale and stores the result into "result"
  86443. * @param scale defines the scaling factor
  86444. * @param result defines the Color3 object where to store the result
  86445. * @returns the unmodified current Color3
  86446. */
  86447. scaleToRef(scale: number, result: Color3): Color3;
  86448. /**
  86449. * Scale the current Color3 values by a factor and add the result to a given Color3
  86450. * @param scale defines the scale factor
  86451. * @param result defines color to store the result into
  86452. * @returns the unmodified current Color3
  86453. */
  86454. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86455. /**
  86456. * Clamps the rgb values by the min and max values and stores the result into "result"
  86457. * @param min defines minimum clamping value (default is 0)
  86458. * @param max defines maximum clamping value (default is 1)
  86459. * @param result defines color to store the result into
  86460. * @returns the original Color3
  86461. */
  86462. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86463. /**
  86464. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86465. * @param otherColor defines the second operand
  86466. * @returns the new Color3
  86467. */
  86468. add(otherColor: DeepImmutable<Color3>): Color3;
  86469. /**
  86470. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86471. * @param otherColor defines the second operand
  86472. * @param result defines Color3 object to store the result into
  86473. * @returns the unmodified current Color3
  86474. */
  86475. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86476. /**
  86477. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86478. * @param otherColor defines the second operand
  86479. * @returns the new Color3
  86480. */
  86481. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86482. /**
  86483. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86484. * @param otherColor defines the second operand
  86485. * @param result defines Color3 object to store the result into
  86486. * @returns the unmodified current Color3
  86487. */
  86488. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86489. /**
  86490. * Copy the current object
  86491. * @returns a new Color3 copied the current one
  86492. */
  86493. clone(): Color3;
  86494. /**
  86495. * Copies the rgb values from the source in the current Color3
  86496. * @param source defines the source Color3 object
  86497. * @returns the updated Color3 object
  86498. */
  86499. copyFrom(source: DeepImmutable<Color3>): Color3;
  86500. /**
  86501. * Updates the Color3 rgb values from the given floats
  86502. * @param r defines the red component to read from
  86503. * @param g defines the green component to read from
  86504. * @param b defines the blue component to read from
  86505. * @returns the current Color3 object
  86506. */
  86507. copyFromFloats(r: number, g: number, b: number): Color3;
  86508. /**
  86509. * Updates the Color3 rgb values from the given floats
  86510. * @param r defines the red component to read from
  86511. * @param g defines the green component to read from
  86512. * @param b defines the blue component to read from
  86513. * @returns the current Color3 object
  86514. */
  86515. set(r: number, g: number, b: number): Color3;
  86516. /**
  86517. * Compute the Color3 hexadecimal code as a string
  86518. * @returns a string containing the hexadecimal representation of the Color3 object
  86519. */
  86520. toHexString(): string;
  86521. /**
  86522. * Computes a new Color3 converted from the current one to linear space
  86523. * @returns a new Color3 object
  86524. */
  86525. toLinearSpace(): Color3;
  86526. /**
  86527. * Converts current color in rgb space to HSV values
  86528. * @returns a new color3 representing the HSV values
  86529. */
  86530. toHSV(): Color3;
  86531. /**
  86532. * Converts current color in rgb space to HSV values
  86533. * @param result defines the Color3 where to store the HSV values
  86534. */
  86535. toHSVToRef(result: Color3): void;
  86536. /**
  86537. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86538. * @param convertedColor defines the Color3 object where to store the linear space version
  86539. * @returns the unmodified Color3
  86540. */
  86541. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86542. /**
  86543. * Computes a new Color3 converted from the current one to gamma space
  86544. * @returns a new Color3 object
  86545. */
  86546. toGammaSpace(): Color3;
  86547. /**
  86548. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86549. * @param convertedColor defines the Color3 object where to store the gamma space version
  86550. * @returns the unmodified Color3
  86551. */
  86552. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86553. private static _BlackReadOnly;
  86554. /**
  86555. * Convert Hue, saturation and value to a Color3 (RGB)
  86556. * @param hue defines the hue
  86557. * @param saturation defines the saturation
  86558. * @param value defines the value
  86559. * @param result defines the Color3 where to store the RGB values
  86560. */
  86561. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86562. /**
  86563. * Creates a new Color3 from the string containing valid hexadecimal values
  86564. * @param hex defines a string containing valid hexadecimal values
  86565. * @returns a new Color3 object
  86566. */
  86567. static FromHexString(hex: string): Color3;
  86568. /**
  86569. * Creates a new Color3 from the starting index of the given array
  86570. * @param array defines the source array
  86571. * @param offset defines an offset in the source array
  86572. * @returns a new Color3 object
  86573. */
  86574. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86575. /**
  86576. * Creates a new Color3 from the starting index element of the given array
  86577. * @param array defines the source array to read from
  86578. * @param offset defines the offset in the source array
  86579. * @param result defines the target Color3 object
  86580. */
  86581. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86582. /**
  86583. * Creates a new Color3 from integer values (< 256)
  86584. * @param r defines the red component to read from (value between 0 and 255)
  86585. * @param g defines the green component to read from (value between 0 and 255)
  86586. * @param b defines the blue component to read from (value between 0 and 255)
  86587. * @returns a new Color3 object
  86588. */
  86589. static FromInts(r: number, g: number, b: number): Color3;
  86590. /**
  86591. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86592. * @param start defines the start Color3 value
  86593. * @param end defines the end Color3 value
  86594. * @param amount defines the gradient value between start and end
  86595. * @returns a new Color3 object
  86596. */
  86597. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86598. /**
  86599. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86600. * @param left defines the start value
  86601. * @param right defines the end value
  86602. * @param amount defines the gradient factor
  86603. * @param result defines the Color3 object where to store the result
  86604. */
  86605. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86606. /**
  86607. * Returns a Color3 value containing a red color
  86608. * @returns a new Color3 object
  86609. */
  86610. static Red(): Color3;
  86611. /**
  86612. * Returns a Color3 value containing a green color
  86613. * @returns a new Color3 object
  86614. */
  86615. static Green(): Color3;
  86616. /**
  86617. * Returns a Color3 value containing a blue color
  86618. * @returns a new Color3 object
  86619. */
  86620. static Blue(): Color3;
  86621. /**
  86622. * Returns a Color3 value containing a black color
  86623. * @returns a new Color3 object
  86624. */
  86625. static Black(): Color3;
  86626. /**
  86627. * Gets a Color3 value containing a black color that must not be updated
  86628. */
  86629. static get BlackReadOnly(): DeepImmutable<Color3>;
  86630. /**
  86631. * Returns a Color3 value containing a white color
  86632. * @returns a new Color3 object
  86633. */
  86634. static White(): Color3;
  86635. /**
  86636. * Returns a Color3 value containing a purple color
  86637. * @returns a new Color3 object
  86638. */
  86639. static Purple(): Color3;
  86640. /**
  86641. * Returns a Color3 value containing a magenta color
  86642. * @returns a new Color3 object
  86643. */
  86644. static Magenta(): Color3;
  86645. /**
  86646. * Returns a Color3 value containing a yellow color
  86647. * @returns a new Color3 object
  86648. */
  86649. static Yellow(): Color3;
  86650. /**
  86651. * Returns a Color3 value containing a gray color
  86652. * @returns a new Color3 object
  86653. */
  86654. static Gray(): Color3;
  86655. /**
  86656. * Returns a Color3 value containing a teal color
  86657. * @returns a new Color3 object
  86658. */
  86659. static Teal(): Color3;
  86660. /**
  86661. * Returns a Color3 value containing a random color
  86662. * @returns a new Color3 object
  86663. */
  86664. static Random(): Color3;
  86665. }
  86666. /**
  86667. * Class used to hold a RBGA color
  86668. */
  86669. export class Color4 {
  86670. /**
  86671. * Defines the red component (between 0 and 1, default is 0)
  86672. */
  86673. r: number;
  86674. /**
  86675. * Defines the green component (between 0 and 1, default is 0)
  86676. */
  86677. g: number;
  86678. /**
  86679. * Defines the blue component (between 0 and 1, default is 0)
  86680. */
  86681. b: number;
  86682. /**
  86683. * Defines the alpha component (between 0 and 1, default is 1)
  86684. */
  86685. a: number;
  86686. /**
  86687. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86688. * @param r defines the red component (between 0 and 1, default is 0)
  86689. * @param g defines the green component (between 0 and 1, default is 0)
  86690. * @param b defines the blue component (between 0 and 1, default is 0)
  86691. * @param a defines the alpha component (between 0 and 1, default is 1)
  86692. */
  86693. constructor(
  86694. /**
  86695. * Defines the red component (between 0 and 1, default is 0)
  86696. */
  86697. r?: number,
  86698. /**
  86699. * Defines the green component (between 0 and 1, default is 0)
  86700. */
  86701. g?: number,
  86702. /**
  86703. * Defines the blue component (between 0 and 1, default is 0)
  86704. */
  86705. b?: number,
  86706. /**
  86707. * Defines the alpha component (between 0 and 1, default is 1)
  86708. */
  86709. a?: number);
  86710. /**
  86711. * Adds in place the given Color4 values to the current Color4 object
  86712. * @param right defines the second operand
  86713. * @returns the current updated Color4 object
  86714. */
  86715. addInPlace(right: DeepImmutable<Color4>): Color4;
  86716. /**
  86717. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86718. * @returns the new array
  86719. */
  86720. asArray(): number[];
  86721. /**
  86722. * Stores from the starting index in the given array the Color4 successive values
  86723. * @param array defines the array where to store the r,g,b components
  86724. * @param index defines an optional index in the target array to define where to start storing values
  86725. * @returns the current Color4 object
  86726. */
  86727. toArray(array: number[], index?: number): Color4;
  86728. /**
  86729. * Update the current color with values stored in an array from the starting index of the given array
  86730. * @param array defines the source array
  86731. * @param offset defines an offset in the source array
  86732. * @returns the current Color4 object
  86733. */
  86734. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86735. /**
  86736. * Determines equality between Color4 objects
  86737. * @param otherColor defines the second operand
  86738. * @returns true if the rgba values are equal to the given ones
  86739. */
  86740. equals(otherColor: DeepImmutable<Color4>): boolean;
  86741. /**
  86742. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86743. * @param right defines the second operand
  86744. * @returns a new Color4 object
  86745. */
  86746. add(right: DeepImmutable<Color4>): Color4;
  86747. /**
  86748. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86749. * @param right defines the second operand
  86750. * @returns a new Color4 object
  86751. */
  86752. subtract(right: DeepImmutable<Color4>): Color4;
  86753. /**
  86754. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86755. * @param right defines the second operand
  86756. * @param result defines the Color4 object where to store the result
  86757. * @returns the current Color4 object
  86758. */
  86759. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86760. /**
  86761. * Creates a new Color4 with the current Color4 values multiplied by scale
  86762. * @param scale defines the scaling factor to apply
  86763. * @returns a new Color4 object
  86764. */
  86765. scale(scale: number): Color4;
  86766. /**
  86767. * Multiplies the current Color4 values by scale and stores the result in "result"
  86768. * @param scale defines the scaling factor to apply
  86769. * @param result defines the Color4 object where to store the result
  86770. * @returns the current unmodified Color4
  86771. */
  86772. scaleToRef(scale: number, result: Color4): Color4;
  86773. /**
  86774. * Scale the current Color4 values by a factor and add the result to a given Color4
  86775. * @param scale defines the scale factor
  86776. * @param result defines the Color4 object where to store the result
  86777. * @returns the unmodified current Color4
  86778. */
  86779. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86780. /**
  86781. * Clamps the rgb values by the min and max values and stores the result into "result"
  86782. * @param min defines minimum clamping value (default is 0)
  86783. * @param max defines maximum clamping value (default is 1)
  86784. * @param result defines color to store the result into.
  86785. * @returns the cuurent Color4
  86786. */
  86787. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86788. /**
  86789. * Multipy an Color4 value by another and return a new Color4 object
  86790. * @param color defines the Color4 value to multiply by
  86791. * @returns a new Color4 object
  86792. */
  86793. multiply(color: Color4): Color4;
  86794. /**
  86795. * Multipy a Color4 value by another and push the result in a reference value
  86796. * @param color defines the Color4 value to multiply by
  86797. * @param result defines the Color4 to fill the result in
  86798. * @returns the result Color4
  86799. */
  86800. multiplyToRef(color: Color4, result: Color4): Color4;
  86801. /**
  86802. * Creates a string with the Color4 current values
  86803. * @returns the string representation of the Color4 object
  86804. */
  86805. toString(): string;
  86806. /**
  86807. * Returns the string "Color4"
  86808. * @returns "Color4"
  86809. */
  86810. getClassName(): string;
  86811. /**
  86812. * Compute the Color4 hash code
  86813. * @returns an unique number that can be used to hash Color4 objects
  86814. */
  86815. getHashCode(): number;
  86816. /**
  86817. * Creates a new Color4 copied from the current one
  86818. * @returns a new Color4 object
  86819. */
  86820. clone(): Color4;
  86821. /**
  86822. * Copies the given Color4 values into the current one
  86823. * @param source defines the source Color4 object
  86824. * @returns the current updated Color4 object
  86825. */
  86826. copyFrom(source: Color4): Color4;
  86827. /**
  86828. * Copies the given float values into the current one
  86829. * @param r defines the red component to read from
  86830. * @param g defines the green component to read from
  86831. * @param b defines the blue component to read from
  86832. * @param a defines the alpha component to read from
  86833. * @returns the current updated Color4 object
  86834. */
  86835. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86836. /**
  86837. * Copies the given float values into the current one
  86838. * @param r defines the red component to read from
  86839. * @param g defines the green component to read from
  86840. * @param b defines the blue component to read from
  86841. * @param a defines the alpha component to read from
  86842. * @returns the current updated Color4 object
  86843. */
  86844. set(r: number, g: number, b: number, a: number): Color4;
  86845. /**
  86846. * Compute the Color4 hexadecimal code as a string
  86847. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86848. * @returns a string containing the hexadecimal representation of the Color4 object
  86849. */
  86850. toHexString(returnAsColor3?: boolean): string;
  86851. /**
  86852. * Computes a new Color4 converted from the current one to linear space
  86853. * @returns a new Color4 object
  86854. */
  86855. toLinearSpace(): Color4;
  86856. /**
  86857. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86858. * @param convertedColor defines the Color4 object where to store the linear space version
  86859. * @returns the unmodified Color4
  86860. */
  86861. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86862. /**
  86863. * Computes a new Color4 converted from the current one to gamma space
  86864. * @returns a new Color4 object
  86865. */
  86866. toGammaSpace(): Color4;
  86867. /**
  86868. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86869. * @param convertedColor defines the Color4 object where to store the gamma space version
  86870. * @returns the unmodified Color4
  86871. */
  86872. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86873. /**
  86874. * Creates a new Color4 from the string containing valid hexadecimal values
  86875. * @param hex defines a string containing valid hexadecimal values
  86876. * @returns a new Color4 object
  86877. */
  86878. static FromHexString(hex: string): Color4;
  86879. /**
  86880. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86881. * @param left defines the start value
  86882. * @param right defines the end value
  86883. * @param amount defines the gradient factor
  86884. * @returns a new Color4 object
  86885. */
  86886. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86887. /**
  86888. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86889. * @param left defines the start value
  86890. * @param right defines the end value
  86891. * @param amount defines the gradient factor
  86892. * @param result defines the Color4 object where to store data
  86893. */
  86894. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86895. /**
  86896. * Creates a new Color4 from a Color3 and an alpha value
  86897. * @param color3 defines the source Color3 to read from
  86898. * @param alpha defines the alpha component (1.0 by default)
  86899. * @returns a new Color4 object
  86900. */
  86901. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86902. /**
  86903. * Creates a new Color4 from the starting index element of the given array
  86904. * @param array defines the source array to read from
  86905. * @param offset defines the offset in the source array
  86906. * @returns a new Color4 object
  86907. */
  86908. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86909. /**
  86910. * Creates a new Color4 from the starting index element of the given array
  86911. * @param array defines the source array to read from
  86912. * @param offset defines the offset in the source array
  86913. * @param result defines the target Color4 object
  86914. */
  86915. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86916. /**
  86917. * Creates a new Color3 from integer values (< 256)
  86918. * @param r defines the red component to read from (value between 0 and 255)
  86919. * @param g defines the green component to read from (value between 0 and 255)
  86920. * @param b defines the blue component to read from (value between 0 and 255)
  86921. * @param a defines the alpha component to read from (value between 0 and 255)
  86922. * @returns a new Color3 object
  86923. */
  86924. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86925. /**
  86926. * Check the content of a given array and convert it to an array containing RGBA data
  86927. * If the original array was already containing count * 4 values then it is returned directly
  86928. * @param colors defines the array to check
  86929. * @param count defines the number of RGBA data to expect
  86930. * @returns an array containing count * 4 values (RGBA)
  86931. */
  86932. static CheckColors4(colors: number[], count: number): number[];
  86933. }
  86934. /**
  86935. * @hidden
  86936. */
  86937. export class TmpColors {
  86938. static Color3: Color3[];
  86939. static Color4: Color4[];
  86940. }
  86941. }
  86942. declare module BABYLON {
  86943. /**
  86944. * Defines an interface which represents an animation key frame
  86945. */
  86946. export interface IAnimationKey {
  86947. /**
  86948. * Frame of the key frame
  86949. */
  86950. frame: number;
  86951. /**
  86952. * Value at the specifies key frame
  86953. */
  86954. value: any;
  86955. /**
  86956. * The input tangent for the cubic hermite spline
  86957. */
  86958. inTangent?: any;
  86959. /**
  86960. * The output tangent for the cubic hermite spline
  86961. */
  86962. outTangent?: any;
  86963. /**
  86964. * The animation interpolation type
  86965. */
  86966. interpolation?: AnimationKeyInterpolation;
  86967. }
  86968. /**
  86969. * Enum for the animation key frame interpolation type
  86970. */
  86971. export enum AnimationKeyInterpolation {
  86972. /**
  86973. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86974. */
  86975. STEP = 1
  86976. }
  86977. }
  86978. declare module BABYLON {
  86979. /**
  86980. * Represents the range of an animation
  86981. */
  86982. export class AnimationRange {
  86983. /**The name of the animation range**/
  86984. name: string;
  86985. /**The starting frame of the animation */
  86986. from: number;
  86987. /**The ending frame of the animation*/
  86988. to: number;
  86989. /**
  86990. * Initializes the range of an animation
  86991. * @param name The name of the animation range
  86992. * @param from The starting frame of the animation
  86993. * @param to The ending frame of the animation
  86994. */
  86995. constructor(
  86996. /**The name of the animation range**/
  86997. name: string,
  86998. /**The starting frame of the animation */
  86999. from: number,
  87000. /**The ending frame of the animation*/
  87001. to: number);
  87002. /**
  87003. * Makes a copy of the animation range
  87004. * @returns A copy of the animation range
  87005. */
  87006. clone(): AnimationRange;
  87007. }
  87008. }
  87009. declare module BABYLON {
  87010. /**
  87011. * Composed of a frame, and an action function
  87012. */
  87013. export class AnimationEvent {
  87014. /** The frame for which the event is triggered **/
  87015. frame: number;
  87016. /** The event to perform when triggered **/
  87017. action: (currentFrame: number) => void;
  87018. /** Specifies if the event should be triggered only once**/
  87019. onlyOnce?: boolean | undefined;
  87020. /**
  87021. * Specifies if the animation event is done
  87022. */
  87023. isDone: boolean;
  87024. /**
  87025. * Initializes the animation event
  87026. * @param frame The frame for which the event is triggered
  87027. * @param action The event to perform when triggered
  87028. * @param onlyOnce Specifies if the event should be triggered only once
  87029. */
  87030. constructor(
  87031. /** The frame for which the event is triggered **/
  87032. frame: number,
  87033. /** The event to perform when triggered **/
  87034. action: (currentFrame: number) => void,
  87035. /** Specifies if the event should be triggered only once**/
  87036. onlyOnce?: boolean | undefined);
  87037. /** @hidden */
  87038. _clone(): AnimationEvent;
  87039. }
  87040. }
  87041. declare module BABYLON {
  87042. /**
  87043. * Interface used to define a behavior
  87044. */
  87045. export interface Behavior<T> {
  87046. /** gets or sets behavior's name */
  87047. name: string;
  87048. /**
  87049. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87050. */
  87051. init(): void;
  87052. /**
  87053. * Called when the behavior is attached to a target
  87054. * @param target defines the target where the behavior is attached to
  87055. */
  87056. attach(target: T): void;
  87057. /**
  87058. * Called when the behavior is detached from its target
  87059. */
  87060. detach(): void;
  87061. }
  87062. /**
  87063. * Interface implemented by classes supporting behaviors
  87064. */
  87065. export interface IBehaviorAware<T> {
  87066. /**
  87067. * Attach a behavior
  87068. * @param behavior defines the behavior to attach
  87069. * @returns the current host
  87070. */
  87071. addBehavior(behavior: Behavior<T>): T;
  87072. /**
  87073. * Remove a behavior from the current object
  87074. * @param behavior defines the behavior to detach
  87075. * @returns the current host
  87076. */
  87077. removeBehavior(behavior: Behavior<T>): T;
  87078. /**
  87079. * Gets a behavior using its name to search
  87080. * @param name defines the name to search
  87081. * @returns the behavior or null if not found
  87082. */
  87083. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87084. }
  87085. }
  87086. declare module BABYLON {
  87087. /**
  87088. * Defines an array and its length.
  87089. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87090. */
  87091. export interface ISmartArrayLike<T> {
  87092. /**
  87093. * The data of the array.
  87094. */
  87095. data: Array<T>;
  87096. /**
  87097. * The active length of the array.
  87098. */
  87099. length: number;
  87100. }
  87101. /**
  87102. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87103. */
  87104. export class SmartArray<T> implements ISmartArrayLike<T> {
  87105. /**
  87106. * The full set of data from the array.
  87107. */
  87108. data: Array<T>;
  87109. /**
  87110. * The active length of the array.
  87111. */
  87112. length: number;
  87113. protected _id: number;
  87114. /**
  87115. * Instantiates a Smart Array.
  87116. * @param capacity defines the default capacity of the array.
  87117. */
  87118. constructor(capacity: number);
  87119. /**
  87120. * Pushes a value at the end of the active data.
  87121. * @param value defines the object to push in the array.
  87122. */
  87123. push(value: T): void;
  87124. /**
  87125. * Iterates over the active data and apply the lambda to them.
  87126. * @param func defines the action to apply on each value.
  87127. */
  87128. forEach(func: (content: T) => void): void;
  87129. /**
  87130. * Sorts the full sets of data.
  87131. * @param compareFn defines the comparison function to apply.
  87132. */
  87133. sort(compareFn: (a: T, b: T) => number): void;
  87134. /**
  87135. * Resets the active data to an empty array.
  87136. */
  87137. reset(): void;
  87138. /**
  87139. * Releases all the data from the array as well as the array.
  87140. */
  87141. dispose(): void;
  87142. /**
  87143. * Concats the active data with a given array.
  87144. * @param array defines the data to concatenate with.
  87145. */
  87146. concat(array: any): void;
  87147. /**
  87148. * Returns the position of a value in the active data.
  87149. * @param value defines the value to find the index for
  87150. * @returns the index if found in the active data otherwise -1
  87151. */
  87152. indexOf(value: T): number;
  87153. /**
  87154. * Returns whether an element is part of the active data.
  87155. * @param value defines the value to look for
  87156. * @returns true if found in the active data otherwise false
  87157. */
  87158. contains(value: T): boolean;
  87159. private static _GlobalId;
  87160. }
  87161. /**
  87162. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87163. * The data in this array can only be present once
  87164. */
  87165. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87166. private _duplicateId;
  87167. /**
  87168. * Pushes a value at the end of the active data.
  87169. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87170. * @param value defines the object to push in the array.
  87171. */
  87172. push(value: T): void;
  87173. /**
  87174. * Pushes a value at the end of the active data.
  87175. * If the data is already present, it won t be added again
  87176. * @param value defines the object to push in the array.
  87177. * @returns true if added false if it was already present
  87178. */
  87179. pushNoDuplicate(value: T): boolean;
  87180. /**
  87181. * Resets the active data to an empty array.
  87182. */
  87183. reset(): void;
  87184. /**
  87185. * Concats the active data with a given array.
  87186. * This ensures no dupplicate will be present in the result.
  87187. * @param array defines the data to concatenate with.
  87188. */
  87189. concatWithNoDuplicate(array: any): void;
  87190. }
  87191. }
  87192. declare module BABYLON {
  87193. /**
  87194. * @ignore
  87195. * This is a list of all the different input types that are available in the application.
  87196. * Fo instance: ArcRotateCameraGamepadInput...
  87197. */
  87198. export var CameraInputTypes: {};
  87199. /**
  87200. * This is the contract to implement in order to create a new input class.
  87201. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87202. */
  87203. export interface ICameraInput<TCamera extends Camera> {
  87204. /**
  87205. * Defines the camera the input is attached to.
  87206. */
  87207. camera: Nullable<TCamera>;
  87208. /**
  87209. * Gets the class name of the current intput.
  87210. * @returns the class name
  87211. */
  87212. getClassName(): string;
  87213. /**
  87214. * Get the friendly name associated with the input class.
  87215. * @returns the input friendly name
  87216. */
  87217. getSimpleName(): string;
  87218. /**
  87219. * Attach the input controls to a specific dom element to get the input from.
  87220. * @param element Defines the element the controls should be listened from
  87221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87222. */
  87223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87224. /**
  87225. * Detach the current controls from the specified dom element.
  87226. * @param element Defines the element to stop listening the inputs from
  87227. */
  87228. detachControl(element: Nullable<HTMLElement>): void;
  87229. /**
  87230. * Update the current camera state depending on the inputs that have been used this frame.
  87231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87232. */
  87233. checkInputs?: () => void;
  87234. }
  87235. /**
  87236. * Represents a map of input types to input instance or input index to input instance.
  87237. */
  87238. export interface CameraInputsMap<TCamera extends Camera> {
  87239. /**
  87240. * Accessor to the input by input type.
  87241. */
  87242. [name: string]: ICameraInput<TCamera>;
  87243. /**
  87244. * Accessor to the input by input index.
  87245. */
  87246. [idx: number]: ICameraInput<TCamera>;
  87247. }
  87248. /**
  87249. * This represents the input manager used within a camera.
  87250. * It helps dealing with all the different kind of input attached to a camera.
  87251. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87252. */
  87253. export class CameraInputsManager<TCamera extends Camera> {
  87254. /**
  87255. * Defines the list of inputs attahed to the camera.
  87256. */
  87257. attached: CameraInputsMap<TCamera>;
  87258. /**
  87259. * Defines the dom element the camera is collecting inputs from.
  87260. * This is null if the controls have not been attached.
  87261. */
  87262. attachedElement: Nullable<HTMLElement>;
  87263. /**
  87264. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87265. */
  87266. noPreventDefault: boolean;
  87267. /**
  87268. * Defined the camera the input manager belongs to.
  87269. */
  87270. camera: TCamera;
  87271. /**
  87272. * Update the current camera state depending on the inputs that have been used this frame.
  87273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87274. */
  87275. checkInputs: () => void;
  87276. /**
  87277. * Instantiate a new Camera Input Manager.
  87278. * @param camera Defines the camera the input manager blongs to
  87279. */
  87280. constructor(camera: TCamera);
  87281. /**
  87282. * Add an input method to a camera
  87283. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87284. * @param input camera input method
  87285. */
  87286. add(input: ICameraInput<TCamera>): void;
  87287. /**
  87288. * Remove a specific input method from a camera
  87289. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87290. * @param inputToRemove camera input method
  87291. */
  87292. remove(inputToRemove: ICameraInput<TCamera>): void;
  87293. /**
  87294. * Remove a specific input type from a camera
  87295. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87296. * @param inputType the type of the input to remove
  87297. */
  87298. removeByType(inputType: string): void;
  87299. private _addCheckInputs;
  87300. /**
  87301. * Attach the input controls to the currently attached dom element to listen the events from.
  87302. * @param input Defines the input to attach
  87303. */
  87304. attachInput(input: ICameraInput<TCamera>): void;
  87305. /**
  87306. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87307. * @param element Defines the dom element to collect the events from
  87308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87309. */
  87310. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87311. /**
  87312. * Detach the current manager inputs controls from a specific dom element.
  87313. * @param element Defines the dom element to collect the events from
  87314. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87315. */
  87316. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87317. /**
  87318. * Rebuild the dynamic inputCheck function from the current list of
  87319. * defined inputs in the manager.
  87320. */
  87321. rebuildInputCheck(): void;
  87322. /**
  87323. * Remove all attached input methods from a camera
  87324. */
  87325. clear(): void;
  87326. /**
  87327. * Serialize the current input manager attached to a camera.
  87328. * This ensures than once parsed,
  87329. * the input associated to the camera will be identical to the current ones
  87330. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87331. */
  87332. serialize(serializedCamera: any): void;
  87333. /**
  87334. * Parses an input manager serialized JSON to restore the previous list of inputs
  87335. * and states associated to a camera.
  87336. * @param parsedCamera Defines the JSON to parse
  87337. */
  87338. parse(parsedCamera: any): void;
  87339. }
  87340. }
  87341. declare module BABYLON {
  87342. /**
  87343. * Class used to store data that will be store in GPU memory
  87344. */
  87345. export class Buffer {
  87346. private _engine;
  87347. private _buffer;
  87348. /** @hidden */
  87349. _data: Nullable<DataArray>;
  87350. private _updatable;
  87351. private _instanced;
  87352. private _divisor;
  87353. /**
  87354. * Gets the byte stride.
  87355. */
  87356. readonly byteStride: number;
  87357. /**
  87358. * Constructor
  87359. * @param engine the engine
  87360. * @param data the data to use for this buffer
  87361. * @param updatable whether the data is updatable
  87362. * @param stride the stride (optional)
  87363. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87364. * @param instanced whether the buffer is instanced (optional)
  87365. * @param useBytes set to true if the stride in in bytes (optional)
  87366. * @param divisor sets an optional divisor for instances (1 by default)
  87367. */
  87368. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87369. /**
  87370. * Create a new VertexBuffer based on the current buffer
  87371. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87372. * @param offset defines offset in the buffer (0 by default)
  87373. * @param size defines the size in floats of attributes (position is 3 for instance)
  87374. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87375. * @param instanced defines if the vertex buffer contains indexed data
  87376. * @param useBytes defines if the offset and stride are in bytes *
  87377. * @param divisor sets an optional divisor for instances (1 by default)
  87378. * @returns the new vertex buffer
  87379. */
  87380. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87381. /**
  87382. * Gets a boolean indicating if the Buffer is updatable?
  87383. * @returns true if the buffer is updatable
  87384. */
  87385. isUpdatable(): boolean;
  87386. /**
  87387. * Gets current buffer's data
  87388. * @returns a DataArray or null
  87389. */
  87390. getData(): Nullable<DataArray>;
  87391. /**
  87392. * Gets underlying native buffer
  87393. * @returns underlying native buffer
  87394. */
  87395. getBuffer(): Nullable<DataBuffer>;
  87396. /**
  87397. * Gets the stride in float32 units (i.e. byte stride / 4).
  87398. * May not be an integer if the byte stride is not divisible by 4.
  87399. * @returns the stride in float32 units
  87400. * @deprecated Please use byteStride instead.
  87401. */
  87402. getStrideSize(): number;
  87403. /**
  87404. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87405. * @param data defines the data to store
  87406. */
  87407. create(data?: Nullable<DataArray>): void;
  87408. /** @hidden */
  87409. _rebuild(): void;
  87410. /**
  87411. * Update current buffer data
  87412. * @param data defines the data to store
  87413. */
  87414. update(data: DataArray): void;
  87415. /**
  87416. * Updates the data directly.
  87417. * @param data the new data
  87418. * @param offset the new offset
  87419. * @param vertexCount the vertex count (optional)
  87420. * @param useBytes set to true if the offset is in bytes
  87421. */
  87422. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87423. /**
  87424. * Release all resources
  87425. */
  87426. dispose(): void;
  87427. }
  87428. /**
  87429. * Specialized buffer used to store vertex data
  87430. */
  87431. export class VertexBuffer {
  87432. /** @hidden */
  87433. _buffer: Buffer;
  87434. private _kind;
  87435. private _size;
  87436. private _ownsBuffer;
  87437. private _instanced;
  87438. private _instanceDivisor;
  87439. /**
  87440. * The byte type.
  87441. */
  87442. static readonly BYTE: number;
  87443. /**
  87444. * The unsigned byte type.
  87445. */
  87446. static readonly UNSIGNED_BYTE: number;
  87447. /**
  87448. * The short type.
  87449. */
  87450. static readonly SHORT: number;
  87451. /**
  87452. * The unsigned short type.
  87453. */
  87454. static readonly UNSIGNED_SHORT: number;
  87455. /**
  87456. * The integer type.
  87457. */
  87458. static readonly INT: number;
  87459. /**
  87460. * The unsigned integer type.
  87461. */
  87462. static readonly UNSIGNED_INT: number;
  87463. /**
  87464. * The float type.
  87465. */
  87466. static readonly FLOAT: number;
  87467. /**
  87468. * Gets or sets the instance divisor when in instanced mode
  87469. */
  87470. get instanceDivisor(): number;
  87471. set instanceDivisor(value: number);
  87472. /**
  87473. * Gets the byte stride.
  87474. */
  87475. readonly byteStride: number;
  87476. /**
  87477. * Gets the byte offset.
  87478. */
  87479. readonly byteOffset: number;
  87480. /**
  87481. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87482. */
  87483. readonly normalized: boolean;
  87484. /**
  87485. * Gets the data type of each component in the array.
  87486. */
  87487. readonly type: number;
  87488. /**
  87489. * Constructor
  87490. * @param engine the engine
  87491. * @param data the data to use for this vertex buffer
  87492. * @param kind the vertex buffer kind
  87493. * @param updatable whether the data is updatable
  87494. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87495. * @param stride the stride (optional)
  87496. * @param instanced whether the buffer is instanced (optional)
  87497. * @param offset the offset of the data (optional)
  87498. * @param size the number of components (optional)
  87499. * @param type the type of the component (optional)
  87500. * @param normalized whether the data contains normalized data (optional)
  87501. * @param useBytes set to true if stride and offset are in bytes (optional)
  87502. * @param divisor defines the instance divisor to use (1 by default)
  87503. */
  87504. 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);
  87505. /** @hidden */
  87506. _rebuild(): void;
  87507. /**
  87508. * Returns the kind of the VertexBuffer (string)
  87509. * @returns a string
  87510. */
  87511. getKind(): string;
  87512. /**
  87513. * Gets a boolean indicating if the VertexBuffer is updatable?
  87514. * @returns true if the buffer is updatable
  87515. */
  87516. isUpdatable(): boolean;
  87517. /**
  87518. * Gets current buffer's data
  87519. * @returns a DataArray or null
  87520. */
  87521. getData(): Nullable<DataArray>;
  87522. /**
  87523. * Gets underlying native buffer
  87524. * @returns underlying native buffer
  87525. */
  87526. getBuffer(): Nullable<DataBuffer>;
  87527. /**
  87528. * Gets the stride in float32 units (i.e. byte stride / 4).
  87529. * May not be an integer if the byte stride is not divisible by 4.
  87530. * @returns the stride in float32 units
  87531. * @deprecated Please use byteStride instead.
  87532. */
  87533. getStrideSize(): number;
  87534. /**
  87535. * Returns the offset as a multiple of the type byte length.
  87536. * @returns the offset in bytes
  87537. * @deprecated Please use byteOffset instead.
  87538. */
  87539. getOffset(): number;
  87540. /**
  87541. * Returns the number of components per vertex attribute (integer)
  87542. * @returns the size in float
  87543. */
  87544. getSize(): number;
  87545. /**
  87546. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87547. * @returns true if this buffer is instanced
  87548. */
  87549. getIsInstanced(): boolean;
  87550. /**
  87551. * Returns the instancing divisor, zero for non-instanced (integer).
  87552. * @returns a number
  87553. */
  87554. getInstanceDivisor(): number;
  87555. /**
  87556. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87557. * @param data defines the data to store
  87558. */
  87559. create(data?: DataArray): void;
  87560. /**
  87561. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87562. * This function will create a new buffer if the current one is not updatable
  87563. * @param data defines the data to store
  87564. */
  87565. update(data: DataArray): void;
  87566. /**
  87567. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87568. * Returns the directly updated WebGLBuffer.
  87569. * @param data the new data
  87570. * @param offset the new offset
  87571. * @param useBytes set to true if the offset is in bytes
  87572. */
  87573. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87574. /**
  87575. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87576. */
  87577. dispose(): void;
  87578. /**
  87579. * Enumerates each value of this vertex buffer as numbers.
  87580. * @param count the number of values to enumerate
  87581. * @param callback the callback function called for each value
  87582. */
  87583. forEach(count: number, callback: (value: number, index: number) => void): void;
  87584. /**
  87585. * Positions
  87586. */
  87587. static readonly PositionKind: string;
  87588. /**
  87589. * Normals
  87590. */
  87591. static readonly NormalKind: string;
  87592. /**
  87593. * Tangents
  87594. */
  87595. static readonly TangentKind: string;
  87596. /**
  87597. * Texture coordinates
  87598. */
  87599. static readonly UVKind: string;
  87600. /**
  87601. * Texture coordinates 2
  87602. */
  87603. static readonly UV2Kind: string;
  87604. /**
  87605. * Texture coordinates 3
  87606. */
  87607. static readonly UV3Kind: string;
  87608. /**
  87609. * Texture coordinates 4
  87610. */
  87611. static readonly UV4Kind: string;
  87612. /**
  87613. * Texture coordinates 5
  87614. */
  87615. static readonly UV5Kind: string;
  87616. /**
  87617. * Texture coordinates 6
  87618. */
  87619. static readonly UV6Kind: string;
  87620. /**
  87621. * Colors
  87622. */
  87623. static readonly ColorKind: string;
  87624. /**
  87625. * Matrix indices (for bones)
  87626. */
  87627. static readonly MatricesIndicesKind: string;
  87628. /**
  87629. * Matrix weights (for bones)
  87630. */
  87631. static readonly MatricesWeightsKind: string;
  87632. /**
  87633. * Additional matrix indices (for bones)
  87634. */
  87635. static readonly MatricesIndicesExtraKind: string;
  87636. /**
  87637. * Additional matrix weights (for bones)
  87638. */
  87639. static readonly MatricesWeightsExtraKind: string;
  87640. /**
  87641. * Deduces the stride given a kind.
  87642. * @param kind The kind string to deduce
  87643. * @returns The deduced stride
  87644. */
  87645. static DeduceStride(kind: string): number;
  87646. /**
  87647. * Gets the byte length of the given type.
  87648. * @param type the type
  87649. * @returns the number of bytes
  87650. */
  87651. static GetTypeByteLength(type: number): number;
  87652. /**
  87653. * Enumerates each value of the given parameters as numbers.
  87654. * @param data the data to enumerate
  87655. * @param byteOffset the byte offset of the data
  87656. * @param byteStride the byte stride of the data
  87657. * @param componentCount the number of components per element
  87658. * @param componentType the type of the component
  87659. * @param count the number of values to enumerate
  87660. * @param normalized whether the data is normalized
  87661. * @param callback the callback function called for each value
  87662. */
  87663. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87664. private static _GetFloatValue;
  87665. }
  87666. }
  87667. declare module BABYLON {
  87668. /**
  87669. * The options Interface for creating a Capsule Mesh
  87670. */
  87671. export interface ICreateCapsuleOptions {
  87672. /** The Orientation of the capsule. Default : Vector3.Up() */
  87673. orientation?: Vector3;
  87674. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87675. subdivisions: number;
  87676. /** Number of cylindrical segments on the capsule. */
  87677. tessellation: number;
  87678. /** Height or Length of the capsule. */
  87679. height: number;
  87680. /** Radius of the capsule. */
  87681. radius: number;
  87682. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87683. capSubdivisions: number;
  87684. /** Overwrite for the top radius. */
  87685. radiusTop?: number;
  87686. /** Overwrite for the bottom radius. */
  87687. radiusBottom?: number;
  87688. /** Overwrite for the top capSubdivisions. */
  87689. topCapSubdivisions?: number;
  87690. /** Overwrite for the bottom capSubdivisions. */
  87691. bottomCapSubdivisions?: number;
  87692. }
  87693. /**
  87694. * Class containing static functions to help procedurally build meshes
  87695. */
  87696. export class CapsuleBuilder {
  87697. /**
  87698. * Creates a capsule or a pill mesh
  87699. * @param name defines the name of the mesh
  87700. * @param options The constructors options.
  87701. * @param scene The scene the mesh is scoped to.
  87702. * @returns Capsule Mesh
  87703. */
  87704. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87705. }
  87706. }
  87707. declare module BABYLON {
  87708. /**
  87709. * @hidden
  87710. */
  87711. export class IntersectionInfo {
  87712. bu: Nullable<number>;
  87713. bv: Nullable<number>;
  87714. distance: number;
  87715. faceId: number;
  87716. subMeshId: number;
  87717. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87718. }
  87719. }
  87720. declare module BABYLON {
  87721. /**
  87722. * Class used to store bounding sphere information
  87723. */
  87724. export class BoundingSphere {
  87725. /**
  87726. * Gets the center of the bounding sphere in local space
  87727. */
  87728. readonly center: Vector3;
  87729. /**
  87730. * Radius of the bounding sphere in local space
  87731. */
  87732. radius: number;
  87733. /**
  87734. * Gets the center of the bounding sphere in world space
  87735. */
  87736. readonly centerWorld: Vector3;
  87737. /**
  87738. * Radius of the bounding sphere in world space
  87739. */
  87740. radiusWorld: number;
  87741. /**
  87742. * Gets the minimum vector in local space
  87743. */
  87744. readonly minimum: Vector3;
  87745. /**
  87746. * Gets the maximum vector in local space
  87747. */
  87748. readonly maximum: Vector3;
  87749. private _worldMatrix;
  87750. private static readonly TmpVector3;
  87751. /**
  87752. * Creates a new bounding sphere
  87753. * @param min defines the minimum vector (in local space)
  87754. * @param max defines the maximum vector (in local space)
  87755. * @param worldMatrix defines the new world matrix
  87756. */
  87757. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87758. /**
  87759. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87760. * @param min defines the new minimum vector (in local space)
  87761. * @param max defines the new maximum vector (in local space)
  87762. * @param worldMatrix defines the new world matrix
  87763. */
  87764. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87765. /**
  87766. * Scale the current bounding sphere by applying a scale factor
  87767. * @param factor defines the scale factor to apply
  87768. * @returns the current bounding box
  87769. */
  87770. scale(factor: number): BoundingSphere;
  87771. /**
  87772. * Gets the world matrix of the bounding box
  87773. * @returns a matrix
  87774. */
  87775. getWorldMatrix(): DeepImmutable<Matrix>;
  87776. /** @hidden */
  87777. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87778. /**
  87779. * Tests if the bounding sphere is intersecting the frustum planes
  87780. * @param frustumPlanes defines the frustum planes to test
  87781. * @returns true if there is an intersection
  87782. */
  87783. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87784. /**
  87785. * Tests if the bounding sphere center is in between the frustum planes.
  87786. * Used for optimistic fast inclusion.
  87787. * @param frustumPlanes defines the frustum planes to test
  87788. * @returns true if the sphere center is in between the frustum planes
  87789. */
  87790. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87791. /**
  87792. * Tests if a point is inside the bounding sphere
  87793. * @param point defines the point to test
  87794. * @returns true if the point is inside the bounding sphere
  87795. */
  87796. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87797. /**
  87798. * Checks if two sphere intersct
  87799. * @param sphere0 sphere 0
  87800. * @param sphere1 sphere 1
  87801. * @returns true if the speres intersect
  87802. */
  87803. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87804. }
  87805. }
  87806. declare module BABYLON {
  87807. /**
  87808. * Class used to store bounding box information
  87809. */
  87810. export class BoundingBox implements ICullable {
  87811. /**
  87812. * Gets the 8 vectors representing the bounding box in local space
  87813. */
  87814. readonly vectors: Vector3[];
  87815. /**
  87816. * Gets the center of the bounding box in local space
  87817. */
  87818. readonly center: Vector3;
  87819. /**
  87820. * Gets the center of the bounding box in world space
  87821. */
  87822. readonly centerWorld: Vector3;
  87823. /**
  87824. * Gets the extend size in local space
  87825. */
  87826. readonly extendSize: Vector3;
  87827. /**
  87828. * Gets the extend size in world space
  87829. */
  87830. readonly extendSizeWorld: Vector3;
  87831. /**
  87832. * Gets the OBB (object bounding box) directions
  87833. */
  87834. readonly directions: Vector3[];
  87835. /**
  87836. * Gets the 8 vectors representing the bounding box in world space
  87837. */
  87838. readonly vectorsWorld: Vector3[];
  87839. /**
  87840. * Gets the minimum vector in world space
  87841. */
  87842. readonly minimumWorld: Vector3;
  87843. /**
  87844. * Gets the maximum vector in world space
  87845. */
  87846. readonly maximumWorld: Vector3;
  87847. /**
  87848. * Gets the minimum vector in local space
  87849. */
  87850. readonly minimum: Vector3;
  87851. /**
  87852. * Gets the maximum vector in local space
  87853. */
  87854. readonly maximum: Vector3;
  87855. private _worldMatrix;
  87856. private static readonly TmpVector3;
  87857. /**
  87858. * @hidden
  87859. */
  87860. _tag: number;
  87861. /**
  87862. * Creates a new bounding box
  87863. * @param min defines the minimum vector (in local space)
  87864. * @param max defines the maximum vector (in local space)
  87865. * @param worldMatrix defines the new world matrix
  87866. */
  87867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87868. /**
  87869. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87870. * @param min defines the new minimum vector (in local space)
  87871. * @param max defines the new maximum vector (in local space)
  87872. * @param worldMatrix defines the new world matrix
  87873. */
  87874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87875. /**
  87876. * Scale the current bounding box by applying a scale factor
  87877. * @param factor defines the scale factor to apply
  87878. * @returns the current bounding box
  87879. */
  87880. scale(factor: number): BoundingBox;
  87881. /**
  87882. * Gets the world matrix of the bounding box
  87883. * @returns a matrix
  87884. */
  87885. getWorldMatrix(): DeepImmutable<Matrix>;
  87886. /** @hidden */
  87887. _update(world: DeepImmutable<Matrix>): void;
  87888. /**
  87889. * Tests if the bounding box is intersecting the frustum planes
  87890. * @param frustumPlanes defines the frustum planes to test
  87891. * @returns true if there is an intersection
  87892. */
  87893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87894. /**
  87895. * Tests if the bounding box is entirely inside the frustum planes
  87896. * @param frustumPlanes defines the frustum planes to test
  87897. * @returns true if there is an inclusion
  87898. */
  87899. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87900. /**
  87901. * Tests if a point is inside the bounding box
  87902. * @param point defines the point to test
  87903. * @returns true if the point is inside the bounding box
  87904. */
  87905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87906. /**
  87907. * Tests if the bounding box intersects with a bounding sphere
  87908. * @param sphere defines the sphere to test
  87909. * @returns true if there is an intersection
  87910. */
  87911. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87912. /**
  87913. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87914. * @param min defines the min vector to use
  87915. * @param max defines the max vector to use
  87916. * @returns true if there is an intersection
  87917. */
  87918. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87919. /**
  87920. * Tests if two bounding boxes are intersections
  87921. * @param box0 defines the first box to test
  87922. * @param box1 defines the second box to test
  87923. * @returns true if there is an intersection
  87924. */
  87925. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87926. /**
  87927. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87928. * @param minPoint defines the minimum vector of the bounding box
  87929. * @param maxPoint defines the maximum vector of the bounding box
  87930. * @param sphereCenter defines the sphere center
  87931. * @param sphereRadius defines the sphere radius
  87932. * @returns true if there is an intersection
  87933. */
  87934. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87935. /**
  87936. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87938. * @param frustumPlanes defines the frustum planes to test
  87939. * @return true if there is an inclusion
  87940. */
  87941. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87942. /**
  87943. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87944. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87945. * @param frustumPlanes defines the frustum planes to test
  87946. * @return true if there is an intersection
  87947. */
  87948. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87949. }
  87950. }
  87951. declare module BABYLON {
  87952. /** @hidden */
  87953. export class Collider {
  87954. /** Define if a collision was found */
  87955. collisionFound: boolean;
  87956. /**
  87957. * Define last intersection point in local space
  87958. */
  87959. intersectionPoint: Vector3;
  87960. /**
  87961. * Define last collided mesh
  87962. */
  87963. collidedMesh: Nullable<AbstractMesh>;
  87964. private _collisionPoint;
  87965. private _planeIntersectionPoint;
  87966. private _tempVector;
  87967. private _tempVector2;
  87968. private _tempVector3;
  87969. private _tempVector4;
  87970. private _edge;
  87971. private _baseToVertex;
  87972. private _destinationPoint;
  87973. private _slidePlaneNormal;
  87974. private _displacementVector;
  87975. /** @hidden */
  87976. _radius: Vector3;
  87977. /** @hidden */
  87978. _retry: number;
  87979. private _velocity;
  87980. private _basePoint;
  87981. private _epsilon;
  87982. /** @hidden */
  87983. _velocityWorldLength: number;
  87984. /** @hidden */
  87985. _basePointWorld: Vector3;
  87986. private _velocityWorld;
  87987. private _normalizedVelocity;
  87988. /** @hidden */
  87989. _initialVelocity: Vector3;
  87990. /** @hidden */
  87991. _initialPosition: Vector3;
  87992. private _nearestDistance;
  87993. private _collisionMask;
  87994. get collisionMask(): number;
  87995. set collisionMask(mask: number);
  87996. /**
  87997. * Gets the plane normal used to compute the sliding response (in local space)
  87998. */
  87999. get slidePlaneNormal(): Vector3;
  88000. /** @hidden */
  88001. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88002. /** @hidden */
  88003. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88004. /** @hidden */
  88005. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88006. /** @hidden */
  88007. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88008. /** @hidden */
  88009. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88010. /** @hidden */
  88011. _getResponse(pos: Vector3, vel: Vector3): void;
  88012. }
  88013. }
  88014. declare module BABYLON {
  88015. /**
  88016. * Interface for cullable objects
  88017. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88018. */
  88019. export interface ICullable {
  88020. /**
  88021. * Checks if the object or part of the object is in the frustum
  88022. * @param frustumPlanes Camera near/planes
  88023. * @returns true if the object is in frustum otherwise false
  88024. */
  88025. isInFrustum(frustumPlanes: Plane[]): boolean;
  88026. /**
  88027. * Checks if a cullable object (mesh...) is in the camera frustum
  88028. * Unlike isInFrustum this cheks the full bounding box
  88029. * @param frustumPlanes Camera near/planes
  88030. * @returns true if the object is in frustum otherwise false
  88031. */
  88032. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88033. }
  88034. /**
  88035. * Info for a bounding data of a mesh
  88036. */
  88037. export class BoundingInfo implements ICullable {
  88038. /**
  88039. * Bounding box for the mesh
  88040. */
  88041. readonly boundingBox: BoundingBox;
  88042. /**
  88043. * Bounding sphere for the mesh
  88044. */
  88045. readonly boundingSphere: BoundingSphere;
  88046. private _isLocked;
  88047. private static readonly TmpVector3;
  88048. /**
  88049. * Constructs bounding info
  88050. * @param minimum min vector of the bounding box/sphere
  88051. * @param maximum max vector of the bounding box/sphere
  88052. * @param worldMatrix defines the new world matrix
  88053. */
  88054. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88055. /**
  88056. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88057. * @param min defines the new minimum vector (in local space)
  88058. * @param max defines the new maximum vector (in local space)
  88059. * @param worldMatrix defines the new world matrix
  88060. */
  88061. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88062. /**
  88063. * min vector of the bounding box/sphere
  88064. */
  88065. get minimum(): Vector3;
  88066. /**
  88067. * max vector of the bounding box/sphere
  88068. */
  88069. get maximum(): Vector3;
  88070. /**
  88071. * If the info is locked and won't be updated to avoid perf overhead
  88072. */
  88073. get isLocked(): boolean;
  88074. set isLocked(value: boolean);
  88075. /**
  88076. * Updates the bounding sphere and box
  88077. * @param world world matrix to be used to update
  88078. */
  88079. update(world: DeepImmutable<Matrix>): void;
  88080. /**
  88081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88082. * @param center New center of the bounding info
  88083. * @param extend New extend of the bounding info
  88084. * @returns the current bounding info
  88085. */
  88086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88087. /**
  88088. * Scale the current bounding info by applying a scale factor
  88089. * @param factor defines the scale factor to apply
  88090. * @returns the current bounding info
  88091. */
  88092. scale(factor: number): BoundingInfo;
  88093. /**
  88094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88095. * @param frustumPlanes defines the frustum to test
  88096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88097. * @returns true if the bounding info is in the frustum planes
  88098. */
  88099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88100. /**
  88101. * Gets the world distance between the min and max points of the bounding box
  88102. */
  88103. get diagonalLength(): number;
  88104. /**
  88105. * Checks if a cullable object (mesh...) is in the camera frustum
  88106. * Unlike isInFrustum this cheks the full bounding box
  88107. * @param frustumPlanes Camera near/planes
  88108. * @returns true if the object is in frustum otherwise false
  88109. */
  88110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88111. /** @hidden */
  88112. _checkCollision(collider: Collider): boolean;
  88113. /**
  88114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88116. * @param point the point to check intersection with
  88117. * @returns if the point intersects
  88118. */
  88119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88120. /**
  88121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88123. * @param boundingInfo the bounding info to check intersection with
  88124. * @param precise if the intersection should be done using OBB
  88125. * @returns if the bounding info intersects
  88126. */
  88127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88128. }
  88129. }
  88130. declare module BABYLON {
  88131. /**
  88132. * Extracts minimum and maximum values from a list of indexed positions
  88133. * @param positions defines the positions to use
  88134. * @param indices defines the indices to the positions
  88135. * @param indexStart defines the start index
  88136. * @param indexCount defines the end index
  88137. * @param bias defines bias value to add to the result
  88138. * @return minimum and maximum values
  88139. */
  88140. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88141. minimum: Vector3;
  88142. maximum: Vector3;
  88143. };
  88144. /**
  88145. * Extracts minimum and maximum values from a list of positions
  88146. * @param positions defines the positions to use
  88147. * @param start defines the start index in the positions array
  88148. * @param count defines the number of positions to handle
  88149. * @param bias defines bias value to add to the result
  88150. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88151. * @return minimum and maximum values
  88152. */
  88153. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88154. minimum: Vector3;
  88155. maximum: Vector3;
  88156. };
  88157. }
  88158. declare module BABYLON {
  88159. /** @hidden */
  88160. export class WebGLDataBuffer extends DataBuffer {
  88161. private _buffer;
  88162. constructor(resource: WebGLBuffer);
  88163. get underlyingResource(): any;
  88164. }
  88165. }
  88166. declare module BABYLON {
  88167. /** @hidden */
  88168. export class WebGLPipelineContext implements IPipelineContext {
  88169. engine: ThinEngine;
  88170. program: Nullable<WebGLProgram>;
  88171. context?: WebGLRenderingContext;
  88172. vertexShader?: WebGLShader;
  88173. fragmentShader?: WebGLShader;
  88174. isParallelCompiled: boolean;
  88175. onCompiled?: () => void;
  88176. transformFeedback?: WebGLTransformFeedback | null;
  88177. vertexCompilationError: Nullable<string>;
  88178. fragmentCompilationError: Nullable<string>;
  88179. programLinkError: Nullable<string>;
  88180. programValidationError: Nullable<string>;
  88181. get isAsync(): boolean;
  88182. get isReady(): boolean;
  88183. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88184. _getVertexShaderCode(): string | null;
  88185. _getFragmentShaderCode(): string | null;
  88186. }
  88187. }
  88188. declare module BABYLON {
  88189. interface ThinEngine {
  88190. /**
  88191. * Create an uniform buffer
  88192. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88193. * @param elements defines the content of the uniform buffer
  88194. * @returns the webGL uniform buffer
  88195. */
  88196. createUniformBuffer(elements: FloatArray): DataBuffer;
  88197. /**
  88198. * Create a dynamic uniform buffer
  88199. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88200. * @param elements defines the content of the uniform buffer
  88201. * @returns the webGL uniform buffer
  88202. */
  88203. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88204. /**
  88205. * Update an existing uniform buffer
  88206. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88207. * @param uniformBuffer defines the target uniform buffer
  88208. * @param elements defines the content to update
  88209. * @param offset defines the offset in the uniform buffer where update should start
  88210. * @param count defines the size of the data to update
  88211. */
  88212. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88213. /**
  88214. * Bind an uniform buffer to the current webGL context
  88215. * @param buffer defines the buffer to bind
  88216. */
  88217. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88218. /**
  88219. * Bind a buffer to the current webGL context at a given location
  88220. * @param buffer defines the buffer to bind
  88221. * @param location defines the index where to bind the buffer
  88222. */
  88223. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88224. /**
  88225. * Bind a specific block at a given index in a specific shader program
  88226. * @param pipelineContext defines the pipeline context to use
  88227. * @param blockName defines the block name
  88228. * @param index defines the index where to bind the block
  88229. */
  88230. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88231. }
  88232. }
  88233. declare module BABYLON {
  88234. /**
  88235. * Uniform buffer objects.
  88236. *
  88237. * Handles blocks of uniform on the GPU.
  88238. *
  88239. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88240. *
  88241. * For more information, please refer to :
  88242. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88243. */
  88244. export class UniformBuffer {
  88245. private _engine;
  88246. private _buffer;
  88247. private _data;
  88248. private _bufferData;
  88249. private _dynamic?;
  88250. private _uniformLocations;
  88251. private _uniformSizes;
  88252. private _uniformLocationPointer;
  88253. private _needSync;
  88254. private _noUBO;
  88255. private _currentEffect;
  88256. /** @hidden */
  88257. _alreadyBound: boolean;
  88258. private static _MAX_UNIFORM_SIZE;
  88259. private static _tempBuffer;
  88260. /**
  88261. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88262. * This is dynamic to allow compat with webgl 1 and 2.
  88263. * You will need to pass the name of the uniform as well as the value.
  88264. */
  88265. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88266. /**
  88267. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88268. * This is dynamic to allow compat with webgl 1 and 2.
  88269. * You will need to pass the name of the uniform as well as the value.
  88270. */
  88271. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88272. /**
  88273. * Lambda to Update a single float in a uniform buffer.
  88274. * This is dynamic to allow compat with webgl 1 and 2.
  88275. * You will need to pass the name of the uniform as well as the value.
  88276. */
  88277. updateFloat: (name: string, x: number) => void;
  88278. /**
  88279. * Lambda to Update a vec2 of float in a uniform buffer.
  88280. * This is dynamic to allow compat with webgl 1 and 2.
  88281. * You will need to pass the name of the uniform as well as the value.
  88282. */
  88283. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88284. /**
  88285. * Lambda to Update a vec3 of float in a uniform buffer.
  88286. * This is dynamic to allow compat with webgl 1 and 2.
  88287. * You will need to pass the name of the uniform as well as the value.
  88288. */
  88289. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88290. /**
  88291. * Lambda to Update a vec4 of float in a uniform buffer.
  88292. * This is dynamic to allow compat with webgl 1 and 2.
  88293. * You will need to pass the name of the uniform as well as the value.
  88294. */
  88295. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88296. /**
  88297. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88298. * This is dynamic to allow compat with webgl 1 and 2.
  88299. * You will need to pass the name of the uniform as well as the value.
  88300. */
  88301. updateMatrix: (name: string, mat: Matrix) => void;
  88302. /**
  88303. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88304. * This is dynamic to allow compat with webgl 1 and 2.
  88305. * You will need to pass the name of the uniform as well as the value.
  88306. */
  88307. updateVector3: (name: string, vector: Vector3) => void;
  88308. /**
  88309. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88310. * This is dynamic to allow compat with webgl 1 and 2.
  88311. * You will need to pass the name of the uniform as well as the value.
  88312. */
  88313. updateVector4: (name: string, vector: Vector4) => void;
  88314. /**
  88315. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88316. * This is dynamic to allow compat with webgl 1 and 2.
  88317. * You will need to pass the name of the uniform as well as the value.
  88318. */
  88319. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88320. /**
  88321. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88322. * This is dynamic to allow compat with webgl 1 and 2.
  88323. * You will need to pass the name of the uniform as well as the value.
  88324. */
  88325. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88326. /**
  88327. * Instantiates a new Uniform buffer objects.
  88328. *
  88329. * Handles blocks of uniform on the GPU.
  88330. *
  88331. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88332. *
  88333. * For more information, please refer to :
  88334. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88335. * @param engine Define the engine the buffer is associated with
  88336. * @param data Define the data contained in the buffer
  88337. * @param dynamic Define if the buffer is updatable
  88338. */
  88339. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88340. /**
  88341. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88342. * or just falling back on setUniformXXX calls.
  88343. */
  88344. get useUbo(): boolean;
  88345. /**
  88346. * Indicates if the WebGL underlying uniform buffer is in sync
  88347. * with the javascript cache data.
  88348. */
  88349. get isSync(): boolean;
  88350. /**
  88351. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88352. * Also, a dynamic UniformBuffer will disable cache verification and always
  88353. * update the underlying WebGL uniform buffer to the GPU.
  88354. * @returns if Dynamic, otherwise false
  88355. */
  88356. isDynamic(): boolean;
  88357. /**
  88358. * The data cache on JS side.
  88359. * @returns the underlying data as a float array
  88360. */
  88361. getData(): Float32Array;
  88362. /**
  88363. * The underlying WebGL Uniform buffer.
  88364. * @returns the webgl buffer
  88365. */
  88366. getBuffer(): Nullable<DataBuffer>;
  88367. /**
  88368. * std140 layout specifies how to align data within an UBO structure.
  88369. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88370. * for specs.
  88371. */
  88372. private _fillAlignment;
  88373. /**
  88374. * Adds an uniform in the buffer.
  88375. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88376. * for the layout to be correct !
  88377. * @param name Name of the uniform, as used in the uniform block in the shader.
  88378. * @param size Data size, or data directly.
  88379. */
  88380. addUniform(name: string, size: number | number[]): void;
  88381. /**
  88382. * Adds a Matrix 4x4 to the uniform buffer.
  88383. * @param name Name of the uniform, as used in the uniform block in the shader.
  88384. * @param mat A 4x4 matrix.
  88385. */
  88386. addMatrix(name: string, mat: Matrix): void;
  88387. /**
  88388. * Adds a vec2 to the uniform buffer.
  88389. * @param name Name of the uniform, as used in the uniform block in the shader.
  88390. * @param x Define the x component value of the vec2
  88391. * @param y Define the y component value of the vec2
  88392. */
  88393. addFloat2(name: string, x: number, y: number): void;
  88394. /**
  88395. * Adds a vec3 to the uniform buffer.
  88396. * @param name Name of the uniform, as used in the uniform block in the shader.
  88397. * @param x Define the x component value of the vec3
  88398. * @param y Define the y component value of the vec3
  88399. * @param z Define the z component value of the vec3
  88400. */
  88401. addFloat3(name: string, x: number, y: number, z: number): void;
  88402. /**
  88403. * Adds a vec3 to the uniform buffer.
  88404. * @param name Name of the uniform, as used in the uniform block in the shader.
  88405. * @param color Define the vec3 from a Color
  88406. */
  88407. addColor3(name: string, color: Color3): void;
  88408. /**
  88409. * Adds a vec4 to the uniform buffer.
  88410. * @param name Name of the uniform, as used in the uniform block in the shader.
  88411. * @param color Define the rgb components from a Color
  88412. * @param alpha Define the a component of the vec4
  88413. */
  88414. addColor4(name: string, color: Color3, alpha: number): void;
  88415. /**
  88416. * Adds a vec3 to the uniform buffer.
  88417. * @param name Name of the uniform, as used in the uniform block in the shader.
  88418. * @param vector Define the vec3 components from a Vector
  88419. */
  88420. addVector3(name: string, vector: Vector3): void;
  88421. /**
  88422. * Adds a Matrix 3x3 to the uniform buffer.
  88423. * @param name Name of the uniform, as used in the uniform block in the shader.
  88424. */
  88425. addMatrix3x3(name: string): void;
  88426. /**
  88427. * Adds a Matrix 2x2 to the uniform buffer.
  88428. * @param name Name of the uniform, as used in the uniform block in the shader.
  88429. */
  88430. addMatrix2x2(name: string): void;
  88431. /**
  88432. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88433. */
  88434. create(): void;
  88435. /** @hidden */
  88436. _rebuild(): void;
  88437. /**
  88438. * Updates the WebGL Uniform Buffer on the GPU.
  88439. * If the `dynamic` flag is set to true, no cache comparison is done.
  88440. * Otherwise, the buffer will be updated only if the cache differs.
  88441. */
  88442. update(): void;
  88443. /**
  88444. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88445. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88446. * @param data Define the flattened data
  88447. * @param size Define the size of the data.
  88448. */
  88449. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88450. private _valueCache;
  88451. private _cacheMatrix;
  88452. private _updateMatrix3x3ForUniform;
  88453. private _updateMatrix3x3ForEffect;
  88454. private _updateMatrix2x2ForEffect;
  88455. private _updateMatrix2x2ForUniform;
  88456. private _updateFloatForEffect;
  88457. private _updateFloatForUniform;
  88458. private _updateFloat2ForEffect;
  88459. private _updateFloat2ForUniform;
  88460. private _updateFloat3ForEffect;
  88461. private _updateFloat3ForUniform;
  88462. private _updateFloat4ForEffect;
  88463. private _updateFloat4ForUniform;
  88464. private _updateMatrixForEffect;
  88465. private _updateMatrixForUniform;
  88466. private _updateVector3ForEffect;
  88467. private _updateVector3ForUniform;
  88468. private _updateVector4ForEffect;
  88469. private _updateVector4ForUniform;
  88470. private _updateColor3ForEffect;
  88471. private _updateColor3ForUniform;
  88472. private _updateColor4ForEffect;
  88473. private _updateColor4ForUniform;
  88474. /**
  88475. * Sets a sampler uniform on the effect.
  88476. * @param name Define the name of the sampler.
  88477. * @param texture Define the texture to set in the sampler
  88478. */
  88479. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88480. /**
  88481. * Directly updates the value of the uniform in the cache AND on the GPU.
  88482. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88483. * @param data Define the flattened data
  88484. */
  88485. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88486. /**
  88487. * Binds this uniform buffer to an effect.
  88488. * @param effect Define the effect to bind the buffer to
  88489. * @param name Name of the uniform block in the shader.
  88490. */
  88491. bindToEffect(effect: Effect, name: string): void;
  88492. /**
  88493. * Disposes the uniform buffer.
  88494. */
  88495. dispose(): void;
  88496. }
  88497. }
  88498. declare module BABYLON {
  88499. /**
  88500. * Enum that determines the text-wrapping mode to use.
  88501. */
  88502. export enum InspectableType {
  88503. /**
  88504. * Checkbox for booleans
  88505. */
  88506. Checkbox = 0,
  88507. /**
  88508. * Sliders for numbers
  88509. */
  88510. Slider = 1,
  88511. /**
  88512. * Vector3
  88513. */
  88514. Vector3 = 2,
  88515. /**
  88516. * Quaternions
  88517. */
  88518. Quaternion = 3,
  88519. /**
  88520. * Color3
  88521. */
  88522. Color3 = 4,
  88523. /**
  88524. * String
  88525. */
  88526. String = 5
  88527. }
  88528. /**
  88529. * Interface used to define custom inspectable properties.
  88530. * This interface is used by the inspector to display custom property grids
  88531. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88532. */
  88533. export interface IInspectable {
  88534. /**
  88535. * Gets the label to display
  88536. */
  88537. label: string;
  88538. /**
  88539. * Gets the name of the property to edit
  88540. */
  88541. propertyName: string;
  88542. /**
  88543. * Gets the type of the editor to use
  88544. */
  88545. type: InspectableType;
  88546. /**
  88547. * Gets the minimum value of the property when using in "slider" mode
  88548. */
  88549. min?: number;
  88550. /**
  88551. * Gets the maximum value of the property when using in "slider" mode
  88552. */
  88553. max?: number;
  88554. /**
  88555. * Gets the setp to use when using in "slider" mode
  88556. */
  88557. step?: number;
  88558. }
  88559. }
  88560. declare module BABYLON {
  88561. /**
  88562. * Class used to provide helper for timing
  88563. */
  88564. export class TimingTools {
  88565. /**
  88566. * Polyfill for setImmediate
  88567. * @param action defines the action to execute after the current execution block
  88568. */
  88569. static SetImmediate(action: () => void): void;
  88570. }
  88571. }
  88572. declare module BABYLON {
  88573. /**
  88574. * Class used to enable instatition of objects by class name
  88575. */
  88576. export class InstantiationTools {
  88577. /**
  88578. * Use this object to register external classes like custom textures or material
  88579. * to allow the laoders to instantiate them
  88580. */
  88581. static RegisteredExternalClasses: {
  88582. [key: string]: Object;
  88583. };
  88584. /**
  88585. * Tries to instantiate a new object from a given class name
  88586. * @param className defines the class name to instantiate
  88587. * @returns the new object or null if the system was not able to do the instantiation
  88588. */
  88589. static Instantiate(className: string): any;
  88590. }
  88591. }
  88592. declare module BABYLON {
  88593. /**
  88594. * Define options used to create a depth texture
  88595. */
  88596. export class DepthTextureCreationOptions {
  88597. /** Specifies whether or not a stencil should be allocated in the texture */
  88598. generateStencil?: boolean;
  88599. /** Specifies whether or not bilinear filtering is enable on the texture */
  88600. bilinearFiltering?: boolean;
  88601. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88602. comparisonFunction?: number;
  88603. /** Specifies if the created texture is a cube texture */
  88604. isCube?: boolean;
  88605. }
  88606. }
  88607. declare module BABYLON {
  88608. interface ThinEngine {
  88609. /**
  88610. * Creates a depth stencil cube texture.
  88611. * This is only available in WebGL 2.
  88612. * @param size The size of face edge in the cube texture.
  88613. * @param options The options defining the cube texture.
  88614. * @returns The cube texture
  88615. */
  88616. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88617. /**
  88618. * Creates a cube texture
  88619. * @param rootUrl defines the url where the files to load is located
  88620. * @param scene defines the current scene
  88621. * @param files defines the list of files to load (1 per face)
  88622. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88623. * @param onLoad defines an optional callback raised when the texture is loaded
  88624. * @param onError defines an optional callback raised if there is an issue to load the texture
  88625. * @param format defines the format of the data
  88626. * @param forcedExtension defines the extension to use to pick the right loader
  88627. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88628. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88629. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88630. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88631. * @param loaderOptions options to be passed to the loader
  88632. * @returns the cube texture as an InternalTexture
  88633. */
  88634. 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>, loaderOptions: any): InternalTexture;
  88635. /**
  88636. * Creates a cube texture
  88637. * @param rootUrl defines the url where the files to load is located
  88638. * @param scene defines the current scene
  88639. * @param files defines the list of files to load (1 per face)
  88640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88641. * @param onLoad defines an optional callback raised when the texture is loaded
  88642. * @param onError defines an optional callback raised if there is an issue to load the texture
  88643. * @param format defines the format of the data
  88644. * @param forcedExtension defines the extension to use to pick the right loader
  88645. * @returns the cube texture as an InternalTexture
  88646. */
  88647. 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;
  88648. /**
  88649. * Creates a cube texture
  88650. * @param rootUrl defines the url where the files to load is located
  88651. * @param scene defines the current scene
  88652. * @param files defines the list of files to load (1 per face)
  88653. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88654. * @param onLoad defines an optional callback raised when the texture is loaded
  88655. * @param onError defines an optional callback raised if there is an issue to load the texture
  88656. * @param format defines the format of the data
  88657. * @param forcedExtension defines the extension to use to pick the right loader
  88658. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88659. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88660. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88661. * @returns the cube texture as an InternalTexture
  88662. */
  88663. 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;
  88664. /** @hidden */
  88665. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88666. /** @hidden */
  88667. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88668. /** @hidden */
  88669. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88670. /** @hidden */
  88671. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88672. /**
  88673. * @hidden
  88674. */
  88675. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  88676. }
  88677. }
  88678. declare module BABYLON {
  88679. /**
  88680. * Class for creating a cube texture
  88681. */
  88682. export class CubeTexture extends BaseTexture {
  88683. private _delayedOnLoad;
  88684. /**
  88685. * Observable triggered once the texture has been loaded.
  88686. */
  88687. onLoadObservable: Observable<CubeTexture>;
  88688. /**
  88689. * The url of the texture
  88690. */
  88691. url: string;
  88692. /**
  88693. * Gets or sets the center of the bounding box associated with the cube texture.
  88694. * It must define where the camera used to render the texture was set
  88695. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88696. */
  88697. boundingBoxPosition: Vector3;
  88698. private _boundingBoxSize;
  88699. /**
  88700. * Gets or sets the size of the bounding box associated with the cube texture
  88701. * When defined, the cubemap will switch to local mode
  88702. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88703. * @example https://www.babylonjs-playground.com/#RNASML
  88704. */
  88705. set boundingBoxSize(value: Vector3);
  88706. /**
  88707. * Returns the bounding box size
  88708. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88709. */
  88710. get boundingBoxSize(): Vector3;
  88711. protected _rotationY: number;
  88712. /**
  88713. * Sets texture matrix rotation angle around Y axis in radians.
  88714. */
  88715. set rotationY(value: number);
  88716. /**
  88717. * Gets texture matrix rotation angle around Y axis radians.
  88718. */
  88719. get rotationY(): number;
  88720. /**
  88721. * Are mip maps generated for this texture or not.
  88722. */
  88723. get noMipmap(): boolean;
  88724. private _noMipmap;
  88725. private _files;
  88726. protected _forcedExtension: Nullable<string>;
  88727. private _extensions;
  88728. private _textureMatrix;
  88729. private _format;
  88730. private _createPolynomials;
  88731. private _loaderOptions;
  88732. /**
  88733. * Creates a cube texture from an array of image urls
  88734. * @param files defines an array of image urls
  88735. * @param scene defines the hosting scene
  88736. * @param noMipmap specifies if mip maps are not used
  88737. * @returns a cube texture
  88738. */
  88739. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88740. /**
  88741. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88742. * @param url defines the url of the prefiltered texture
  88743. * @param scene defines the scene the texture is attached to
  88744. * @param forcedExtension defines the extension of the file if different from the url
  88745. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88746. * @return the prefiltered texture
  88747. */
  88748. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88749. /**
  88750. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88751. * as prefiltered data.
  88752. * @param rootUrl defines the url of the texture or the root name of the six images
  88753. * @param null defines the scene or engine the texture is attached to
  88754. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88755. * @param noMipmap defines if mipmaps should be created or not
  88756. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88757. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88758. * @param onError defines a callback triggered in case of error during load
  88759. * @param format defines the internal format to use for the texture once loaded
  88760. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88761. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88762. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88765. * @param loaderOptions options to be passed to the loader
  88766. * @return the cube texture
  88767. */
  88768. 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, loaderOptions?: any);
  88769. /**
  88770. * Get the current class name of the texture useful for serialization or dynamic coding.
  88771. * @returns "CubeTexture"
  88772. */
  88773. getClassName(): string;
  88774. /**
  88775. * Update the url (and optional buffer) of this texture if url was null during construction.
  88776. * @param url the url of the texture
  88777. * @param forcedExtension defines the extension to use
  88778. * @param onLoad callback called when the texture is loaded (defaults to null)
  88779. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88780. */
  88781. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88782. /**
  88783. * Delays loading of the cube texture
  88784. * @param forcedExtension defines the extension to use
  88785. */
  88786. delayLoad(forcedExtension?: string): void;
  88787. /**
  88788. * Returns the reflection texture matrix
  88789. * @returns the reflection texture matrix
  88790. */
  88791. getReflectionTextureMatrix(): Matrix;
  88792. /**
  88793. * Sets the reflection texture matrix
  88794. * @param value Reflection texture matrix
  88795. */
  88796. setReflectionTextureMatrix(value: Matrix): void;
  88797. /**
  88798. * Parses text to create a cube texture
  88799. * @param parsedTexture define the serialized text to read from
  88800. * @param scene defines the hosting scene
  88801. * @param rootUrl defines the root url of the cube texture
  88802. * @returns a cube texture
  88803. */
  88804. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88805. /**
  88806. * Makes a clone, or deep copy, of the cube texture
  88807. * @returns a new cube texture
  88808. */
  88809. clone(): CubeTexture;
  88810. }
  88811. }
  88812. declare module BABYLON {
  88813. /**
  88814. * Manages the defines for the Material
  88815. */
  88816. export class MaterialDefines {
  88817. /** @hidden */
  88818. protected _keys: string[];
  88819. private _isDirty;
  88820. /** @hidden */
  88821. _renderId: number;
  88822. /** @hidden */
  88823. _areLightsDirty: boolean;
  88824. /** @hidden */
  88825. _areLightsDisposed: boolean;
  88826. /** @hidden */
  88827. _areAttributesDirty: boolean;
  88828. /** @hidden */
  88829. _areTexturesDirty: boolean;
  88830. /** @hidden */
  88831. _areFresnelDirty: boolean;
  88832. /** @hidden */
  88833. _areMiscDirty: boolean;
  88834. /** @hidden */
  88835. _arePrePassDirty: boolean;
  88836. /** @hidden */
  88837. _areImageProcessingDirty: boolean;
  88838. /** @hidden */
  88839. _normals: boolean;
  88840. /** @hidden */
  88841. _uvs: boolean;
  88842. /** @hidden */
  88843. _needNormals: boolean;
  88844. /** @hidden */
  88845. _needUVs: boolean;
  88846. [id: string]: any;
  88847. /**
  88848. * Specifies if the material needs to be re-calculated
  88849. */
  88850. get isDirty(): boolean;
  88851. /**
  88852. * Marks the material to indicate that it has been re-calculated
  88853. */
  88854. markAsProcessed(): void;
  88855. /**
  88856. * Marks the material to indicate that it needs to be re-calculated
  88857. */
  88858. markAsUnprocessed(): void;
  88859. /**
  88860. * Marks the material to indicate all of its defines need to be re-calculated
  88861. */
  88862. markAllAsDirty(): void;
  88863. /**
  88864. * Marks the material to indicate that image processing needs to be re-calculated
  88865. */
  88866. markAsImageProcessingDirty(): void;
  88867. /**
  88868. * Marks the material to indicate the lights need to be re-calculated
  88869. * @param disposed Defines whether the light is dirty due to dispose or not
  88870. */
  88871. markAsLightDirty(disposed?: boolean): void;
  88872. /**
  88873. * Marks the attribute state as changed
  88874. */
  88875. markAsAttributesDirty(): void;
  88876. /**
  88877. * Marks the texture state as changed
  88878. */
  88879. markAsTexturesDirty(): void;
  88880. /**
  88881. * Marks the fresnel state as changed
  88882. */
  88883. markAsFresnelDirty(): void;
  88884. /**
  88885. * Marks the misc state as changed
  88886. */
  88887. markAsMiscDirty(): void;
  88888. /**
  88889. * Marks the prepass state as changed
  88890. */
  88891. markAsPrePassDirty(): void;
  88892. /**
  88893. * Rebuilds the material defines
  88894. */
  88895. rebuild(): void;
  88896. /**
  88897. * Specifies if two material defines are equal
  88898. * @param other - A material define instance to compare to
  88899. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88900. */
  88901. isEqual(other: MaterialDefines): boolean;
  88902. /**
  88903. * Clones this instance's defines to another instance
  88904. * @param other - material defines to clone values to
  88905. */
  88906. cloneTo(other: MaterialDefines): void;
  88907. /**
  88908. * Resets the material define values
  88909. */
  88910. reset(): void;
  88911. /**
  88912. * Converts the material define values to a string
  88913. * @returns - String of material define information
  88914. */
  88915. toString(): string;
  88916. }
  88917. }
  88918. declare module BABYLON {
  88919. /**
  88920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88922. * 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;
  88923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88924. */
  88925. export class ColorCurves {
  88926. private _dirty;
  88927. private _tempColor;
  88928. private _globalCurve;
  88929. private _highlightsCurve;
  88930. private _midtonesCurve;
  88931. private _shadowsCurve;
  88932. private _positiveCurve;
  88933. private _negativeCurve;
  88934. private _globalHue;
  88935. private _globalDensity;
  88936. private _globalSaturation;
  88937. private _globalExposure;
  88938. /**
  88939. * Gets the global Hue value.
  88940. * 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).
  88941. */
  88942. get globalHue(): number;
  88943. /**
  88944. * Sets the global Hue value.
  88945. * 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).
  88946. */
  88947. set globalHue(value: number);
  88948. /**
  88949. * Gets the global Density value.
  88950. * 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.
  88951. * Values less than zero provide a filter of opposite hue.
  88952. */
  88953. get globalDensity(): number;
  88954. /**
  88955. * Sets the global Density value.
  88956. * 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.
  88957. * Values less than zero provide a filter of opposite hue.
  88958. */
  88959. set globalDensity(value: number);
  88960. /**
  88961. * Gets the global Saturation value.
  88962. * 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.
  88963. */
  88964. get globalSaturation(): number;
  88965. /**
  88966. * Sets the global Saturation value.
  88967. * 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.
  88968. */
  88969. set globalSaturation(value: number);
  88970. /**
  88971. * Gets the global Exposure value.
  88972. * 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.
  88973. */
  88974. get globalExposure(): number;
  88975. /**
  88976. * Sets the global Exposure value.
  88977. * 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.
  88978. */
  88979. set globalExposure(value: number);
  88980. private _highlightsHue;
  88981. private _highlightsDensity;
  88982. private _highlightsSaturation;
  88983. private _highlightsExposure;
  88984. /**
  88985. * Gets the highlights Hue value.
  88986. * 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).
  88987. */
  88988. get highlightsHue(): number;
  88989. /**
  88990. * Sets the highlights Hue value.
  88991. * 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).
  88992. */
  88993. set highlightsHue(value: number);
  88994. /**
  88995. * Gets the highlights Density value.
  88996. * 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.
  88997. * Values less than zero provide a filter of opposite hue.
  88998. */
  88999. get highlightsDensity(): number;
  89000. /**
  89001. * Sets the highlights Density value.
  89002. * 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.
  89003. * Values less than zero provide a filter of opposite hue.
  89004. */
  89005. set highlightsDensity(value: number);
  89006. /**
  89007. * Gets the highlights Saturation value.
  89008. * 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.
  89009. */
  89010. get highlightsSaturation(): number;
  89011. /**
  89012. * Sets the highlights Saturation value.
  89013. * 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.
  89014. */
  89015. set highlightsSaturation(value: number);
  89016. /**
  89017. * Gets the highlights Exposure value.
  89018. * 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.
  89019. */
  89020. get highlightsExposure(): number;
  89021. /**
  89022. * Sets the highlights Exposure value.
  89023. * 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.
  89024. */
  89025. set highlightsExposure(value: number);
  89026. private _midtonesHue;
  89027. private _midtonesDensity;
  89028. private _midtonesSaturation;
  89029. private _midtonesExposure;
  89030. /**
  89031. * Gets the midtones Hue value.
  89032. * 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).
  89033. */
  89034. get midtonesHue(): number;
  89035. /**
  89036. * Sets the midtones Hue value.
  89037. * 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).
  89038. */
  89039. set midtonesHue(value: number);
  89040. /**
  89041. * Gets the midtones Density value.
  89042. * 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.
  89043. * Values less than zero provide a filter of opposite hue.
  89044. */
  89045. get midtonesDensity(): number;
  89046. /**
  89047. * Sets the midtones Density value.
  89048. * 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.
  89049. * Values less than zero provide a filter of opposite hue.
  89050. */
  89051. set midtonesDensity(value: number);
  89052. /**
  89053. * Gets the midtones Saturation value.
  89054. * 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.
  89055. */
  89056. get midtonesSaturation(): number;
  89057. /**
  89058. * Sets the midtones Saturation value.
  89059. * 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.
  89060. */
  89061. set midtonesSaturation(value: number);
  89062. /**
  89063. * Gets the midtones Exposure value.
  89064. * 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.
  89065. */
  89066. get midtonesExposure(): number;
  89067. /**
  89068. * Sets the midtones Exposure value.
  89069. * 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.
  89070. */
  89071. set midtonesExposure(value: number);
  89072. private _shadowsHue;
  89073. private _shadowsDensity;
  89074. private _shadowsSaturation;
  89075. private _shadowsExposure;
  89076. /**
  89077. * Gets the shadows Hue value.
  89078. * 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).
  89079. */
  89080. get shadowsHue(): number;
  89081. /**
  89082. * Sets the shadows Hue value.
  89083. * 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).
  89084. */
  89085. set shadowsHue(value: number);
  89086. /**
  89087. * Gets the shadows Density value.
  89088. * 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.
  89089. * Values less than zero provide a filter of opposite hue.
  89090. */
  89091. get shadowsDensity(): number;
  89092. /**
  89093. * Sets the shadows Density value.
  89094. * 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.
  89095. * Values less than zero provide a filter of opposite hue.
  89096. */
  89097. set shadowsDensity(value: number);
  89098. /**
  89099. * Gets the shadows Saturation value.
  89100. * 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.
  89101. */
  89102. get shadowsSaturation(): number;
  89103. /**
  89104. * Sets the shadows Saturation value.
  89105. * 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.
  89106. */
  89107. set shadowsSaturation(value: number);
  89108. /**
  89109. * Gets the shadows Exposure value.
  89110. * 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.
  89111. */
  89112. get shadowsExposure(): number;
  89113. /**
  89114. * Sets the shadows Exposure value.
  89115. * 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.
  89116. */
  89117. set shadowsExposure(value: number);
  89118. /**
  89119. * Returns the class name
  89120. * @returns The class name
  89121. */
  89122. getClassName(): string;
  89123. /**
  89124. * Binds the color curves to the shader.
  89125. * @param colorCurves The color curve to bind
  89126. * @param effect The effect to bind to
  89127. * @param positiveUniform The positive uniform shader parameter
  89128. * @param neutralUniform The neutral uniform shader parameter
  89129. * @param negativeUniform The negative uniform shader parameter
  89130. */
  89131. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89132. /**
  89133. * Prepare the list of uniforms associated with the ColorCurves effects.
  89134. * @param uniformsList The list of uniforms used in the effect
  89135. */
  89136. static PrepareUniforms(uniformsList: string[]): void;
  89137. /**
  89138. * Returns color grading data based on a hue, density, saturation and exposure value.
  89139. * @param filterHue The hue of the color filter.
  89140. * @param filterDensity The density of the color filter.
  89141. * @param saturation The saturation.
  89142. * @param exposure The exposure.
  89143. * @param result The result data container.
  89144. */
  89145. private getColorGradingDataToRef;
  89146. /**
  89147. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89148. * @param value The input slider value in range [-100,100].
  89149. * @returns Adjusted value.
  89150. */
  89151. private static applyColorGradingSliderNonlinear;
  89152. /**
  89153. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89154. * @param hue The hue (H) input.
  89155. * @param saturation The saturation (S) input.
  89156. * @param brightness The brightness (B) input.
  89157. * @result An RGBA color represented as Vector4.
  89158. */
  89159. private static fromHSBToRef;
  89160. /**
  89161. * Returns a value clamped between min and max
  89162. * @param value The value to clamp
  89163. * @param min The minimum of value
  89164. * @param max The maximum of value
  89165. * @returns The clamped value.
  89166. */
  89167. private static clamp;
  89168. /**
  89169. * Clones the current color curve instance.
  89170. * @return The cloned curves
  89171. */
  89172. clone(): ColorCurves;
  89173. /**
  89174. * Serializes the current color curve instance to a json representation.
  89175. * @return a JSON representation
  89176. */
  89177. serialize(): any;
  89178. /**
  89179. * Parses the color curve from a json representation.
  89180. * @param source the JSON source to parse
  89181. * @return The parsed curves
  89182. */
  89183. static Parse(source: any): ColorCurves;
  89184. }
  89185. }
  89186. declare module BABYLON {
  89187. /**
  89188. * Interface to follow in your material defines to integrate easily the
  89189. * Image proccessing functions.
  89190. * @hidden
  89191. */
  89192. export interface IImageProcessingConfigurationDefines {
  89193. IMAGEPROCESSING: boolean;
  89194. VIGNETTE: boolean;
  89195. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89196. VIGNETTEBLENDMODEOPAQUE: boolean;
  89197. TONEMAPPING: boolean;
  89198. TONEMAPPING_ACES: boolean;
  89199. CONTRAST: boolean;
  89200. EXPOSURE: boolean;
  89201. COLORCURVES: boolean;
  89202. COLORGRADING: boolean;
  89203. COLORGRADING3D: boolean;
  89204. SAMPLER3DGREENDEPTH: boolean;
  89205. SAMPLER3DBGRMAP: boolean;
  89206. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89207. }
  89208. /**
  89209. * @hidden
  89210. */
  89211. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89212. IMAGEPROCESSING: boolean;
  89213. VIGNETTE: boolean;
  89214. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89215. VIGNETTEBLENDMODEOPAQUE: boolean;
  89216. TONEMAPPING: boolean;
  89217. TONEMAPPING_ACES: boolean;
  89218. CONTRAST: boolean;
  89219. COLORCURVES: boolean;
  89220. COLORGRADING: boolean;
  89221. COLORGRADING3D: boolean;
  89222. SAMPLER3DGREENDEPTH: boolean;
  89223. SAMPLER3DBGRMAP: boolean;
  89224. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89225. EXPOSURE: boolean;
  89226. constructor();
  89227. }
  89228. /**
  89229. * This groups together the common properties used for image processing either in direct forward pass
  89230. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89231. * or not.
  89232. */
  89233. export class ImageProcessingConfiguration {
  89234. /**
  89235. * Default tone mapping applied in BabylonJS.
  89236. */
  89237. static readonly TONEMAPPING_STANDARD: number;
  89238. /**
  89239. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89240. * to other engines rendering to increase portability.
  89241. */
  89242. static readonly TONEMAPPING_ACES: number;
  89243. /**
  89244. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89245. */
  89246. colorCurves: Nullable<ColorCurves>;
  89247. private _colorCurvesEnabled;
  89248. /**
  89249. * Gets wether the color curves effect is enabled.
  89250. */
  89251. get colorCurvesEnabled(): boolean;
  89252. /**
  89253. * Sets wether the color curves effect is enabled.
  89254. */
  89255. set colorCurvesEnabled(value: boolean);
  89256. private _colorGradingTexture;
  89257. /**
  89258. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89259. */
  89260. get colorGradingTexture(): Nullable<BaseTexture>;
  89261. /**
  89262. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89263. */
  89264. set colorGradingTexture(value: Nullable<BaseTexture>);
  89265. private _colorGradingEnabled;
  89266. /**
  89267. * Gets wether the color grading effect is enabled.
  89268. */
  89269. get colorGradingEnabled(): boolean;
  89270. /**
  89271. * Sets wether the color grading effect is enabled.
  89272. */
  89273. set colorGradingEnabled(value: boolean);
  89274. private _colorGradingWithGreenDepth;
  89275. /**
  89276. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89277. */
  89278. get colorGradingWithGreenDepth(): boolean;
  89279. /**
  89280. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89281. */
  89282. set colorGradingWithGreenDepth(value: boolean);
  89283. private _colorGradingBGR;
  89284. /**
  89285. * Gets wether the color grading texture contains BGR values.
  89286. */
  89287. get colorGradingBGR(): boolean;
  89288. /**
  89289. * Sets wether the color grading texture contains BGR values.
  89290. */
  89291. set colorGradingBGR(value: boolean);
  89292. /** @hidden */
  89293. _exposure: number;
  89294. /**
  89295. * Gets the Exposure used in the effect.
  89296. */
  89297. get exposure(): number;
  89298. /**
  89299. * Sets the Exposure used in the effect.
  89300. */
  89301. set exposure(value: number);
  89302. private _toneMappingEnabled;
  89303. /**
  89304. * Gets wether the tone mapping effect is enabled.
  89305. */
  89306. get toneMappingEnabled(): boolean;
  89307. /**
  89308. * Sets wether the tone mapping effect is enabled.
  89309. */
  89310. set toneMappingEnabled(value: boolean);
  89311. private _toneMappingType;
  89312. /**
  89313. * Gets the type of tone mapping effect.
  89314. */
  89315. get toneMappingType(): number;
  89316. /**
  89317. * Sets the type of tone mapping effect used in BabylonJS.
  89318. */
  89319. set toneMappingType(value: number);
  89320. protected _contrast: number;
  89321. /**
  89322. * Gets the contrast used in the effect.
  89323. */
  89324. get contrast(): number;
  89325. /**
  89326. * Sets the contrast used in the effect.
  89327. */
  89328. set contrast(value: number);
  89329. /**
  89330. * Vignette stretch size.
  89331. */
  89332. vignetteStretch: number;
  89333. /**
  89334. * Vignette centre X Offset.
  89335. */
  89336. vignetteCentreX: number;
  89337. /**
  89338. * Vignette centre Y Offset.
  89339. */
  89340. vignetteCentreY: number;
  89341. /**
  89342. * Vignette weight or intensity of the vignette effect.
  89343. */
  89344. vignetteWeight: number;
  89345. /**
  89346. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89347. * if vignetteEnabled is set to true.
  89348. */
  89349. vignetteColor: Color4;
  89350. /**
  89351. * Camera field of view used by the Vignette effect.
  89352. */
  89353. vignetteCameraFov: number;
  89354. private _vignetteBlendMode;
  89355. /**
  89356. * Gets the vignette blend mode allowing different kind of effect.
  89357. */
  89358. get vignetteBlendMode(): number;
  89359. /**
  89360. * Sets the vignette blend mode allowing different kind of effect.
  89361. */
  89362. set vignetteBlendMode(value: number);
  89363. private _vignetteEnabled;
  89364. /**
  89365. * Gets wether the vignette effect is enabled.
  89366. */
  89367. get vignetteEnabled(): boolean;
  89368. /**
  89369. * Sets wether the vignette effect is enabled.
  89370. */
  89371. set vignetteEnabled(value: boolean);
  89372. private _applyByPostProcess;
  89373. /**
  89374. * Gets wether the image processing is applied through a post process or not.
  89375. */
  89376. get applyByPostProcess(): boolean;
  89377. /**
  89378. * Sets wether the image processing is applied through a post process or not.
  89379. */
  89380. set applyByPostProcess(value: boolean);
  89381. private _isEnabled;
  89382. /**
  89383. * Gets wether the image processing is enabled or not.
  89384. */
  89385. get isEnabled(): boolean;
  89386. /**
  89387. * Sets wether the image processing is enabled or not.
  89388. */
  89389. set isEnabled(value: boolean);
  89390. /**
  89391. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89392. */
  89393. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89394. /**
  89395. * Method called each time the image processing information changes requires to recompile the effect.
  89396. */
  89397. protected _updateParameters(): void;
  89398. /**
  89399. * Gets the current class name.
  89400. * @return "ImageProcessingConfiguration"
  89401. */
  89402. getClassName(): string;
  89403. /**
  89404. * Prepare the list of uniforms associated with the Image Processing effects.
  89405. * @param uniforms The list of uniforms used in the effect
  89406. * @param defines the list of defines currently in use
  89407. */
  89408. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89409. /**
  89410. * Prepare the list of samplers associated with the Image Processing effects.
  89411. * @param samplersList The list of uniforms used in the effect
  89412. * @param defines the list of defines currently in use
  89413. */
  89414. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89415. /**
  89416. * Prepare the list of defines associated to the shader.
  89417. * @param defines the list of defines to complete
  89418. * @param forPostProcess Define if we are currently in post process mode or not
  89419. */
  89420. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89421. /**
  89422. * Returns true if all the image processing information are ready.
  89423. * @returns True if ready, otherwise, false
  89424. */
  89425. isReady(): boolean;
  89426. /**
  89427. * Binds the image processing to the shader.
  89428. * @param effect The effect to bind to
  89429. * @param overrideAspectRatio Override the aspect ratio of the effect
  89430. */
  89431. bind(effect: Effect, overrideAspectRatio?: number): void;
  89432. /**
  89433. * Clones the current image processing instance.
  89434. * @return The cloned image processing
  89435. */
  89436. clone(): ImageProcessingConfiguration;
  89437. /**
  89438. * Serializes the current image processing instance to a json representation.
  89439. * @return a JSON representation
  89440. */
  89441. serialize(): any;
  89442. /**
  89443. * Parses the image processing from a json representation.
  89444. * @param source the JSON source to parse
  89445. * @return The parsed image processing
  89446. */
  89447. static Parse(source: any): ImageProcessingConfiguration;
  89448. private static _VIGNETTEMODE_MULTIPLY;
  89449. private static _VIGNETTEMODE_OPAQUE;
  89450. /**
  89451. * Used to apply the vignette as a mix with the pixel color.
  89452. */
  89453. static get VIGNETTEMODE_MULTIPLY(): number;
  89454. /**
  89455. * Used to apply the vignette as a replacement of the pixel color.
  89456. */
  89457. static get VIGNETTEMODE_OPAQUE(): number;
  89458. }
  89459. }
  89460. declare module BABYLON {
  89461. /** @hidden */
  89462. export var postprocessVertexShader: {
  89463. name: string;
  89464. shader: string;
  89465. };
  89466. }
  89467. declare module BABYLON {
  89468. /**
  89469. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89470. */
  89471. export type RenderTargetTextureSize = number | {
  89472. width: number;
  89473. height: number;
  89474. layers?: number;
  89475. };
  89476. interface ThinEngine {
  89477. /**
  89478. * Creates a new render target texture
  89479. * @param size defines the size of the texture
  89480. * @param options defines the options used to create the texture
  89481. * @returns a new render target texture stored in an InternalTexture
  89482. */
  89483. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89484. /**
  89485. * Creates a depth stencil texture.
  89486. * This is only available in WebGL 2 or with the depth texture extension available.
  89487. * @param size The size of face edge in the texture.
  89488. * @param options The options defining the texture.
  89489. * @returns The texture
  89490. */
  89491. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89492. /** @hidden */
  89493. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89494. }
  89495. }
  89496. declare module BABYLON {
  89497. /**
  89498. * Defines the kind of connection point for node based material
  89499. */
  89500. export enum NodeMaterialBlockConnectionPointTypes {
  89501. /** Float */
  89502. Float = 1,
  89503. /** Int */
  89504. Int = 2,
  89505. /** Vector2 */
  89506. Vector2 = 4,
  89507. /** Vector3 */
  89508. Vector3 = 8,
  89509. /** Vector4 */
  89510. Vector4 = 16,
  89511. /** Color3 */
  89512. Color3 = 32,
  89513. /** Color4 */
  89514. Color4 = 64,
  89515. /** Matrix */
  89516. Matrix = 128,
  89517. /** Custom object */
  89518. Object = 256,
  89519. /** Detect type based on connection */
  89520. AutoDetect = 1024,
  89521. /** Output type that will be defined by input type */
  89522. BasedOnInput = 2048
  89523. }
  89524. }
  89525. declare module BABYLON {
  89526. /**
  89527. * Enum used to define the target of a block
  89528. */
  89529. export enum NodeMaterialBlockTargets {
  89530. /** Vertex shader */
  89531. Vertex = 1,
  89532. /** Fragment shader */
  89533. Fragment = 2,
  89534. /** Neutral */
  89535. Neutral = 4,
  89536. /** Vertex and Fragment */
  89537. VertexAndFragment = 3
  89538. }
  89539. }
  89540. declare module BABYLON {
  89541. /**
  89542. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89543. */
  89544. export enum NodeMaterialBlockConnectionPointMode {
  89545. /** Value is an uniform */
  89546. Uniform = 0,
  89547. /** Value is a mesh attribute */
  89548. Attribute = 1,
  89549. /** Value is a varying between vertex and fragment shaders */
  89550. Varying = 2,
  89551. /** Mode is undefined */
  89552. Undefined = 3
  89553. }
  89554. }
  89555. declare module BABYLON {
  89556. /**
  89557. * Enum used to define system values e.g. values automatically provided by the system
  89558. */
  89559. export enum NodeMaterialSystemValues {
  89560. /** World */
  89561. World = 1,
  89562. /** View */
  89563. View = 2,
  89564. /** Projection */
  89565. Projection = 3,
  89566. /** ViewProjection */
  89567. ViewProjection = 4,
  89568. /** WorldView */
  89569. WorldView = 5,
  89570. /** WorldViewProjection */
  89571. WorldViewProjection = 6,
  89572. /** CameraPosition */
  89573. CameraPosition = 7,
  89574. /** Fog Color */
  89575. FogColor = 8,
  89576. /** Delta time */
  89577. DeltaTime = 9
  89578. }
  89579. }
  89580. declare module BABYLON {
  89581. /** Defines supported spaces */
  89582. export enum Space {
  89583. /** Local (object) space */
  89584. LOCAL = 0,
  89585. /** World space */
  89586. WORLD = 1,
  89587. /** Bone space */
  89588. BONE = 2
  89589. }
  89590. /** Defines the 3 main axes */
  89591. export class Axis {
  89592. /** X axis */
  89593. static X: Vector3;
  89594. /** Y axis */
  89595. static Y: Vector3;
  89596. /** Z axis */
  89597. static Z: Vector3;
  89598. }
  89599. }
  89600. declare module BABYLON {
  89601. /**
  89602. * Represents a camera frustum
  89603. */
  89604. export class Frustum {
  89605. /**
  89606. * Gets the planes representing the frustum
  89607. * @param transform matrix to be applied to the returned planes
  89608. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89609. */
  89610. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89611. /**
  89612. * Gets the near frustum plane transformed by the transform matrix
  89613. * @param transform transformation matrix to be applied to the resulting frustum plane
  89614. * @param frustumPlane the resuling frustum plane
  89615. */
  89616. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89617. /**
  89618. * Gets the far frustum plane transformed by the transform matrix
  89619. * @param transform transformation matrix to be applied to the resulting frustum plane
  89620. * @param frustumPlane the resuling frustum plane
  89621. */
  89622. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89623. /**
  89624. * Gets the left frustum plane transformed by the transform matrix
  89625. * @param transform transformation matrix to be applied to the resulting frustum plane
  89626. * @param frustumPlane the resuling frustum plane
  89627. */
  89628. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89629. /**
  89630. * Gets the right frustum plane transformed by the transform matrix
  89631. * @param transform transformation matrix to be applied to the resulting frustum plane
  89632. * @param frustumPlane the resuling frustum plane
  89633. */
  89634. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89635. /**
  89636. * Gets the top frustum plane transformed by the transform matrix
  89637. * @param transform transformation matrix to be applied to the resulting frustum plane
  89638. * @param frustumPlane the resuling frustum plane
  89639. */
  89640. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89641. /**
  89642. * Gets the bottom frustum plane transformed by the transform matrix
  89643. * @param transform transformation matrix to be applied to the resulting frustum plane
  89644. * @param frustumPlane the resuling frustum plane
  89645. */
  89646. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89647. /**
  89648. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89649. * @param transform transformation matrix to be applied to the resulting frustum planes
  89650. * @param frustumPlanes the resuling frustum planes
  89651. */
  89652. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89653. }
  89654. }
  89655. declare module BABYLON {
  89656. /**
  89657. * Interface for the size containing width and height
  89658. */
  89659. export interface ISize {
  89660. /**
  89661. * Width
  89662. */
  89663. width: number;
  89664. /**
  89665. * Heighht
  89666. */
  89667. height: number;
  89668. }
  89669. /**
  89670. * Size containing widht and height
  89671. */
  89672. export class Size implements ISize {
  89673. /**
  89674. * Width
  89675. */
  89676. width: number;
  89677. /**
  89678. * Height
  89679. */
  89680. height: number;
  89681. /**
  89682. * Creates a Size object from the given width and height (floats).
  89683. * @param width width of the new size
  89684. * @param height height of the new size
  89685. */
  89686. constructor(width: number, height: number);
  89687. /**
  89688. * Returns a string with the Size width and height
  89689. * @returns a string with the Size width and height
  89690. */
  89691. toString(): string;
  89692. /**
  89693. * "Size"
  89694. * @returns the string "Size"
  89695. */
  89696. getClassName(): string;
  89697. /**
  89698. * Returns the Size hash code.
  89699. * @returns a hash code for a unique width and height
  89700. */
  89701. getHashCode(): number;
  89702. /**
  89703. * Updates the current size from the given one.
  89704. * @param src the given size
  89705. */
  89706. copyFrom(src: Size): void;
  89707. /**
  89708. * Updates in place the current Size from the given floats.
  89709. * @param width width of the new size
  89710. * @param height height of the new size
  89711. * @returns the updated Size.
  89712. */
  89713. copyFromFloats(width: number, height: number): Size;
  89714. /**
  89715. * Updates in place the current Size from the given floats.
  89716. * @param width width to set
  89717. * @param height height to set
  89718. * @returns the updated Size.
  89719. */
  89720. set(width: number, height: number): Size;
  89721. /**
  89722. * Multiplies the width and height by numbers
  89723. * @param w factor to multiple the width by
  89724. * @param h factor to multiple the height by
  89725. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89726. */
  89727. multiplyByFloats(w: number, h: number): Size;
  89728. /**
  89729. * Clones the size
  89730. * @returns a new Size copied from the given one.
  89731. */
  89732. clone(): Size;
  89733. /**
  89734. * True if the current Size and the given one width and height are strictly equal.
  89735. * @param other the other size to compare against
  89736. * @returns True if the current Size and the given one width and height are strictly equal.
  89737. */
  89738. equals(other: Size): boolean;
  89739. /**
  89740. * The surface of the Size : width * height (float).
  89741. */
  89742. get surface(): number;
  89743. /**
  89744. * Create a new size of zero
  89745. * @returns a new Size set to (0.0, 0.0)
  89746. */
  89747. static Zero(): Size;
  89748. /**
  89749. * Sums the width and height of two sizes
  89750. * @param otherSize size to add to this size
  89751. * @returns a new Size set as the addition result of the current Size and the given one.
  89752. */
  89753. add(otherSize: Size): Size;
  89754. /**
  89755. * Subtracts the width and height of two
  89756. * @param otherSize size to subtract to this size
  89757. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89758. */
  89759. subtract(otherSize: Size): Size;
  89760. /**
  89761. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89762. * @param start starting size to lerp between
  89763. * @param end end size to lerp between
  89764. * @param amount amount to lerp between the start and end values
  89765. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89766. */
  89767. static Lerp(start: Size, end: Size, amount: number): Size;
  89768. }
  89769. }
  89770. declare module BABYLON {
  89771. /**
  89772. * Contains position and normal vectors for a vertex
  89773. */
  89774. export class PositionNormalVertex {
  89775. /** the position of the vertex (defaut: 0,0,0) */
  89776. position: Vector3;
  89777. /** the normal of the vertex (defaut: 0,1,0) */
  89778. normal: Vector3;
  89779. /**
  89780. * Creates a PositionNormalVertex
  89781. * @param position the position of the vertex (defaut: 0,0,0)
  89782. * @param normal the normal of the vertex (defaut: 0,1,0)
  89783. */
  89784. constructor(
  89785. /** the position of the vertex (defaut: 0,0,0) */
  89786. position?: Vector3,
  89787. /** the normal of the vertex (defaut: 0,1,0) */
  89788. normal?: Vector3);
  89789. /**
  89790. * Clones the PositionNormalVertex
  89791. * @returns the cloned PositionNormalVertex
  89792. */
  89793. clone(): PositionNormalVertex;
  89794. }
  89795. /**
  89796. * Contains position, normal and uv vectors for a vertex
  89797. */
  89798. export class PositionNormalTextureVertex {
  89799. /** the position of the vertex (defaut: 0,0,0) */
  89800. position: Vector3;
  89801. /** the normal of the vertex (defaut: 0,1,0) */
  89802. normal: Vector3;
  89803. /** the uv of the vertex (default: 0,0) */
  89804. uv: Vector2;
  89805. /**
  89806. * Creates a PositionNormalTextureVertex
  89807. * @param position the position of the vertex (defaut: 0,0,0)
  89808. * @param normal the normal of the vertex (defaut: 0,1,0)
  89809. * @param uv the uv of the vertex (default: 0,0)
  89810. */
  89811. constructor(
  89812. /** the position of the vertex (defaut: 0,0,0) */
  89813. position?: Vector3,
  89814. /** the normal of the vertex (defaut: 0,1,0) */
  89815. normal?: Vector3,
  89816. /** the uv of the vertex (default: 0,0) */
  89817. uv?: Vector2);
  89818. /**
  89819. * Clones the PositionNormalTextureVertex
  89820. * @returns the cloned PositionNormalTextureVertex
  89821. */
  89822. clone(): PositionNormalTextureVertex;
  89823. }
  89824. }
  89825. declare module BABYLON {
  89826. /**
  89827. * Enum defining the type of animations supported by InputBlock
  89828. */
  89829. export enum AnimatedInputBlockTypes {
  89830. /** No animation */
  89831. None = 0,
  89832. /** Time based animation. Will only work for floats */
  89833. Time = 1
  89834. }
  89835. }
  89836. declare module BABYLON {
  89837. /**
  89838. * Interface describing all the common properties and methods a shadow light needs to implement.
  89839. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89840. * as well as binding the different shadow properties to the effects.
  89841. */
  89842. export interface IShadowLight extends Light {
  89843. /**
  89844. * The light id in the scene (used in scene.findLighById for instance)
  89845. */
  89846. id: string;
  89847. /**
  89848. * The position the shdow will be casted from.
  89849. */
  89850. position: Vector3;
  89851. /**
  89852. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89853. */
  89854. direction: Vector3;
  89855. /**
  89856. * The transformed position. Position of the light in world space taking parenting in account.
  89857. */
  89858. transformedPosition: Vector3;
  89859. /**
  89860. * The transformed direction. Direction of the light in world space taking parenting in account.
  89861. */
  89862. transformedDirection: Vector3;
  89863. /**
  89864. * The friendly name of the light in the scene.
  89865. */
  89866. name: string;
  89867. /**
  89868. * Defines the shadow projection clipping minimum z value.
  89869. */
  89870. shadowMinZ: number;
  89871. /**
  89872. * Defines the shadow projection clipping maximum z value.
  89873. */
  89874. shadowMaxZ: number;
  89875. /**
  89876. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89877. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89878. */
  89879. computeTransformedInformation(): boolean;
  89880. /**
  89881. * Gets the scene the light belongs to.
  89882. * @returns The scene
  89883. */
  89884. getScene(): Scene;
  89885. /**
  89886. * Callback defining a custom Projection Matrix Builder.
  89887. * This can be used to override the default projection matrix computation.
  89888. */
  89889. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89890. /**
  89891. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89892. * @param matrix The materix to updated with the projection information
  89893. * @param viewMatrix The transform matrix of the light
  89894. * @param renderList The list of mesh to render in the map
  89895. * @returns The current light
  89896. */
  89897. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89898. /**
  89899. * Gets the current depth scale used in ESM.
  89900. * @returns The scale
  89901. */
  89902. getDepthScale(): number;
  89903. /**
  89904. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89905. * @returns true if a cube texture needs to be use
  89906. */
  89907. needCube(): boolean;
  89908. /**
  89909. * Detects if the projection matrix requires to be recomputed this frame.
  89910. * @returns true if it requires to be recomputed otherwise, false.
  89911. */
  89912. needProjectionMatrixCompute(): boolean;
  89913. /**
  89914. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89915. */
  89916. forceProjectionMatrixCompute(): void;
  89917. /**
  89918. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89919. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89920. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89921. */
  89922. getShadowDirection(faceIndex?: number): Vector3;
  89923. /**
  89924. * Gets the minZ used for shadow according to both the scene and the light.
  89925. * @param activeCamera The camera we are returning the min for
  89926. * @returns the depth min z
  89927. */
  89928. getDepthMinZ(activeCamera: Camera): number;
  89929. /**
  89930. * Gets the maxZ used for shadow according to both the scene and the light.
  89931. * @param activeCamera The camera we are returning the max for
  89932. * @returns the depth max z
  89933. */
  89934. getDepthMaxZ(activeCamera: Camera): number;
  89935. }
  89936. /**
  89937. * Base implementation IShadowLight
  89938. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89939. */
  89940. export abstract class ShadowLight extends Light implements IShadowLight {
  89941. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89942. protected _position: Vector3;
  89943. protected _setPosition(value: Vector3): void;
  89944. /**
  89945. * Sets the position the shadow will be casted from. Also use as the light position for both
  89946. * point and spot lights.
  89947. */
  89948. get position(): Vector3;
  89949. /**
  89950. * Sets the position the shadow will be casted from. Also use as the light position for both
  89951. * point and spot lights.
  89952. */
  89953. set position(value: Vector3);
  89954. protected _direction: Vector3;
  89955. protected _setDirection(value: Vector3): void;
  89956. /**
  89957. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89958. * Also use as the light direction on spot and directional lights.
  89959. */
  89960. get direction(): Vector3;
  89961. /**
  89962. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89963. * Also use as the light direction on spot and directional lights.
  89964. */
  89965. set direction(value: Vector3);
  89966. protected _shadowMinZ: number;
  89967. /**
  89968. * Gets the shadow projection clipping minimum z value.
  89969. */
  89970. get shadowMinZ(): number;
  89971. /**
  89972. * Sets the shadow projection clipping minimum z value.
  89973. */
  89974. set shadowMinZ(value: number);
  89975. protected _shadowMaxZ: number;
  89976. /**
  89977. * Sets the shadow projection clipping maximum z value.
  89978. */
  89979. get shadowMaxZ(): number;
  89980. /**
  89981. * Gets the shadow projection clipping maximum z value.
  89982. */
  89983. set shadowMaxZ(value: number);
  89984. /**
  89985. * Callback defining a custom Projection Matrix Builder.
  89986. * This can be used to override the default projection matrix computation.
  89987. */
  89988. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89989. /**
  89990. * The transformed position. Position of the light in world space taking parenting in account.
  89991. */
  89992. transformedPosition: Vector3;
  89993. /**
  89994. * The transformed direction. Direction of the light in world space taking parenting in account.
  89995. */
  89996. transformedDirection: Vector3;
  89997. private _needProjectionMatrixCompute;
  89998. /**
  89999. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90000. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90001. */
  90002. computeTransformedInformation(): boolean;
  90003. /**
  90004. * Return the depth scale used for the shadow map.
  90005. * @returns the depth scale.
  90006. */
  90007. getDepthScale(): number;
  90008. /**
  90009. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90010. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90011. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90012. */
  90013. getShadowDirection(faceIndex?: number): Vector3;
  90014. /**
  90015. * Returns the ShadowLight absolute position in the World.
  90016. * @returns the position vector in world space
  90017. */
  90018. getAbsolutePosition(): Vector3;
  90019. /**
  90020. * Sets the ShadowLight direction toward the passed target.
  90021. * @param target The point to target in local space
  90022. * @returns the updated ShadowLight direction
  90023. */
  90024. setDirectionToTarget(target: Vector3): Vector3;
  90025. /**
  90026. * Returns the light rotation in euler definition.
  90027. * @returns the x y z rotation in local space.
  90028. */
  90029. getRotation(): Vector3;
  90030. /**
  90031. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90032. * @returns true if a cube texture needs to be use
  90033. */
  90034. needCube(): boolean;
  90035. /**
  90036. * Detects if the projection matrix requires to be recomputed this frame.
  90037. * @returns true if it requires to be recomputed otherwise, false.
  90038. */
  90039. needProjectionMatrixCompute(): boolean;
  90040. /**
  90041. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90042. */
  90043. forceProjectionMatrixCompute(): void;
  90044. /** @hidden */
  90045. _initCache(): void;
  90046. /** @hidden */
  90047. _isSynchronized(): boolean;
  90048. /**
  90049. * Computes the world matrix of the node
  90050. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90051. * @returns the world matrix
  90052. */
  90053. computeWorldMatrix(force?: boolean): Matrix;
  90054. /**
  90055. * Gets the minZ used for shadow according to both the scene and the light.
  90056. * @param activeCamera The camera we are returning the min for
  90057. * @returns the depth min z
  90058. */
  90059. getDepthMinZ(activeCamera: Camera): number;
  90060. /**
  90061. * Gets the maxZ used for shadow according to both the scene and the light.
  90062. * @param activeCamera The camera we are returning the max for
  90063. * @returns the depth max z
  90064. */
  90065. getDepthMaxZ(activeCamera: Camera): number;
  90066. /**
  90067. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90068. * @param matrix The materix to updated with the projection information
  90069. * @param viewMatrix The transform matrix of the light
  90070. * @param renderList The list of mesh to render in the map
  90071. * @returns The current light
  90072. */
  90073. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90074. }
  90075. }
  90076. declare module BABYLON {
  90077. /** @hidden */
  90078. export var packingFunctions: {
  90079. name: string;
  90080. shader: string;
  90081. };
  90082. }
  90083. declare module BABYLON {
  90084. /** @hidden */
  90085. export var bayerDitherFunctions: {
  90086. name: string;
  90087. shader: string;
  90088. };
  90089. }
  90090. declare module BABYLON {
  90091. /** @hidden */
  90092. export var shadowMapFragmentDeclaration: {
  90093. name: string;
  90094. shader: string;
  90095. };
  90096. }
  90097. declare module BABYLON {
  90098. /** @hidden */
  90099. export var clipPlaneFragmentDeclaration: {
  90100. name: string;
  90101. shader: string;
  90102. };
  90103. }
  90104. declare module BABYLON {
  90105. /** @hidden */
  90106. export var clipPlaneFragment: {
  90107. name: string;
  90108. shader: string;
  90109. };
  90110. }
  90111. declare module BABYLON {
  90112. /** @hidden */
  90113. export var shadowMapFragment: {
  90114. name: string;
  90115. shader: string;
  90116. };
  90117. }
  90118. declare module BABYLON {
  90119. /** @hidden */
  90120. export var shadowMapPixelShader: {
  90121. name: string;
  90122. shader: string;
  90123. };
  90124. }
  90125. declare module BABYLON {
  90126. /** @hidden */
  90127. export var bonesDeclaration: {
  90128. name: string;
  90129. shader: string;
  90130. };
  90131. }
  90132. declare module BABYLON {
  90133. /** @hidden */
  90134. export var morphTargetsVertexGlobalDeclaration: {
  90135. name: string;
  90136. shader: string;
  90137. };
  90138. }
  90139. declare module BABYLON {
  90140. /** @hidden */
  90141. export var morphTargetsVertexDeclaration: {
  90142. name: string;
  90143. shader: string;
  90144. };
  90145. }
  90146. declare module BABYLON {
  90147. /** @hidden */
  90148. export var instancesDeclaration: {
  90149. name: string;
  90150. shader: string;
  90151. };
  90152. }
  90153. declare module BABYLON {
  90154. /** @hidden */
  90155. export var helperFunctions: {
  90156. name: string;
  90157. shader: string;
  90158. };
  90159. }
  90160. declare module BABYLON {
  90161. /** @hidden */
  90162. export var shadowMapVertexDeclaration: {
  90163. name: string;
  90164. shader: string;
  90165. };
  90166. }
  90167. declare module BABYLON {
  90168. /** @hidden */
  90169. export var clipPlaneVertexDeclaration: {
  90170. name: string;
  90171. shader: string;
  90172. };
  90173. }
  90174. declare module BABYLON {
  90175. /** @hidden */
  90176. export var morphTargetsVertex: {
  90177. name: string;
  90178. shader: string;
  90179. };
  90180. }
  90181. declare module BABYLON {
  90182. /** @hidden */
  90183. export var instancesVertex: {
  90184. name: string;
  90185. shader: string;
  90186. };
  90187. }
  90188. declare module BABYLON {
  90189. /** @hidden */
  90190. export var bonesVertex: {
  90191. name: string;
  90192. shader: string;
  90193. };
  90194. }
  90195. declare module BABYLON {
  90196. /** @hidden */
  90197. export var shadowMapVertexNormalBias: {
  90198. name: string;
  90199. shader: string;
  90200. };
  90201. }
  90202. declare module BABYLON {
  90203. /** @hidden */
  90204. export var shadowMapVertexMetric: {
  90205. name: string;
  90206. shader: string;
  90207. };
  90208. }
  90209. declare module BABYLON {
  90210. /** @hidden */
  90211. export var clipPlaneVertex: {
  90212. name: string;
  90213. shader: string;
  90214. };
  90215. }
  90216. declare module BABYLON {
  90217. /** @hidden */
  90218. export var shadowMapVertexShader: {
  90219. name: string;
  90220. shader: string;
  90221. };
  90222. }
  90223. declare module BABYLON {
  90224. /** @hidden */
  90225. export var depthBoxBlurPixelShader: {
  90226. name: string;
  90227. shader: string;
  90228. };
  90229. }
  90230. declare module BABYLON {
  90231. /** @hidden */
  90232. export var shadowMapFragmentSoftTransparentShadow: {
  90233. name: string;
  90234. shader: string;
  90235. };
  90236. }
  90237. declare module BABYLON {
  90238. /**
  90239. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90240. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90241. */
  90242. export class EffectFallbacks implements IEffectFallbacks {
  90243. private _defines;
  90244. private _currentRank;
  90245. private _maxRank;
  90246. private _mesh;
  90247. /**
  90248. * Removes the fallback from the bound mesh.
  90249. */
  90250. unBindMesh(): void;
  90251. /**
  90252. * Adds a fallback on the specified property.
  90253. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90254. * @param define The name of the define in the shader
  90255. */
  90256. addFallback(rank: number, define: string): void;
  90257. /**
  90258. * Sets the mesh to use CPU skinning when needing to fallback.
  90259. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90260. * @param mesh The mesh to use the fallbacks.
  90261. */
  90262. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90263. /**
  90264. * Checks to see if more fallbacks are still availible.
  90265. */
  90266. get hasMoreFallbacks(): boolean;
  90267. /**
  90268. * Removes the defines that should be removed when falling back.
  90269. * @param currentDefines defines the current define statements for the shader.
  90270. * @param effect defines the current effect we try to compile
  90271. * @returns The resulting defines with defines of the current rank removed.
  90272. */
  90273. reduce(currentDefines: string, effect: Effect): string;
  90274. }
  90275. }
  90276. declare module BABYLON {
  90277. /**
  90278. * Interface used to define Action
  90279. */
  90280. export interface IAction {
  90281. /**
  90282. * Trigger for the action
  90283. */
  90284. trigger: number;
  90285. /** Options of the trigger */
  90286. triggerOptions: any;
  90287. /**
  90288. * Gets the trigger parameters
  90289. * @returns the trigger parameters
  90290. */
  90291. getTriggerParameter(): any;
  90292. /**
  90293. * Internal only - executes current action event
  90294. * @hidden
  90295. */
  90296. _executeCurrent(evt?: ActionEvent): void;
  90297. /**
  90298. * Serialize placeholder for child classes
  90299. * @param parent of child
  90300. * @returns the serialized object
  90301. */
  90302. serialize(parent: any): any;
  90303. /**
  90304. * Internal only
  90305. * @hidden
  90306. */
  90307. _prepare(): void;
  90308. /**
  90309. * Internal only - manager for action
  90310. * @hidden
  90311. */
  90312. _actionManager: Nullable<AbstractActionManager>;
  90313. /**
  90314. * Adds action to chain of actions, may be a DoNothingAction
  90315. * @param action defines the next action to execute
  90316. * @returns The action passed in
  90317. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90318. */
  90319. then(action: IAction): IAction;
  90320. }
  90321. /**
  90322. * The action to be carried out following a trigger
  90323. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90324. */
  90325. export class Action implements IAction {
  90326. /** the trigger, with or without parameters, for the action */
  90327. triggerOptions: any;
  90328. /**
  90329. * Trigger for the action
  90330. */
  90331. trigger: number;
  90332. /**
  90333. * Internal only - manager for action
  90334. * @hidden
  90335. */
  90336. _actionManager: ActionManager;
  90337. private _nextActiveAction;
  90338. private _child;
  90339. private _condition?;
  90340. private _triggerParameter;
  90341. /**
  90342. * An event triggered prior to action being executed.
  90343. */
  90344. onBeforeExecuteObservable: Observable<Action>;
  90345. /**
  90346. * Creates a new Action
  90347. * @param triggerOptions the trigger, with or without parameters, for the action
  90348. * @param condition an optional determinant of action
  90349. */
  90350. constructor(
  90351. /** the trigger, with or without parameters, for the action */
  90352. triggerOptions: any, condition?: Condition);
  90353. /**
  90354. * Internal only
  90355. * @hidden
  90356. */
  90357. _prepare(): void;
  90358. /**
  90359. * Gets the trigger parameters
  90360. * @returns the trigger parameters
  90361. */
  90362. getTriggerParameter(): any;
  90363. /**
  90364. * Internal only - executes current action event
  90365. * @hidden
  90366. */
  90367. _executeCurrent(evt?: ActionEvent): void;
  90368. /**
  90369. * Execute placeholder for child classes
  90370. * @param evt optional action event
  90371. */
  90372. execute(evt?: ActionEvent): void;
  90373. /**
  90374. * Skips to next active action
  90375. */
  90376. skipToNextActiveAction(): void;
  90377. /**
  90378. * Adds action to chain of actions, may be a DoNothingAction
  90379. * @param action defines the next action to execute
  90380. * @returns The action passed in
  90381. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90382. */
  90383. then(action: Action): Action;
  90384. /**
  90385. * Internal only
  90386. * @hidden
  90387. */
  90388. _getProperty(propertyPath: string): string;
  90389. /**
  90390. * Internal only
  90391. * @hidden
  90392. */
  90393. _getEffectiveTarget(target: any, propertyPath: string): any;
  90394. /**
  90395. * Serialize placeholder for child classes
  90396. * @param parent of child
  90397. * @returns the serialized object
  90398. */
  90399. serialize(parent: any): any;
  90400. /**
  90401. * Internal only called by serialize
  90402. * @hidden
  90403. */
  90404. protected _serialize(serializedAction: any, parent?: any): any;
  90405. /**
  90406. * Internal only
  90407. * @hidden
  90408. */
  90409. static _SerializeValueAsString: (value: any) => string;
  90410. /**
  90411. * Internal only
  90412. * @hidden
  90413. */
  90414. static _GetTargetProperty: (target: Scene | Node) => {
  90415. name: string;
  90416. targetType: string;
  90417. value: string;
  90418. };
  90419. }
  90420. }
  90421. declare module BABYLON {
  90422. /**
  90423. * A Condition applied to an Action
  90424. */
  90425. export class Condition {
  90426. /**
  90427. * Internal only - manager for action
  90428. * @hidden
  90429. */
  90430. _actionManager: ActionManager;
  90431. /**
  90432. * Internal only
  90433. * @hidden
  90434. */
  90435. _evaluationId: number;
  90436. /**
  90437. * Internal only
  90438. * @hidden
  90439. */
  90440. _currentResult: boolean;
  90441. /**
  90442. * Creates a new Condition
  90443. * @param actionManager the manager of the action the condition is applied to
  90444. */
  90445. constructor(actionManager: ActionManager);
  90446. /**
  90447. * Check if the current condition is valid
  90448. * @returns a boolean
  90449. */
  90450. isValid(): boolean;
  90451. /**
  90452. * Internal only
  90453. * @hidden
  90454. */
  90455. _getProperty(propertyPath: string): string;
  90456. /**
  90457. * Internal only
  90458. * @hidden
  90459. */
  90460. _getEffectiveTarget(target: any, propertyPath: string): any;
  90461. /**
  90462. * Serialize placeholder for child classes
  90463. * @returns the serialized object
  90464. */
  90465. serialize(): any;
  90466. /**
  90467. * Internal only
  90468. * @hidden
  90469. */
  90470. protected _serialize(serializedCondition: any): any;
  90471. }
  90472. /**
  90473. * Defines specific conditional operators as extensions of Condition
  90474. */
  90475. export class ValueCondition extends Condition {
  90476. /** path to specify the property of the target the conditional operator uses */
  90477. propertyPath: string;
  90478. /** the value compared by the conditional operator against the current value of the property */
  90479. value: any;
  90480. /** the conditional operator, default ValueCondition.IsEqual */
  90481. operator: number;
  90482. /**
  90483. * Internal only
  90484. * @hidden
  90485. */
  90486. private static _IsEqual;
  90487. /**
  90488. * Internal only
  90489. * @hidden
  90490. */
  90491. private static _IsDifferent;
  90492. /**
  90493. * Internal only
  90494. * @hidden
  90495. */
  90496. private static _IsGreater;
  90497. /**
  90498. * Internal only
  90499. * @hidden
  90500. */
  90501. private static _IsLesser;
  90502. /**
  90503. * returns the number for IsEqual
  90504. */
  90505. static get IsEqual(): number;
  90506. /**
  90507. * Returns the number for IsDifferent
  90508. */
  90509. static get IsDifferent(): number;
  90510. /**
  90511. * Returns the number for IsGreater
  90512. */
  90513. static get IsGreater(): number;
  90514. /**
  90515. * Returns the number for IsLesser
  90516. */
  90517. static get IsLesser(): number;
  90518. /**
  90519. * Internal only The action manager for the condition
  90520. * @hidden
  90521. */
  90522. _actionManager: ActionManager;
  90523. /**
  90524. * Internal only
  90525. * @hidden
  90526. */
  90527. private _target;
  90528. /**
  90529. * Internal only
  90530. * @hidden
  90531. */
  90532. private _effectiveTarget;
  90533. /**
  90534. * Internal only
  90535. * @hidden
  90536. */
  90537. private _property;
  90538. /**
  90539. * Creates a new ValueCondition
  90540. * @param actionManager manager for the action the condition applies to
  90541. * @param target for the action
  90542. * @param propertyPath path to specify the property of the target the conditional operator uses
  90543. * @param value the value compared by the conditional operator against the current value of the property
  90544. * @param operator the conditional operator, default ValueCondition.IsEqual
  90545. */
  90546. constructor(actionManager: ActionManager, target: any,
  90547. /** path to specify the property of the target the conditional operator uses */
  90548. propertyPath: string,
  90549. /** the value compared by the conditional operator against the current value of the property */
  90550. value: any,
  90551. /** the conditional operator, default ValueCondition.IsEqual */
  90552. operator?: number);
  90553. /**
  90554. * Compares the given value with the property value for the specified conditional operator
  90555. * @returns the result of the comparison
  90556. */
  90557. isValid(): boolean;
  90558. /**
  90559. * Serialize the ValueCondition into a JSON compatible object
  90560. * @returns serialization object
  90561. */
  90562. serialize(): any;
  90563. /**
  90564. * Gets the name of the conditional operator for the ValueCondition
  90565. * @param operator the conditional operator
  90566. * @returns the name
  90567. */
  90568. static GetOperatorName(operator: number): string;
  90569. }
  90570. /**
  90571. * Defines a predicate condition as an extension of Condition
  90572. */
  90573. export class PredicateCondition extends Condition {
  90574. /** defines the predicate function used to validate the condition */
  90575. predicate: () => boolean;
  90576. /**
  90577. * Internal only - manager for action
  90578. * @hidden
  90579. */
  90580. _actionManager: ActionManager;
  90581. /**
  90582. * Creates a new PredicateCondition
  90583. * @param actionManager manager for the action the condition applies to
  90584. * @param predicate defines the predicate function used to validate the condition
  90585. */
  90586. constructor(actionManager: ActionManager,
  90587. /** defines the predicate function used to validate the condition */
  90588. predicate: () => boolean);
  90589. /**
  90590. * @returns the validity of the predicate condition
  90591. */
  90592. isValid(): boolean;
  90593. }
  90594. /**
  90595. * Defines a state condition as an extension of Condition
  90596. */
  90597. export class StateCondition extends Condition {
  90598. /** Value to compare with target state */
  90599. value: string;
  90600. /**
  90601. * Internal only - manager for action
  90602. * @hidden
  90603. */
  90604. _actionManager: ActionManager;
  90605. /**
  90606. * Internal only
  90607. * @hidden
  90608. */
  90609. private _target;
  90610. /**
  90611. * Creates a new StateCondition
  90612. * @param actionManager manager for the action the condition applies to
  90613. * @param target of the condition
  90614. * @param value to compare with target state
  90615. */
  90616. constructor(actionManager: ActionManager, target: any,
  90617. /** Value to compare with target state */
  90618. value: string);
  90619. /**
  90620. * Gets a boolean indicating if the current condition is met
  90621. * @returns the validity of the state
  90622. */
  90623. isValid(): boolean;
  90624. /**
  90625. * Serialize the StateCondition into a JSON compatible object
  90626. * @returns serialization object
  90627. */
  90628. serialize(): any;
  90629. }
  90630. }
  90631. declare module BABYLON {
  90632. /**
  90633. * This defines an action responsible to toggle a boolean once triggered.
  90634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90635. */
  90636. export class SwitchBooleanAction extends Action {
  90637. /**
  90638. * The path to the boolean property in the target object
  90639. */
  90640. propertyPath: string;
  90641. private _target;
  90642. private _effectiveTarget;
  90643. private _property;
  90644. /**
  90645. * Instantiate the action
  90646. * @param triggerOptions defines the trigger options
  90647. * @param target defines the object containing the boolean
  90648. * @param propertyPath defines the path to the boolean property in the target object
  90649. * @param condition defines the trigger related conditions
  90650. */
  90651. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90652. /** @hidden */
  90653. _prepare(): void;
  90654. /**
  90655. * Execute the action toggle the boolean value.
  90656. */
  90657. execute(): void;
  90658. /**
  90659. * Serializes the actions and its related information.
  90660. * @param parent defines the object to serialize in
  90661. * @returns the serialized object
  90662. */
  90663. serialize(parent: any): any;
  90664. }
  90665. /**
  90666. * This defines an action responsible to set a the state field of the target
  90667. * to a desired value once triggered.
  90668. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90669. */
  90670. export class SetStateAction extends Action {
  90671. /**
  90672. * The value to store in the state field.
  90673. */
  90674. value: string;
  90675. private _target;
  90676. /**
  90677. * Instantiate the action
  90678. * @param triggerOptions defines the trigger options
  90679. * @param target defines the object containing the state property
  90680. * @param value defines the value to store in the state field
  90681. * @param condition defines the trigger related conditions
  90682. */
  90683. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90684. /**
  90685. * Execute the action and store the value on the target state property.
  90686. */
  90687. execute(): void;
  90688. /**
  90689. * Serializes the actions and its related information.
  90690. * @param parent defines the object to serialize in
  90691. * @returns the serialized object
  90692. */
  90693. serialize(parent: any): any;
  90694. }
  90695. /**
  90696. * This defines an action responsible to set a property of the target
  90697. * to a desired value once triggered.
  90698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90699. */
  90700. export class SetValueAction extends Action {
  90701. /**
  90702. * The path of the property to set in the target.
  90703. */
  90704. propertyPath: string;
  90705. /**
  90706. * The value to set in the property
  90707. */
  90708. value: any;
  90709. private _target;
  90710. private _effectiveTarget;
  90711. private _property;
  90712. /**
  90713. * Instantiate the action
  90714. * @param triggerOptions defines the trigger options
  90715. * @param target defines the object containing the property
  90716. * @param propertyPath defines the path of the property to set in the target
  90717. * @param value defines the value to set in the property
  90718. * @param condition defines the trigger related conditions
  90719. */
  90720. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90721. /** @hidden */
  90722. _prepare(): void;
  90723. /**
  90724. * Execute the action and set the targetted property to the desired value.
  90725. */
  90726. execute(): void;
  90727. /**
  90728. * Serializes the actions and its related information.
  90729. * @param parent defines the object to serialize in
  90730. * @returns the serialized object
  90731. */
  90732. serialize(parent: any): any;
  90733. }
  90734. /**
  90735. * This defines an action responsible to increment the target value
  90736. * to a desired value once triggered.
  90737. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90738. */
  90739. export class IncrementValueAction extends Action {
  90740. /**
  90741. * The path of the property to increment in the target.
  90742. */
  90743. propertyPath: string;
  90744. /**
  90745. * The value we should increment the property by.
  90746. */
  90747. value: any;
  90748. private _target;
  90749. private _effectiveTarget;
  90750. private _property;
  90751. /**
  90752. * Instantiate the action
  90753. * @param triggerOptions defines the trigger options
  90754. * @param target defines the object containing the property
  90755. * @param propertyPath defines the path of the property to increment in the target
  90756. * @param value defines the value value we should increment the property by
  90757. * @param condition defines the trigger related conditions
  90758. */
  90759. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90760. /** @hidden */
  90761. _prepare(): void;
  90762. /**
  90763. * Execute the action and increment the target of the value amount.
  90764. */
  90765. execute(): void;
  90766. /**
  90767. * Serializes the actions and its related information.
  90768. * @param parent defines the object to serialize in
  90769. * @returns the serialized object
  90770. */
  90771. serialize(parent: any): any;
  90772. }
  90773. /**
  90774. * This defines an action responsible to start an animation once triggered.
  90775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90776. */
  90777. export class PlayAnimationAction extends Action {
  90778. /**
  90779. * Where the animation should start (animation frame)
  90780. */
  90781. from: number;
  90782. /**
  90783. * Where the animation should stop (animation frame)
  90784. */
  90785. to: number;
  90786. /**
  90787. * Define if the animation should loop or stop after the first play.
  90788. */
  90789. loop?: boolean;
  90790. private _target;
  90791. /**
  90792. * Instantiate the action
  90793. * @param triggerOptions defines the trigger options
  90794. * @param target defines the target animation or animation name
  90795. * @param from defines from where the animation should start (animation frame)
  90796. * @param end defines where the animation should stop (animation frame)
  90797. * @param loop defines if the animation should loop or stop after the first play
  90798. * @param condition defines the trigger related conditions
  90799. */
  90800. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90801. /** @hidden */
  90802. _prepare(): void;
  90803. /**
  90804. * Execute the action and play the animation.
  90805. */
  90806. execute(): void;
  90807. /**
  90808. * Serializes the actions and its related information.
  90809. * @param parent defines the object to serialize in
  90810. * @returns the serialized object
  90811. */
  90812. serialize(parent: any): any;
  90813. }
  90814. /**
  90815. * This defines an action responsible to stop an animation once triggered.
  90816. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90817. */
  90818. export class StopAnimationAction extends Action {
  90819. private _target;
  90820. /**
  90821. * Instantiate the action
  90822. * @param triggerOptions defines the trigger options
  90823. * @param target defines the target animation or animation name
  90824. * @param condition defines the trigger related conditions
  90825. */
  90826. constructor(triggerOptions: any, target: any, condition?: Condition);
  90827. /** @hidden */
  90828. _prepare(): void;
  90829. /**
  90830. * Execute the action and stop the animation.
  90831. */
  90832. execute(): void;
  90833. /**
  90834. * Serializes the actions and its related information.
  90835. * @param parent defines the object to serialize in
  90836. * @returns the serialized object
  90837. */
  90838. serialize(parent: any): any;
  90839. }
  90840. /**
  90841. * This defines an action responsible that does nothing once triggered.
  90842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90843. */
  90844. export class DoNothingAction extends Action {
  90845. /**
  90846. * Instantiate the action
  90847. * @param triggerOptions defines the trigger options
  90848. * @param condition defines the trigger related conditions
  90849. */
  90850. constructor(triggerOptions?: any, condition?: Condition);
  90851. /**
  90852. * Execute the action and do nothing.
  90853. */
  90854. execute(): void;
  90855. /**
  90856. * Serializes the actions and its related information.
  90857. * @param parent defines the object to serialize in
  90858. * @returns the serialized object
  90859. */
  90860. serialize(parent: any): any;
  90861. }
  90862. /**
  90863. * This defines an action responsible to trigger several actions once triggered.
  90864. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90865. */
  90866. export class CombineAction extends Action {
  90867. /**
  90868. * The list of aggregated animations to run.
  90869. */
  90870. children: Action[];
  90871. /**
  90872. * Instantiate the action
  90873. * @param triggerOptions defines the trigger options
  90874. * @param children defines the list of aggregated animations to run
  90875. * @param condition defines the trigger related conditions
  90876. */
  90877. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90878. /** @hidden */
  90879. _prepare(): void;
  90880. /**
  90881. * Execute the action and executes all the aggregated actions.
  90882. */
  90883. execute(evt: ActionEvent): void;
  90884. /**
  90885. * Serializes the actions and its related information.
  90886. * @param parent defines the object to serialize in
  90887. * @returns the serialized object
  90888. */
  90889. serialize(parent: any): any;
  90890. }
  90891. /**
  90892. * This defines an action responsible to run code (external event) once triggered.
  90893. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90894. */
  90895. export class ExecuteCodeAction extends Action {
  90896. /**
  90897. * The callback function to run.
  90898. */
  90899. func: (evt: ActionEvent) => void;
  90900. /**
  90901. * Instantiate the action
  90902. * @param triggerOptions defines the trigger options
  90903. * @param func defines the callback function to run
  90904. * @param condition defines the trigger related conditions
  90905. */
  90906. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90907. /**
  90908. * Execute the action and run the attached code.
  90909. */
  90910. execute(evt: ActionEvent): void;
  90911. }
  90912. /**
  90913. * This defines an action responsible to set the parent property of the target once triggered.
  90914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90915. */
  90916. export class SetParentAction extends Action {
  90917. private _parent;
  90918. private _target;
  90919. /**
  90920. * Instantiate the action
  90921. * @param triggerOptions defines the trigger options
  90922. * @param target defines the target containing the parent property
  90923. * @param parent defines from where the animation should start (animation frame)
  90924. * @param condition defines the trigger related conditions
  90925. */
  90926. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90927. /** @hidden */
  90928. _prepare(): void;
  90929. /**
  90930. * Execute the action and set the parent property.
  90931. */
  90932. execute(): void;
  90933. /**
  90934. * Serializes the actions and its related information.
  90935. * @param parent defines the object to serialize in
  90936. * @returns the serialized object
  90937. */
  90938. serialize(parent: any): any;
  90939. }
  90940. }
  90941. declare module BABYLON {
  90942. /**
  90943. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90944. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90946. */
  90947. export class ActionManager extends AbstractActionManager {
  90948. /**
  90949. * Nothing
  90950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90951. */
  90952. static readonly NothingTrigger: number;
  90953. /**
  90954. * On pick
  90955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90956. */
  90957. static readonly OnPickTrigger: number;
  90958. /**
  90959. * On left pick
  90960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90961. */
  90962. static readonly OnLeftPickTrigger: number;
  90963. /**
  90964. * On right pick
  90965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90966. */
  90967. static readonly OnRightPickTrigger: number;
  90968. /**
  90969. * On center pick
  90970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90971. */
  90972. static readonly OnCenterPickTrigger: number;
  90973. /**
  90974. * On pick down
  90975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90976. */
  90977. static readonly OnPickDownTrigger: number;
  90978. /**
  90979. * On double pick
  90980. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90981. */
  90982. static readonly OnDoublePickTrigger: number;
  90983. /**
  90984. * On pick up
  90985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90986. */
  90987. static readonly OnPickUpTrigger: number;
  90988. /**
  90989. * On pick out.
  90990. * This trigger will only be raised if you also declared a OnPickDown
  90991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90992. */
  90993. static readonly OnPickOutTrigger: number;
  90994. /**
  90995. * On long press
  90996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90997. */
  90998. static readonly OnLongPressTrigger: number;
  90999. /**
  91000. * On pointer over
  91001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91002. */
  91003. static readonly OnPointerOverTrigger: number;
  91004. /**
  91005. * On pointer out
  91006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91007. */
  91008. static readonly OnPointerOutTrigger: number;
  91009. /**
  91010. * On every frame
  91011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91012. */
  91013. static readonly OnEveryFrameTrigger: number;
  91014. /**
  91015. * On intersection enter
  91016. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91017. */
  91018. static readonly OnIntersectionEnterTrigger: number;
  91019. /**
  91020. * On intersection exit
  91021. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91022. */
  91023. static readonly OnIntersectionExitTrigger: number;
  91024. /**
  91025. * On key down
  91026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91027. */
  91028. static readonly OnKeyDownTrigger: number;
  91029. /**
  91030. * On key up
  91031. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91032. */
  91033. static readonly OnKeyUpTrigger: number;
  91034. private _scene;
  91035. /**
  91036. * Creates a new action manager
  91037. * @param scene defines the hosting scene
  91038. */
  91039. constructor(scene: Scene);
  91040. /**
  91041. * Releases all associated resources
  91042. */
  91043. dispose(): void;
  91044. /**
  91045. * Gets hosting scene
  91046. * @returns the hosting scene
  91047. */
  91048. getScene(): Scene;
  91049. /**
  91050. * Does this action manager handles actions of any of the given triggers
  91051. * @param triggers defines the triggers to be tested
  91052. * @return a boolean indicating whether one (or more) of the triggers is handled
  91053. */
  91054. hasSpecificTriggers(triggers: number[]): boolean;
  91055. /**
  91056. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91057. * speed.
  91058. * @param triggerA defines the trigger to be tested
  91059. * @param triggerB defines the trigger to be tested
  91060. * @return a boolean indicating whether one (or more) of the triggers is handled
  91061. */
  91062. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91063. /**
  91064. * Does this action manager handles actions of a given trigger
  91065. * @param trigger defines the trigger to be tested
  91066. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91067. * @return whether the trigger is handled
  91068. */
  91069. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91070. /**
  91071. * Does this action manager has pointer triggers
  91072. */
  91073. get hasPointerTriggers(): boolean;
  91074. /**
  91075. * Does this action manager has pick triggers
  91076. */
  91077. get hasPickTriggers(): boolean;
  91078. /**
  91079. * Registers an action to this action manager
  91080. * @param action defines the action to be registered
  91081. * @return the action amended (prepared) after registration
  91082. */
  91083. registerAction(action: IAction): Nullable<IAction>;
  91084. /**
  91085. * Unregisters an action to this action manager
  91086. * @param action defines the action to be unregistered
  91087. * @return a boolean indicating whether the action has been unregistered
  91088. */
  91089. unregisterAction(action: IAction): Boolean;
  91090. /**
  91091. * Process a specific trigger
  91092. * @param trigger defines the trigger to process
  91093. * @param evt defines the event details to be processed
  91094. */
  91095. processTrigger(trigger: number, evt?: IActionEvent): void;
  91096. /** @hidden */
  91097. _getEffectiveTarget(target: any, propertyPath: string): any;
  91098. /** @hidden */
  91099. _getProperty(propertyPath: string): string;
  91100. /**
  91101. * Serialize this manager to a JSON object
  91102. * @param name defines the property name to store this manager
  91103. * @returns a JSON representation of this manager
  91104. */
  91105. serialize(name: string): any;
  91106. /**
  91107. * Creates a new ActionManager from a JSON data
  91108. * @param parsedActions defines the JSON data to read from
  91109. * @param object defines the hosting mesh
  91110. * @param scene defines the hosting scene
  91111. */
  91112. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91113. /**
  91114. * Get a trigger name by index
  91115. * @param trigger defines the trigger index
  91116. * @returns a trigger name
  91117. */
  91118. static GetTriggerName(trigger: number): string;
  91119. }
  91120. }
  91121. declare module BABYLON {
  91122. /**
  91123. * Class used to represent a sprite
  91124. * @see https://doc.babylonjs.com/babylon101/sprites
  91125. */
  91126. export class Sprite implements IAnimatable {
  91127. /** defines the name */
  91128. name: string;
  91129. /** Gets or sets the current world position */
  91130. position: Vector3;
  91131. /** Gets or sets the main color */
  91132. color: Color4;
  91133. /** Gets or sets the width */
  91134. width: number;
  91135. /** Gets or sets the height */
  91136. height: number;
  91137. /** Gets or sets rotation angle */
  91138. angle: number;
  91139. /** Gets or sets the cell index in the sprite sheet */
  91140. cellIndex: number;
  91141. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91142. cellRef: string;
  91143. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91144. invertU: boolean;
  91145. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91146. invertV: boolean;
  91147. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91148. disposeWhenFinishedAnimating: boolean;
  91149. /** Gets the list of attached animations */
  91150. animations: Nullable<Array<Animation>>;
  91151. /** Gets or sets a boolean indicating if the sprite can be picked */
  91152. isPickable: boolean;
  91153. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91154. useAlphaForPicking: boolean;
  91155. /** @hidden */
  91156. _xOffset: number;
  91157. /** @hidden */
  91158. _yOffset: number;
  91159. /** @hidden */
  91160. _xSize: number;
  91161. /** @hidden */
  91162. _ySize: number;
  91163. /**
  91164. * Gets or sets the associated action manager
  91165. */
  91166. actionManager: Nullable<ActionManager>;
  91167. /**
  91168. * An event triggered when the control has been disposed
  91169. */
  91170. onDisposeObservable: Observable<Sprite>;
  91171. private _animationStarted;
  91172. private _loopAnimation;
  91173. private _fromIndex;
  91174. private _toIndex;
  91175. private _delay;
  91176. private _direction;
  91177. private _manager;
  91178. private _time;
  91179. private _onAnimationEnd;
  91180. /**
  91181. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91182. */
  91183. isVisible: boolean;
  91184. /**
  91185. * Gets or sets the sprite size
  91186. */
  91187. get size(): number;
  91188. set size(value: number);
  91189. /**
  91190. * Returns a boolean indicating if the animation is started
  91191. */
  91192. get animationStarted(): boolean;
  91193. /**
  91194. * Gets or sets the unique id of the sprite
  91195. */
  91196. uniqueId: number;
  91197. /**
  91198. * Gets the manager of this sprite
  91199. */
  91200. get manager(): ISpriteManager;
  91201. /**
  91202. * Creates a new Sprite
  91203. * @param name defines the name
  91204. * @param manager defines the manager
  91205. */
  91206. constructor(
  91207. /** defines the name */
  91208. name: string, manager: ISpriteManager);
  91209. /**
  91210. * Returns the string "Sprite"
  91211. * @returns "Sprite"
  91212. */
  91213. getClassName(): string;
  91214. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91215. get fromIndex(): number;
  91216. set fromIndex(value: number);
  91217. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91218. get toIndex(): number;
  91219. set toIndex(value: number);
  91220. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91221. get loopAnimation(): boolean;
  91222. set loopAnimation(value: boolean);
  91223. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91224. get delay(): number;
  91225. set delay(value: number);
  91226. /**
  91227. * Starts an animation
  91228. * @param from defines the initial key
  91229. * @param to defines the end key
  91230. * @param loop defines if the animation must loop
  91231. * @param delay defines the start delay (in ms)
  91232. * @param onAnimationEnd defines a callback to call when animation ends
  91233. */
  91234. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91235. /** Stops current animation (if any) */
  91236. stopAnimation(): void;
  91237. /** @hidden */
  91238. _animate(deltaTime: number): void;
  91239. /** Release associated resources */
  91240. dispose(): void;
  91241. /**
  91242. * Serializes the sprite to a JSON object
  91243. * @returns the JSON object
  91244. */
  91245. serialize(): any;
  91246. /**
  91247. * Parses a JSON object to create a new sprite
  91248. * @param parsedSprite The JSON object to parse
  91249. * @param manager defines the hosting manager
  91250. * @returns the new sprite
  91251. */
  91252. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91253. }
  91254. }
  91255. declare module BABYLON {
  91256. /**
  91257. * Information about the result of picking within a scene
  91258. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91259. */
  91260. export class PickingInfo {
  91261. /** @hidden */
  91262. _pickingUnavailable: boolean;
  91263. /**
  91264. * If the pick collided with an object
  91265. */
  91266. hit: boolean;
  91267. /**
  91268. * Distance away where the pick collided
  91269. */
  91270. distance: number;
  91271. /**
  91272. * The location of pick collision
  91273. */
  91274. pickedPoint: Nullable<Vector3>;
  91275. /**
  91276. * The mesh corresponding the the pick collision
  91277. */
  91278. pickedMesh: Nullable<AbstractMesh>;
  91279. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91280. bu: number;
  91281. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91282. bv: number;
  91283. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91284. faceId: number;
  91285. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91286. subMeshFaceId: number;
  91287. /** Id of the the submesh that was picked */
  91288. subMeshId: number;
  91289. /** If a sprite was picked, this will be the sprite the pick collided with */
  91290. pickedSprite: Nullable<Sprite>;
  91291. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91292. thinInstanceIndex: number;
  91293. /**
  91294. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91295. */
  91296. originMesh: Nullable<AbstractMesh>;
  91297. /**
  91298. * The ray that was used to perform the picking.
  91299. */
  91300. ray: Nullable<Ray>;
  91301. /**
  91302. * Gets the normal correspodning to the face the pick collided with
  91303. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91304. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91305. * @returns The normal correspodning to the face the pick collided with
  91306. */
  91307. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91308. /**
  91309. * Gets the texture coordinates of where the pick occured
  91310. * @returns the vector containing the coordnates of the texture
  91311. */
  91312. getTextureCoordinates(): Nullable<Vector2>;
  91313. }
  91314. }
  91315. declare module BABYLON {
  91316. /**
  91317. * Class representing a ray with position and direction
  91318. */
  91319. export class Ray {
  91320. /** origin point */
  91321. origin: Vector3;
  91322. /** direction */
  91323. direction: Vector3;
  91324. /** length of the ray */
  91325. length: number;
  91326. private static readonly _TmpVector3;
  91327. private _tmpRay;
  91328. /**
  91329. * Creates a new ray
  91330. * @param origin origin point
  91331. * @param direction direction
  91332. * @param length length of the ray
  91333. */
  91334. constructor(
  91335. /** origin point */
  91336. origin: Vector3,
  91337. /** direction */
  91338. direction: Vector3,
  91339. /** length of the ray */
  91340. length?: number);
  91341. /**
  91342. * Checks if the ray intersects a box
  91343. * This does not account for the ray lenght by design to improve perfs.
  91344. * @param minimum bound of the box
  91345. * @param maximum bound of the box
  91346. * @param intersectionTreshold extra extend to be added to the box in all direction
  91347. * @returns if the box was hit
  91348. */
  91349. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91350. /**
  91351. * Checks if the ray intersects a box
  91352. * This does not account for the ray lenght by design to improve perfs.
  91353. * @param box the bounding box to check
  91354. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91355. * @returns if the box was hit
  91356. */
  91357. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91358. /**
  91359. * If the ray hits a sphere
  91360. * @param sphere the bounding sphere to check
  91361. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91362. * @returns true if it hits the sphere
  91363. */
  91364. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91365. /**
  91366. * If the ray hits a triange
  91367. * @param vertex0 triangle vertex
  91368. * @param vertex1 triangle vertex
  91369. * @param vertex2 triangle vertex
  91370. * @returns intersection information if hit
  91371. */
  91372. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91373. /**
  91374. * Checks if ray intersects a plane
  91375. * @param plane the plane to check
  91376. * @returns the distance away it was hit
  91377. */
  91378. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91379. /**
  91380. * Calculate the intercept of a ray on a given axis
  91381. * @param axis to check 'x' | 'y' | 'z'
  91382. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91383. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91384. */
  91385. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91386. /**
  91387. * Checks if ray intersects a mesh
  91388. * @param mesh the mesh to check
  91389. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91390. * @returns picking info of the intersecton
  91391. */
  91392. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91393. /**
  91394. * Checks if ray intersects a mesh
  91395. * @param meshes the meshes to check
  91396. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91397. * @param results array to store result in
  91398. * @returns Array of picking infos
  91399. */
  91400. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91401. private _comparePickingInfo;
  91402. private static smallnum;
  91403. private static rayl;
  91404. /**
  91405. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91406. * @param sega the first point of the segment to test the intersection against
  91407. * @param segb the second point of the segment to test the intersection against
  91408. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91409. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91410. */
  91411. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91412. /**
  91413. * Update the ray from viewport position
  91414. * @param x position
  91415. * @param y y position
  91416. * @param viewportWidth viewport width
  91417. * @param viewportHeight viewport height
  91418. * @param world world matrix
  91419. * @param view view matrix
  91420. * @param projection projection matrix
  91421. * @returns this ray updated
  91422. */
  91423. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91424. /**
  91425. * Creates a ray with origin and direction of 0,0,0
  91426. * @returns the new ray
  91427. */
  91428. static Zero(): Ray;
  91429. /**
  91430. * Creates a new ray from screen space and viewport
  91431. * @param x position
  91432. * @param y y position
  91433. * @param viewportWidth viewport width
  91434. * @param viewportHeight viewport height
  91435. * @param world world matrix
  91436. * @param view view matrix
  91437. * @param projection projection matrix
  91438. * @returns new ray
  91439. */
  91440. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91441. /**
  91442. * 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
  91443. * transformed to the given world matrix.
  91444. * @param origin The origin point
  91445. * @param end The end point
  91446. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91447. * @returns the new ray
  91448. */
  91449. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91450. /**
  91451. * Transforms a ray by a matrix
  91452. * @param ray ray to transform
  91453. * @param matrix matrix to apply
  91454. * @returns the resulting new ray
  91455. */
  91456. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91457. /**
  91458. * Transforms a ray by a matrix
  91459. * @param ray ray to transform
  91460. * @param matrix matrix to apply
  91461. * @param result ray to store result in
  91462. */
  91463. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91464. /**
  91465. * Unproject a ray from screen space to object space
  91466. * @param sourceX defines the screen space x coordinate to use
  91467. * @param sourceY defines the screen space y coordinate to use
  91468. * @param viewportWidth defines the current width of the viewport
  91469. * @param viewportHeight defines the current height of the viewport
  91470. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91471. * @param view defines the view matrix to use
  91472. * @param projection defines the projection matrix to use
  91473. */
  91474. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91475. }
  91476. /**
  91477. * Type used to define predicate used to select faces when a mesh intersection is detected
  91478. */
  91479. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91480. interface Scene {
  91481. /** @hidden */
  91482. _tempPickingRay: Nullable<Ray>;
  91483. /** @hidden */
  91484. _cachedRayForTransform: Ray;
  91485. /** @hidden */
  91486. _pickWithRayInverseMatrix: Matrix;
  91487. /** @hidden */
  91488. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91489. /** @hidden */
  91490. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91491. /** @hidden */
  91492. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91493. }
  91494. }
  91495. declare module BABYLON {
  91496. /**
  91497. * Groups all the scene component constants in one place to ease maintenance.
  91498. * @hidden
  91499. */
  91500. export class SceneComponentConstants {
  91501. static readonly NAME_EFFECTLAYER: string;
  91502. static readonly NAME_LAYER: string;
  91503. static readonly NAME_LENSFLARESYSTEM: string;
  91504. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91505. static readonly NAME_PARTICLESYSTEM: string;
  91506. static readonly NAME_GAMEPAD: string;
  91507. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91508. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91509. static readonly NAME_PREPASSRENDERER: string;
  91510. static readonly NAME_DEPTHRENDERER: string;
  91511. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91512. static readonly NAME_SPRITE: string;
  91513. static readonly NAME_SUBSURFACE: string;
  91514. static readonly NAME_OUTLINERENDERER: string;
  91515. static readonly NAME_PROCEDURALTEXTURE: string;
  91516. static readonly NAME_SHADOWGENERATOR: string;
  91517. static readonly NAME_OCTREE: string;
  91518. static readonly NAME_PHYSICSENGINE: string;
  91519. static readonly NAME_AUDIO: string;
  91520. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91521. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91522. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91523. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91524. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91525. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91526. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91527. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91528. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91529. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91530. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91531. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91532. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91533. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91534. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91535. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91536. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91537. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91538. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91539. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91540. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91541. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91542. static readonly STEP_AFTERRENDER_AUDIO: number;
  91543. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91544. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91545. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91546. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91547. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91548. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91549. static readonly STEP_POINTERMOVE_SPRITE: number;
  91550. static readonly STEP_POINTERDOWN_SPRITE: number;
  91551. static readonly STEP_POINTERUP_SPRITE: number;
  91552. }
  91553. /**
  91554. * This represents a scene component.
  91555. *
  91556. * This is used to decouple the dependency the scene is having on the different workloads like
  91557. * layers, post processes...
  91558. */
  91559. export interface ISceneComponent {
  91560. /**
  91561. * The name of the component. Each component must have a unique name.
  91562. */
  91563. name: string;
  91564. /**
  91565. * The scene the component belongs to.
  91566. */
  91567. scene: Scene;
  91568. /**
  91569. * Register the component to one instance of a scene.
  91570. */
  91571. register(): void;
  91572. /**
  91573. * Rebuilds the elements related to this component in case of
  91574. * context lost for instance.
  91575. */
  91576. rebuild(): void;
  91577. /**
  91578. * Disposes the component and the associated ressources.
  91579. */
  91580. dispose(): void;
  91581. }
  91582. /**
  91583. * This represents a SERIALIZABLE scene component.
  91584. *
  91585. * This extends Scene Component to add Serialization methods on top.
  91586. */
  91587. export interface ISceneSerializableComponent extends ISceneComponent {
  91588. /**
  91589. * Adds all the elements from the container to the scene
  91590. * @param container the container holding the elements
  91591. */
  91592. addFromContainer(container: AbstractScene): void;
  91593. /**
  91594. * Removes all the elements in the container from the scene
  91595. * @param container contains the elements to remove
  91596. * @param dispose if the removed element should be disposed (default: false)
  91597. */
  91598. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91599. /**
  91600. * Serializes the component data to the specified json object
  91601. * @param serializationObject The object to serialize to
  91602. */
  91603. serialize(serializationObject: any): void;
  91604. }
  91605. /**
  91606. * Strong typing of a Mesh related stage step action
  91607. */
  91608. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91609. /**
  91610. * Strong typing of a Evaluate Sub Mesh related stage step action
  91611. */
  91612. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91613. /**
  91614. * Strong typing of a Active Mesh related stage step action
  91615. */
  91616. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91617. /**
  91618. * Strong typing of a Camera related stage step action
  91619. */
  91620. export type CameraStageAction = (camera: Camera) => void;
  91621. /**
  91622. * Strong typing of a Camera Frame buffer related stage step action
  91623. */
  91624. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91625. /**
  91626. * Strong typing of a Render Target related stage step action
  91627. */
  91628. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91629. /**
  91630. * Strong typing of a RenderingGroup related stage step action
  91631. */
  91632. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91633. /**
  91634. * Strong typing of a Mesh Render related stage step action
  91635. */
  91636. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91637. /**
  91638. * Strong typing of a simple stage step action
  91639. */
  91640. export type SimpleStageAction = () => void;
  91641. /**
  91642. * Strong typing of a render target action.
  91643. */
  91644. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91645. /**
  91646. * Strong typing of a pointer move action.
  91647. */
  91648. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91649. /**
  91650. * Strong typing of a pointer up/down action.
  91651. */
  91652. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91653. /**
  91654. * Representation of a stage in the scene (Basically a list of ordered steps)
  91655. * @hidden
  91656. */
  91657. export class Stage<T extends Function> extends Array<{
  91658. index: number;
  91659. component: ISceneComponent;
  91660. action: T;
  91661. }> {
  91662. /**
  91663. * Hide ctor from the rest of the world.
  91664. * @param items The items to add.
  91665. */
  91666. private constructor();
  91667. /**
  91668. * Creates a new Stage.
  91669. * @returns A new instance of a Stage
  91670. */
  91671. static Create<T extends Function>(): Stage<T>;
  91672. /**
  91673. * Registers a step in an ordered way in the targeted stage.
  91674. * @param index Defines the position to register the step in
  91675. * @param component Defines the component attached to the step
  91676. * @param action Defines the action to launch during the step
  91677. */
  91678. registerStep(index: number, component: ISceneComponent, action: T): void;
  91679. /**
  91680. * Clears all the steps from the stage.
  91681. */
  91682. clear(): void;
  91683. }
  91684. }
  91685. declare module BABYLON {
  91686. interface Scene {
  91687. /** @hidden */
  91688. _pointerOverSprite: Nullable<Sprite>;
  91689. /** @hidden */
  91690. _pickedDownSprite: Nullable<Sprite>;
  91691. /** @hidden */
  91692. _tempSpritePickingRay: Nullable<Ray>;
  91693. /**
  91694. * All of the sprite managers added to this scene
  91695. * @see https://doc.babylonjs.com/babylon101/sprites
  91696. */
  91697. spriteManagers: Array<ISpriteManager>;
  91698. /**
  91699. * An event triggered when sprites rendering is about to start
  91700. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91701. */
  91702. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91703. /**
  91704. * An event triggered when sprites rendering is done
  91705. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91706. */
  91707. onAfterSpritesRenderingObservable: Observable<Scene>;
  91708. /** @hidden */
  91709. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91710. /** Launch a ray to try to pick a sprite in the scene
  91711. * @param x position on screen
  91712. * @param y position on screen
  91713. * @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
  91714. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91715. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91716. * @returns a PickingInfo
  91717. */
  91718. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91719. /** Use the given ray to pick a sprite in the scene
  91720. * @param ray The ray (in world space) to use to pick meshes
  91721. * @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
  91722. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91723. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91724. * @returns a PickingInfo
  91725. */
  91726. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91727. /** @hidden */
  91728. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91729. /** Launch a ray to try to pick sprites in the scene
  91730. * @param x position on screen
  91731. * @param y position on screen
  91732. * @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
  91733. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91734. * @returns a PickingInfo array
  91735. */
  91736. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91737. /** Use the given ray to pick sprites in the scene
  91738. * @param ray The ray (in world space) to use to pick meshes
  91739. * @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
  91740. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91741. * @returns a PickingInfo array
  91742. */
  91743. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91744. /**
  91745. * Force the sprite under the pointer
  91746. * @param sprite defines the sprite to use
  91747. */
  91748. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91749. /**
  91750. * Gets the sprite under the pointer
  91751. * @returns a Sprite or null if no sprite is under the pointer
  91752. */
  91753. getPointerOverSprite(): Nullable<Sprite>;
  91754. }
  91755. /**
  91756. * Defines the sprite scene component responsible to manage sprites
  91757. * in a given scene.
  91758. */
  91759. export class SpriteSceneComponent implements ISceneComponent {
  91760. /**
  91761. * The component name helpfull to identify the component in the list of scene components.
  91762. */
  91763. readonly name: string;
  91764. /**
  91765. * The scene the component belongs to.
  91766. */
  91767. scene: Scene;
  91768. /** @hidden */
  91769. private _spritePredicate;
  91770. /**
  91771. * Creates a new instance of the component for the given scene
  91772. * @param scene Defines the scene to register the component in
  91773. */
  91774. constructor(scene: Scene);
  91775. /**
  91776. * Registers the component in a given scene
  91777. */
  91778. register(): void;
  91779. /**
  91780. * Rebuilds the elements related to this component in case of
  91781. * context lost for instance.
  91782. */
  91783. rebuild(): void;
  91784. /**
  91785. * Disposes the component and the associated ressources.
  91786. */
  91787. dispose(): void;
  91788. private _pickSpriteButKeepRay;
  91789. private _pointerMove;
  91790. private _pointerDown;
  91791. private _pointerUp;
  91792. }
  91793. }
  91794. declare module BABYLON {
  91795. /** @hidden */
  91796. export var fogFragmentDeclaration: {
  91797. name: string;
  91798. shader: string;
  91799. };
  91800. }
  91801. declare module BABYLON {
  91802. /** @hidden */
  91803. export var fogFragment: {
  91804. name: string;
  91805. shader: string;
  91806. };
  91807. }
  91808. declare module BABYLON {
  91809. /** @hidden */
  91810. export var imageProcessingCompatibility: {
  91811. name: string;
  91812. shader: string;
  91813. };
  91814. }
  91815. declare module BABYLON {
  91816. /** @hidden */
  91817. export var spritesPixelShader: {
  91818. name: string;
  91819. shader: string;
  91820. };
  91821. }
  91822. declare module BABYLON {
  91823. /** @hidden */
  91824. export var fogVertexDeclaration: {
  91825. name: string;
  91826. shader: string;
  91827. };
  91828. }
  91829. declare module BABYLON {
  91830. /** @hidden */
  91831. export var spritesVertexShader: {
  91832. name: string;
  91833. shader: string;
  91834. };
  91835. }
  91836. declare module BABYLON {
  91837. /**
  91838. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91839. */
  91840. export interface ISpriteManager extends IDisposable {
  91841. /**
  91842. * Gets manager's name
  91843. */
  91844. name: string;
  91845. /**
  91846. * Restricts the camera to viewing objects with the same layerMask.
  91847. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91848. */
  91849. layerMask: number;
  91850. /**
  91851. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91852. */
  91853. isPickable: boolean;
  91854. /**
  91855. * Gets the hosting scene
  91856. */
  91857. scene: Scene;
  91858. /**
  91859. * Specifies the rendering group id for this mesh (0 by default)
  91860. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91861. */
  91862. renderingGroupId: number;
  91863. /**
  91864. * Defines the list of sprites managed by the manager.
  91865. */
  91866. sprites: Array<Sprite>;
  91867. /**
  91868. * Gets or sets the spritesheet texture
  91869. */
  91870. texture: Texture;
  91871. /** Defines the default width of a cell in the spritesheet */
  91872. cellWidth: number;
  91873. /** Defines the default height of a cell in the spritesheet */
  91874. cellHeight: number;
  91875. /**
  91876. * Tests the intersection of a sprite with a specific ray.
  91877. * @param ray The ray we are sending to test the collision
  91878. * @param camera The camera space we are sending rays in
  91879. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91880. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91881. * @returns picking info or null.
  91882. */
  91883. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91884. /**
  91885. * Intersects the sprites with a ray
  91886. * @param ray defines the ray to intersect with
  91887. * @param camera defines the current active camera
  91888. * @param predicate defines a predicate used to select candidate sprites
  91889. * @returns null if no hit or a PickingInfo array
  91890. */
  91891. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91892. /**
  91893. * Renders the list of sprites on screen.
  91894. */
  91895. render(): void;
  91896. }
  91897. /**
  91898. * Class used to manage multiple sprites on the same spritesheet
  91899. * @see https://doc.babylonjs.com/babylon101/sprites
  91900. */
  91901. export class SpriteManager implements ISpriteManager {
  91902. /** defines the manager's name */
  91903. name: string;
  91904. /** Define the Url to load snippets */
  91905. static SnippetUrl: string;
  91906. /** Snippet ID if the manager was created from the snippet server */
  91907. snippetId: string;
  91908. /** Gets the list of sprites */
  91909. sprites: Sprite[];
  91910. /** Gets or sets the rendering group id (0 by default) */
  91911. renderingGroupId: number;
  91912. /** Gets or sets camera layer mask */
  91913. layerMask: number;
  91914. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91915. fogEnabled: boolean;
  91916. /** Gets or sets a boolean indicating if the sprites are pickable */
  91917. isPickable: boolean;
  91918. /** Defines the default width of a cell in the spritesheet */
  91919. cellWidth: number;
  91920. /** Defines the default height of a cell in the spritesheet */
  91921. cellHeight: number;
  91922. /** Associative array from JSON sprite data file */
  91923. private _cellData;
  91924. /** Array of sprite names from JSON sprite data file */
  91925. private _spriteMap;
  91926. /** True when packed cell data from JSON file is ready*/
  91927. private _packedAndReady;
  91928. private _textureContent;
  91929. private _useInstancing;
  91930. /**
  91931. * An event triggered when the manager is disposed.
  91932. */
  91933. onDisposeObservable: Observable<SpriteManager>;
  91934. private _onDisposeObserver;
  91935. /**
  91936. * Callback called when the manager is disposed
  91937. */
  91938. set onDispose(callback: () => void);
  91939. private _capacity;
  91940. private _fromPacked;
  91941. private _spriteTexture;
  91942. private _epsilon;
  91943. private _scene;
  91944. private _vertexData;
  91945. private _buffer;
  91946. private _vertexBuffers;
  91947. private _spriteBuffer;
  91948. private _indexBuffer;
  91949. private _effectBase;
  91950. private _effectFog;
  91951. private _vertexBufferSize;
  91952. /**
  91953. * Gets or sets the unique id of the sprite
  91954. */
  91955. uniqueId: number;
  91956. /**
  91957. * Gets the array of sprites
  91958. */
  91959. get children(): Sprite[];
  91960. /**
  91961. * Gets the hosting scene
  91962. */
  91963. get scene(): Scene;
  91964. /**
  91965. * Gets the capacity of the manager
  91966. */
  91967. get capacity(): number;
  91968. /**
  91969. * Gets or sets the spritesheet texture
  91970. */
  91971. get texture(): Texture;
  91972. set texture(value: Texture);
  91973. private _blendMode;
  91974. /**
  91975. * Blend mode use to render the particle, it can be any of
  91976. * the static Constants.ALPHA_x properties provided in this class.
  91977. * Default value is Constants.ALPHA_COMBINE
  91978. */
  91979. get blendMode(): number;
  91980. set blendMode(blendMode: number);
  91981. /** Disables writing to the depth buffer when rendering the sprites.
  91982. * It can be handy to disable depth writing when using textures without alpha channel
  91983. * and setting some specific blend modes.
  91984. */
  91985. disableDepthWrite: boolean;
  91986. /**
  91987. * Creates a new sprite manager
  91988. * @param name defines the manager's name
  91989. * @param imgUrl defines the sprite sheet url
  91990. * @param capacity defines the maximum allowed number of sprites
  91991. * @param cellSize defines the size of a sprite cell
  91992. * @param scene defines the hosting scene
  91993. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91994. * @param samplingMode defines the smapling mode to use with spritesheet
  91995. * @param fromPacked set to false; do not alter
  91996. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91997. */
  91998. constructor(
  91999. /** defines the manager's name */
  92000. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  92001. /**
  92002. * Returns the string "SpriteManager"
  92003. * @returns "SpriteManager"
  92004. */
  92005. getClassName(): string;
  92006. private _makePacked;
  92007. private _appendSpriteVertex;
  92008. private _checkTextureAlpha;
  92009. /**
  92010. * Intersects the sprites with a ray
  92011. * @param ray defines the ray to intersect with
  92012. * @param camera defines the current active camera
  92013. * @param predicate defines a predicate used to select candidate sprites
  92014. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  92015. * @returns null if no hit or a PickingInfo
  92016. */
  92017. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92018. /**
  92019. * Intersects the sprites with a ray
  92020. * @param ray defines the ray to intersect with
  92021. * @param camera defines the current active camera
  92022. * @param predicate defines a predicate used to select candidate sprites
  92023. * @returns null if no hit or a PickingInfo array
  92024. */
  92025. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92026. /**
  92027. * Render all child sprites
  92028. */
  92029. render(): void;
  92030. /**
  92031. * Release associated resources
  92032. */
  92033. dispose(): void;
  92034. /**
  92035. * Serializes the sprite manager to a JSON object
  92036. * @param serializeTexture defines if the texture must be serialized as well
  92037. * @returns the JSON object
  92038. */
  92039. serialize(serializeTexture?: boolean): any;
  92040. /**
  92041. * Parses a JSON object to create a new sprite manager.
  92042. * @param parsedManager The JSON object to parse
  92043. * @param scene The scene to create the sprite managerin
  92044. * @param rootUrl The root url to use to load external dependencies like texture
  92045. * @returns the new sprite manager
  92046. */
  92047. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92048. /**
  92049. * Creates a sprite manager from a snippet saved in a remote file
  92050. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92051. * @param url defines the url to load from
  92052. * @param scene defines the hosting scene
  92053. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92054. * @returns a promise that will resolve to the new sprite manager
  92055. */
  92056. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92057. /**
  92058. * Creates a sprite manager from a snippet saved by the sprite editor
  92059. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92060. * @param scene defines the hosting scene
  92061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92062. * @returns a promise that will resolve to the new sprite manager
  92063. */
  92064. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92065. }
  92066. }
  92067. declare module BABYLON {
  92068. /** Interface used by value gradients (color, factor, ...) */
  92069. export interface IValueGradient {
  92070. /**
  92071. * Gets or sets the gradient value (between 0 and 1)
  92072. */
  92073. gradient: number;
  92074. }
  92075. /** Class used to store color4 gradient */
  92076. export class ColorGradient implements IValueGradient {
  92077. /**
  92078. * Gets or sets the gradient value (between 0 and 1)
  92079. */
  92080. gradient: number;
  92081. /**
  92082. * Gets or sets first associated color
  92083. */
  92084. color1: Color4;
  92085. /**
  92086. * Gets or sets second associated color
  92087. */
  92088. color2?: Color4 | undefined;
  92089. /**
  92090. * Creates a new color4 gradient
  92091. * @param gradient gets or sets the gradient value (between 0 and 1)
  92092. * @param color1 gets or sets first associated color
  92093. * @param color2 gets or sets first second color
  92094. */
  92095. constructor(
  92096. /**
  92097. * Gets or sets the gradient value (between 0 and 1)
  92098. */
  92099. gradient: number,
  92100. /**
  92101. * Gets or sets first associated color
  92102. */
  92103. color1: Color4,
  92104. /**
  92105. * Gets or sets second associated color
  92106. */
  92107. color2?: Color4 | undefined);
  92108. /**
  92109. * Will get a color picked randomly between color1 and color2.
  92110. * If color2 is undefined then color1 will be used
  92111. * @param result defines the target Color4 to store the result in
  92112. */
  92113. getColorToRef(result: Color4): void;
  92114. }
  92115. /** Class used to store color 3 gradient */
  92116. export class Color3Gradient implements IValueGradient {
  92117. /**
  92118. * Gets or sets the gradient value (between 0 and 1)
  92119. */
  92120. gradient: number;
  92121. /**
  92122. * Gets or sets the associated color
  92123. */
  92124. color: Color3;
  92125. /**
  92126. * Creates a new color3 gradient
  92127. * @param gradient gets or sets the gradient value (between 0 and 1)
  92128. * @param color gets or sets associated color
  92129. */
  92130. constructor(
  92131. /**
  92132. * Gets or sets the gradient value (between 0 and 1)
  92133. */
  92134. gradient: number,
  92135. /**
  92136. * Gets or sets the associated color
  92137. */
  92138. color: Color3);
  92139. }
  92140. /** Class used to store factor gradient */
  92141. export class FactorGradient implements IValueGradient {
  92142. /**
  92143. * Gets or sets the gradient value (between 0 and 1)
  92144. */
  92145. gradient: number;
  92146. /**
  92147. * Gets or sets first associated factor
  92148. */
  92149. factor1: number;
  92150. /**
  92151. * Gets or sets second associated factor
  92152. */
  92153. factor2?: number | undefined;
  92154. /**
  92155. * Creates a new factor gradient
  92156. * @param gradient gets or sets the gradient value (between 0 and 1)
  92157. * @param factor1 gets or sets first associated factor
  92158. * @param factor2 gets or sets second associated factor
  92159. */
  92160. constructor(
  92161. /**
  92162. * Gets or sets the gradient value (between 0 and 1)
  92163. */
  92164. gradient: number,
  92165. /**
  92166. * Gets or sets first associated factor
  92167. */
  92168. factor1: number,
  92169. /**
  92170. * Gets or sets second associated factor
  92171. */
  92172. factor2?: number | undefined);
  92173. /**
  92174. * Will get a number picked randomly between factor1 and factor2.
  92175. * If factor2 is undefined then factor1 will be used
  92176. * @returns the picked number
  92177. */
  92178. getFactor(): number;
  92179. }
  92180. /**
  92181. * Helper used to simplify some generic gradient tasks
  92182. */
  92183. export class GradientHelper {
  92184. /**
  92185. * Gets the current gradient from an array of IValueGradient
  92186. * @param ratio defines the current ratio to get
  92187. * @param gradients defines the array of IValueGradient
  92188. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92189. */
  92190. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92191. }
  92192. }
  92193. declare module BABYLON {
  92194. interface ThinEngine {
  92195. /**
  92196. * Creates a raw texture
  92197. * @param data defines the data to store in the texture
  92198. * @param width defines the width of the texture
  92199. * @param height defines the height of the texture
  92200. * @param format defines the format of the data
  92201. * @param generateMipMaps defines if the engine should generate the mip levels
  92202. * @param invertY defines if data must be stored with Y axis inverted
  92203. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92204. * @param compression defines the compression used (null by default)
  92205. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92206. * @returns the raw texture inside an InternalTexture
  92207. */
  92208. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92209. /**
  92210. * Update a raw texture
  92211. * @param texture defines the texture to update
  92212. * @param data defines the data to store in the texture
  92213. * @param format defines the format of the data
  92214. * @param invertY defines if data must be stored with Y axis inverted
  92215. */
  92216. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92217. /**
  92218. * Update a raw texture
  92219. * @param texture defines the texture to update
  92220. * @param data defines the data to store in the texture
  92221. * @param format defines the format of the data
  92222. * @param invertY defines if data must be stored with Y axis inverted
  92223. * @param compression defines the compression used (null by default)
  92224. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92225. */
  92226. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92227. /**
  92228. * Creates a new raw cube texture
  92229. * @param data defines the array of data to use to create each face
  92230. * @param size defines the size of the textures
  92231. * @param format defines the format of the data
  92232. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92233. * @param generateMipMaps defines if the engine should generate the mip levels
  92234. * @param invertY defines if data must be stored with Y axis inverted
  92235. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92236. * @param compression defines the compression used (null by default)
  92237. * @returns the cube texture as an InternalTexture
  92238. */
  92239. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92240. /**
  92241. * Update a raw cube texture
  92242. * @param texture defines the texture to udpdate
  92243. * @param data defines the data to store
  92244. * @param format defines the data format
  92245. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92246. * @param invertY defines if data must be stored with Y axis inverted
  92247. */
  92248. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92249. /**
  92250. * Update a raw cube texture
  92251. * @param texture defines the texture to udpdate
  92252. * @param data defines the data to store
  92253. * @param format defines the data format
  92254. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92255. * @param invertY defines if data must be stored with Y axis inverted
  92256. * @param compression defines the compression used (null by default)
  92257. */
  92258. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92259. /**
  92260. * Update a raw cube texture
  92261. * @param texture defines the texture to udpdate
  92262. * @param data defines the data to store
  92263. * @param format defines the data format
  92264. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92265. * @param invertY defines if data must be stored with Y axis inverted
  92266. * @param compression defines the compression used (null by default)
  92267. * @param level defines which level of the texture to update
  92268. */
  92269. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92270. /**
  92271. * Creates a new raw cube texture from a specified url
  92272. * @param url defines the url where the data is located
  92273. * @param scene defines the current scene
  92274. * @param size defines the size of the textures
  92275. * @param format defines the format of the data
  92276. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92277. * @param noMipmap defines if the engine should avoid generating the mip levels
  92278. * @param callback defines a callback used to extract texture data from loaded data
  92279. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92280. * @param onLoad defines a callback called when texture is loaded
  92281. * @param onError defines a callback called if there is an error
  92282. * @returns the cube texture as an InternalTexture
  92283. */
  92284. 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;
  92285. /**
  92286. * Creates a new raw cube texture from a specified url
  92287. * @param url defines the url where the data is located
  92288. * @param scene defines the current scene
  92289. * @param size defines the size of the textures
  92290. * @param format defines the format of the data
  92291. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92292. * @param noMipmap defines if the engine should avoid generating the mip levels
  92293. * @param callback defines a callback used to extract texture data from loaded data
  92294. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92295. * @param onLoad defines a callback called when texture is loaded
  92296. * @param onError defines a callback called if there is an error
  92297. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92298. * @param invertY defines if data must be stored with Y axis inverted
  92299. * @returns the cube texture as an InternalTexture
  92300. */
  92301. 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;
  92302. /**
  92303. * Creates a new raw 3D texture
  92304. * @param data defines the data used to create the texture
  92305. * @param width defines the width of the texture
  92306. * @param height defines the height of the texture
  92307. * @param depth defines the depth of the texture
  92308. * @param format defines the format of the texture
  92309. * @param generateMipMaps defines if the engine must generate mip levels
  92310. * @param invertY defines if data must be stored with Y axis inverted
  92311. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92312. * @param compression defines the compressed used (can be null)
  92313. * @param textureType defines the compressed used (can be null)
  92314. * @returns a new raw 3D texture (stored in an InternalTexture)
  92315. */
  92316. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92317. /**
  92318. * Update a raw 3D texture
  92319. * @param texture defines the texture to update
  92320. * @param data defines the data to store
  92321. * @param format defines the data format
  92322. * @param invertY defines if data must be stored with Y axis inverted
  92323. */
  92324. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92325. /**
  92326. * Update a raw 3D texture
  92327. * @param texture defines the texture to update
  92328. * @param data defines the data to store
  92329. * @param format defines the data format
  92330. * @param invertY defines if data must be stored with Y axis inverted
  92331. * @param compression defines the used compression (can be null)
  92332. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92333. */
  92334. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92335. /**
  92336. * Creates a new raw 2D array texture
  92337. * @param data defines the data used to create the texture
  92338. * @param width defines the width of the texture
  92339. * @param height defines the height of the texture
  92340. * @param depth defines the number of layers of the texture
  92341. * @param format defines the format of the texture
  92342. * @param generateMipMaps defines if the engine must generate mip levels
  92343. * @param invertY defines if data must be stored with Y axis inverted
  92344. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92345. * @param compression defines the compressed used (can be null)
  92346. * @param textureType defines the compressed used (can be null)
  92347. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92348. */
  92349. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92350. /**
  92351. * Update a raw 2D array texture
  92352. * @param texture defines the texture to update
  92353. * @param data defines the data to store
  92354. * @param format defines the data format
  92355. * @param invertY defines if data must be stored with Y axis inverted
  92356. */
  92357. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92358. /**
  92359. * Update a raw 2D array texture
  92360. * @param texture defines the texture to update
  92361. * @param data defines the data to store
  92362. * @param format defines the data format
  92363. * @param invertY defines if data must be stored with Y axis inverted
  92364. * @param compression defines the used compression (can be null)
  92365. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92366. */
  92367. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92368. }
  92369. }
  92370. declare module BABYLON {
  92371. /**
  92372. * Raw texture can help creating a texture directly from an array of data.
  92373. * This can be super useful if you either get the data from an uncompressed source or
  92374. * if you wish to create your texture pixel by pixel.
  92375. */
  92376. export class RawTexture extends Texture {
  92377. /**
  92378. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92379. */
  92380. format: number;
  92381. /**
  92382. * Instantiates a new RawTexture.
  92383. * Raw texture can help creating a texture directly from an array of data.
  92384. * This can be super useful if you either get the data from an uncompressed source or
  92385. * if you wish to create your texture pixel by pixel.
  92386. * @param data define the array of data to use to create the texture
  92387. * @param width define the width of the texture
  92388. * @param height define the height of the texture
  92389. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92390. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92391. * @param generateMipMaps define whether mip maps should be generated or not
  92392. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92393. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92394. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92395. */
  92396. constructor(data: ArrayBufferView, width: number, height: number,
  92397. /**
  92398. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92399. */
  92400. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92401. /**
  92402. * Updates the texture underlying data.
  92403. * @param data Define the new data of the texture
  92404. */
  92405. update(data: ArrayBufferView): void;
  92406. /**
  92407. * Creates a luminance texture from some data.
  92408. * @param data Define the texture data
  92409. * @param width Define the width of the texture
  92410. * @param height Define the height of the texture
  92411. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92412. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92413. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92414. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92415. * @returns the luminance texture
  92416. */
  92417. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92418. /**
  92419. * Creates a luminance alpha texture from some data.
  92420. * @param data Define the texture data
  92421. * @param width Define the width of the texture
  92422. * @param height Define the height of the texture
  92423. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92424. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92425. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92426. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92427. * @returns the luminance alpha texture
  92428. */
  92429. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92430. /**
  92431. * Creates an alpha texture from some data.
  92432. * @param data Define the texture data
  92433. * @param width Define the width of the texture
  92434. * @param height Define the height of the texture
  92435. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92436. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92437. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92438. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92439. * @returns the alpha texture
  92440. */
  92441. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92442. /**
  92443. * Creates a RGB texture from some data.
  92444. * @param data Define the texture data
  92445. * @param width Define the width of the texture
  92446. * @param height Define the height of the texture
  92447. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92448. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92449. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92450. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92451. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92452. * @returns the RGB alpha texture
  92453. */
  92454. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92455. /**
  92456. * Creates a RGBA texture from some data.
  92457. * @param data Define the texture data
  92458. * @param width Define the width of the texture
  92459. * @param height Define the height of the texture
  92460. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92464. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92465. * @returns the RGBA texture
  92466. */
  92467. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92468. /**
  92469. * Creates a R texture from some data.
  92470. * @param data Define the texture data
  92471. * @param width Define the width of the texture
  92472. * @param height Define the height of the texture
  92473. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92474. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92475. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92476. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92477. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92478. * @returns the R texture
  92479. */
  92480. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92481. }
  92482. }
  92483. declare module BABYLON {
  92484. interface ThinEngine {
  92485. /**
  92486. * Update a dynamic index buffer
  92487. * @param indexBuffer defines the target index buffer
  92488. * @param indices defines the data to update
  92489. * @param offset defines the offset in the target index buffer where update should start
  92490. */
  92491. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92492. /**
  92493. * Updates a dynamic vertex buffer.
  92494. * @param vertexBuffer the vertex buffer to update
  92495. * @param data the data used to update the vertex buffer
  92496. * @param byteOffset the byte offset of the data
  92497. * @param byteLength the byte length of the data
  92498. */
  92499. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92500. }
  92501. }
  92502. declare module BABYLON {
  92503. interface AbstractScene {
  92504. /**
  92505. * The list of procedural textures added to the scene
  92506. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92507. */
  92508. proceduralTextures: Array<ProceduralTexture>;
  92509. }
  92510. /**
  92511. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92512. * in a given scene.
  92513. */
  92514. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92515. /**
  92516. * The component name helpfull to identify the component in the list of scene components.
  92517. */
  92518. readonly name: string;
  92519. /**
  92520. * The scene the component belongs to.
  92521. */
  92522. scene: Scene;
  92523. /**
  92524. * Creates a new instance of the component for the given scene
  92525. * @param scene Defines the scene to register the component in
  92526. */
  92527. constructor(scene: Scene);
  92528. /**
  92529. * Registers the component in a given scene
  92530. */
  92531. register(): void;
  92532. /**
  92533. * Rebuilds the elements related to this component in case of
  92534. * context lost for instance.
  92535. */
  92536. rebuild(): void;
  92537. /**
  92538. * Disposes the component and the associated ressources.
  92539. */
  92540. dispose(): void;
  92541. private _beforeClear;
  92542. }
  92543. }
  92544. declare module BABYLON {
  92545. interface ThinEngine {
  92546. /**
  92547. * Creates a new render target cube texture
  92548. * @param size defines the size of the texture
  92549. * @param options defines the options used to create the texture
  92550. * @returns a new render target cube texture stored in an InternalTexture
  92551. */
  92552. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92553. }
  92554. }
  92555. declare module BABYLON {
  92556. /** @hidden */
  92557. export var proceduralVertexShader: {
  92558. name: string;
  92559. shader: string;
  92560. };
  92561. }
  92562. declare module BABYLON {
  92563. /**
  92564. * 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.
  92565. * This is the base class of any Procedural texture and contains most of the shareable code.
  92566. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92567. */
  92568. export class ProceduralTexture extends Texture {
  92569. /**
  92570. * Define if the texture is enabled or not (disabled texture will not render)
  92571. */
  92572. isEnabled: boolean;
  92573. /**
  92574. * Define if the texture must be cleared before rendering (default is true)
  92575. */
  92576. autoClear: boolean;
  92577. /**
  92578. * Callback called when the texture is generated
  92579. */
  92580. onGenerated: () => void;
  92581. /**
  92582. * Event raised when the texture is generated
  92583. */
  92584. onGeneratedObservable: Observable<ProceduralTexture>;
  92585. /**
  92586. * Event raised before the texture is generated
  92587. */
  92588. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92589. /**
  92590. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92591. */
  92592. nodeMaterialSource: Nullable<NodeMaterial>;
  92593. /** @hidden */
  92594. _generateMipMaps: boolean;
  92595. /** @hidden **/
  92596. _effect: Effect;
  92597. /** @hidden */
  92598. _textures: {
  92599. [key: string]: Texture;
  92600. };
  92601. /** @hidden */
  92602. protected _fallbackTexture: Nullable<Texture>;
  92603. private _size;
  92604. private _currentRefreshId;
  92605. private _frameId;
  92606. private _refreshRate;
  92607. private _vertexBuffers;
  92608. private _indexBuffer;
  92609. private _uniforms;
  92610. private _samplers;
  92611. private _fragment;
  92612. private _floats;
  92613. private _ints;
  92614. private _floatsArrays;
  92615. private _colors3;
  92616. private _colors4;
  92617. private _vectors2;
  92618. private _vectors3;
  92619. private _matrices;
  92620. private _fallbackTextureUsed;
  92621. private _fullEngine;
  92622. private _cachedDefines;
  92623. private _contentUpdateId;
  92624. private _contentData;
  92625. /**
  92626. * Instantiates a new procedural texture.
  92627. * 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.
  92628. * This is the base class of any Procedural texture and contains most of the shareable code.
  92629. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92630. * @param name Define the name of the texture
  92631. * @param size Define the size of the texture to create
  92632. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92633. * @param scene Define the scene the texture belongs to
  92634. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92635. * @param generateMipMaps Define if the texture should creates mip maps or not
  92636. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92637. * @param textureType The FBO internal texture type
  92638. */
  92639. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92640. /**
  92641. * The effect that is created when initializing the post process.
  92642. * @returns The created effect corresponding the the postprocess.
  92643. */
  92644. getEffect(): Effect;
  92645. /**
  92646. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92647. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92648. */
  92649. getContent(): Nullable<ArrayBufferView>;
  92650. private _createIndexBuffer;
  92651. /** @hidden */
  92652. _rebuild(): void;
  92653. /**
  92654. * Resets the texture in order to recreate its associated resources.
  92655. * This can be called in case of context loss
  92656. */
  92657. reset(): void;
  92658. protected _getDefines(): string;
  92659. /**
  92660. * Is the texture ready to be used ? (rendered at least once)
  92661. * @returns true if ready, otherwise, false.
  92662. */
  92663. isReady(): boolean;
  92664. /**
  92665. * Resets the refresh counter of the texture and start bak from scratch.
  92666. * Could be useful to regenerate the texture if it is setup to render only once.
  92667. */
  92668. resetRefreshCounter(): void;
  92669. /**
  92670. * Set the fragment shader to use in order to render the texture.
  92671. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92672. */
  92673. setFragment(fragment: any): void;
  92674. /**
  92675. * Define the refresh rate of the texture or the rendering frequency.
  92676. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92677. */
  92678. get refreshRate(): number;
  92679. set refreshRate(value: number);
  92680. /** @hidden */
  92681. _shouldRender(): boolean;
  92682. /**
  92683. * Get the size the texture is rendering at.
  92684. * @returns the size (on cube texture it is always squared)
  92685. */
  92686. getRenderSize(): RenderTargetTextureSize;
  92687. /**
  92688. * Resize the texture to new value.
  92689. * @param size Define the new size the texture should have
  92690. * @param generateMipMaps Define whether the new texture should create mip maps
  92691. */
  92692. resize(size: number, generateMipMaps: boolean): void;
  92693. private _checkUniform;
  92694. /**
  92695. * Set a texture in the shader program used to render.
  92696. * @param name Define the name of the uniform samplers as defined in the shader
  92697. * @param texture Define the texture to bind to this sampler
  92698. * @return the texture itself allowing "fluent" like uniform updates
  92699. */
  92700. setTexture(name: string, texture: Texture): ProceduralTexture;
  92701. /**
  92702. * Set a float in the shader.
  92703. * @param name Define the name of the uniform as defined in the shader
  92704. * @param value Define the value to give to the uniform
  92705. * @return the texture itself allowing "fluent" like uniform updates
  92706. */
  92707. setFloat(name: string, value: number): ProceduralTexture;
  92708. /**
  92709. * Set a int in the shader.
  92710. * @param name Define the name of the uniform as defined in the shader
  92711. * @param value Define the value to give to the uniform
  92712. * @return the texture itself allowing "fluent" like uniform updates
  92713. */
  92714. setInt(name: string, value: number): ProceduralTexture;
  92715. /**
  92716. * Set an array of floats in the shader.
  92717. * @param name Define the name of the uniform as defined in the shader
  92718. * @param value Define the value to give to the uniform
  92719. * @return the texture itself allowing "fluent" like uniform updates
  92720. */
  92721. setFloats(name: string, value: number[]): ProceduralTexture;
  92722. /**
  92723. * Set a vec3 in the shader from a Color3.
  92724. * @param name Define the name of the uniform as defined in the shader
  92725. * @param value Define the value to give to the uniform
  92726. * @return the texture itself allowing "fluent" like uniform updates
  92727. */
  92728. setColor3(name: string, value: Color3): ProceduralTexture;
  92729. /**
  92730. * Set a vec4 in the shader from a Color4.
  92731. * @param name Define the name of the uniform as defined in the shader
  92732. * @param value Define the value to give to the uniform
  92733. * @return the texture itself allowing "fluent" like uniform updates
  92734. */
  92735. setColor4(name: string, value: Color4): ProceduralTexture;
  92736. /**
  92737. * Set a vec2 in the shader from a Vector2.
  92738. * @param name Define the name of the uniform as defined in the shader
  92739. * @param value Define the value to give to the uniform
  92740. * @return the texture itself allowing "fluent" like uniform updates
  92741. */
  92742. setVector2(name: string, value: Vector2): ProceduralTexture;
  92743. /**
  92744. * Set a vec3 in the shader from a Vector3.
  92745. * @param name Define the name of the uniform as defined in the shader
  92746. * @param value Define the value to give to the uniform
  92747. * @return the texture itself allowing "fluent" like uniform updates
  92748. */
  92749. setVector3(name: string, value: Vector3): ProceduralTexture;
  92750. /**
  92751. * Set a mat4 in the shader from a MAtrix.
  92752. * @param name Define the name of the uniform as defined in the shader
  92753. * @param value Define the value to give to the uniform
  92754. * @return the texture itself allowing "fluent" like uniform updates
  92755. */
  92756. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92757. /**
  92758. * Render the texture to its associated render target.
  92759. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92760. */
  92761. render(useCameraPostProcess?: boolean): void;
  92762. /**
  92763. * Clone the texture.
  92764. * @returns the cloned texture
  92765. */
  92766. clone(): ProceduralTexture;
  92767. /**
  92768. * Dispose the texture and release its asoociated resources.
  92769. */
  92770. dispose(): void;
  92771. }
  92772. }
  92773. declare module BABYLON {
  92774. /**
  92775. * This represents the base class for particle system in Babylon.
  92776. * 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.
  92777. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92778. * @example https://doc.babylonjs.com/babylon101/particles
  92779. */
  92780. export class BaseParticleSystem {
  92781. /**
  92782. * Source color is added to the destination color without alpha affecting the result
  92783. */
  92784. static BLENDMODE_ONEONE: number;
  92785. /**
  92786. * Blend current color and particle color using particle’s alpha
  92787. */
  92788. static BLENDMODE_STANDARD: number;
  92789. /**
  92790. * Add current color and particle color multiplied by particle’s alpha
  92791. */
  92792. static BLENDMODE_ADD: number;
  92793. /**
  92794. * Multiply current color with particle color
  92795. */
  92796. static BLENDMODE_MULTIPLY: number;
  92797. /**
  92798. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92799. */
  92800. static BLENDMODE_MULTIPLYADD: number;
  92801. /**
  92802. * List of animations used by the particle system.
  92803. */
  92804. animations: Animation[];
  92805. /**
  92806. * Gets or sets the unique id of the particle system
  92807. */
  92808. uniqueId: number;
  92809. /**
  92810. * The id of the Particle system.
  92811. */
  92812. id: string;
  92813. /**
  92814. * The friendly name of the Particle system.
  92815. */
  92816. name: string;
  92817. /**
  92818. * Snippet ID if the particle system was created from the snippet server
  92819. */
  92820. snippetId: string;
  92821. /**
  92822. * The rendering group used by the Particle system to chose when to render.
  92823. */
  92824. renderingGroupId: number;
  92825. /**
  92826. * The emitter represents the Mesh or position we are attaching the particle system to.
  92827. */
  92828. emitter: Nullable<AbstractMesh | Vector3>;
  92829. /**
  92830. * The maximum number of particles to emit per frame
  92831. */
  92832. emitRate: number;
  92833. /**
  92834. * If you want to launch only a few particles at once, that can be done, as well.
  92835. */
  92836. manualEmitCount: number;
  92837. /**
  92838. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92839. */
  92840. updateSpeed: number;
  92841. /**
  92842. * The amount of time the particle system is running (depends of the overall update speed).
  92843. */
  92844. targetStopDuration: number;
  92845. /**
  92846. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92847. */
  92848. disposeOnStop: boolean;
  92849. /**
  92850. * Minimum power of emitting particles.
  92851. */
  92852. minEmitPower: number;
  92853. /**
  92854. * Maximum power of emitting particles.
  92855. */
  92856. maxEmitPower: number;
  92857. /**
  92858. * Minimum life time of emitting particles.
  92859. */
  92860. minLifeTime: number;
  92861. /**
  92862. * Maximum life time of emitting particles.
  92863. */
  92864. maxLifeTime: number;
  92865. /**
  92866. * Minimum Size of emitting particles.
  92867. */
  92868. minSize: number;
  92869. /**
  92870. * Maximum Size of emitting particles.
  92871. */
  92872. maxSize: number;
  92873. /**
  92874. * Minimum scale of emitting particles on X axis.
  92875. */
  92876. minScaleX: number;
  92877. /**
  92878. * Maximum scale of emitting particles on X axis.
  92879. */
  92880. maxScaleX: number;
  92881. /**
  92882. * Minimum scale of emitting particles on Y axis.
  92883. */
  92884. minScaleY: number;
  92885. /**
  92886. * Maximum scale of emitting particles on Y axis.
  92887. */
  92888. maxScaleY: number;
  92889. /**
  92890. * Gets or sets the minimal initial rotation in radians.
  92891. */
  92892. minInitialRotation: number;
  92893. /**
  92894. * Gets or sets the maximal initial rotation in radians.
  92895. */
  92896. maxInitialRotation: number;
  92897. /**
  92898. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92899. */
  92900. minAngularSpeed: number;
  92901. /**
  92902. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92903. */
  92904. maxAngularSpeed: number;
  92905. /**
  92906. * The texture used to render each particle. (this can be a spritesheet)
  92907. */
  92908. particleTexture: Nullable<BaseTexture>;
  92909. /**
  92910. * The layer mask we are rendering the particles through.
  92911. */
  92912. layerMask: number;
  92913. /**
  92914. * This can help using your own shader to render the particle system.
  92915. * The according effect will be created
  92916. */
  92917. customShader: any;
  92918. /**
  92919. * By default particle system starts as soon as they are created. This prevents the
  92920. * automatic start to happen and let you decide when to start emitting particles.
  92921. */
  92922. preventAutoStart: boolean;
  92923. private _noiseTexture;
  92924. /**
  92925. * Gets or sets a texture used to add random noise to particle positions
  92926. */
  92927. get noiseTexture(): Nullable<ProceduralTexture>;
  92928. set noiseTexture(value: Nullable<ProceduralTexture>);
  92929. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92930. noiseStrength: Vector3;
  92931. /**
  92932. * Callback triggered when the particle animation is ending.
  92933. */
  92934. onAnimationEnd: Nullable<() => void>;
  92935. /**
  92936. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92937. */
  92938. blendMode: number;
  92939. /**
  92940. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92941. * to override the particles.
  92942. */
  92943. forceDepthWrite: boolean;
  92944. /** 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 */
  92945. preWarmCycles: number;
  92946. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92947. preWarmStepOffset: number;
  92948. /**
  92949. * 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)
  92950. */
  92951. spriteCellChangeSpeed: number;
  92952. /**
  92953. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92954. */
  92955. startSpriteCellID: number;
  92956. /**
  92957. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92958. */
  92959. endSpriteCellID: number;
  92960. /**
  92961. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92962. */
  92963. spriteCellWidth: number;
  92964. /**
  92965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92966. */
  92967. spriteCellHeight: number;
  92968. /**
  92969. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92970. */
  92971. spriteRandomStartCell: boolean;
  92972. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92973. translationPivot: Vector2;
  92974. /** @hidden */
  92975. protected _isAnimationSheetEnabled: boolean;
  92976. /**
  92977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92978. */
  92979. beginAnimationOnStart: boolean;
  92980. /**
  92981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92982. */
  92983. beginAnimationFrom: number;
  92984. /**
  92985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92986. */
  92987. beginAnimationTo: number;
  92988. /**
  92989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92990. */
  92991. beginAnimationLoop: boolean;
  92992. /**
  92993. * Gets or sets a world offset applied to all particles
  92994. */
  92995. worldOffset: Vector3;
  92996. /**
  92997. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92998. */
  92999. get isAnimationSheetEnabled(): boolean;
  93000. set isAnimationSheetEnabled(value: boolean);
  93001. /**
  93002. * Get hosting scene
  93003. * @returns the scene
  93004. */
  93005. getScene(): Nullable<Scene>;
  93006. /**
  93007. * You can use gravity if you want to give an orientation to your particles.
  93008. */
  93009. gravity: Vector3;
  93010. protected _colorGradients: Nullable<Array<ColorGradient>>;
  93011. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  93012. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  93013. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  93014. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  93015. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  93016. protected _dragGradients: Nullable<Array<FactorGradient>>;
  93017. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  93018. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  93019. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  93020. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  93021. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  93022. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  93023. /**
  93024. * Defines the delay in milliseconds before starting the system (0 by default)
  93025. */
  93026. startDelay: number;
  93027. /**
  93028. * Gets the current list of drag gradients.
  93029. * You must use addDragGradient and removeDragGradient to udpate this list
  93030. * @returns the list of drag gradients
  93031. */
  93032. getDragGradients(): Nullable<Array<FactorGradient>>;
  93033. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93034. limitVelocityDamping: number;
  93035. /**
  93036. * Gets the current list of limit velocity gradients.
  93037. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93038. * @returns the list of limit velocity gradients
  93039. */
  93040. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93041. /**
  93042. * Gets the current list of color gradients.
  93043. * You must use addColorGradient and removeColorGradient to udpate this list
  93044. * @returns the list of color gradients
  93045. */
  93046. getColorGradients(): Nullable<Array<ColorGradient>>;
  93047. /**
  93048. * Gets the current list of size gradients.
  93049. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93050. * @returns the list of size gradients
  93051. */
  93052. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93053. /**
  93054. * Gets the current list of color remap gradients.
  93055. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93056. * @returns the list of color remap gradients
  93057. */
  93058. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93059. /**
  93060. * Gets the current list of alpha remap gradients.
  93061. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93062. * @returns the list of alpha remap gradients
  93063. */
  93064. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93065. /**
  93066. * Gets the current list of life time gradients.
  93067. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93068. * @returns the list of life time gradients
  93069. */
  93070. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93071. /**
  93072. * Gets the current list of angular speed gradients.
  93073. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93074. * @returns the list of angular speed gradients
  93075. */
  93076. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93077. /**
  93078. * Gets the current list of velocity gradients.
  93079. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93080. * @returns the list of velocity gradients
  93081. */
  93082. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93083. /**
  93084. * Gets the current list of start size gradients.
  93085. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93086. * @returns the list of start size gradients
  93087. */
  93088. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93089. /**
  93090. * Gets the current list of emit rate gradients.
  93091. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93092. * @returns the list of emit rate gradients
  93093. */
  93094. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93095. /**
  93096. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93097. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93098. */
  93099. get direction1(): Vector3;
  93100. set direction1(value: Vector3);
  93101. /**
  93102. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93103. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93104. */
  93105. get direction2(): Vector3;
  93106. set direction2(value: Vector3);
  93107. /**
  93108. * 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.
  93109. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93110. */
  93111. get minEmitBox(): Vector3;
  93112. set minEmitBox(value: Vector3);
  93113. /**
  93114. * 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.
  93115. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93116. */
  93117. get maxEmitBox(): Vector3;
  93118. set maxEmitBox(value: Vector3);
  93119. /**
  93120. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93121. */
  93122. color1: Color4;
  93123. /**
  93124. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93125. */
  93126. color2: Color4;
  93127. /**
  93128. * Color the particle will have at the end of its lifetime
  93129. */
  93130. colorDead: Color4;
  93131. /**
  93132. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93133. */
  93134. textureMask: Color4;
  93135. /**
  93136. * The particle emitter type defines the emitter used by the particle system.
  93137. * It can be for example box, sphere, or cone...
  93138. */
  93139. particleEmitterType: IParticleEmitterType;
  93140. /** @hidden */
  93141. _isSubEmitter: boolean;
  93142. /**
  93143. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93144. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93145. */
  93146. billboardMode: number;
  93147. protected _isBillboardBased: boolean;
  93148. /**
  93149. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93150. */
  93151. get isBillboardBased(): boolean;
  93152. set isBillboardBased(value: boolean);
  93153. /**
  93154. * The scene the particle system belongs to.
  93155. */
  93156. protected _scene: Nullable<Scene>;
  93157. /**
  93158. * The engine the particle system belongs to.
  93159. */
  93160. protected _engine: ThinEngine;
  93161. /**
  93162. * Local cache of defines for image processing.
  93163. */
  93164. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93165. /**
  93166. * Default configuration related to image processing available in the standard Material.
  93167. */
  93168. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93169. /**
  93170. * Gets the image processing configuration used either in this material.
  93171. */
  93172. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93173. /**
  93174. * Sets the Default image processing configuration used either in the this material.
  93175. *
  93176. * If sets to null, the scene one is in use.
  93177. */
  93178. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93179. /**
  93180. * Attaches a new image processing configuration to the Standard Material.
  93181. * @param configuration
  93182. */
  93183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93184. /** @hidden */
  93185. protected _reset(): void;
  93186. /** @hidden */
  93187. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93188. /**
  93189. * Instantiates a particle system.
  93190. * 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.
  93191. * @param name The name of the particle system
  93192. */
  93193. constructor(name: string);
  93194. /**
  93195. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93196. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93197. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93198. * @returns the emitter
  93199. */
  93200. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93201. /**
  93202. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93203. * @param radius The radius of the hemisphere to emit from
  93204. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93205. * @returns the emitter
  93206. */
  93207. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93208. /**
  93209. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93210. * @param radius The radius of the sphere to emit from
  93211. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93212. * @returns the emitter
  93213. */
  93214. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93215. /**
  93216. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93217. * @param radius The radius of the sphere to emit from
  93218. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93219. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93220. * @returns the emitter
  93221. */
  93222. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93223. /**
  93224. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93225. * @param radius The radius of the emission cylinder
  93226. * @param height The height of the emission cylinder
  93227. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93228. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93229. * @returns the emitter
  93230. */
  93231. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93232. /**
  93233. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93234. * @param radius The radius of the cylinder to emit from
  93235. * @param height The height of the emission cylinder
  93236. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93237. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93238. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93239. * @returns the emitter
  93240. */
  93241. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93242. /**
  93243. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93244. * @param radius The radius of the cone to emit from
  93245. * @param angle The base angle of the cone
  93246. * @returns the emitter
  93247. */
  93248. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93249. /**
  93250. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93251. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93252. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93253. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93254. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93255. * @returns the emitter
  93256. */
  93257. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93258. }
  93259. }
  93260. declare module BABYLON {
  93261. /**
  93262. * Type of sub emitter
  93263. */
  93264. export enum SubEmitterType {
  93265. /**
  93266. * Attached to the particle over it's lifetime
  93267. */
  93268. ATTACHED = 0,
  93269. /**
  93270. * Created when the particle dies
  93271. */
  93272. END = 1
  93273. }
  93274. /**
  93275. * Sub emitter class used to emit particles from an existing particle
  93276. */
  93277. export class SubEmitter {
  93278. /**
  93279. * the particle system to be used by the sub emitter
  93280. */
  93281. particleSystem: ParticleSystem;
  93282. /**
  93283. * Type of the submitter (Default: END)
  93284. */
  93285. type: SubEmitterType;
  93286. /**
  93287. * 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)
  93288. * Note: This only is supported when using an emitter of type Mesh
  93289. */
  93290. inheritDirection: boolean;
  93291. /**
  93292. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93293. */
  93294. inheritedVelocityAmount: number;
  93295. /**
  93296. * Creates a sub emitter
  93297. * @param particleSystem the particle system to be used by the sub emitter
  93298. */
  93299. constructor(
  93300. /**
  93301. * the particle system to be used by the sub emitter
  93302. */
  93303. particleSystem: ParticleSystem);
  93304. /**
  93305. * Clones the sub emitter
  93306. * @returns the cloned sub emitter
  93307. */
  93308. clone(): SubEmitter;
  93309. /**
  93310. * Serialize current object to a JSON object
  93311. * @returns the serialized object
  93312. */
  93313. serialize(): any;
  93314. /** @hidden */
  93315. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93316. /**
  93317. * Creates a new SubEmitter from a serialized JSON version
  93318. * @param serializationObject defines the JSON object to read from
  93319. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93320. * @param rootUrl defines the rootUrl for data loading
  93321. * @returns a new SubEmitter
  93322. */
  93323. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93324. /** Release associated resources */
  93325. dispose(): void;
  93326. }
  93327. }
  93328. declare module BABYLON {
  93329. /** @hidden */
  93330. export var imageProcessingDeclaration: {
  93331. name: string;
  93332. shader: string;
  93333. };
  93334. }
  93335. declare module BABYLON {
  93336. /** @hidden */
  93337. export var imageProcessingFunctions: {
  93338. name: string;
  93339. shader: string;
  93340. };
  93341. }
  93342. declare module BABYLON {
  93343. /** @hidden */
  93344. export var particlesPixelShader: {
  93345. name: string;
  93346. shader: string;
  93347. };
  93348. }
  93349. declare module BABYLON {
  93350. /** @hidden */
  93351. export var particlesVertexShader: {
  93352. name: string;
  93353. shader: string;
  93354. };
  93355. }
  93356. declare module BABYLON {
  93357. /**
  93358. * Interface used to define entities containing multiple clip planes
  93359. */
  93360. export interface IClipPlanesHolder {
  93361. /**
  93362. * Gets or sets the active clipplane 1
  93363. */
  93364. clipPlane: Nullable<Plane>;
  93365. /**
  93366. * Gets or sets the active clipplane 2
  93367. */
  93368. clipPlane2: Nullable<Plane>;
  93369. /**
  93370. * Gets or sets the active clipplane 3
  93371. */
  93372. clipPlane3: Nullable<Plane>;
  93373. /**
  93374. * Gets or sets the active clipplane 4
  93375. */
  93376. clipPlane4: Nullable<Plane>;
  93377. /**
  93378. * Gets or sets the active clipplane 5
  93379. */
  93380. clipPlane5: Nullable<Plane>;
  93381. /**
  93382. * Gets or sets the active clipplane 6
  93383. */
  93384. clipPlane6: Nullable<Plane>;
  93385. }
  93386. }
  93387. declare module BABYLON {
  93388. /**
  93389. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93390. *
  93391. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93392. *
  93393. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93394. */
  93395. export class ThinMaterialHelper {
  93396. /**
  93397. * Binds the clip plane information from the holder to the effect.
  93398. * @param effect The effect we are binding the data to
  93399. * @param holder The entity containing the clip plane information
  93400. */
  93401. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93402. }
  93403. }
  93404. declare module BABYLON {
  93405. interface ThinEngine {
  93406. /**
  93407. * Sets alpha constants used by some alpha blending modes
  93408. * @param r defines the red component
  93409. * @param g defines the green component
  93410. * @param b defines the blue component
  93411. * @param a defines the alpha component
  93412. */
  93413. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93414. /**
  93415. * Sets the current alpha mode
  93416. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93417. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93418. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93419. */
  93420. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93421. /**
  93422. * Gets the current alpha mode
  93423. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93424. * @returns the current alpha mode
  93425. */
  93426. getAlphaMode(): number;
  93427. /**
  93428. * Sets the current alpha equation
  93429. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93430. */
  93431. setAlphaEquation(equation: number): void;
  93432. /**
  93433. * Gets the current alpha equation.
  93434. * @returns the current alpha equation
  93435. */
  93436. getAlphaEquation(): number;
  93437. }
  93438. }
  93439. declare module BABYLON {
  93440. /**
  93441. * This represents a particle system in Babylon.
  93442. * 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.
  93443. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93444. * @example https://doc.babylonjs.com/babylon101/particles
  93445. */
  93446. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93447. /**
  93448. * Billboard mode will only apply to Y axis
  93449. */
  93450. static readonly BILLBOARDMODE_Y: number;
  93451. /**
  93452. * Billboard mode will apply to all axes
  93453. */
  93454. static readonly BILLBOARDMODE_ALL: number;
  93455. /**
  93456. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93457. */
  93458. static readonly BILLBOARDMODE_STRETCHED: number;
  93459. /**
  93460. * This function can be defined to provide custom update for active particles.
  93461. * This function will be called instead of regular update (age, position, color, etc.).
  93462. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93463. */
  93464. updateFunction: (particles: Particle[]) => void;
  93465. private _emitterWorldMatrix;
  93466. /**
  93467. * This function can be defined to specify initial direction for every new particle.
  93468. * It by default use the emitterType defined function
  93469. */
  93470. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93471. /**
  93472. * This function can be defined to specify initial position for every new particle.
  93473. * It by default use the emitterType defined function
  93474. */
  93475. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93476. /**
  93477. * @hidden
  93478. */
  93479. _inheritedVelocityOffset: Vector3;
  93480. /**
  93481. * An event triggered when the system is disposed
  93482. */
  93483. onDisposeObservable: Observable<IParticleSystem>;
  93484. /**
  93485. * An event triggered when the system is stopped
  93486. */
  93487. onStoppedObservable: Observable<IParticleSystem>;
  93488. private _onDisposeObserver;
  93489. /**
  93490. * Sets a callback that will be triggered when the system is disposed
  93491. */
  93492. set onDispose(callback: () => void);
  93493. private _particles;
  93494. private _epsilon;
  93495. private _capacity;
  93496. private _stockParticles;
  93497. private _newPartsExcess;
  93498. private _vertexData;
  93499. private _vertexBuffer;
  93500. private _vertexBuffers;
  93501. private _spriteBuffer;
  93502. private _indexBuffer;
  93503. private _effect;
  93504. private _customEffect;
  93505. private _cachedDefines;
  93506. private _scaledColorStep;
  93507. private _colorDiff;
  93508. private _scaledDirection;
  93509. private _scaledGravity;
  93510. private _currentRenderId;
  93511. private _alive;
  93512. private _useInstancing;
  93513. private _vertexArrayObject;
  93514. private _started;
  93515. private _stopped;
  93516. private _actualFrame;
  93517. private _scaledUpdateSpeed;
  93518. private _vertexBufferSize;
  93519. /** @hidden */
  93520. _currentEmitRateGradient: Nullable<FactorGradient>;
  93521. /** @hidden */
  93522. _currentEmitRate1: number;
  93523. /** @hidden */
  93524. _currentEmitRate2: number;
  93525. /** @hidden */
  93526. _currentStartSizeGradient: Nullable<FactorGradient>;
  93527. /** @hidden */
  93528. _currentStartSize1: number;
  93529. /** @hidden */
  93530. _currentStartSize2: number;
  93531. private readonly _rawTextureWidth;
  93532. private _rampGradientsTexture;
  93533. private _useRampGradients;
  93534. /** Gets or sets a matrix to use to compute projection */
  93535. defaultProjectionMatrix: Matrix;
  93536. /** Gets or sets a matrix to use to compute view */
  93537. defaultViewMatrix: Matrix;
  93538. /** Gets or sets a boolean indicating that ramp gradients must be used
  93539. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93540. */
  93541. get useRampGradients(): boolean;
  93542. set useRampGradients(value: boolean);
  93543. /**
  93544. * 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.
  93545. * 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: [])
  93546. */
  93547. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93548. private _subEmitters;
  93549. /**
  93550. * @hidden
  93551. * If the particle systems emitter should be disposed when the particle system is disposed
  93552. */
  93553. _disposeEmitterOnDispose: boolean;
  93554. /**
  93555. * The current active Sub-systems, this property is used by the root particle system only.
  93556. */
  93557. activeSubSystems: Array<ParticleSystem>;
  93558. /**
  93559. * Specifies if the particles are updated in emitter local space or world space
  93560. */
  93561. isLocal: boolean;
  93562. private _rootParticleSystem;
  93563. /**
  93564. * Gets the current list of active particles
  93565. */
  93566. get particles(): Particle[];
  93567. /**
  93568. * Gets the number of particles active at the same time.
  93569. * @returns The number of active particles.
  93570. */
  93571. getActiveCount(): number;
  93572. /**
  93573. * Returns the string "ParticleSystem"
  93574. * @returns a string containing the class name
  93575. */
  93576. getClassName(): string;
  93577. /**
  93578. * Gets a boolean indicating that the system is stopping
  93579. * @returns true if the system is currently stopping
  93580. */
  93581. isStopping(): boolean;
  93582. /**
  93583. * Gets the custom effect used to render the particles
  93584. * @param blendMode Blend mode for which the effect should be retrieved
  93585. * @returns The effect
  93586. */
  93587. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93588. /**
  93589. * Sets the custom effect used to render the particles
  93590. * @param effect The effect to set
  93591. * @param blendMode Blend mode for which the effect should be set
  93592. */
  93593. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93594. /** @hidden */
  93595. private _onBeforeDrawParticlesObservable;
  93596. /**
  93597. * Observable that will be called just before the particles are drawn
  93598. */
  93599. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93600. /**
  93601. * Gets the name of the particle vertex shader
  93602. */
  93603. get vertexShaderName(): string;
  93604. /**
  93605. * Instantiates a particle system.
  93606. * 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.
  93607. * @param name The name of the particle system
  93608. * @param capacity The max number of particles alive at the same time
  93609. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93610. * @param customEffect a custom effect used to change the way particles are rendered by default
  93611. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93612. * @param epsilon Offset used to render the particles
  93613. */
  93614. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93615. private _addFactorGradient;
  93616. private _removeFactorGradient;
  93617. /**
  93618. * Adds a new life time gradient
  93619. * @param gradient defines the gradient to use (between 0 and 1)
  93620. * @param factor defines the life time factor to affect to the specified gradient
  93621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93622. * @returns the current particle system
  93623. */
  93624. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93625. /**
  93626. * Remove a specific life time gradient
  93627. * @param gradient defines the gradient to remove
  93628. * @returns the current particle system
  93629. */
  93630. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93631. /**
  93632. * Adds a new size gradient
  93633. * @param gradient defines the gradient to use (between 0 and 1)
  93634. * @param factor defines the size factor to affect to the specified gradient
  93635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93636. * @returns the current particle system
  93637. */
  93638. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93639. /**
  93640. * Remove a specific size gradient
  93641. * @param gradient defines the gradient to remove
  93642. * @returns the current particle system
  93643. */
  93644. removeSizeGradient(gradient: number): IParticleSystem;
  93645. /**
  93646. * Adds a new color remap gradient
  93647. * @param gradient defines the gradient to use (between 0 and 1)
  93648. * @param min defines the color remap minimal range
  93649. * @param max defines the color remap maximal range
  93650. * @returns the current particle system
  93651. */
  93652. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93653. /**
  93654. * Remove a specific color remap gradient
  93655. * @param gradient defines the gradient to remove
  93656. * @returns the current particle system
  93657. */
  93658. removeColorRemapGradient(gradient: number): IParticleSystem;
  93659. /**
  93660. * Adds a new alpha remap gradient
  93661. * @param gradient defines the gradient to use (between 0 and 1)
  93662. * @param min defines the alpha remap minimal range
  93663. * @param max defines the alpha remap maximal range
  93664. * @returns the current particle system
  93665. */
  93666. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93667. /**
  93668. * Remove a specific alpha remap gradient
  93669. * @param gradient defines the gradient to remove
  93670. * @returns the current particle system
  93671. */
  93672. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93673. /**
  93674. * Adds a new angular speed gradient
  93675. * @param gradient defines the gradient to use (between 0 and 1)
  93676. * @param factor defines the angular speed to affect to the specified gradient
  93677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93678. * @returns the current particle system
  93679. */
  93680. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93681. /**
  93682. * Remove a specific angular speed gradient
  93683. * @param gradient defines the gradient to remove
  93684. * @returns the current particle system
  93685. */
  93686. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93687. /**
  93688. * Adds a new velocity gradient
  93689. * @param gradient defines the gradient to use (between 0 and 1)
  93690. * @param factor defines the velocity to affect to the specified gradient
  93691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93692. * @returns the current particle system
  93693. */
  93694. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93695. /**
  93696. * Remove a specific velocity gradient
  93697. * @param gradient defines the gradient to remove
  93698. * @returns the current particle system
  93699. */
  93700. removeVelocityGradient(gradient: number): IParticleSystem;
  93701. /**
  93702. * Adds a new limit velocity gradient
  93703. * @param gradient defines the gradient to use (between 0 and 1)
  93704. * @param factor defines the limit velocity value to affect to the specified gradient
  93705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93706. * @returns the current particle system
  93707. */
  93708. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93709. /**
  93710. * Remove a specific limit velocity gradient
  93711. * @param gradient defines the gradient to remove
  93712. * @returns the current particle system
  93713. */
  93714. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93715. /**
  93716. * Adds a new drag gradient
  93717. * @param gradient defines the gradient to use (between 0 and 1)
  93718. * @param factor defines the drag value to affect to the specified gradient
  93719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93720. * @returns the current particle system
  93721. */
  93722. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93723. /**
  93724. * Remove a specific drag gradient
  93725. * @param gradient defines the gradient to remove
  93726. * @returns the current particle system
  93727. */
  93728. removeDragGradient(gradient: number): IParticleSystem;
  93729. /**
  93730. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93731. * @param gradient defines the gradient to use (between 0 and 1)
  93732. * @param factor defines the emit rate value to affect to the specified gradient
  93733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93734. * @returns the current particle system
  93735. */
  93736. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93737. /**
  93738. * Remove a specific emit rate gradient
  93739. * @param gradient defines the gradient to remove
  93740. * @returns the current particle system
  93741. */
  93742. removeEmitRateGradient(gradient: number): IParticleSystem;
  93743. /**
  93744. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93745. * @param gradient defines the gradient to use (between 0 and 1)
  93746. * @param factor defines the start size value to affect to the specified gradient
  93747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93748. * @returns the current particle system
  93749. */
  93750. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93751. /**
  93752. * Remove a specific start size gradient
  93753. * @param gradient defines the gradient to remove
  93754. * @returns the current particle system
  93755. */
  93756. removeStartSizeGradient(gradient: number): IParticleSystem;
  93757. private _createRampGradientTexture;
  93758. /**
  93759. * Gets the current list of ramp gradients.
  93760. * You must use addRampGradient and removeRampGradient to udpate this list
  93761. * @returns the list of ramp gradients
  93762. */
  93763. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93764. /** Force the system to rebuild all gradients that need to be resync */
  93765. forceRefreshGradients(): void;
  93766. private _syncRampGradientTexture;
  93767. /**
  93768. * Adds a new ramp gradient used to remap particle colors
  93769. * @param gradient defines the gradient to use (between 0 and 1)
  93770. * @param color defines the color to affect to the specified gradient
  93771. * @returns the current particle system
  93772. */
  93773. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93774. /**
  93775. * Remove a specific ramp gradient
  93776. * @param gradient defines the gradient to remove
  93777. * @returns the current particle system
  93778. */
  93779. removeRampGradient(gradient: number): ParticleSystem;
  93780. /**
  93781. * Adds a new color gradient
  93782. * @param gradient defines the gradient to use (between 0 and 1)
  93783. * @param color1 defines the color to affect to the specified gradient
  93784. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93785. * @returns this particle system
  93786. */
  93787. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93788. /**
  93789. * Remove a specific color gradient
  93790. * @param gradient defines the gradient to remove
  93791. * @returns this particle system
  93792. */
  93793. removeColorGradient(gradient: number): IParticleSystem;
  93794. private _fetchR;
  93795. protected _reset(): void;
  93796. private _resetEffect;
  93797. private _createVertexBuffers;
  93798. private _createIndexBuffer;
  93799. /**
  93800. * Gets the maximum number of particles active at the same time.
  93801. * @returns The max number of active particles.
  93802. */
  93803. getCapacity(): number;
  93804. /**
  93805. * Gets whether there are still active particles in the system.
  93806. * @returns True if it is alive, otherwise false.
  93807. */
  93808. isAlive(): boolean;
  93809. /**
  93810. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93811. * @returns True if it has been started, otherwise false.
  93812. */
  93813. isStarted(): boolean;
  93814. private _prepareSubEmitterInternalArray;
  93815. /**
  93816. * Starts the particle system and begins to emit
  93817. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93818. */
  93819. start(delay?: number): void;
  93820. /**
  93821. * Stops the particle system.
  93822. * @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.
  93823. */
  93824. stop(stopSubEmitters?: boolean): void;
  93825. /**
  93826. * Remove all active particles
  93827. */
  93828. reset(): void;
  93829. /**
  93830. * @hidden (for internal use only)
  93831. */
  93832. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93833. /**
  93834. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93835. * Its lifetime will start back at 0.
  93836. */
  93837. recycleParticle: (particle: Particle) => void;
  93838. private _stopSubEmitters;
  93839. private _createParticle;
  93840. private _removeFromRoot;
  93841. private _emitFromParticle;
  93842. private _update;
  93843. /** @hidden */
  93844. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93845. /** @hidden */
  93846. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93847. /**
  93848. * Fill the defines array according to the current settings of the particle system
  93849. * @param defines Array to be updated
  93850. * @param blendMode blend mode to take into account when updating the array
  93851. */
  93852. fillDefines(defines: Array<string>, blendMode: number): void;
  93853. /**
  93854. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93855. * @param uniforms Uniforms array to fill
  93856. * @param attributes Attributes array to fill
  93857. * @param samplers Samplers array to fill
  93858. */
  93859. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93860. /** @hidden */
  93861. private _getEffect;
  93862. /**
  93863. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93864. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93865. */
  93866. animate(preWarmOnly?: boolean): void;
  93867. private _appendParticleVertices;
  93868. /**
  93869. * Rebuilds the particle system.
  93870. */
  93871. rebuild(): void;
  93872. /**
  93873. * Is this system ready to be used/rendered
  93874. * @return true if the system is ready
  93875. */
  93876. isReady(): boolean;
  93877. private _render;
  93878. /**
  93879. * Renders the particle system in its current state.
  93880. * @returns the current number of particles
  93881. */
  93882. render(): number;
  93883. /**
  93884. * Disposes the particle system and free the associated resources
  93885. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93886. */
  93887. dispose(disposeTexture?: boolean): void;
  93888. /**
  93889. * Clones the particle system.
  93890. * @param name The name of the cloned object
  93891. * @param newEmitter The new emitter to use
  93892. * @returns the cloned particle system
  93893. */
  93894. clone(name: string, newEmitter: any): ParticleSystem;
  93895. /**
  93896. * Serializes the particle system to a JSON object
  93897. * @param serializeTexture defines if the texture must be serialized as well
  93898. * @returns the JSON object
  93899. */
  93900. serialize(serializeTexture?: boolean): any;
  93901. /** @hidden */
  93902. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93903. /** @hidden */
  93904. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93905. /**
  93906. * Parses a JSON object to create a particle system.
  93907. * @param parsedParticleSystem The JSON object to parse
  93908. * @param sceneOrEngine The scene or the engine to create the particle system in
  93909. * @param rootUrl The root url to use to load external dependencies like texture
  93910. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93911. * @returns the Parsed particle system
  93912. */
  93913. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93914. }
  93915. }
  93916. declare module BABYLON {
  93917. /**
  93918. * A particle represents one of the element emitted by a particle system.
  93919. * This is mainly define by its coordinates, direction, velocity and age.
  93920. */
  93921. export class Particle {
  93922. /**
  93923. * The particle system the particle belongs to.
  93924. */
  93925. particleSystem: ParticleSystem;
  93926. private static _Count;
  93927. /**
  93928. * Unique ID of the particle
  93929. */
  93930. id: number;
  93931. /**
  93932. * The world position of the particle in the scene.
  93933. */
  93934. position: Vector3;
  93935. /**
  93936. * The world direction of the particle in the scene.
  93937. */
  93938. direction: Vector3;
  93939. /**
  93940. * The color of the particle.
  93941. */
  93942. color: Color4;
  93943. /**
  93944. * The color change of the particle per step.
  93945. */
  93946. colorStep: Color4;
  93947. /**
  93948. * Defines how long will the life of the particle be.
  93949. */
  93950. lifeTime: number;
  93951. /**
  93952. * The current age of the particle.
  93953. */
  93954. age: number;
  93955. /**
  93956. * The current size of the particle.
  93957. */
  93958. size: number;
  93959. /**
  93960. * The current scale of the particle.
  93961. */
  93962. scale: Vector2;
  93963. /**
  93964. * The current angle of the particle.
  93965. */
  93966. angle: number;
  93967. /**
  93968. * Defines how fast is the angle changing.
  93969. */
  93970. angularSpeed: number;
  93971. /**
  93972. * Defines the cell index used by the particle to be rendered from a sprite.
  93973. */
  93974. cellIndex: number;
  93975. /**
  93976. * The information required to support color remapping
  93977. */
  93978. remapData: Vector4;
  93979. /** @hidden */
  93980. _randomCellOffset?: number;
  93981. /** @hidden */
  93982. _initialDirection: Nullable<Vector3>;
  93983. /** @hidden */
  93984. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93985. /** @hidden */
  93986. _initialStartSpriteCellID: number;
  93987. /** @hidden */
  93988. _initialEndSpriteCellID: number;
  93989. /** @hidden */
  93990. _currentColorGradient: Nullable<ColorGradient>;
  93991. /** @hidden */
  93992. _currentColor1: Color4;
  93993. /** @hidden */
  93994. _currentColor2: Color4;
  93995. /** @hidden */
  93996. _currentSizeGradient: Nullable<FactorGradient>;
  93997. /** @hidden */
  93998. _currentSize1: number;
  93999. /** @hidden */
  94000. _currentSize2: number;
  94001. /** @hidden */
  94002. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  94003. /** @hidden */
  94004. _currentAngularSpeed1: number;
  94005. /** @hidden */
  94006. _currentAngularSpeed2: number;
  94007. /** @hidden */
  94008. _currentVelocityGradient: Nullable<FactorGradient>;
  94009. /** @hidden */
  94010. _currentVelocity1: number;
  94011. /** @hidden */
  94012. _currentVelocity2: number;
  94013. /** @hidden */
  94014. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  94015. /** @hidden */
  94016. _currentLimitVelocity1: number;
  94017. /** @hidden */
  94018. _currentLimitVelocity2: number;
  94019. /** @hidden */
  94020. _currentDragGradient: Nullable<FactorGradient>;
  94021. /** @hidden */
  94022. _currentDrag1: number;
  94023. /** @hidden */
  94024. _currentDrag2: number;
  94025. /** @hidden */
  94026. _randomNoiseCoordinates1: Vector3;
  94027. /** @hidden */
  94028. _randomNoiseCoordinates2: Vector3;
  94029. /** @hidden */
  94030. _localPosition?: Vector3;
  94031. /**
  94032. * Creates a new instance Particle
  94033. * @param particleSystem the particle system the particle belongs to
  94034. */
  94035. constructor(
  94036. /**
  94037. * The particle system the particle belongs to.
  94038. */
  94039. particleSystem: ParticleSystem);
  94040. private updateCellInfoFromSystem;
  94041. /**
  94042. * Defines how the sprite cell index is updated for the particle
  94043. */
  94044. updateCellIndex(): void;
  94045. /** @hidden */
  94046. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94047. /** @hidden */
  94048. _inheritParticleInfoToSubEmitters(): void;
  94049. /** @hidden */
  94050. _reset(): void;
  94051. /**
  94052. * Copy the properties of particle to another one.
  94053. * @param other the particle to copy the information to.
  94054. */
  94055. copyTo(other: Particle): void;
  94056. }
  94057. }
  94058. declare module BABYLON {
  94059. /**
  94060. * Particle emitter represents a volume emitting particles.
  94061. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94062. */
  94063. export interface IParticleEmitterType {
  94064. /**
  94065. * Called by the particle System when the direction is computed for the created particle.
  94066. * @param worldMatrix is the world matrix of the particle system
  94067. * @param directionToUpdate is the direction vector to update with the result
  94068. * @param particle is the particle we are computed the direction for
  94069. * @param isLocal defines if the direction should be set in local space
  94070. */
  94071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94072. /**
  94073. * Called by the particle System when the position is computed for the created particle.
  94074. * @param worldMatrix is the world matrix of the particle system
  94075. * @param positionToUpdate is the position vector to update with the result
  94076. * @param particle is the particle we are computed the position for
  94077. * @param isLocal defines if the position should be set in local space
  94078. */
  94079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94080. /**
  94081. * Clones the current emitter and returns a copy of it
  94082. * @returns the new emitter
  94083. */
  94084. clone(): IParticleEmitterType;
  94085. /**
  94086. * Called by the GPUParticleSystem to setup the update shader
  94087. * @param effect defines the update shader
  94088. */
  94089. applyToShader(effect: Effect): void;
  94090. /**
  94091. * Returns a string to use to update the GPU particles update shader
  94092. * @returns the effect defines string
  94093. */
  94094. getEffectDefines(): string;
  94095. /**
  94096. * Returns a string representing the class name
  94097. * @returns a string containing the class name
  94098. */
  94099. getClassName(): string;
  94100. /**
  94101. * Serializes the particle system to a JSON object.
  94102. * @returns the JSON object
  94103. */
  94104. serialize(): any;
  94105. /**
  94106. * Parse properties from a JSON object
  94107. * @param serializationObject defines the JSON object
  94108. * @param scene defines the hosting scene
  94109. */
  94110. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94111. }
  94112. }
  94113. declare module BABYLON {
  94114. /**
  94115. * Particle emitter emitting particles from the inside of a box.
  94116. * It emits the particles randomly between 2 given directions.
  94117. */
  94118. export class BoxParticleEmitter implements IParticleEmitterType {
  94119. /**
  94120. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94121. */
  94122. direction1: Vector3;
  94123. /**
  94124. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94125. */
  94126. direction2: Vector3;
  94127. /**
  94128. * 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.
  94129. */
  94130. minEmitBox: Vector3;
  94131. /**
  94132. * 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.
  94133. */
  94134. maxEmitBox: Vector3;
  94135. /**
  94136. * Creates a new instance BoxParticleEmitter
  94137. */
  94138. constructor();
  94139. /**
  94140. * Called by the particle System when the direction is computed for the created particle.
  94141. * @param worldMatrix is the world matrix of the particle system
  94142. * @param directionToUpdate is the direction vector to update with the result
  94143. * @param particle is the particle we are computed the direction for
  94144. * @param isLocal defines if the direction should be set in local space
  94145. */
  94146. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94147. /**
  94148. * Called by the particle System when the position is computed for the created particle.
  94149. * @param worldMatrix is the world matrix of the particle system
  94150. * @param positionToUpdate is the position vector to update with the result
  94151. * @param particle is the particle we are computed the position for
  94152. * @param isLocal defines if the position should be set in local space
  94153. */
  94154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94155. /**
  94156. * Clones the current emitter and returns a copy of it
  94157. * @returns the new emitter
  94158. */
  94159. clone(): BoxParticleEmitter;
  94160. /**
  94161. * Called by the GPUParticleSystem to setup the update shader
  94162. * @param effect defines the update shader
  94163. */
  94164. applyToShader(effect: Effect): void;
  94165. /**
  94166. * Returns a string to use to update the GPU particles update shader
  94167. * @returns a string containng the defines string
  94168. */
  94169. getEffectDefines(): string;
  94170. /**
  94171. * Returns the string "BoxParticleEmitter"
  94172. * @returns a string containing the class name
  94173. */
  94174. getClassName(): string;
  94175. /**
  94176. * Serializes the particle system to a JSON object.
  94177. * @returns the JSON object
  94178. */
  94179. serialize(): any;
  94180. /**
  94181. * Parse properties from a JSON object
  94182. * @param serializationObject defines the JSON object
  94183. */
  94184. parse(serializationObject: any): void;
  94185. }
  94186. }
  94187. declare module BABYLON {
  94188. /**
  94189. * Particle emitter emitting particles from the inside of a cone.
  94190. * It emits the particles alongside the cone volume from the base to the particle.
  94191. * The emission direction might be randomized.
  94192. */
  94193. export class ConeParticleEmitter implements IParticleEmitterType {
  94194. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94195. directionRandomizer: number;
  94196. private _radius;
  94197. private _angle;
  94198. private _height;
  94199. /**
  94200. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94201. */
  94202. radiusRange: number;
  94203. /**
  94204. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94205. */
  94206. heightRange: number;
  94207. /**
  94208. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94209. */
  94210. emitFromSpawnPointOnly: boolean;
  94211. /**
  94212. * Gets or sets the radius of the emission cone
  94213. */
  94214. get radius(): number;
  94215. set radius(value: number);
  94216. /**
  94217. * Gets or sets the angle of the emission cone
  94218. */
  94219. get angle(): number;
  94220. set angle(value: number);
  94221. private _buildHeight;
  94222. /**
  94223. * Creates a new instance ConeParticleEmitter
  94224. * @param radius the radius of the emission cone (1 by default)
  94225. * @param angle the cone base angle (PI by default)
  94226. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94227. */
  94228. constructor(radius?: number, angle?: number,
  94229. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94230. directionRandomizer?: number);
  94231. /**
  94232. * Called by the particle System when the direction is computed for the created particle.
  94233. * @param worldMatrix is the world matrix of the particle system
  94234. * @param directionToUpdate is the direction vector to update with the result
  94235. * @param particle is the particle we are computed the direction for
  94236. * @param isLocal defines if the direction should be set in local space
  94237. */
  94238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94239. /**
  94240. * Called by the particle System when the position is computed for the created particle.
  94241. * @param worldMatrix is the world matrix of the particle system
  94242. * @param positionToUpdate is the position vector to update with the result
  94243. * @param particle is the particle we are computed the position for
  94244. * @param isLocal defines if the position should be set in local space
  94245. */
  94246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94247. /**
  94248. * Clones the current emitter and returns a copy of it
  94249. * @returns the new emitter
  94250. */
  94251. clone(): ConeParticleEmitter;
  94252. /**
  94253. * Called by the GPUParticleSystem to setup the update shader
  94254. * @param effect defines the update shader
  94255. */
  94256. applyToShader(effect: Effect): void;
  94257. /**
  94258. * Returns a string to use to update the GPU particles update shader
  94259. * @returns a string containng the defines string
  94260. */
  94261. getEffectDefines(): string;
  94262. /**
  94263. * Returns the string "ConeParticleEmitter"
  94264. * @returns a string containing the class name
  94265. */
  94266. getClassName(): string;
  94267. /**
  94268. * Serializes the particle system to a JSON object.
  94269. * @returns the JSON object
  94270. */
  94271. serialize(): any;
  94272. /**
  94273. * Parse properties from a JSON object
  94274. * @param serializationObject defines the JSON object
  94275. */
  94276. parse(serializationObject: any): void;
  94277. }
  94278. }
  94279. declare module BABYLON {
  94280. /**
  94281. * Particle emitter emitting particles from the inside of a cylinder.
  94282. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94283. */
  94284. export class CylinderParticleEmitter implements IParticleEmitterType {
  94285. /**
  94286. * The radius of the emission cylinder.
  94287. */
  94288. radius: number;
  94289. /**
  94290. * The height of the emission cylinder.
  94291. */
  94292. height: number;
  94293. /**
  94294. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94295. */
  94296. radiusRange: number;
  94297. /**
  94298. * How much to randomize the particle direction [0-1].
  94299. */
  94300. directionRandomizer: number;
  94301. /**
  94302. * Creates a new instance CylinderParticleEmitter
  94303. * @param radius the radius of the emission cylinder (1 by default)
  94304. * @param height the height of the emission cylinder (1 by default)
  94305. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94306. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94307. */
  94308. constructor(
  94309. /**
  94310. * The radius of the emission cylinder.
  94311. */
  94312. radius?: number,
  94313. /**
  94314. * The height of the emission cylinder.
  94315. */
  94316. height?: number,
  94317. /**
  94318. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94319. */
  94320. radiusRange?: number,
  94321. /**
  94322. * How much to randomize the particle direction [0-1].
  94323. */
  94324. directionRandomizer?: number);
  94325. /**
  94326. * Called by the particle System when the direction is computed for the created particle.
  94327. * @param worldMatrix is the world matrix of the particle system
  94328. * @param directionToUpdate is the direction vector to update with the result
  94329. * @param particle is the particle we are computed the direction for
  94330. * @param isLocal defines if the direction should be set in local space
  94331. */
  94332. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94333. /**
  94334. * Called by the particle System when the position is computed for the created particle.
  94335. * @param worldMatrix is the world matrix of the particle system
  94336. * @param positionToUpdate is the position vector to update with the result
  94337. * @param particle is the particle we are computed the position for
  94338. * @param isLocal defines if the position should be set in local space
  94339. */
  94340. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94341. /**
  94342. * Clones the current emitter and returns a copy of it
  94343. * @returns the new emitter
  94344. */
  94345. clone(): CylinderParticleEmitter;
  94346. /**
  94347. * Called by the GPUParticleSystem to setup the update shader
  94348. * @param effect defines the update shader
  94349. */
  94350. applyToShader(effect: Effect): void;
  94351. /**
  94352. * Returns a string to use to update the GPU particles update shader
  94353. * @returns a string containng the defines string
  94354. */
  94355. getEffectDefines(): string;
  94356. /**
  94357. * Returns the string "CylinderParticleEmitter"
  94358. * @returns a string containing the class name
  94359. */
  94360. getClassName(): string;
  94361. /**
  94362. * Serializes the particle system to a JSON object.
  94363. * @returns the JSON object
  94364. */
  94365. serialize(): any;
  94366. /**
  94367. * Parse properties from a JSON object
  94368. * @param serializationObject defines the JSON object
  94369. */
  94370. parse(serializationObject: any): void;
  94371. }
  94372. /**
  94373. * Particle emitter emitting particles from the inside of a cylinder.
  94374. * It emits the particles randomly between two vectors.
  94375. */
  94376. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94377. /**
  94378. * The min limit of the emission direction.
  94379. */
  94380. direction1: Vector3;
  94381. /**
  94382. * The max limit of the emission direction.
  94383. */
  94384. direction2: Vector3;
  94385. /**
  94386. * Creates a new instance CylinderDirectedParticleEmitter
  94387. * @param radius the radius of the emission cylinder (1 by default)
  94388. * @param height the height of the emission cylinder (1 by default)
  94389. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94390. * @param direction1 the min limit of the emission direction (up vector by default)
  94391. * @param direction2 the max limit of the emission direction (up vector by default)
  94392. */
  94393. constructor(radius?: number, height?: number, radiusRange?: number,
  94394. /**
  94395. * The min limit of the emission direction.
  94396. */
  94397. direction1?: Vector3,
  94398. /**
  94399. * The max limit of the emission direction.
  94400. */
  94401. direction2?: Vector3);
  94402. /**
  94403. * Called by the particle System when the direction is computed for the created particle.
  94404. * @param worldMatrix is the world matrix of the particle system
  94405. * @param directionToUpdate is the direction vector to update with the result
  94406. * @param particle is the particle we are computed the direction for
  94407. */
  94408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94409. /**
  94410. * Clones the current emitter and returns a copy of it
  94411. * @returns the new emitter
  94412. */
  94413. clone(): CylinderDirectedParticleEmitter;
  94414. /**
  94415. * Called by the GPUParticleSystem to setup the update shader
  94416. * @param effect defines the update shader
  94417. */
  94418. applyToShader(effect: Effect): void;
  94419. /**
  94420. * Returns a string to use to update the GPU particles update shader
  94421. * @returns a string containng the defines string
  94422. */
  94423. getEffectDefines(): string;
  94424. /**
  94425. * Returns the string "CylinderDirectedParticleEmitter"
  94426. * @returns a string containing the class name
  94427. */
  94428. getClassName(): string;
  94429. /**
  94430. * Serializes the particle system to a JSON object.
  94431. * @returns the JSON object
  94432. */
  94433. serialize(): any;
  94434. /**
  94435. * Parse properties from a JSON object
  94436. * @param serializationObject defines the JSON object
  94437. */
  94438. parse(serializationObject: any): void;
  94439. }
  94440. }
  94441. declare module BABYLON {
  94442. /**
  94443. * Particle emitter emitting particles from the inside of a hemisphere.
  94444. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94445. */
  94446. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94447. /**
  94448. * The radius of the emission hemisphere.
  94449. */
  94450. radius: number;
  94451. /**
  94452. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94453. */
  94454. radiusRange: number;
  94455. /**
  94456. * How much to randomize the particle direction [0-1].
  94457. */
  94458. directionRandomizer: number;
  94459. /**
  94460. * Creates a new instance HemisphericParticleEmitter
  94461. * @param radius the radius of the emission hemisphere (1 by default)
  94462. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94463. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94464. */
  94465. constructor(
  94466. /**
  94467. * The radius of the emission hemisphere.
  94468. */
  94469. radius?: number,
  94470. /**
  94471. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94472. */
  94473. radiusRange?: number,
  94474. /**
  94475. * How much to randomize the particle direction [0-1].
  94476. */
  94477. directionRandomizer?: number);
  94478. /**
  94479. * Called by the particle System when the direction is computed for the created particle.
  94480. * @param worldMatrix is the world matrix of the particle system
  94481. * @param directionToUpdate is the direction vector to update with the result
  94482. * @param particle is the particle we are computed the direction for
  94483. * @param isLocal defines if the direction should be set in local space
  94484. */
  94485. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94486. /**
  94487. * Called by the particle System when the position is computed for the created particle.
  94488. * @param worldMatrix is the world matrix of the particle system
  94489. * @param positionToUpdate is the position vector to update with the result
  94490. * @param particle is the particle we are computed the position for
  94491. * @param isLocal defines if the position should be set in local space
  94492. */
  94493. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94494. /**
  94495. * Clones the current emitter and returns a copy of it
  94496. * @returns the new emitter
  94497. */
  94498. clone(): HemisphericParticleEmitter;
  94499. /**
  94500. * Called by the GPUParticleSystem to setup the update shader
  94501. * @param effect defines the update shader
  94502. */
  94503. applyToShader(effect: Effect): void;
  94504. /**
  94505. * Returns a string to use to update the GPU particles update shader
  94506. * @returns a string containng the defines string
  94507. */
  94508. getEffectDefines(): string;
  94509. /**
  94510. * Returns the string "HemisphericParticleEmitter"
  94511. * @returns a string containing the class name
  94512. */
  94513. getClassName(): string;
  94514. /**
  94515. * Serializes the particle system to a JSON object.
  94516. * @returns the JSON object
  94517. */
  94518. serialize(): any;
  94519. /**
  94520. * Parse properties from a JSON object
  94521. * @param serializationObject defines the JSON object
  94522. */
  94523. parse(serializationObject: any): void;
  94524. }
  94525. }
  94526. declare module BABYLON {
  94527. /**
  94528. * Particle emitter emitting particles from a point.
  94529. * It emits the particles randomly between 2 given directions.
  94530. */
  94531. export class PointParticleEmitter implements IParticleEmitterType {
  94532. /**
  94533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94534. */
  94535. direction1: Vector3;
  94536. /**
  94537. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94538. */
  94539. direction2: Vector3;
  94540. /**
  94541. * Creates a new instance PointParticleEmitter
  94542. */
  94543. constructor();
  94544. /**
  94545. * Called by the particle System when the direction is computed for the created particle.
  94546. * @param worldMatrix is the world matrix of the particle system
  94547. * @param directionToUpdate is the direction vector to update with the result
  94548. * @param particle is the particle we are computed the direction for
  94549. * @param isLocal defines if the direction should be set in local space
  94550. */
  94551. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94552. /**
  94553. * Called by the particle System when the position is computed for the created particle.
  94554. * @param worldMatrix is the world matrix of the particle system
  94555. * @param positionToUpdate is the position vector to update with the result
  94556. * @param particle is the particle we are computed the position for
  94557. * @param isLocal defines if the position should be set in local space
  94558. */
  94559. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94560. /**
  94561. * Clones the current emitter and returns a copy of it
  94562. * @returns the new emitter
  94563. */
  94564. clone(): PointParticleEmitter;
  94565. /**
  94566. * Called by the GPUParticleSystem to setup the update shader
  94567. * @param effect defines the update shader
  94568. */
  94569. applyToShader(effect: Effect): void;
  94570. /**
  94571. * Returns a string to use to update the GPU particles update shader
  94572. * @returns a string containng the defines string
  94573. */
  94574. getEffectDefines(): string;
  94575. /**
  94576. * Returns the string "PointParticleEmitter"
  94577. * @returns a string containing the class name
  94578. */
  94579. getClassName(): string;
  94580. /**
  94581. * Serializes the particle system to a JSON object.
  94582. * @returns the JSON object
  94583. */
  94584. serialize(): any;
  94585. /**
  94586. * Parse properties from a JSON object
  94587. * @param serializationObject defines the JSON object
  94588. */
  94589. parse(serializationObject: any): void;
  94590. }
  94591. }
  94592. declare module BABYLON {
  94593. /**
  94594. * Particle emitter emitting particles from the inside of a sphere.
  94595. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94596. */
  94597. export class SphereParticleEmitter implements IParticleEmitterType {
  94598. /**
  94599. * The radius of the emission sphere.
  94600. */
  94601. radius: number;
  94602. /**
  94603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94604. */
  94605. radiusRange: number;
  94606. /**
  94607. * How much to randomize the particle direction [0-1].
  94608. */
  94609. directionRandomizer: number;
  94610. /**
  94611. * Creates a new instance SphereParticleEmitter
  94612. * @param radius the radius of the emission sphere (1 by default)
  94613. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94614. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94615. */
  94616. constructor(
  94617. /**
  94618. * The radius of the emission sphere.
  94619. */
  94620. radius?: number,
  94621. /**
  94622. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94623. */
  94624. radiusRange?: number,
  94625. /**
  94626. * How much to randomize the particle direction [0-1].
  94627. */
  94628. directionRandomizer?: number);
  94629. /**
  94630. * Called by the particle System when the direction is computed for the created particle.
  94631. * @param worldMatrix is the world matrix of the particle system
  94632. * @param directionToUpdate is the direction vector to update with the result
  94633. * @param particle is the particle we are computed the direction for
  94634. * @param isLocal defines if the direction should be set in local space
  94635. */
  94636. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94637. /**
  94638. * Called by the particle System when the position is computed for the created particle.
  94639. * @param worldMatrix is the world matrix of the particle system
  94640. * @param positionToUpdate is the position vector to update with the result
  94641. * @param particle is the particle we are computed the position for
  94642. * @param isLocal defines if the position should be set in local space
  94643. */
  94644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94645. /**
  94646. * Clones the current emitter and returns a copy of it
  94647. * @returns the new emitter
  94648. */
  94649. clone(): SphereParticleEmitter;
  94650. /**
  94651. * Called by the GPUParticleSystem to setup the update shader
  94652. * @param effect defines the update shader
  94653. */
  94654. applyToShader(effect: Effect): void;
  94655. /**
  94656. * Returns a string to use to update the GPU particles update shader
  94657. * @returns a string containng the defines string
  94658. */
  94659. getEffectDefines(): string;
  94660. /**
  94661. * Returns the string "SphereParticleEmitter"
  94662. * @returns a string containing the class name
  94663. */
  94664. getClassName(): string;
  94665. /**
  94666. * Serializes the particle system to a JSON object.
  94667. * @returns the JSON object
  94668. */
  94669. serialize(): any;
  94670. /**
  94671. * Parse properties from a JSON object
  94672. * @param serializationObject defines the JSON object
  94673. */
  94674. parse(serializationObject: any): void;
  94675. }
  94676. /**
  94677. * Particle emitter emitting particles from the inside of a sphere.
  94678. * It emits the particles randomly between two vectors.
  94679. */
  94680. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94681. /**
  94682. * The min limit of the emission direction.
  94683. */
  94684. direction1: Vector3;
  94685. /**
  94686. * The max limit of the emission direction.
  94687. */
  94688. direction2: Vector3;
  94689. /**
  94690. * Creates a new instance SphereDirectedParticleEmitter
  94691. * @param radius the radius of the emission sphere (1 by default)
  94692. * @param direction1 the min limit of the emission direction (up vector by default)
  94693. * @param direction2 the max limit of the emission direction (up vector by default)
  94694. */
  94695. constructor(radius?: number,
  94696. /**
  94697. * The min limit of the emission direction.
  94698. */
  94699. direction1?: Vector3,
  94700. /**
  94701. * The max limit of the emission direction.
  94702. */
  94703. direction2?: Vector3);
  94704. /**
  94705. * Called by the particle System when the direction is computed for the created particle.
  94706. * @param worldMatrix is the world matrix of the particle system
  94707. * @param directionToUpdate is the direction vector to update with the result
  94708. * @param particle is the particle we are computed the direction for
  94709. */
  94710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94711. /**
  94712. * Clones the current emitter and returns a copy of it
  94713. * @returns the new emitter
  94714. */
  94715. clone(): SphereDirectedParticleEmitter;
  94716. /**
  94717. * Called by the GPUParticleSystem to setup the update shader
  94718. * @param effect defines the update shader
  94719. */
  94720. applyToShader(effect: Effect): void;
  94721. /**
  94722. * Returns a string to use to update the GPU particles update shader
  94723. * @returns a string containng the defines string
  94724. */
  94725. getEffectDefines(): string;
  94726. /**
  94727. * Returns the string "SphereDirectedParticleEmitter"
  94728. * @returns a string containing the class name
  94729. */
  94730. getClassName(): string;
  94731. /**
  94732. * Serializes the particle system to a JSON object.
  94733. * @returns the JSON object
  94734. */
  94735. serialize(): any;
  94736. /**
  94737. * Parse properties from a JSON object
  94738. * @param serializationObject defines the JSON object
  94739. */
  94740. parse(serializationObject: any): void;
  94741. }
  94742. }
  94743. declare module BABYLON {
  94744. /**
  94745. * Particle emitter emitting particles from a custom list of positions.
  94746. */
  94747. export class CustomParticleEmitter implements IParticleEmitterType {
  94748. /**
  94749. * Gets or sets the position generator that will create the inital position of each particle.
  94750. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94751. */
  94752. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94753. /**
  94754. * Gets or sets the destination generator that will create the final destination of each particle.
  94755. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94756. */
  94757. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94758. /**
  94759. * Creates a new instance CustomParticleEmitter
  94760. */
  94761. constructor();
  94762. /**
  94763. * Called by the particle System when the direction is computed for the created particle.
  94764. * @param worldMatrix is the world matrix of the particle system
  94765. * @param directionToUpdate is the direction vector to update with the result
  94766. * @param particle is the particle we are computed the direction for
  94767. * @param isLocal defines if the direction should be set in local space
  94768. */
  94769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94770. /**
  94771. * Called by the particle System when the position is computed for the created particle.
  94772. * @param worldMatrix is the world matrix of the particle system
  94773. * @param positionToUpdate is the position vector to update with the result
  94774. * @param particle is the particle we are computed the position for
  94775. * @param isLocal defines if the position should be set in local space
  94776. */
  94777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94778. /**
  94779. * Clones the current emitter and returns a copy of it
  94780. * @returns the new emitter
  94781. */
  94782. clone(): CustomParticleEmitter;
  94783. /**
  94784. * Called by the GPUParticleSystem to setup the update shader
  94785. * @param effect defines the update shader
  94786. */
  94787. applyToShader(effect: Effect): void;
  94788. /**
  94789. * Returns a string to use to update the GPU particles update shader
  94790. * @returns a string containng the defines string
  94791. */
  94792. getEffectDefines(): string;
  94793. /**
  94794. * Returns the string "PointParticleEmitter"
  94795. * @returns a string containing the class name
  94796. */
  94797. getClassName(): string;
  94798. /**
  94799. * Serializes the particle system to a JSON object.
  94800. * @returns the JSON object
  94801. */
  94802. serialize(): any;
  94803. /**
  94804. * Parse properties from a JSON object
  94805. * @param serializationObject defines the JSON object
  94806. */
  94807. parse(serializationObject: any): void;
  94808. }
  94809. }
  94810. declare module BABYLON {
  94811. /**
  94812. * Particle emitter emitting particles from the inside of a box.
  94813. * It emits the particles randomly between 2 given directions.
  94814. */
  94815. export class MeshParticleEmitter implements IParticleEmitterType {
  94816. private _indices;
  94817. private _positions;
  94818. private _normals;
  94819. private _storedNormal;
  94820. private _mesh;
  94821. /**
  94822. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94823. */
  94824. direction1: Vector3;
  94825. /**
  94826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94827. */
  94828. direction2: Vector3;
  94829. /**
  94830. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94831. */
  94832. useMeshNormalsForDirection: boolean;
  94833. /** Defines the mesh to use as source */
  94834. get mesh(): Nullable<AbstractMesh>;
  94835. set mesh(value: Nullable<AbstractMesh>);
  94836. /**
  94837. * Creates a new instance MeshParticleEmitter
  94838. * @param mesh defines the mesh to use as source
  94839. */
  94840. constructor(mesh?: Nullable<AbstractMesh>);
  94841. /**
  94842. * Called by the particle System when the direction is computed for the created particle.
  94843. * @param worldMatrix is the world matrix of the particle system
  94844. * @param directionToUpdate is the direction vector to update with the result
  94845. * @param particle is the particle we are computed the direction for
  94846. * @param isLocal defines if the direction should be set in local space
  94847. */
  94848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94849. /**
  94850. * Called by the particle System when the position is computed for the created particle.
  94851. * @param worldMatrix is the world matrix of the particle system
  94852. * @param positionToUpdate is the position vector to update with the result
  94853. * @param particle is the particle we are computed the position for
  94854. * @param isLocal defines if the position should be set in local space
  94855. */
  94856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94857. /**
  94858. * Clones the current emitter and returns a copy of it
  94859. * @returns the new emitter
  94860. */
  94861. clone(): MeshParticleEmitter;
  94862. /**
  94863. * Called by the GPUParticleSystem to setup the update shader
  94864. * @param effect defines the update shader
  94865. */
  94866. applyToShader(effect: Effect): void;
  94867. /**
  94868. * Returns a string to use to update the GPU particles update shader
  94869. * @returns a string containng the defines string
  94870. */
  94871. getEffectDefines(): string;
  94872. /**
  94873. * Returns the string "BoxParticleEmitter"
  94874. * @returns a string containing the class name
  94875. */
  94876. getClassName(): string;
  94877. /**
  94878. * Serializes the particle system to a JSON object.
  94879. * @returns the JSON object
  94880. */
  94881. serialize(): any;
  94882. /**
  94883. * Parse properties from a JSON object
  94884. * @param serializationObject defines the JSON object
  94885. * @param scene defines the hosting scene
  94886. */
  94887. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94888. }
  94889. }
  94890. declare module BABYLON {
  94891. /**
  94892. * Interface representing a particle system in Babylon.js.
  94893. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94894. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94895. */
  94896. export interface IParticleSystem {
  94897. /**
  94898. * List of animations used by the particle system.
  94899. */
  94900. animations: Animation[];
  94901. /**
  94902. * The id of the Particle system.
  94903. */
  94904. id: string;
  94905. /**
  94906. * The name of the Particle system.
  94907. */
  94908. name: string;
  94909. /**
  94910. * The emitter represents the Mesh or position we are attaching the particle system to.
  94911. */
  94912. emitter: Nullable<AbstractMesh | Vector3>;
  94913. /**
  94914. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94915. */
  94916. isBillboardBased: boolean;
  94917. /**
  94918. * The rendering group used by the Particle system to chose when to render.
  94919. */
  94920. renderingGroupId: number;
  94921. /**
  94922. * The layer mask we are rendering the particles through.
  94923. */
  94924. layerMask: number;
  94925. /**
  94926. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94927. */
  94928. updateSpeed: number;
  94929. /**
  94930. * The amount of time the particle system is running (depends of the overall update speed).
  94931. */
  94932. targetStopDuration: number;
  94933. /**
  94934. * The texture used to render each particle. (this can be a spritesheet)
  94935. */
  94936. particleTexture: Nullable<BaseTexture>;
  94937. /**
  94938. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94939. */
  94940. blendMode: number;
  94941. /**
  94942. * Minimum life time of emitting particles.
  94943. */
  94944. minLifeTime: number;
  94945. /**
  94946. * Maximum life time of emitting particles.
  94947. */
  94948. maxLifeTime: number;
  94949. /**
  94950. * Minimum Size of emitting particles.
  94951. */
  94952. minSize: number;
  94953. /**
  94954. * Maximum Size of emitting particles.
  94955. */
  94956. maxSize: number;
  94957. /**
  94958. * Minimum scale of emitting particles on X axis.
  94959. */
  94960. minScaleX: number;
  94961. /**
  94962. * Maximum scale of emitting particles on X axis.
  94963. */
  94964. maxScaleX: number;
  94965. /**
  94966. * Minimum scale of emitting particles on Y axis.
  94967. */
  94968. minScaleY: number;
  94969. /**
  94970. * Maximum scale of emitting particles on Y axis.
  94971. */
  94972. maxScaleY: number;
  94973. /**
  94974. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94975. */
  94976. color1: Color4;
  94977. /**
  94978. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94979. */
  94980. color2: Color4;
  94981. /**
  94982. * Color the particle will have at the end of its lifetime.
  94983. */
  94984. colorDead: Color4;
  94985. /**
  94986. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94987. */
  94988. emitRate: number;
  94989. /**
  94990. * You can use gravity if you want to give an orientation to your particles.
  94991. */
  94992. gravity: Vector3;
  94993. /**
  94994. * Minimum power of emitting particles.
  94995. */
  94996. minEmitPower: number;
  94997. /**
  94998. * Maximum power of emitting particles.
  94999. */
  95000. maxEmitPower: number;
  95001. /**
  95002. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95003. */
  95004. minAngularSpeed: number;
  95005. /**
  95006. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95007. */
  95008. maxAngularSpeed: number;
  95009. /**
  95010. * Gets or sets the minimal initial rotation in radians.
  95011. */
  95012. minInitialRotation: number;
  95013. /**
  95014. * Gets or sets the maximal initial rotation in radians.
  95015. */
  95016. maxInitialRotation: number;
  95017. /**
  95018. * The particle emitter type defines the emitter used by the particle system.
  95019. * It can be for example box, sphere, or cone...
  95020. */
  95021. particleEmitterType: Nullable<IParticleEmitterType>;
  95022. /**
  95023. * Defines the delay in milliseconds before starting the system (0 by default)
  95024. */
  95025. startDelay: number;
  95026. /**
  95027. * 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
  95028. */
  95029. preWarmCycles: number;
  95030. /**
  95031. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  95032. */
  95033. preWarmStepOffset: number;
  95034. /**
  95035. * 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)
  95036. */
  95037. spriteCellChangeSpeed: number;
  95038. /**
  95039. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95040. */
  95041. startSpriteCellID: number;
  95042. /**
  95043. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95044. */
  95045. endSpriteCellID: number;
  95046. /**
  95047. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95048. */
  95049. spriteCellWidth: number;
  95050. /**
  95051. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95052. */
  95053. spriteCellHeight: number;
  95054. /**
  95055. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95056. */
  95057. spriteRandomStartCell: boolean;
  95058. /**
  95059. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95060. */
  95061. isAnimationSheetEnabled: boolean;
  95062. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95063. translationPivot: Vector2;
  95064. /**
  95065. * Gets or sets a texture used to add random noise to particle positions
  95066. */
  95067. noiseTexture: Nullable<BaseTexture>;
  95068. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95069. noiseStrength: Vector3;
  95070. /**
  95071. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95072. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95073. */
  95074. billboardMode: number;
  95075. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95076. limitVelocityDamping: number;
  95077. /**
  95078. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95079. */
  95080. beginAnimationOnStart: boolean;
  95081. /**
  95082. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95083. */
  95084. beginAnimationFrom: number;
  95085. /**
  95086. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95087. */
  95088. beginAnimationTo: number;
  95089. /**
  95090. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95091. */
  95092. beginAnimationLoop: boolean;
  95093. /**
  95094. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95095. */
  95096. disposeOnStop: boolean;
  95097. /**
  95098. * Specifies if the particles are updated in emitter local space or world space
  95099. */
  95100. isLocal: boolean;
  95101. /** Snippet ID if the particle system was created from the snippet server */
  95102. snippetId: string;
  95103. /** Gets or sets a matrix to use to compute projection */
  95104. defaultProjectionMatrix: Matrix;
  95105. /**
  95106. * Gets the maximum number of particles active at the same time.
  95107. * @returns The max number of active particles.
  95108. */
  95109. getCapacity(): number;
  95110. /**
  95111. * Gets the number of particles active at the same time.
  95112. * @returns The number of active particles.
  95113. */
  95114. getActiveCount(): number;
  95115. /**
  95116. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95117. * @returns True if it has been started, otherwise false.
  95118. */
  95119. isStarted(): boolean;
  95120. /**
  95121. * Animates the particle system for this frame.
  95122. */
  95123. animate(): void;
  95124. /**
  95125. * Renders the particle system in its current state.
  95126. * @returns the current number of particles
  95127. */
  95128. render(): number;
  95129. /**
  95130. * Dispose the particle system and frees its associated resources.
  95131. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95132. */
  95133. dispose(disposeTexture?: boolean): void;
  95134. /**
  95135. * An event triggered when the system is disposed
  95136. */
  95137. onDisposeObservable: Observable<IParticleSystem>;
  95138. /**
  95139. * An event triggered when the system is stopped
  95140. */
  95141. onStoppedObservable: Observable<IParticleSystem>;
  95142. /**
  95143. * Clones the particle system.
  95144. * @param name The name of the cloned object
  95145. * @param newEmitter The new emitter to use
  95146. * @returns the cloned particle system
  95147. */
  95148. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95149. /**
  95150. * Serializes the particle system to a JSON object
  95151. * @param serializeTexture defines if the texture must be serialized as well
  95152. * @returns the JSON object
  95153. */
  95154. serialize(serializeTexture: boolean): any;
  95155. /**
  95156. * Rebuild the particle system
  95157. */
  95158. rebuild(): void;
  95159. /** Force the system to rebuild all gradients that need to be resync */
  95160. forceRefreshGradients(): void;
  95161. /**
  95162. * Starts the particle system and begins to emit
  95163. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95164. */
  95165. start(delay?: number): void;
  95166. /**
  95167. * Stops the particle system.
  95168. */
  95169. stop(): void;
  95170. /**
  95171. * Remove all active particles
  95172. */
  95173. reset(): void;
  95174. /**
  95175. * Gets a boolean indicating that the system is stopping
  95176. * @returns true if the system is currently stopping
  95177. */
  95178. isStopping(): boolean;
  95179. /**
  95180. * Is this system ready to be used/rendered
  95181. * @return true if the system is ready
  95182. */
  95183. isReady(): boolean;
  95184. /**
  95185. * Returns the string "ParticleSystem"
  95186. * @returns a string containing the class name
  95187. */
  95188. getClassName(): string;
  95189. /**
  95190. * Gets the custom effect used to render the particles
  95191. * @param blendMode Blend mode for which the effect should be retrieved
  95192. * @returns The effect
  95193. */
  95194. getCustomEffect(blendMode: number): Nullable<Effect>;
  95195. /**
  95196. * Sets the custom effect used to render the particles
  95197. * @param effect The effect to set
  95198. * @param blendMode Blend mode for which the effect should be set
  95199. */
  95200. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95201. /**
  95202. * Fill the defines array according to the current settings of the particle system
  95203. * @param defines Array to be updated
  95204. * @param blendMode blend mode to take into account when updating the array
  95205. */
  95206. fillDefines(defines: Array<string>, blendMode: number): void;
  95207. /**
  95208. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95209. * @param uniforms Uniforms array to fill
  95210. * @param attributes Attributes array to fill
  95211. * @param samplers Samplers array to fill
  95212. */
  95213. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95214. /**
  95215. * Observable that will be called just before the particles are drawn
  95216. */
  95217. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95218. /**
  95219. * Gets the name of the particle vertex shader
  95220. */
  95221. vertexShaderName: string;
  95222. /**
  95223. * Adds a new color gradient
  95224. * @param gradient defines the gradient to use (between 0 and 1)
  95225. * @param color1 defines the color to affect to the specified gradient
  95226. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95227. * @returns the current particle system
  95228. */
  95229. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95230. /**
  95231. * Remove a specific color gradient
  95232. * @param gradient defines the gradient to remove
  95233. * @returns the current particle system
  95234. */
  95235. removeColorGradient(gradient: number): IParticleSystem;
  95236. /**
  95237. * Adds a new size gradient
  95238. * @param gradient defines the gradient to use (between 0 and 1)
  95239. * @param factor defines the size factor to affect to the specified gradient
  95240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95241. * @returns the current particle system
  95242. */
  95243. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95244. /**
  95245. * Remove a specific size gradient
  95246. * @param gradient defines the gradient to remove
  95247. * @returns the current particle system
  95248. */
  95249. removeSizeGradient(gradient: number): IParticleSystem;
  95250. /**
  95251. * Gets the current list of color gradients.
  95252. * You must use addColorGradient and removeColorGradient to udpate this list
  95253. * @returns the list of color gradients
  95254. */
  95255. getColorGradients(): Nullable<Array<ColorGradient>>;
  95256. /**
  95257. * Gets the current list of size gradients.
  95258. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95259. * @returns the list of size gradients
  95260. */
  95261. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95262. /**
  95263. * Gets the current list of angular speed gradients.
  95264. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95265. * @returns the list of angular speed gradients
  95266. */
  95267. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95268. /**
  95269. * Adds a new angular speed gradient
  95270. * @param gradient defines the gradient to use (between 0 and 1)
  95271. * @param factor defines the angular speed to affect to the specified gradient
  95272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95273. * @returns the current particle system
  95274. */
  95275. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95276. /**
  95277. * Remove a specific angular speed gradient
  95278. * @param gradient defines the gradient to remove
  95279. * @returns the current particle system
  95280. */
  95281. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95282. /**
  95283. * Gets the current list of velocity gradients.
  95284. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95285. * @returns the list of velocity gradients
  95286. */
  95287. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95288. /**
  95289. * Adds a new velocity gradient
  95290. * @param gradient defines the gradient to use (between 0 and 1)
  95291. * @param factor defines the velocity to affect to the specified gradient
  95292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95293. * @returns the current particle system
  95294. */
  95295. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95296. /**
  95297. * Remove a specific velocity gradient
  95298. * @param gradient defines the gradient to remove
  95299. * @returns the current particle system
  95300. */
  95301. removeVelocityGradient(gradient: number): IParticleSystem;
  95302. /**
  95303. * Gets the current list of limit velocity gradients.
  95304. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95305. * @returns the list of limit velocity gradients
  95306. */
  95307. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95308. /**
  95309. * Adds a new limit velocity gradient
  95310. * @param gradient defines the gradient to use (between 0 and 1)
  95311. * @param factor defines the limit velocity to affect to the specified gradient
  95312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95313. * @returns the current particle system
  95314. */
  95315. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95316. /**
  95317. * Remove a specific limit velocity gradient
  95318. * @param gradient defines the gradient to remove
  95319. * @returns the current particle system
  95320. */
  95321. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95322. /**
  95323. * Adds a new drag gradient
  95324. * @param gradient defines the gradient to use (between 0 and 1)
  95325. * @param factor defines the drag to affect to the specified gradient
  95326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95327. * @returns the current particle system
  95328. */
  95329. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95330. /**
  95331. * Remove a specific drag gradient
  95332. * @param gradient defines the gradient to remove
  95333. * @returns the current particle system
  95334. */
  95335. removeDragGradient(gradient: number): IParticleSystem;
  95336. /**
  95337. * Gets the current list of drag gradients.
  95338. * You must use addDragGradient and removeDragGradient to udpate this list
  95339. * @returns the list of drag gradients
  95340. */
  95341. getDragGradients(): Nullable<Array<FactorGradient>>;
  95342. /**
  95343. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95344. * @param gradient defines the gradient to use (between 0 and 1)
  95345. * @param factor defines the emit rate to affect to the specified gradient
  95346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95347. * @returns the current particle system
  95348. */
  95349. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95350. /**
  95351. * Remove a specific emit rate gradient
  95352. * @param gradient defines the gradient to remove
  95353. * @returns the current particle system
  95354. */
  95355. removeEmitRateGradient(gradient: number): IParticleSystem;
  95356. /**
  95357. * Gets the current list of emit rate gradients.
  95358. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95359. * @returns the list of emit rate gradients
  95360. */
  95361. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95362. /**
  95363. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95364. * @param gradient defines the gradient to use (between 0 and 1)
  95365. * @param factor defines the start size to affect to the specified gradient
  95366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95367. * @returns the current particle system
  95368. */
  95369. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95370. /**
  95371. * Remove a specific start size gradient
  95372. * @param gradient defines the gradient to remove
  95373. * @returns the current particle system
  95374. */
  95375. removeStartSizeGradient(gradient: number): IParticleSystem;
  95376. /**
  95377. * Gets the current list of start size gradients.
  95378. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95379. * @returns the list of start size gradients
  95380. */
  95381. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95382. /**
  95383. * Adds a new life time gradient
  95384. * @param gradient defines the gradient to use (between 0 and 1)
  95385. * @param factor defines the life time factor to affect to the specified gradient
  95386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95387. * @returns the current particle system
  95388. */
  95389. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95390. /**
  95391. * Remove a specific life time gradient
  95392. * @param gradient defines the gradient to remove
  95393. * @returns the current particle system
  95394. */
  95395. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95396. /**
  95397. * Gets the current list of life time gradients.
  95398. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95399. * @returns the list of life time gradients
  95400. */
  95401. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95402. /**
  95403. * Gets the current list of color gradients.
  95404. * You must use addColorGradient and removeColorGradient to udpate this list
  95405. * @returns the list of color gradients
  95406. */
  95407. getColorGradients(): Nullable<Array<ColorGradient>>;
  95408. /**
  95409. * Adds a new ramp gradient used to remap particle colors
  95410. * @param gradient defines the gradient to use (between 0 and 1)
  95411. * @param color defines the color to affect to the specified gradient
  95412. * @returns the current particle system
  95413. */
  95414. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95415. /**
  95416. * Gets the current list of ramp gradients.
  95417. * You must use addRampGradient and removeRampGradient to udpate this list
  95418. * @returns the list of ramp gradients
  95419. */
  95420. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95421. /** Gets or sets a boolean indicating that ramp gradients must be used
  95422. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95423. */
  95424. useRampGradients: boolean;
  95425. /**
  95426. * Adds a new color remap gradient
  95427. * @param gradient defines the gradient to use (between 0 and 1)
  95428. * @param min defines the color remap minimal range
  95429. * @param max defines the color remap maximal range
  95430. * @returns the current particle system
  95431. */
  95432. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95433. /**
  95434. * Gets the current list of color remap gradients.
  95435. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95436. * @returns the list of color remap gradients
  95437. */
  95438. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95439. /**
  95440. * Adds a new alpha remap gradient
  95441. * @param gradient defines the gradient to use (between 0 and 1)
  95442. * @param min defines the alpha remap minimal range
  95443. * @param max defines the alpha remap maximal range
  95444. * @returns the current particle system
  95445. */
  95446. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95447. /**
  95448. * Gets the current list of alpha remap gradients.
  95449. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95450. * @returns the list of alpha remap gradients
  95451. */
  95452. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95453. /**
  95454. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95455. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95456. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95457. * @returns the emitter
  95458. */
  95459. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95460. /**
  95461. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95462. * @param radius The radius of the hemisphere to emit from
  95463. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95464. * @returns the emitter
  95465. */
  95466. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95467. /**
  95468. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95469. * @param radius The radius of the sphere to emit from
  95470. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95471. * @returns the emitter
  95472. */
  95473. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95474. /**
  95475. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95476. * @param radius The radius of the sphere to emit from
  95477. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95478. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95479. * @returns the emitter
  95480. */
  95481. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95482. /**
  95483. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95484. * @param radius The radius of the emission cylinder
  95485. * @param height The height of the emission cylinder
  95486. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95487. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95488. * @returns the emitter
  95489. */
  95490. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95491. /**
  95492. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95493. * @param radius The radius of the cylinder to emit from
  95494. * @param height The height of the emission cylinder
  95495. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95498. * @returns the emitter
  95499. */
  95500. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95501. /**
  95502. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95503. * @param radius The radius of the cone to emit from
  95504. * @param angle The base angle of the cone
  95505. * @returns the emitter
  95506. */
  95507. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95508. /**
  95509. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95510. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95511. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95512. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95513. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95514. * @returns the emitter
  95515. */
  95516. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95517. /**
  95518. * Get hosting scene
  95519. * @returns the scene
  95520. */
  95521. getScene(): Nullable<Scene>;
  95522. }
  95523. }
  95524. declare module BABYLON {
  95525. /**
  95526. * 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.
  95527. * @see https://doc.babylonjs.com/how_to/transformnode
  95528. */
  95529. export class TransformNode extends Node {
  95530. /**
  95531. * Object will not rotate to face the camera
  95532. */
  95533. static BILLBOARDMODE_NONE: number;
  95534. /**
  95535. * Object will rotate to face the camera but only on the x axis
  95536. */
  95537. static BILLBOARDMODE_X: number;
  95538. /**
  95539. * Object will rotate to face the camera but only on the y axis
  95540. */
  95541. static BILLBOARDMODE_Y: number;
  95542. /**
  95543. * Object will rotate to face the camera but only on the z axis
  95544. */
  95545. static BILLBOARDMODE_Z: number;
  95546. /**
  95547. * Object will rotate to face the camera
  95548. */
  95549. static BILLBOARDMODE_ALL: number;
  95550. /**
  95551. * Object will rotate to face the camera's position instead of orientation
  95552. */
  95553. static BILLBOARDMODE_USE_POSITION: number;
  95554. private static _TmpRotation;
  95555. private static _TmpScaling;
  95556. private static _TmpTranslation;
  95557. private _forward;
  95558. private _forwardInverted;
  95559. private _up;
  95560. private _right;
  95561. private _rightInverted;
  95562. private _position;
  95563. private _rotation;
  95564. private _rotationQuaternion;
  95565. protected _scaling: Vector3;
  95566. protected _isDirty: boolean;
  95567. private _transformToBoneReferal;
  95568. private _isAbsoluteSynced;
  95569. private _billboardMode;
  95570. /**
  95571. * Gets or sets the billboard mode. Default is 0.
  95572. *
  95573. * | Value | Type | Description |
  95574. * | --- | --- | --- |
  95575. * | 0 | BILLBOARDMODE_NONE | |
  95576. * | 1 | BILLBOARDMODE_X | |
  95577. * | 2 | BILLBOARDMODE_Y | |
  95578. * | 4 | BILLBOARDMODE_Z | |
  95579. * | 7 | BILLBOARDMODE_ALL | |
  95580. *
  95581. */
  95582. get billboardMode(): number;
  95583. set billboardMode(value: number);
  95584. private _preserveParentRotationForBillboard;
  95585. /**
  95586. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95587. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95588. */
  95589. get preserveParentRotationForBillboard(): boolean;
  95590. set preserveParentRotationForBillboard(value: boolean);
  95591. /**
  95592. * 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
  95593. */
  95594. scalingDeterminant: number;
  95595. private _infiniteDistance;
  95596. /**
  95597. * Gets or sets the distance of the object to max, often used by skybox
  95598. */
  95599. get infiniteDistance(): boolean;
  95600. set infiniteDistance(value: boolean);
  95601. /**
  95602. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95603. * By default the system will update normals to compensate
  95604. */
  95605. ignoreNonUniformScaling: boolean;
  95606. /**
  95607. * 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
  95608. */
  95609. reIntegrateRotationIntoRotationQuaternion: boolean;
  95610. /** @hidden */
  95611. _poseMatrix: Nullable<Matrix>;
  95612. /** @hidden */
  95613. _localMatrix: Matrix;
  95614. private _usePivotMatrix;
  95615. private _absolutePosition;
  95616. private _absoluteScaling;
  95617. private _absoluteRotationQuaternion;
  95618. private _pivotMatrix;
  95619. private _pivotMatrixInverse;
  95620. /** @hidden */
  95621. _postMultiplyPivotMatrix: boolean;
  95622. protected _isWorldMatrixFrozen: boolean;
  95623. /** @hidden */
  95624. _indexInSceneTransformNodesArray: number;
  95625. /**
  95626. * An event triggered after the world matrix is updated
  95627. */
  95628. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95629. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95630. /**
  95631. * Gets a string identifying the name of the class
  95632. * @returns "TransformNode" string
  95633. */
  95634. getClassName(): string;
  95635. /**
  95636. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95637. */
  95638. get position(): Vector3;
  95639. set position(newPosition: Vector3);
  95640. /**
  95641. * 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)).
  95642. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95643. */
  95644. get rotation(): Vector3;
  95645. set rotation(newRotation: Vector3);
  95646. /**
  95647. * 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)).
  95648. */
  95649. get scaling(): Vector3;
  95650. set scaling(newScaling: Vector3);
  95651. /**
  95652. * 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).
  95653. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95654. */
  95655. get rotationQuaternion(): Nullable<Quaternion>;
  95656. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95657. /**
  95658. * The forward direction of that transform in world space.
  95659. */
  95660. get forward(): Vector3;
  95661. /**
  95662. * The up direction of that transform in world space.
  95663. */
  95664. get up(): Vector3;
  95665. /**
  95666. * The right direction of that transform in world space.
  95667. */
  95668. get right(): Vector3;
  95669. /**
  95670. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95671. * @param matrix the matrix to copy the pose from
  95672. * @returns this TransformNode.
  95673. */
  95674. updatePoseMatrix(matrix: Matrix): TransformNode;
  95675. /**
  95676. * Returns the mesh Pose matrix.
  95677. * @returns the pose matrix
  95678. */
  95679. getPoseMatrix(): Matrix;
  95680. /** @hidden */
  95681. _isSynchronized(): boolean;
  95682. /** @hidden */
  95683. _initCache(): void;
  95684. /**
  95685. * Flag the transform node as dirty (Forcing it to update everything)
  95686. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95687. * @returns this transform node
  95688. */
  95689. markAsDirty(property: string): TransformNode;
  95690. /**
  95691. * Returns the current mesh absolute position.
  95692. * Returns a Vector3.
  95693. */
  95694. get absolutePosition(): Vector3;
  95695. /**
  95696. * Returns the current mesh absolute scaling.
  95697. * Returns a Vector3.
  95698. */
  95699. get absoluteScaling(): Vector3;
  95700. /**
  95701. * Returns the current mesh absolute rotation.
  95702. * Returns a Quaternion.
  95703. */
  95704. get absoluteRotationQuaternion(): Quaternion;
  95705. /**
  95706. * Sets a new matrix to apply before all other transformation
  95707. * @param matrix defines the transform matrix
  95708. * @returns the current TransformNode
  95709. */
  95710. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95711. /**
  95712. * Sets a new pivot matrix to the current node
  95713. * @param matrix defines the new pivot matrix to use
  95714. * @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
  95715. * @returns the current TransformNode
  95716. */
  95717. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95718. /**
  95719. * Returns the mesh pivot matrix.
  95720. * Default : Identity.
  95721. * @returns the matrix
  95722. */
  95723. getPivotMatrix(): Matrix;
  95724. /**
  95725. * Instantiate (when possible) or clone that node with its hierarchy
  95726. * @param newParent defines the new parent to use for the instance (or clone)
  95727. * @param options defines options to configure how copy is done
  95728. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95729. * @returns an instance (or a clone) of the current node with its hiearchy
  95730. */
  95731. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95732. doNotInstantiate: boolean;
  95733. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95734. /**
  95735. * Prevents the World matrix to be computed any longer
  95736. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95737. * @returns the TransformNode.
  95738. */
  95739. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95740. /**
  95741. * Allows back the World matrix computation.
  95742. * @returns the TransformNode.
  95743. */
  95744. unfreezeWorldMatrix(): this;
  95745. /**
  95746. * True if the World matrix has been frozen.
  95747. */
  95748. get isWorldMatrixFrozen(): boolean;
  95749. /**
  95750. * Retuns the mesh absolute position in the World.
  95751. * @returns a Vector3.
  95752. */
  95753. getAbsolutePosition(): Vector3;
  95754. /**
  95755. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95756. * @param absolutePosition the absolute position to set
  95757. * @returns the TransformNode.
  95758. */
  95759. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95760. /**
  95761. * Sets the mesh position in its local space.
  95762. * @param vector3 the position to set in localspace
  95763. * @returns the TransformNode.
  95764. */
  95765. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95766. /**
  95767. * Returns the mesh position in the local space from the current World matrix values.
  95768. * @returns a new Vector3.
  95769. */
  95770. getPositionExpressedInLocalSpace(): Vector3;
  95771. /**
  95772. * Translates the mesh along the passed Vector3 in its local space.
  95773. * @param vector3 the distance to translate in localspace
  95774. * @returns the TransformNode.
  95775. */
  95776. locallyTranslate(vector3: Vector3): TransformNode;
  95777. private static _lookAtVectorCache;
  95778. /**
  95779. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95780. * @param targetPoint the position (must be in same space as current mesh) to look at
  95781. * @param yawCor optional yaw (y-axis) correction in radians
  95782. * @param pitchCor optional pitch (x-axis) correction in radians
  95783. * @param rollCor optional roll (z-axis) correction in radians
  95784. * @param space the choosen space of the target
  95785. * @returns the TransformNode.
  95786. */
  95787. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95788. /**
  95789. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95790. * This Vector3 is expressed in the World space.
  95791. * @param localAxis axis to rotate
  95792. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95793. */
  95794. getDirection(localAxis: Vector3): Vector3;
  95795. /**
  95796. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95797. * localAxis is expressed in the mesh local space.
  95798. * result is computed in the Wordl space from the mesh World matrix.
  95799. * @param localAxis axis to rotate
  95800. * @param result the resulting transformnode
  95801. * @returns this TransformNode.
  95802. */
  95803. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95804. /**
  95805. * Sets this transform node rotation to the given local axis.
  95806. * @param localAxis the axis in local space
  95807. * @param yawCor optional yaw (y-axis) correction in radians
  95808. * @param pitchCor optional pitch (x-axis) correction in radians
  95809. * @param rollCor optional roll (z-axis) correction in radians
  95810. * @returns this TransformNode
  95811. */
  95812. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95813. /**
  95814. * Sets a new pivot point to the current node
  95815. * @param point defines the new pivot point to use
  95816. * @param space defines if the point is in world or local space (local by default)
  95817. * @returns the current TransformNode
  95818. */
  95819. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95820. /**
  95821. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95822. * @returns the pivot point
  95823. */
  95824. getPivotPoint(): Vector3;
  95825. /**
  95826. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95827. * @param result the vector3 to store the result
  95828. * @returns this TransformNode.
  95829. */
  95830. getPivotPointToRef(result: Vector3): TransformNode;
  95831. /**
  95832. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95833. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95834. */
  95835. getAbsolutePivotPoint(): Vector3;
  95836. /**
  95837. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95838. * @param result vector3 to store the result
  95839. * @returns this TransformNode.
  95840. */
  95841. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95842. /**
  95843. * Defines the passed node as the parent of the current node.
  95844. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95845. * @see https://doc.babylonjs.com/how_to/parenting
  95846. * @param node the node ot set as the parent
  95847. * @returns this TransformNode.
  95848. */
  95849. setParent(node: Nullable<Node>): TransformNode;
  95850. private _nonUniformScaling;
  95851. /**
  95852. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95853. */
  95854. get nonUniformScaling(): boolean;
  95855. /** @hidden */
  95856. _updateNonUniformScalingState(value: boolean): boolean;
  95857. /**
  95858. * Attach the current TransformNode to another TransformNode associated with a bone
  95859. * @param bone Bone affecting the TransformNode
  95860. * @param affectedTransformNode TransformNode associated with the bone
  95861. * @returns this object
  95862. */
  95863. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95864. /**
  95865. * Detach the transform node if its associated with a bone
  95866. * @returns this object
  95867. */
  95868. detachFromBone(): TransformNode;
  95869. private static _rotationAxisCache;
  95870. /**
  95871. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95872. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95873. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95874. * The passed axis is also normalized.
  95875. * @param axis the axis to rotate around
  95876. * @param amount the amount to rotate in radians
  95877. * @param space Space to rotate in (Default: local)
  95878. * @returns the TransformNode.
  95879. */
  95880. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95881. /**
  95882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95883. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95884. * The passed axis is also normalized. .
  95885. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95886. * @param point the point to rotate around
  95887. * @param axis the axis to rotate around
  95888. * @param amount the amount to rotate in radians
  95889. * @returns the TransformNode
  95890. */
  95891. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95892. /**
  95893. * Translates the mesh along the axis vector for the passed distance in the given space.
  95894. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95895. * @param axis the axis to translate in
  95896. * @param distance the distance to translate
  95897. * @param space Space to rotate in (Default: local)
  95898. * @returns the TransformNode.
  95899. */
  95900. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95901. /**
  95902. * Adds a rotation step to the mesh current rotation.
  95903. * x, y, z are Euler angles expressed in radians.
  95904. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95905. * This means this rotation is made in the mesh local space only.
  95906. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95907. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95908. * ```javascript
  95909. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95910. * ```
  95911. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95912. * 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.
  95913. * @param x Rotation to add
  95914. * @param y Rotation to add
  95915. * @param z Rotation to add
  95916. * @returns the TransformNode.
  95917. */
  95918. addRotation(x: number, y: number, z: number): TransformNode;
  95919. /**
  95920. * @hidden
  95921. */
  95922. protected _getEffectiveParent(): Nullable<Node>;
  95923. /**
  95924. * Computes the world matrix of the node
  95925. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95926. * @returns the world matrix
  95927. */
  95928. computeWorldMatrix(force?: boolean): Matrix;
  95929. /**
  95930. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95931. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95932. */
  95933. resetLocalMatrix(independentOfChildren?: boolean): void;
  95934. protected _afterComputeWorldMatrix(): void;
  95935. /**
  95936. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95937. * @param func callback function to add
  95938. *
  95939. * @returns the TransformNode.
  95940. */
  95941. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95942. /**
  95943. * Removes a registered callback function.
  95944. * @param func callback function to remove
  95945. * @returns the TransformNode.
  95946. */
  95947. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95948. /**
  95949. * Gets the position of the current mesh in camera space
  95950. * @param camera defines the camera to use
  95951. * @returns a position
  95952. */
  95953. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95954. /**
  95955. * Returns the distance from the mesh to the active camera
  95956. * @param camera defines the camera to use
  95957. * @returns the distance
  95958. */
  95959. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95960. /**
  95961. * Clone the current transform node
  95962. * @param name Name of the new clone
  95963. * @param newParent New parent for the clone
  95964. * @param doNotCloneChildren Do not clone children hierarchy
  95965. * @returns the new transform node
  95966. */
  95967. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95968. /**
  95969. * Serializes the objects information.
  95970. * @param currentSerializationObject defines the object to serialize in
  95971. * @returns the serialized object
  95972. */
  95973. serialize(currentSerializationObject?: any): any;
  95974. /**
  95975. * Returns a new TransformNode object parsed from the source provided.
  95976. * @param parsedTransformNode is the source.
  95977. * @param scene the scne the object belongs to
  95978. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95979. * @returns a new TransformNode object parsed from the source provided.
  95980. */
  95981. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95982. /**
  95983. * Get all child-transformNodes of this node
  95984. * @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
  95985. * @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
  95986. * @returns an array of TransformNode
  95987. */
  95988. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95989. /**
  95990. * Releases resources associated with this transform node.
  95991. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95992. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95993. */
  95994. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95995. /**
  95996. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95997. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95998. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95999. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96000. * @returns the current mesh
  96001. */
  96002. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  96003. private _syncAbsoluteScalingAndRotation;
  96004. }
  96005. }
  96006. declare module BABYLON {
  96007. /**
  96008. * Class used to override all child animations of a given target
  96009. */
  96010. export class AnimationPropertiesOverride {
  96011. /**
  96012. * Gets or sets a value indicating if animation blending must be used
  96013. */
  96014. enableBlending: boolean;
  96015. /**
  96016. * Gets or sets the blending speed to use when enableBlending is true
  96017. */
  96018. blendingSpeed: number;
  96019. /**
  96020. * Gets or sets the default loop mode to use
  96021. */
  96022. loopMode: number;
  96023. }
  96024. }
  96025. declare module BABYLON {
  96026. /**
  96027. * Class used to store bone information
  96028. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96029. */
  96030. export class Bone extends Node {
  96031. /**
  96032. * defines the bone name
  96033. */
  96034. name: string;
  96035. private static _tmpVecs;
  96036. private static _tmpQuat;
  96037. private static _tmpMats;
  96038. /**
  96039. * Gets the list of child bones
  96040. */
  96041. children: Bone[];
  96042. /** Gets the animations associated with this bone */
  96043. animations: Animation[];
  96044. /**
  96045. * Gets or sets bone length
  96046. */
  96047. length: number;
  96048. /**
  96049. * @hidden Internal only
  96050. * Set this value to map this bone to a different index in the transform matrices
  96051. * Set this value to -1 to exclude the bone from the transform matrices
  96052. */
  96053. _index: Nullable<number>;
  96054. private _skeleton;
  96055. private _localMatrix;
  96056. private _restPose;
  96057. private _bindPose;
  96058. private _baseMatrix;
  96059. private _absoluteTransform;
  96060. private _invertedAbsoluteTransform;
  96061. private _parent;
  96062. private _scalingDeterminant;
  96063. private _worldTransform;
  96064. private _localScaling;
  96065. private _localRotation;
  96066. private _localPosition;
  96067. private _needToDecompose;
  96068. private _needToCompose;
  96069. /** @hidden */
  96070. _linkedTransformNode: Nullable<TransformNode>;
  96071. /** @hidden */
  96072. _waitingTransformNodeId: Nullable<string>;
  96073. /** @hidden */
  96074. get _matrix(): Matrix;
  96075. /** @hidden */
  96076. set _matrix(value: Matrix);
  96077. /**
  96078. * Create a new bone
  96079. * @param name defines the bone name
  96080. * @param skeleton defines the parent skeleton
  96081. * @param parentBone defines the parent (can be null if the bone is the root)
  96082. * @param localMatrix defines the local matrix
  96083. * @param restPose defines the rest pose matrix
  96084. * @param baseMatrix defines the base matrix
  96085. * @param index defines index of the bone in the hiearchy
  96086. */
  96087. constructor(
  96088. /**
  96089. * defines the bone name
  96090. */
  96091. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96092. /**
  96093. * Gets the current object class name.
  96094. * @return the class name
  96095. */
  96096. getClassName(): string;
  96097. /**
  96098. * Gets the parent skeleton
  96099. * @returns a skeleton
  96100. */
  96101. getSkeleton(): Skeleton;
  96102. /**
  96103. * Gets parent bone
  96104. * @returns a bone or null if the bone is the root of the bone hierarchy
  96105. */
  96106. getParent(): Nullable<Bone>;
  96107. /**
  96108. * Returns an array containing the root bones
  96109. * @returns an array containing the root bones
  96110. */
  96111. getChildren(): Array<Bone>;
  96112. /**
  96113. * Gets the node index in matrix array generated for rendering
  96114. * @returns the node index
  96115. */
  96116. getIndex(): number;
  96117. /**
  96118. * Sets the parent bone
  96119. * @param parent defines the parent (can be null if the bone is the root)
  96120. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96121. */
  96122. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96123. /**
  96124. * Gets the local matrix
  96125. * @returns a matrix
  96126. */
  96127. getLocalMatrix(): Matrix;
  96128. /**
  96129. * Gets the base matrix (initial matrix which remains unchanged)
  96130. * @returns a matrix
  96131. */
  96132. getBaseMatrix(): Matrix;
  96133. /**
  96134. * Gets the rest pose matrix
  96135. * @returns a matrix
  96136. */
  96137. getRestPose(): Matrix;
  96138. /**
  96139. * Sets the rest pose matrix
  96140. * @param matrix the local-space rest pose to set for this bone
  96141. */
  96142. setRestPose(matrix: Matrix): void;
  96143. /**
  96144. * Gets the bind pose matrix
  96145. * @returns the bind pose matrix
  96146. */
  96147. getBindPose(): Matrix;
  96148. /**
  96149. * Sets the bind pose matrix
  96150. * @param matrix the local-space bind pose to set for this bone
  96151. */
  96152. setBindPose(matrix: Matrix): void;
  96153. /**
  96154. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96155. */
  96156. getWorldMatrix(): Matrix;
  96157. /**
  96158. * Sets the local matrix to rest pose matrix
  96159. */
  96160. returnToRest(): void;
  96161. /**
  96162. * Gets the inverse of the absolute transform matrix.
  96163. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96164. * @returns a matrix
  96165. */
  96166. getInvertedAbsoluteTransform(): Matrix;
  96167. /**
  96168. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96169. * @returns a matrix
  96170. */
  96171. getAbsoluteTransform(): Matrix;
  96172. /**
  96173. * Links with the given transform node.
  96174. * The local matrix of this bone is copied from the transform node every frame.
  96175. * @param transformNode defines the transform node to link to
  96176. */
  96177. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96178. /**
  96179. * Gets the node used to drive the bone's transformation
  96180. * @returns a transform node or null
  96181. */
  96182. getTransformNode(): Nullable<TransformNode>;
  96183. /** Gets or sets current position (in local space) */
  96184. get position(): Vector3;
  96185. set position(newPosition: Vector3);
  96186. /** Gets or sets current rotation (in local space) */
  96187. get rotation(): Vector3;
  96188. set rotation(newRotation: Vector3);
  96189. /** Gets or sets current rotation quaternion (in local space) */
  96190. get rotationQuaternion(): Quaternion;
  96191. set rotationQuaternion(newRotation: Quaternion);
  96192. /** Gets or sets current scaling (in local space) */
  96193. get scaling(): Vector3;
  96194. set scaling(newScaling: Vector3);
  96195. /**
  96196. * Gets the animation properties override
  96197. */
  96198. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96199. private _decompose;
  96200. private _compose;
  96201. /**
  96202. * Update the base and local matrices
  96203. * @param matrix defines the new base or local matrix
  96204. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96205. * @param updateLocalMatrix defines if the local matrix should be updated
  96206. */
  96207. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96208. /** @hidden */
  96209. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96210. /**
  96211. * Flag the bone as dirty (Forcing it to update everything)
  96212. */
  96213. markAsDirty(): void;
  96214. /** @hidden */
  96215. _markAsDirtyAndCompose(): void;
  96216. private _markAsDirtyAndDecompose;
  96217. /**
  96218. * Translate the bone in local or world space
  96219. * @param vec The amount to translate the bone
  96220. * @param space The space that the translation is in
  96221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96222. */
  96223. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96224. /**
  96225. * Set the postion of the bone in local or world space
  96226. * @param position The position to set the bone
  96227. * @param space The space that the position is in
  96228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96229. */
  96230. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96231. /**
  96232. * Set the absolute position of the bone (world space)
  96233. * @param position The position to set the bone
  96234. * @param mesh The mesh that this bone is attached to
  96235. */
  96236. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96237. /**
  96238. * Scale the bone on the x, y and z axes (in local space)
  96239. * @param x The amount to scale the bone on the x axis
  96240. * @param y The amount to scale the bone on the y axis
  96241. * @param z The amount to scale the bone on the z axis
  96242. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96243. */
  96244. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96245. /**
  96246. * Set the bone scaling in local space
  96247. * @param scale defines the scaling vector
  96248. */
  96249. setScale(scale: Vector3): void;
  96250. /**
  96251. * Gets the current scaling in local space
  96252. * @returns the current scaling vector
  96253. */
  96254. getScale(): Vector3;
  96255. /**
  96256. * Gets the current scaling in local space and stores it in a target vector
  96257. * @param result defines the target vector
  96258. */
  96259. getScaleToRef(result: Vector3): void;
  96260. /**
  96261. * Set the yaw, pitch, and roll of the bone in local or world space
  96262. * @param yaw The rotation of the bone on the y axis
  96263. * @param pitch The rotation of the bone on the x axis
  96264. * @param roll The rotation of the bone on the z axis
  96265. * @param space The space that the axes of rotation are in
  96266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96267. */
  96268. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96269. /**
  96270. * Add a rotation to the bone on an axis in local or world space
  96271. * @param axis The axis to rotate the bone on
  96272. * @param amount The amount to rotate the bone
  96273. * @param space The space that the axis is in
  96274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96275. */
  96276. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96277. /**
  96278. * Set the rotation of the bone to a particular axis angle in local or world space
  96279. * @param axis The axis to rotate the bone on
  96280. * @param angle The angle that the bone should be rotated to
  96281. * @param space The space that the axis is in
  96282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96283. */
  96284. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96285. /**
  96286. * Set the euler rotation of the bone in local or world space
  96287. * @param rotation The euler rotation that the bone should be set to
  96288. * @param space The space that the rotation is in
  96289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96290. */
  96291. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96292. /**
  96293. * Set the quaternion rotation of the bone in local or world space
  96294. * @param quat The quaternion rotation that the bone should be set to
  96295. * @param space The space that the rotation is in
  96296. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96297. */
  96298. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96299. /**
  96300. * Set the rotation matrix of the bone in local or world space
  96301. * @param rotMat The rotation matrix that the bone should be set to
  96302. * @param space The space that the rotation is in
  96303. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96304. */
  96305. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96306. private _rotateWithMatrix;
  96307. private _getNegativeRotationToRef;
  96308. /**
  96309. * Get the position of the bone in local or world space
  96310. * @param space The space that the returned position is in
  96311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96312. * @returns The position of the bone
  96313. */
  96314. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96315. /**
  96316. * Copy the position of the bone to a vector3 in local or world space
  96317. * @param space The space that the returned position is in
  96318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96319. * @param result The vector3 to copy the position to
  96320. */
  96321. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96322. /**
  96323. * Get the absolute position of the bone (world space)
  96324. * @param mesh The mesh that this bone is attached to
  96325. * @returns The absolute position of the bone
  96326. */
  96327. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96328. /**
  96329. * Copy the absolute position of the bone (world space) to the result param
  96330. * @param mesh The mesh that this bone is attached to
  96331. * @param result The vector3 to copy the absolute position to
  96332. */
  96333. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96334. /**
  96335. * Compute the absolute transforms of this bone and its children
  96336. */
  96337. computeAbsoluteTransforms(): void;
  96338. /**
  96339. * Get the world direction from an axis that is in the local space of the bone
  96340. * @param localAxis The local direction that is used to compute the world direction
  96341. * @param mesh The mesh that this bone is attached to
  96342. * @returns The world direction
  96343. */
  96344. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96345. /**
  96346. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96347. * @param localAxis The local direction that is used to compute the world direction
  96348. * @param mesh The mesh that this bone is attached to
  96349. * @param result The vector3 that the world direction will be copied to
  96350. */
  96351. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96352. /**
  96353. * Get the euler rotation of the bone in local or world space
  96354. * @param space The space that the rotation should be in
  96355. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96356. * @returns The euler rotation
  96357. */
  96358. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96359. /**
  96360. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96361. * @param space The space that the rotation should be in
  96362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96363. * @param result The vector3 that the rotation should be copied to
  96364. */
  96365. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96366. /**
  96367. * Get the quaternion rotation of the bone in either local or world space
  96368. * @param space The space that the rotation should be in
  96369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96370. * @returns The quaternion rotation
  96371. */
  96372. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96373. /**
  96374. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96375. * @param space The space that the rotation should be in
  96376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96377. * @param result The quaternion that the rotation should be copied to
  96378. */
  96379. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96380. /**
  96381. * Get the rotation matrix of the bone in local or world space
  96382. * @param space The space that the rotation should be in
  96383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96384. * @returns The rotation matrix
  96385. */
  96386. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96387. /**
  96388. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96389. * @param space The space that the rotation should be in
  96390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96391. * @param result The quaternion that the rotation should be copied to
  96392. */
  96393. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96394. /**
  96395. * Get the world position of a point that is in the local space of the bone
  96396. * @param position The local position
  96397. * @param mesh The mesh that this bone is attached to
  96398. * @returns The world position
  96399. */
  96400. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96401. /**
  96402. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96403. * @param position The local position
  96404. * @param mesh The mesh that this bone is attached to
  96405. * @param result The vector3 that the world position should be copied to
  96406. */
  96407. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96408. /**
  96409. * Get the local position of a point that is in world space
  96410. * @param position The world position
  96411. * @param mesh The mesh that this bone is attached to
  96412. * @returns The local position
  96413. */
  96414. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96415. /**
  96416. * Get the local position of a point that is in world space and copy it to the result param
  96417. * @param position The world position
  96418. * @param mesh The mesh that this bone is attached to
  96419. * @param result The vector3 that the local position should be copied to
  96420. */
  96421. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96422. /**
  96423. * Set the current local matrix as the restPose for this bone.
  96424. */
  96425. setCurrentPoseAsRest(): void;
  96426. }
  96427. }
  96428. declare module BABYLON {
  96429. /**
  96430. * Defines a runtime animation
  96431. */
  96432. export class RuntimeAnimation {
  96433. private _events;
  96434. /**
  96435. * The current frame of the runtime animation
  96436. */
  96437. private _currentFrame;
  96438. /**
  96439. * The animation used by the runtime animation
  96440. */
  96441. private _animation;
  96442. /**
  96443. * The target of the runtime animation
  96444. */
  96445. private _target;
  96446. /**
  96447. * The initiating animatable
  96448. */
  96449. private _host;
  96450. /**
  96451. * The original value of the runtime animation
  96452. */
  96453. private _originalValue;
  96454. /**
  96455. * The original blend value of the runtime animation
  96456. */
  96457. private _originalBlendValue;
  96458. /**
  96459. * The offsets cache of the runtime animation
  96460. */
  96461. private _offsetsCache;
  96462. /**
  96463. * The high limits cache of the runtime animation
  96464. */
  96465. private _highLimitsCache;
  96466. /**
  96467. * Specifies if the runtime animation has been stopped
  96468. */
  96469. private _stopped;
  96470. /**
  96471. * The blending factor of the runtime animation
  96472. */
  96473. private _blendingFactor;
  96474. /**
  96475. * The BabylonJS scene
  96476. */
  96477. private _scene;
  96478. /**
  96479. * The current value of the runtime animation
  96480. */
  96481. private _currentValue;
  96482. /** @hidden */
  96483. _animationState: _IAnimationState;
  96484. /**
  96485. * The active target of the runtime animation
  96486. */
  96487. private _activeTargets;
  96488. private _currentActiveTarget;
  96489. private _directTarget;
  96490. /**
  96491. * The target path of the runtime animation
  96492. */
  96493. private _targetPath;
  96494. /**
  96495. * The weight of the runtime animation
  96496. */
  96497. private _weight;
  96498. /**
  96499. * The ratio offset of the runtime animation
  96500. */
  96501. private _ratioOffset;
  96502. /**
  96503. * The previous delay of the runtime animation
  96504. */
  96505. private _previousDelay;
  96506. /**
  96507. * The previous ratio of the runtime animation
  96508. */
  96509. private _previousRatio;
  96510. private _enableBlending;
  96511. private _keys;
  96512. private _minFrame;
  96513. private _maxFrame;
  96514. private _minValue;
  96515. private _maxValue;
  96516. private _targetIsArray;
  96517. /**
  96518. * Gets the current frame of the runtime animation
  96519. */
  96520. get currentFrame(): number;
  96521. /**
  96522. * Gets the weight of the runtime animation
  96523. */
  96524. get weight(): number;
  96525. /**
  96526. * Gets the current value of the runtime animation
  96527. */
  96528. get currentValue(): any;
  96529. /**
  96530. * Gets the target path of the runtime animation
  96531. */
  96532. get targetPath(): string;
  96533. /**
  96534. * Gets the actual target of the runtime animation
  96535. */
  96536. get target(): any;
  96537. /**
  96538. * Gets the additive state of the runtime animation
  96539. */
  96540. get isAdditive(): boolean;
  96541. /** @hidden */
  96542. _onLoop: () => void;
  96543. /**
  96544. * Create a new RuntimeAnimation object
  96545. * @param target defines the target of the animation
  96546. * @param animation defines the source animation object
  96547. * @param scene defines the hosting scene
  96548. * @param host defines the initiating Animatable
  96549. */
  96550. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96551. private _preparePath;
  96552. /**
  96553. * Gets the animation from the runtime animation
  96554. */
  96555. get animation(): Animation;
  96556. /**
  96557. * Resets the runtime animation to the beginning
  96558. * @param restoreOriginal defines whether to restore the target property to the original value
  96559. */
  96560. reset(restoreOriginal?: boolean): void;
  96561. /**
  96562. * Specifies if the runtime animation is stopped
  96563. * @returns Boolean specifying if the runtime animation is stopped
  96564. */
  96565. isStopped(): boolean;
  96566. /**
  96567. * Disposes of the runtime animation
  96568. */
  96569. dispose(): void;
  96570. /**
  96571. * Apply the interpolated value to the target
  96572. * @param currentValue defines the value computed by the animation
  96573. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96574. */
  96575. setValue(currentValue: any, weight: number): void;
  96576. private _getOriginalValues;
  96577. private _setValue;
  96578. /**
  96579. * Gets the loop pmode of the runtime animation
  96580. * @returns Loop Mode
  96581. */
  96582. private _getCorrectLoopMode;
  96583. /**
  96584. * Move the current animation to a given frame
  96585. * @param frame defines the frame to move to
  96586. */
  96587. goToFrame(frame: number): void;
  96588. /**
  96589. * @hidden Internal use only
  96590. */
  96591. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96592. /**
  96593. * Execute the current animation
  96594. * @param delay defines the delay to add to the current frame
  96595. * @param from defines the lower bound of the animation range
  96596. * @param to defines the upper bound of the animation range
  96597. * @param loop defines if the current animation must loop
  96598. * @param speedRatio defines the current speed ratio
  96599. * @param weight defines the weight of the animation (default is -1 so no weight)
  96600. * @param onLoop optional callback called when animation loops
  96601. * @returns a boolean indicating if the animation is running
  96602. */
  96603. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96604. }
  96605. }
  96606. declare module BABYLON {
  96607. /**
  96608. * Class used to store an actual running animation
  96609. */
  96610. export class Animatable {
  96611. /** defines the target object */
  96612. target: any;
  96613. /** defines the starting frame number (default is 0) */
  96614. fromFrame: number;
  96615. /** defines the ending frame number (default is 100) */
  96616. toFrame: number;
  96617. /** defines if the animation must loop (default is false) */
  96618. loopAnimation: boolean;
  96619. /** defines a callback to call when animation ends if it is not looping */
  96620. onAnimationEnd?: (() => void) | null | undefined;
  96621. /** defines a callback to call when animation loops */
  96622. onAnimationLoop?: (() => void) | null | undefined;
  96623. /** defines whether the animation should be evaluated additively */
  96624. isAdditive: boolean;
  96625. private _localDelayOffset;
  96626. private _pausedDelay;
  96627. private _runtimeAnimations;
  96628. private _paused;
  96629. private _scene;
  96630. private _speedRatio;
  96631. private _weight;
  96632. private _syncRoot;
  96633. /**
  96634. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96635. * This will only apply for non looping animation (default is true)
  96636. */
  96637. disposeOnEnd: boolean;
  96638. /**
  96639. * Gets a boolean indicating if the animation has started
  96640. */
  96641. animationStarted: boolean;
  96642. /**
  96643. * Observer raised when the animation ends
  96644. */
  96645. onAnimationEndObservable: Observable<Animatable>;
  96646. /**
  96647. * Observer raised when the animation loops
  96648. */
  96649. onAnimationLoopObservable: Observable<Animatable>;
  96650. /**
  96651. * Gets the root Animatable used to synchronize and normalize animations
  96652. */
  96653. get syncRoot(): Nullable<Animatable>;
  96654. /**
  96655. * Gets the current frame of the first RuntimeAnimation
  96656. * Used to synchronize Animatables
  96657. */
  96658. get masterFrame(): number;
  96659. /**
  96660. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96661. */
  96662. get weight(): number;
  96663. set weight(value: number);
  96664. /**
  96665. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96666. */
  96667. get speedRatio(): number;
  96668. set speedRatio(value: number);
  96669. /**
  96670. * Creates a new Animatable
  96671. * @param scene defines the hosting scene
  96672. * @param target defines the target object
  96673. * @param fromFrame defines the starting frame number (default is 0)
  96674. * @param toFrame defines the ending frame number (default is 100)
  96675. * @param loopAnimation defines if the animation must loop (default is false)
  96676. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96677. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96678. * @param animations defines a group of animation to add to the new Animatable
  96679. * @param onAnimationLoop defines a callback to call when animation loops
  96680. * @param isAdditive defines whether the animation should be evaluated additively
  96681. */
  96682. constructor(scene: Scene,
  96683. /** defines the target object */
  96684. target: any,
  96685. /** defines the starting frame number (default is 0) */
  96686. fromFrame?: number,
  96687. /** defines the ending frame number (default is 100) */
  96688. toFrame?: number,
  96689. /** defines if the animation must loop (default is false) */
  96690. loopAnimation?: boolean, speedRatio?: number,
  96691. /** defines a callback to call when animation ends if it is not looping */
  96692. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96693. /** defines a callback to call when animation loops */
  96694. onAnimationLoop?: (() => void) | null | undefined,
  96695. /** defines whether the animation should be evaluated additively */
  96696. isAdditive?: boolean);
  96697. /**
  96698. * Synchronize and normalize current Animatable with a source Animatable
  96699. * This is useful when using animation weights and when animations are not of the same length
  96700. * @param root defines the root Animatable to synchronize with
  96701. * @returns the current Animatable
  96702. */
  96703. syncWith(root: Animatable): Animatable;
  96704. /**
  96705. * Gets the list of runtime animations
  96706. * @returns an array of RuntimeAnimation
  96707. */
  96708. getAnimations(): RuntimeAnimation[];
  96709. /**
  96710. * Adds more animations to the current animatable
  96711. * @param target defines the target of the animations
  96712. * @param animations defines the new animations to add
  96713. */
  96714. appendAnimations(target: any, animations: Animation[]): void;
  96715. /**
  96716. * Gets the source animation for a specific property
  96717. * @param property defines the propertyu to look for
  96718. * @returns null or the source animation for the given property
  96719. */
  96720. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96721. /**
  96722. * Gets the runtime animation for a specific property
  96723. * @param property defines the propertyu to look for
  96724. * @returns null or the runtime animation for the given property
  96725. */
  96726. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96727. /**
  96728. * Resets the animatable to its original state
  96729. */
  96730. reset(): void;
  96731. /**
  96732. * Allows the animatable to blend with current running animations
  96733. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96734. * @param blendingSpeed defines the blending speed to use
  96735. */
  96736. enableBlending(blendingSpeed: number): void;
  96737. /**
  96738. * Disable animation blending
  96739. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96740. */
  96741. disableBlending(): void;
  96742. /**
  96743. * Jump directly to a given frame
  96744. * @param frame defines the frame to jump to
  96745. */
  96746. goToFrame(frame: number): void;
  96747. /**
  96748. * Pause the animation
  96749. */
  96750. pause(): void;
  96751. /**
  96752. * Restart the animation
  96753. */
  96754. restart(): void;
  96755. private _raiseOnAnimationEnd;
  96756. /**
  96757. * Stop and delete the current animation
  96758. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96759. * @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)
  96760. */
  96761. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96762. /**
  96763. * Wait asynchronously for the animation to end
  96764. * @returns a promise which will be fullfilled when the animation ends
  96765. */
  96766. waitAsync(): Promise<Animatable>;
  96767. /** @hidden */
  96768. _animate(delay: number): boolean;
  96769. }
  96770. interface Scene {
  96771. /** @hidden */
  96772. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96773. /** @hidden */
  96774. _processLateAnimationBindingsForMatrices(holder: {
  96775. totalWeight: number;
  96776. totalAdditiveWeight: number;
  96777. animations: RuntimeAnimation[];
  96778. additiveAnimations: RuntimeAnimation[];
  96779. originalValue: Matrix;
  96780. }): any;
  96781. /** @hidden */
  96782. _processLateAnimationBindingsForQuaternions(holder: {
  96783. totalWeight: number;
  96784. totalAdditiveWeight: number;
  96785. animations: RuntimeAnimation[];
  96786. additiveAnimations: RuntimeAnimation[];
  96787. originalValue: Quaternion;
  96788. }, refQuaternion: Quaternion): Quaternion;
  96789. /** @hidden */
  96790. _processLateAnimationBindings(): void;
  96791. /**
  96792. * Will start the animation sequence of a given target
  96793. * @param target defines the target
  96794. * @param from defines from which frame should animation start
  96795. * @param to defines until which frame should animation run.
  96796. * @param weight defines the weight to apply to the animation (1.0 by default)
  96797. * @param loop defines if the animation loops
  96798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96799. * @param onAnimationEnd defines the function to be executed when the animation ends
  96800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96802. * @param onAnimationLoop defines the callback to call when an animation loops
  96803. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96804. * @returns the animatable object created for this animation
  96805. */
  96806. 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;
  96807. /**
  96808. * Will start the animation sequence of a given target
  96809. * @param target defines the target
  96810. * @param from defines from which frame should animation start
  96811. * @param to defines until which frame should animation run.
  96812. * @param loop defines if the animation loops
  96813. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96814. * @param onAnimationEnd defines the function to be executed when the animation ends
  96815. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96816. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96817. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96818. * @param onAnimationLoop defines the callback to call when an animation loops
  96819. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96820. * @returns the animatable object created for this animation
  96821. */
  96822. 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;
  96823. /**
  96824. * Will start the animation sequence of a given target and its hierarchy
  96825. * @param target defines the target
  96826. * @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.
  96827. * @param from defines from which frame should animation start
  96828. * @param to defines until which frame should animation run.
  96829. * @param loop defines if the animation loops
  96830. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96831. * @param onAnimationEnd defines the function to be executed when the animation ends
  96832. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96833. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96834. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96835. * @param onAnimationLoop defines the callback to call when an animation loops
  96836. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96837. * @returns the list of created animatables
  96838. */
  96839. 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[];
  96840. /**
  96841. * Begin a new animation on a given node
  96842. * @param target defines the target where the animation will take place
  96843. * @param animations defines the list of animations to start
  96844. * @param from defines the initial value
  96845. * @param to defines the final value
  96846. * @param loop defines if you want animation to loop (off by default)
  96847. * @param speedRatio defines the speed ratio to apply to all animations
  96848. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96849. * @param onAnimationLoop defines the callback to call when an animation loops
  96850. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96851. * @returns the list of created animatables
  96852. */
  96853. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96854. /**
  96855. * Begin a new animation on a given node and its hierarchy
  96856. * @param target defines the root node where the animation will take place
  96857. * @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.
  96858. * @param animations defines the list of animations to start
  96859. * @param from defines the initial value
  96860. * @param to defines the final value
  96861. * @param loop defines if you want animation to loop (off by default)
  96862. * @param speedRatio defines the speed ratio to apply to all animations
  96863. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96864. * @param onAnimationLoop defines the callback to call when an animation loops
  96865. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96866. * @returns the list of animatables created for all nodes
  96867. */
  96868. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96869. /**
  96870. * Gets the animatable associated with a specific target
  96871. * @param target defines the target of the animatable
  96872. * @returns the required animatable if found
  96873. */
  96874. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96875. /**
  96876. * Gets all animatables associated with a given target
  96877. * @param target defines the target to look animatables for
  96878. * @returns an array of Animatables
  96879. */
  96880. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96881. /**
  96882. * Stops and removes all animations that have been applied to the scene
  96883. */
  96884. stopAllAnimations(): void;
  96885. /**
  96886. * Gets the current delta time used by animation engine
  96887. */
  96888. deltaTime: number;
  96889. }
  96890. interface Bone {
  96891. /**
  96892. * Copy an animation range from another bone
  96893. * @param source defines the source bone
  96894. * @param rangeName defines the range name to copy
  96895. * @param frameOffset defines the frame offset
  96896. * @param rescaleAsRequired defines if rescaling must be applied if required
  96897. * @param skelDimensionsRatio defines the scaling ratio
  96898. * @returns true if operation was successful
  96899. */
  96900. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96901. }
  96902. }
  96903. declare module BABYLON {
  96904. /**
  96905. * Class used to handle skinning animations
  96906. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96907. */
  96908. export class Skeleton implements IAnimatable {
  96909. /** defines the skeleton name */
  96910. name: string;
  96911. /** defines the skeleton Id */
  96912. id: string;
  96913. /**
  96914. * Defines the list of child bones
  96915. */
  96916. bones: Bone[];
  96917. /**
  96918. * Defines an estimate of the dimension of the skeleton at rest
  96919. */
  96920. dimensionsAtRest: Vector3;
  96921. /**
  96922. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96923. */
  96924. needInitialSkinMatrix: boolean;
  96925. /**
  96926. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96927. */
  96928. overrideMesh: Nullable<AbstractMesh>;
  96929. /**
  96930. * Gets the list of animations attached to this skeleton
  96931. */
  96932. animations: Array<Animation>;
  96933. private _scene;
  96934. private _isDirty;
  96935. private _transformMatrices;
  96936. private _transformMatrixTexture;
  96937. private _meshesWithPoseMatrix;
  96938. private _animatables;
  96939. private _identity;
  96940. private _synchronizedWithMesh;
  96941. private _ranges;
  96942. private _lastAbsoluteTransformsUpdateId;
  96943. private _canUseTextureForBones;
  96944. private _uniqueId;
  96945. /** @hidden */
  96946. _numBonesWithLinkedTransformNode: number;
  96947. /** @hidden */
  96948. _hasWaitingData: Nullable<boolean>;
  96949. /** @hidden */
  96950. _waitingOverrideMeshId: Nullable<string>;
  96951. /**
  96952. * Specifies if the skeleton should be serialized
  96953. */
  96954. doNotSerialize: boolean;
  96955. private _useTextureToStoreBoneMatrices;
  96956. /**
  96957. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96958. * Please note that this option is not available if the hardware does not support it
  96959. */
  96960. get useTextureToStoreBoneMatrices(): boolean;
  96961. set useTextureToStoreBoneMatrices(value: boolean);
  96962. private _animationPropertiesOverride;
  96963. /**
  96964. * Gets or sets the animation properties override
  96965. */
  96966. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96967. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96968. /**
  96969. * List of inspectable custom properties (used by the Inspector)
  96970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96971. */
  96972. inspectableCustomProperties: IInspectable[];
  96973. /**
  96974. * An observable triggered before computing the skeleton's matrices
  96975. */
  96976. onBeforeComputeObservable: Observable<Skeleton>;
  96977. /**
  96978. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96979. */
  96980. get isUsingTextureForMatrices(): boolean;
  96981. /**
  96982. * Gets the unique ID of this skeleton
  96983. */
  96984. get uniqueId(): number;
  96985. /**
  96986. * Creates a new skeleton
  96987. * @param name defines the skeleton name
  96988. * @param id defines the skeleton Id
  96989. * @param scene defines the hosting scene
  96990. */
  96991. constructor(
  96992. /** defines the skeleton name */
  96993. name: string,
  96994. /** defines the skeleton Id */
  96995. id: string, scene: Scene);
  96996. /**
  96997. * Gets the current object class name.
  96998. * @return the class name
  96999. */
  97000. getClassName(): string;
  97001. /**
  97002. * Returns an array containing the root bones
  97003. * @returns an array containing the root bones
  97004. */
  97005. getChildren(): Array<Bone>;
  97006. /**
  97007. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  97008. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97009. * @returns a Float32Array containing matrices data
  97010. */
  97011. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  97012. /**
  97013. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  97014. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97015. * @returns a raw texture containing the data
  97016. */
  97017. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  97018. /**
  97019. * Gets the current hosting scene
  97020. * @returns a scene object
  97021. */
  97022. getScene(): Scene;
  97023. /**
  97024. * Gets a string representing the current skeleton data
  97025. * @param fullDetails defines a boolean indicating if we want a verbose version
  97026. * @returns a string representing the current skeleton data
  97027. */
  97028. toString(fullDetails?: boolean): string;
  97029. /**
  97030. * Get bone's index searching by name
  97031. * @param name defines bone's name to search for
  97032. * @return the indice of the bone. Returns -1 if not found
  97033. */
  97034. getBoneIndexByName(name: string): number;
  97035. /**
  97036. * Creater a new animation range
  97037. * @param name defines the name of the range
  97038. * @param from defines the start key
  97039. * @param to defines the end key
  97040. */
  97041. createAnimationRange(name: string, from: number, to: number): void;
  97042. /**
  97043. * Delete a specific animation range
  97044. * @param name defines the name of the range
  97045. * @param deleteFrames defines if frames must be removed as well
  97046. */
  97047. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97048. /**
  97049. * Gets a specific animation range
  97050. * @param name defines the name of the range to look for
  97051. * @returns the requested animation range or null if not found
  97052. */
  97053. getAnimationRange(name: string): Nullable<AnimationRange>;
  97054. /**
  97055. * Gets the list of all animation ranges defined on this skeleton
  97056. * @returns an array
  97057. */
  97058. getAnimationRanges(): Nullable<AnimationRange>[];
  97059. /**
  97060. * Copy animation range from a source skeleton.
  97061. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97062. * @param source defines the source skeleton
  97063. * @param name defines the name of the range to copy
  97064. * @param rescaleAsRequired defines if rescaling must be applied if required
  97065. * @returns true if operation was successful
  97066. */
  97067. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97068. /**
  97069. * Forces the skeleton to go to rest pose
  97070. */
  97071. returnToRest(): void;
  97072. private _getHighestAnimationFrame;
  97073. /**
  97074. * Begin a specific animation range
  97075. * @param name defines the name of the range to start
  97076. * @param loop defines if looping must be turned on (false by default)
  97077. * @param speedRatio defines the speed ratio to apply (1 by default)
  97078. * @param onAnimationEnd defines a callback which will be called when animation will end
  97079. * @returns a new animatable
  97080. */
  97081. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97082. /**
  97083. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97084. * @param skeleton defines the Skeleton containing the animation range to convert
  97085. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97086. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97087. * @returns the original skeleton
  97088. */
  97089. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97090. /** @hidden */
  97091. _markAsDirty(): void;
  97092. /** @hidden */
  97093. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97094. /** @hidden */
  97095. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97096. private _computeTransformMatrices;
  97097. /**
  97098. * Build all resources required to render a skeleton
  97099. */
  97100. prepare(): void;
  97101. /**
  97102. * Gets the list of animatables currently running for this skeleton
  97103. * @returns an array of animatables
  97104. */
  97105. getAnimatables(): IAnimatable[];
  97106. /**
  97107. * Clone the current skeleton
  97108. * @param name defines the name of the new skeleton
  97109. * @param id defines the id of the new skeleton
  97110. * @returns the new skeleton
  97111. */
  97112. clone(name: string, id?: string): Skeleton;
  97113. /**
  97114. * Enable animation blending for this skeleton
  97115. * @param blendingSpeed defines the blending speed to apply
  97116. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97117. */
  97118. enableBlending(blendingSpeed?: number): void;
  97119. /**
  97120. * Releases all resources associated with the current skeleton
  97121. */
  97122. dispose(): void;
  97123. /**
  97124. * Serialize the skeleton in a JSON object
  97125. * @returns a JSON object
  97126. */
  97127. serialize(): any;
  97128. /**
  97129. * Creates a new skeleton from serialized data
  97130. * @param parsedSkeleton defines the serialized data
  97131. * @param scene defines the hosting scene
  97132. * @returns a new skeleton
  97133. */
  97134. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97135. /**
  97136. * Compute all node absolute transforms
  97137. * @param forceUpdate defines if computation must be done even if cache is up to date
  97138. */
  97139. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97140. /**
  97141. * Gets the root pose matrix
  97142. * @returns a matrix
  97143. */
  97144. getPoseMatrix(): Nullable<Matrix>;
  97145. /**
  97146. * Sorts bones per internal index
  97147. */
  97148. sortBones(): void;
  97149. private _sortBones;
  97150. /**
  97151. * Set the current local matrix as the restPose for all bones in the skeleton.
  97152. */
  97153. setCurrentPoseAsRest(): void;
  97154. }
  97155. }
  97156. declare module BABYLON {
  97157. /**
  97158. * Creates an instance based on a source mesh.
  97159. */
  97160. export class InstancedMesh extends AbstractMesh {
  97161. private _sourceMesh;
  97162. private _currentLOD;
  97163. /** @hidden */
  97164. _indexInSourceMeshInstanceArray: number;
  97165. constructor(name: string, source: Mesh);
  97166. /**
  97167. * Returns the string "InstancedMesh".
  97168. */
  97169. getClassName(): string;
  97170. /** Gets the list of lights affecting that mesh */
  97171. get lightSources(): Light[];
  97172. _resyncLightSources(): void;
  97173. _resyncLightSource(light: Light): void;
  97174. _removeLightSource(light: Light, dispose: boolean): void;
  97175. /**
  97176. * If the source mesh receives shadows
  97177. */
  97178. get receiveShadows(): boolean;
  97179. /**
  97180. * The material of the source mesh
  97181. */
  97182. get material(): Nullable<Material>;
  97183. /**
  97184. * Visibility of the source mesh
  97185. */
  97186. get visibility(): number;
  97187. /**
  97188. * Skeleton of the source mesh
  97189. */
  97190. get skeleton(): Nullable<Skeleton>;
  97191. /**
  97192. * Rendering ground id of the source mesh
  97193. */
  97194. get renderingGroupId(): number;
  97195. set renderingGroupId(value: number);
  97196. /**
  97197. * Returns the total number of vertices (integer).
  97198. */
  97199. getTotalVertices(): number;
  97200. /**
  97201. * Returns a positive integer : the total number of indices in this mesh geometry.
  97202. * @returns the numner of indices or zero if the mesh has no geometry.
  97203. */
  97204. getTotalIndices(): number;
  97205. /**
  97206. * The source mesh of the instance
  97207. */
  97208. get sourceMesh(): Mesh;
  97209. /**
  97210. * Creates a new InstancedMesh object from the mesh model.
  97211. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97212. * @param name defines the name of the new instance
  97213. * @returns a new InstancedMesh
  97214. */
  97215. createInstance(name: string): InstancedMesh;
  97216. /**
  97217. * Is this node ready to be used/rendered
  97218. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97219. * @return {boolean} is it ready
  97220. */
  97221. isReady(completeCheck?: boolean): boolean;
  97222. /**
  97223. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97224. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97225. * @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.
  97226. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97227. */
  97228. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97229. /**
  97230. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97231. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97232. * The `data` are either a numeric array either a Float32Array.
  97233. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97234. * 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).
  97235. * Note that a new underlying VertexBuffer object is created each call.
  97236. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97237. *
  97238. * Possible `kind` values :
  97239. * - VertexBuffer.PositionKind
  97240. * - VertexBuffer.UVKind
  97241. * - VertexBuffer.UV2Kind
  97242. * - VertexBuffer.UV3Kind
  97243. * - VertexBuffer.UV4Kind
  97244. * - VertexBuffer.UV5Kind
  97245. * - VertexBuffer.UV6Kind
  97246. * - VertexBuffer.ColorKind
  97247. * - VertexBuffer.MatricesIndicesKind
  97248. * - VertexBuffer.MatricesIndicesExtraKind
  97249. * - VertexBuffer.MatricesWeightsKind
  97250. * - VertexBuffer.MatricesWeightsExtraKind
  97251. *
  97252. * Returns the Mesh.
  97253. */
  97254. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97255. /**
  97256. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97257. * If the mesh has no geometry, it is simply returned as it is.
  97258. * The `data` are either a numeric array either a Float32Array.
  97259. * No new underlying VertexBuffer object is created.
  97260. * 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.
  97261. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97262. *
  97263. * Possible `kind` values :
  97264. * - VertexBuffer.PositionKind
  97265. * - VertexBuffer.UVKind
  97266. * - VertexBuffer.UV2Kind
  97267. * - VertexBuffer.UV3Kind
  97268. * - VertexBuffer.UV4Kind
  97269. * - VertexBuffer.UV5Kind
  97270. * - VertexBuffer.UV6Kind
  97271. * - VertexBuffer.ColorKind
  97272. * - VertexBuffer.MatricesIndicesKind
  97273. * - VertexBuffer.MatricesIndicesExtraKind
  97274. * - VertexBuffer.MatricesWeightsKind
  97275. * - VertexBuffer.MatricesWeightsExtraKind
  97276. *
  97277. * Returns the Mesh.
  97278. */
  97279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97280. /**
  97281. * Sets the mesh indices.
  97282. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97283. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97284. * This method creates a new index buffer each call.
  97285. * Returns the Mesh.
  97286. */
  97287. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97288. /**
  97289. * Boolean : True if the mesh owns the requested kind of data.
  97290. */
  97291. isVerticesDataPresent(kind: string): boolean;
  97292. /**
  97293. * Returns an array of indices (IndicesArray).
  97294. */
  97295. getIndices(): Nullable<IndicesArray>;
  97296. get _positions(): Nullable<Vector3[]>;
  97297. /**
  97298. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97299. * This means the mesh underlying bounding box and sphere are recomputed.
  97300. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97301. * @returns the current mesh
  97302. */
  97303. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97304. /** @hidden */
  97305. _preActivate(): InstancedMesh;
  97306. /** @hidden */
  97307. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97308. /** @hidden */
  97309. _postActivate(): void;
  97310. getWorldMatrix(): Matrix;
  97311. get isAnInstance(): boolean;
  97312. /**
  97313. * Returns the current associated LOD AbstractMesh.
  97314. */
  97315. getLOD(camera: Camera): AbstractMesh;
  97316. /** @hidden */
  97317. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97318. /** @hidden */
  97319. _syncSubMeshes(): InstancedMesh;
  97320. /** @hidden */
  97321. _generatePointsArray(): boolean;
  97322. /** @hidden */
  97323. _updateBoundingInfo(): AbstractMesh;
  97324. /**
  97325. * Creates a new InstancedMesh from the current mesh.
  97326. * - name (string) : the cloned mesh name
  97327. * - newParent (optional Node) : the optional Node to parent the clone to.
  97328. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97329. *
  97330. * Returns the clone.
  97331. */
  97332. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97333. /**
  97334. * Disposes the InstancedMesh.
  97335. * Returns nothing.
  97336. */
  97337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97338. }
  97339. interface Mesh {
  97340. /**
  97341. * Register a custom buffer that will be instanced
  97342. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97343. * @param kind defines the buffer kind
  97344. * @param stride defines the stride in floats
  97345. */
  97346. registerInstancedBuffer(kind: string, stride: number): void;
  97347. /**
  97348. * true to use the edge renderer for all instances of this mesh
  97349. */
  97350. edgesShareWithInstances: boolean;
  97351. /** @hidden */
  97352. _userInstancedBuffersStorage: {
  97353. data: {
  97354. [key: string]: Float32Array;
  97355. };
  97356. sizes: {
  97357. [key: string]: number;
  97358. };
  97359. vertexBuffers: {
  97360. [key: string]: Nullable<VertexBuffer>;
  97361. };
  97362. strides: {
  97363. [key: string]: number;
  97364. };
  97365. };
  97366. }
  97367. interface AbstractMesh {
  97368. /**
  97369. * Object used to store instanced buffers defined by user
  97370. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97371. */
  97372. instancedBuffers: {
  97373. [key: string]: any;
  97374. };
  97375. }
  97376. }
  97377. declare module BABYLON {
  97378. /**
  97379. * Defines the options associated with the creation of a shader material.
  97380. */
  97381. export interface IShaderMaterialOptions {
  97382. /**
  97383. * Does the material work in alpha blend mode
  97384. */
  97385. needAlphaBlending: boolean;
  97386. /**
  97387. * Does the material work in alpha test mode
  97388. */
  97389. needAlphaTesting: boolean;
  97390. /**
  97391. * The list of attribute names used in the shader
  97392. */
  97393. attributes: string[];
  97394. /**
  97395. * The list of unifrom names used in the shader
  97396. */
  97397. uniforms: string[];
  97398. /**
  97399. * The list of UBO names used in the shader
  97400. */
  97401. uniformBuffers: string[];
  97402. /**
  97403. * The list of sampler names used in the shader
  97404. */
  97405. samplers: string[];
  97406. /**
  97407. * The list of defines used in the shader
  97408. */
  97409. defines: string[];
  97410. }
  97411. /**
  97412. * 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.
  97413. *
  97414. * This returned material effects how the mesh will look based on the code in the shaders.
  97415. *
  97416. * @see https://doc.babylonjs.com/how_to/shader_material
  97417. */
  97418. export class ShaderMaterial extends Material {
  97419. private _shaderPath;
  97420. private _options;
  97421. private _textures;
  97422. private _textureArrays;
  97423. private _floats;
  97424. private _ints;
  97425. private _floatsArrays;
  97426. private _colors3;
  97427. private _colors3Arrays;
  97428. private _colors4;
  97429. private _colors4Arrays;
  97430. private _vectors2;
  97431. private _vectors3;
  97432. private _vectors4;
  97433. private _matrices;
  97434. private _matrixArrays;
  97435. private _matrices3x3;
  97436. private _matrices2x2;
  97437. private _vectors2Arrays;
  97438. private _vectors3Arrays;
  97439. private _vectors4Arrays;
  97440. private _cachedWorldViewMatrix;
  97441. private _cachedWorldViewProjectionMatrix;
  97442. private _renderId;
  97443. private _multiview;
  97444. private _cachedDefines;
  97445. /** Define the Url to load snippets */
  97446. static SnippetUrl: string;
  97447. /** Snippet ID if the material was created from the snippet server */
  97448. snippetId: string;
  97449. /**
  97450. * Instantiate a new shader material.
  97451. * 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.
  97452. * This returned material effects how the mesh will look based on the code in the shaders.
  97453. * @see https://doc.babylonjs.com/how_to/shader_material
  97454. * @param name Define the name of the material in the scene
  97455. * @param scene Define the scene the material belongs to
  97456. * @param shaderPath Defines the route to the shader code in one of three ways:
  97457. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97458. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97459. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97460. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97461. * @param options Define the options used to create the shader
  97462. */
  97463. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97464. /**
  97465. * Gets the shader path used to define the shader code
  97466. * It can be modified to trigger a new compilation
  97467. */
  97468. get shaderPath(): any;
  97469. /**
  97470. * Sets the shader path used to define the shader code
  97471. * It can be modified to trigger a new compilation
  97472. */
  97473. set shaderPath(shaderPath: any);
  97474. /**
  97475. * Gets the options used to compile the shader.
  97476. * They can be modified to trigger a new compilation
  97477. */
  97478. get options(): IShaderMaterialOptions;
  97479. /**
  97480. * Gets the current class name of the material e.g. "ShaderMaterial"
  97481. * Mainly use in serialization.
  97482. * @returns the class name
  97483. */
  97484. getClassName(): string;
  97485. /**
  97486. * Specifies if the material will require alpha blending
  97487. * @returns a boolean specifying if alpha blending is needed
  97488. */
  97489. needAlphaBlending(): boolean;
  97490. /**
  97491. * Specifies if this material should be rendered in alpha test mode
  97492. * @returns a boolean specifying if an alpha test is needed.
  97493. */
  97494. needAlphaTesting(): boolean;
  97495. private _checkUniform;
  97496. /**
  97497. * Set a texture in the shader.
  97498. * @param name Define the name of the uniform samplers as defined in the shader
  97499. * @param texture Define the texture to bind to this sampler
  97500. * @return the material itself allowing "fluent" like uniform updates
  97501. */
  97502. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97503. /**
  97504. * Set a texture array in the shader.
  97505. * @param name Define the name of the uniform sampler array as defined in the shader
  97506. * @param textures Define the list of textures to bind to this sampler
  97507. * @return the material itself allowing "fluent" like uniform updates
  97508. */
  97509. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97510. /**
  97511. * Set a float in the shader.
  97512. * @param name Define the name of the uniform as defined in the shader
  97513. * @param value Define the value to give to the uniform
  97514. * @return the material itself allowing "fluent" like uniform updates
  97515. */
  97516. setFloat(name: string, value: number): ShaderMaterial;
  97517. /**
  97518. * Set a int in the shader.
  97519. * @param name Define the name of the uniform as defined in the shader
  97520. * @param value Define the value to give to the uniform
  97521. * @return the material itself allowing "fluent" like uniform updates
  97522. */
  97523. setInt(name: string, value: number): ShaderMaterial;
  97524. /**
  97525. * Set an array of floats in the shader.
  97526. * @param name Define the name of the uniform as defined in the shader
  97527. * @param value Define the value to give to the uniform
  97528. * @return the material itself allowing "fluent" like uniform updates
  97529. */
  97530. setFloats(name: string, value: number[]): ShaderMaterial;
  97531. /**
  97532. * Set a vec3 in the shader from a Color3.
  97533. * @param name Define the name of the uniform as defined in the shader
  97534. * @param value Define the value to give to the uniform
  97535. * @return the material itself allowing "fluent" like uniform updates
  97536. */
  97537. setColor3(name: string, value: Color3): ShaderMaterial;
  97538. /**
  97539. * Set a vec3 array in the shader from a Color3 array.
  97540. * @param name Define the name of the uniform as defined in the shader
  97541. * @param value Define the value to give to the uniform
  97542. * @return the material itself allowing "fluent" like uniform updates
  97543. */
  97544. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97545. /**
  97546. * Set a vec4 in the shader from a Color4.
  97547. * @param name Define the name of the uniform as defined in the shader
  97548. * @param value Define the value to give to the uniform
  97549. * @return the material itself allowing "fluent" like uniform updates
  97550. */
  97551. setColor4(name: string, value: Color4): ShaderMaterial;
  97552. /**
  97553. * Set a vec4 array in the shader from a Color4 array.
  97554. * @param name Define the name of the uniform as defined in the shader
  97555. * @param value Define the value to give to the uniform
  97556. * @return the material itself allowing "fluent" like uniform updates
  97557. */
  97558. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97559. /**
  97560. * Set a vec2 in the shader from a Vector2.
  97561. * @param name Define the name of the uniform as defined in the shader
  97562. * @param value Define the value to give to the uniform
  97563. * @return the material itself allowing "fluent" like uniform updates
  97564. */
  97565. setVector2(name: string, value: Vector2): ShaderMaterial;
  97566. /**
  97567. * Set a vec3 in the shader from a Vector3.
  97568. * @param name Define the name of the uniform as defined in the shader
  97569. * @param value Define the value to give to the uniform
  97570. * @return the material itself allowing "fluent" like uniform updates
  97571. */
  97572. setVector3(name: string, value: Vector3): ShaderMaterial;
  97573. /**
  97574. * Set a vec4 in the shader from a Vector4.
  97575. * @param name Define the name of the uniform as defined in the shader
  97576. * @param value Define the value to give to the uniform
  97577. * @return the material itself allowing "fluent" like uniform updates
  97578. */
  97579. setVector4(name: string, value: Vector4): ShaderMaterial;
  97580. /**
  97581. * Set a mat4 in the shader from a Matrix.
  97582. * @param name Define the name of the uniform as defined in the shader
  97583. * @param value Define the value to give to the uniform
  97584. * @return the material itself allowing "fluent" like uniform updates
  97585. */
  97586. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97587. /**
  97588. * Set a float32Array in the shader from a matrix array.
  97589. * @param name Define the name of the uniform as defined in the shader
  97590. * @param value Define the value to give to the uniform
  97591. * @return the material itself allowing "fluent" like uniform updates
  97592. */
  97593. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97594. /**
  97595. * Set a mat3 in the shader from a Float32Array.
  97596. * @param name Define the name of the uniform as defined in the shader
  97597. * @param value Define the value to give to the uniform
  97598. * @return the material itself allowing "fluent" like uniform updates
  97599. */
  97600. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97601. /**
  97602. * Set a mat2 in the shader from a Float32Array.
  97603. * @param name Define the name of the uniform as defined in the shader
  97604. * @param value Define the value to give to the uniform
  97605. * @return the material itself allowing "fluent" like uniform updates
  97606. */
  97607. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97608. /**
  97609. * Set a vec2 array in the shader from a number array.
  97610. * @param name Define the name of the uniform as defined in the shader
  97611. * @param value Define the value to give to the uniform
  97612. * @return the material itself allowing "fluent" like uniform updates
  97613. */
  97614. setArray2(name: string, value: number[]): ShaderMaterial;
  97615. /**
  97616. * Set a vec3 array in the shader from a number array.
  97617. * @param name Define the name of the uniform as defined in the shader
  97618. * @param value Define the value to give to the uniform
  97619. * @return the material itself allowing "fluent" like uniform updates
  97620. */
  97621. setArray3(name: string, value: number[]): ShaderMaterial;
  97622. /**
  97623. * Set a vec4 array in the shader from a number array.
  97624. * @param name Define the name of the uniform as defined in the shader
  97625. * @param value Define the value to give to the uniform
  97626. * @return the material itself allowing "fluent" like uniform updates
  97627. */
  97628. setArray4(name: string, value: number[]): ShaderMaterial;
  97629. private _checkCache;
  97630. /**
  97631. * Specifies that the submesh is ready to be used
  97632. * @param mesh defines the mesh to check
  97633. * @param subMesh defines which submesh to check
  97634. * @param useInstances specifies that instances should be used
  97635. * @returns a boolean indicating that the submesh is ready or not
  97636. */
  97637. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97638. /**
  97639. * Checks if the material is ready to render the requested mesh
  97640. * @param mesh Define the mesh to render
  97641. * @param useInstances Define whether or not the material is used with instances
  97642. * @returns true if ready, otherwise false
  97643. */
  97644. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97645. /**
  97646. * Binds the world matrix to the material
  97647. * @param world defines the world transformation matrix
  97648. * @param effectOverride - If provided, use this effect instead of internal effect
  97649. */
  97650. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97651. /**
  97652. * Binds the submesh to this material by preparing the effect and shader to draw
  97653. * @param world defines the world transformation matrix
  97654. * @param mesh defines the mesh containing the submesh
  97655. * @param subMesh defines the submesh to bind the material to
  97656. */
  97657. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97658. /**
  97659. * Binds the material to the mesh
  97660. * @param world defines the world transformation matrix
  97661. * @param mesh defines the mesh to bind the material to
  97662. * @param effectOverride - If provided, use this effect instead of internal effect
  97663. */
  97664. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97665. protected _afterBind(mesh?: Mesh): void;
  97666. /**
  97667. * Gets the active textures from the material
  97668. * @returns an array of textures
  97669. */
  97670. getActiveTextures(): BaseTexture[];
  97671. /**
  97672. * Specifies if the material uses a texture
  97673. * @param texture defines the texture to check against the material
  97674. * @returns a boolean specifying if the material uses the texture
  97675. */
  97676. hasTexture(texture: BaseTexture): boolean;
  97677. /**
  97678. * Makes a duplicate of the material, and gives it a new name
  97679. * @param name defines the new name for the duplicated material
  97680. * @returns the cloned material
  97681. */
  97682. clone(name: string): ShaderMaterial;
  97683. /**
  97684. * Disposes the material
  97685. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97686. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97687. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97688. */
  97689. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97690. /**
  97691. * Serializes this material in a JSON representation
  97692. * @returns the serialized material object
  97693. */
  97694. serialize(): any;
  97695. /**
  97696. * Creates a shader material from parsed shader material data
  97697. * @param source defines the JSON represnetation of the material
  97698. * @param scene defines the hosting scene
  97699. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97700. * @returns a new material
  97701. */
  97702. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97703. /**
  97704. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97705. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97706. * @param url defines the url to load from
  97707. * @param scene defines the hosting scene
  97708. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97709. * @returns a promise that will resolve to the new ShaderMaterial
  97710. */
  97711. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97712. /**
  97713. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97714. * @param snippetId defines the snippet to load
  97715. * @param scene defines the hosting scene
  97716. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97717. * @returns a promise that will resolve to the new ShaderMaterial
  97718. */
  97719. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97720. }
  97721. }
  97722. declare module BABYLON {
  97723. /** @hidden */
  97724. export var colorPixelShader: {
  97725. name: string;
  97726. shader: string;
  97727. };
  97728. }
  97729. declare module BABYLON {
  97730. /** @hidden */
  97731. export var colorVertexShader: {
  97732. name: string;
  97733. shader: string;
  97734. };
  97735. }
  97736. declare module BABYLON {
  97737. /**
  97738. * Line mesh
  97739. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97740. */
  97741. export class LinesMesh extends Mesh {
  97742. /**
  97743. * If vertex color should be applied to the mesh
  97744. */
  97745. readonly useVertexColor?: boolean | undefined;
  97746. /**
  97747. * If vertex alpha should be applied to the mesh
  97748. */
  97749. readonly useVertexAlpha?: boolean | undefined;
  97750. /**
  97751. * Color of the line (Default: White)
  97752. */
  97753. color: Color3;
  97754. /**
  97755. * Alpha of the line (Default: 1)
  97756. */
  97757. alpha: number;
  97758. /**
  97759. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97760. * This margin is expressed in world space coordinates, so its value may vary.
  97761. * Default value is 0.1
  97762. */
  97763. intersectionThreshold: number;
  97764. private _colorShader;
  97765. private color4;
  97766. /**
  97767. * Creates a new LinesMesh
  97768. * @param name defines the name
  97769. * @param scene defines the hosting scene
  97770. * @param parent defines the parent mesh if any
  97771. * @param source defines the optional source LinesMesh used to clone data from
  97772. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97773. * When false, achieved by calling a clone(), also passing False.
  97774. * This will make creation of children, recursive.
  97775. * @param useVertexColor defines if this LinesMesh supports vertex color
  97776. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97777. */
  97778. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97779. /**
  97780. * If vertex color should be applied to the mesh
  97781. */
  97782. useVertexColor?: boolean | undefined,
  97783. /**
  97784. * If vertex alpha should be applied to the mesh
  97785. */
  97786. useVertexAlpha?: boolean | undefined);
  97787. private _addClipPlaneDefine;
  97788. private _removeClipPlaneDefine;
  97789. isReady(): boolean;
  97790. /**
  97791. * Returns the string "LineMesh"
  97792. */
  97793. getClassName(): string;
  97794. /**
  97795. * @hidden
  97796. */
  97797. get material(): Material;
  97798. /**
  97799. * @hidden
  97800. */
  97801. set material(value: Material);
  97802. /**
  97803. * @hidden
  97804. */
  97805. get checkCollisions(): boolean;
  97806. /** @hidden */
  97807. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97808. /** @hidden */
  97809. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97810. /**
  97811. * Disposes of the line mesh
  97812. * @param doNotRecurse If children should be disposed
  97813. */
  97814. dispose(doNotRecurse?: boolean): void;
  97815. /**
  97816. * Returns a new LineMesh object cloned from the current one.
  97817. */
  97818. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97819. /**
  97820. * Creates a new InstancedLinesMesh object from the mesh model.
  97821. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97822. * @param name defines the name of the new instance
  97823. * @returns a new InstancedLinesMesh
  97824. */
  97825. createInstance(name: string): InstancedLinesMesh;
  97826. }
  97827. /**
  97828. * Creates an instance based on a source LinesMesh
  97829. */
  97830. export class InstancedLinesMesh extends InstancedMesh {
  97831. /**
  97832. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97833. * This margin is expressed in world space coordinates, so its value may vary.
  97834. * Initilized with the intersectionThreshold value of the source LinesMesh
  97835. */
  97836. intersectionThreshold: number;
  97837. constructor(name: string, source: LinesMesh);
  97838. /**
  97839. * Returns the string "InstancedLinesMesh".
  97840. */
  97841. getClassName(): string;
  97842. }
  97843. }
  97844. declare module BABYLON {
  97845. /** @hidden */
  97846. export var linePixelShader: {
  97847. name: string;
  97848. shader: string;
  97849. };
  97850. }
  97851. declare module BABYLON {
  97852. /** @hidden */
  97853. export var lineVertexShader: {
  97854. name: string;
  97855. shader: string;
  97856. };
  97857. }
  97858. declare module BABYLON {
  97859. interface Scene {
  97860. /** @hidden */
  97861. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97862. }
  97863. interface AbstractMesh {
  97864. /**
  97865. * Gets the edgesRenderer associated with the mesh
  97866. */
  97867. edgesRenderer: Nullable<EdgesRenderer>;
  97868. }
  97869. interface LinesMesh {
  97870. /**
  97871. * Enables the edge rendering mode on the mesh.
  97872. * This mode makes the mesh edges visible
  97873. * @param epsilon defines the maximal distance between two angles to detect a face
  97874. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97875. * @returns the currentAbstractMesh
  97876. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97877. */
  97878. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97879. }
  97880. interface InstancedLinesMesh {
  97881. /**
  97882. * Enables the edge rendering mode on the mesh.
  97883. * This mode makes the mesh edges visible
  97884. * @param epsilon defines the maximal distance between two angles to detect a face
  97885. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97886. * @returns the current InstancedLinesMesh
  97887. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97888. */
  97889. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97890. }
  97891. /**
  97892. * Defines the minimum contract an Edges renderer should follow.
  97893. */
  97894. export interface IEdgesRenderer extends IDisposable {
  97895. /**
  97896. * Gets or sets a boolean indicating if the edgesRenderer is active
  97897. */
  97898. isEnabled: boolean;
  97899. /**
  97900. * Renders the edges of the attached mesh,
  97901. */
  97902. render(): void;
  97903. /**
  97904. * Checks wether or not the edges renderer is ready to render.
  97905. * @return true if ready, otherwise false.
  97906. */
  97907. isReady(): boolean;
  97908. /**
  97909. * List of instances to render in case the source mesh has instances
  97910. */
  97911. customInstances: SmartArray<Matrix>;
  97912. }
  97913. /**
  97914. * Defines the additional options of the edges renderer
  97915. */
  97916. export interface IEdgesRendererOptions {
  97917. /**
  97918. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97919. * If not defined, the default value is true
  97920. */
  97921. useAlternateEdgeFinder?: boolean;
  97922. /**
  97923. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97924. * If not defined, the default value is true.
  97925. * 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)
  97926. * This option is used only if useAlternateEdgeFinder = true
  97927. */
  97928. useFastVertexMerger?: boolean;
  97929. /**
  97930. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97931. * The default value is 1e-6
  97932. * This option is used only if useAlternateEdgeFinder = true
  97933. */
  97934. epsilonVertexMerge?: number;
  97935. /**
  97936. * 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
  97937. * 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.
  97938. * This option is used only if useAlternateEdgeFinder = true
  97939. */
  97940. applyTessellation?: boolean;
  97941. /**
  97942. * 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
  97943. * The default value is 1e-6
  97944. * This option is used only if useAlternateEdgeFinder = true
  97945. */
  97946. epsilonVertexAligned?: number;
  97947. }
  97948. /**
  97949. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97950. */
  97951. export class EdgesRenderer implements IEdgesRenderer {
  97952. /**
  97953. * Define the size of the edges with an orthographic camera
  97954. */
  97955. edgesWidthScalerForOrthographic: number;
  97956. /**
  97957. * Define the size of the edges with a perspective camera
  97958. */
  97959. edgesWidthScalerForPerspective: number;
  97960. protected _source: AbstractMesh;
  97961. protected _linesPositions: number[];
  97962. protected _linesNormals: number[];
  97963. protected _linesIndices: number[];
  97964. protected _epsilon: number;
  97965. protected _indicesCount: number;
  97966. protected _lineShader: ShaderMaterial;
  97967. protected _ib: DataBuffer;
  97968. protected _buffers: {
  97969. [key: string]: Nullable<VertexBuffer>;
  97970. };
  97971. protected _buffersForInstances: {
  97972. [key: string]: Nullable<VertexBuffer>;
  97973. };
  97974. protected _checkVerticesInsteadOfIndices: boolean;
  97975. protected _options: Nullable<IEdgesRendererOptions>;
  97976. private _meshRebuildObserver;
  97977. private _meshDisposeObserver;
  97978. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97979. isEnabled: boolean;
  97980. /**
  97981. * List of instances to render in case the source mesh has instances
  97982. */
  97983. customInstances: SmartArray<Matrix>;
  97984. private static GetShader;
  97985. /**
  97986. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97987. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97988. * @param source Mesh used to create edges
  97989. * @param epsilon sum of angles in adjacency to check for edge
  97990. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97991. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97992. * @param options The options to apply when generating the edges
  97993. */
  97994. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97995. protected _prepareRessources(): void;
  97996. /** @hidden */
  97997. _rebuild(): void;
  97998. /**
  97999. * Releases the required resources for the edges renderer
  98000. */
  98001. dispose(): void;
  98002. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  98003. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  98004. /**
  98005. * Checks if the pair of p0 and p1 is en edge
  98006. * @param faceIndex
  98007. * @param edge
  98008. * @param faceNormals
  98009. * @param p0
  98010. * @param p1
  98011. * @private
  98012. */
  98013. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  98014. /**
  98015. * push line into the position, normal and index buffer
  98016. * @protected
  98017. */
  98018. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  98019. /**
  98020. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  98021. */
  98022. private _tessellateTriangle;
  98023. private _generateEdgesLinesAlternate;
  98024. /**
  98025. * Generates lines edges from adjacencjes
  98026. * @private
  98027. */
  98028. _generateEdgesLines(): void;
  98029. /**
  98030. * Checks wether or not the edges renderer is ready to render.
  98031. * @return true if ready, otherwise false.
  98032. */
  98033. isReady(): boolean;
  98034. /**
  98035. * Renders the edges of the attached mesh,
  98036. */
  98037. render(): void;
  98038. }
  98039. /**
  98040. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  98041. */
  98042. export class LineEdgesRenderer extends EdgesRenderer {
  98043. /**
  98044. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98045. * @param source LineMesh used to generate edges
  98046. * @param epsilon not important (specified angle for edge detection)
  98047. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98048. */
  98049. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98050. /**
  98051. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98052. */
  98053. _generateEdgesLines(): void;
  98054. }
  98055. }
  98056. declare module BABYLON {
  98057. /**
  98058. * This represents the object necessary to create a rendering group.
  98059. * This is exclusively used and created by the rendering manager.
  98060. * To modify the behavior, you use the available helpers in your scene or meshes.
  98061. * @hidden
  98062. */
  98063. export class RenderingGroup {
  98064. index: number;
  98065. private static _zeroVector;
  98066. private _scene;
  98067. private _opaqueSubMeshes;
  98068. private _transparentSubMeshes;
  98069. private _alphaTestSubMeshes;
  98070. private _depthOnlySubMeshes;
  98071. private _particleSystems;
  98072. private _spriteManagers;
  98073. private _opaqueSortCompareFn;
  98074. private _alphaTestSortCompareFn;
  98075. private _transparentSortCompareFn;
  98076. private _renderOpaque;
  98077. private _renderAlphaTest;
  98078. private _renderTransparent;
  98079. /** @hidden */
  98080. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98081. onBeforeTransparentRendering: () => void;
  98082. /**
  98083. * Set the opaque sort comparison function.
  98084. * If null the sub meshes will be render in the order they were created
  98085. */
  98086. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98087. /**
  98088. * Set the alpha test sort comparison function.
  98089. * If null the sub meshes will be render in the order they were created
  98090. */
  98091. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98092. /**
  98093. * Set the transparent sort comparison function.
  98094. * If null the sub meshes will be render in the order they were created
  98095. */
  98096. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98097. /**
  98098. * Creates a new rendering group.
  98099. * @param index The rendering group index
  98100. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98101. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98102. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98103. */
  98104. 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>);
  98105. /**
  98106. * Render all the sub meshes contained in the group.
  98107. * @param customRenderFunction Used to override the default render behaviour of the group.
  98108. * @returns true if rendered some submeshes.
  98109. */
  98110. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98111. /**
  98112. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98113. * @param subMeshes The submeshes to render
  98114. */
  98115. private renderOpaqueSorted;
  98116. /**
  98117. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98118. * @param subMeshes The submeshes to render
  98119. */
  98120. private renderAlphaTestSorted;
  98121. /**
  98122. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98123. * @param subMeshes The submeshes to render
  98124. */
  98125. private renderTransparentSorted;
  98126. /**
  98127. * Renders the submeshes in a specified order.
  98128. * @param subMeshes The submeshes to sort before render
  98129. * @param sortCompareFn The comparison function use to sort
  98130. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98131. * @param transparent Specifies to activate blending if true
  98132. */
  98133. private static renderSorted;
  98134. /**
  98135. * Renders the submeshes in the order they were dispatched (no sort applied).
  98136. * @param subMeshes The submeshes to render
  98137. */
  98138. private static renderUnsorted;
  98139. /**
  98140. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98141. * are rendered back to front if in the same alpha index.
  98142. *
  98143. * @param a The first submesh
  98144. * @param b The second submesh
  98145. * @returns The result of the comparison
  98146. */
  98147. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98148. /**
  98149. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98150. * are rendered back to front.
  98151. *
  98152. * @param a The first submesh
  98153. * @param b The second submesh
  98154. * @returns The result of the comparison
  98155. */
  98156. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98157. /**
  98158. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98159. * are rendered front to back (prevent overdraw).
  98160. *
  98161. * @param a The first submesh
  98162. * @param b The second submesh
  98163. * @returns The result of the comparison
  98164. */
  98165. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98166. /**
  98167. * Resets the different lists of submeshes to prepare a new frame.
  98168. */
  98169. prepare(): void;
  98170. dispose(): void;
  98171. /**
  98172. * Inserts the submesh in its correct queue depending on its material.
  98173. * @param subMesh The submesh to dispatch
  98174. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98175. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98176. */
  98177. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98178. dispatchSprites(spriteManager: ISpriteManager): void;
  98179. dispatchParticles(particleSystem: IParticleSystem): void;
  98180. private _renderParticles;
  98181. private _renderSprites;
  98182. }
  98183. }
  98184. declare module BABYLON {
  98185. /**
  98186. * Interface describing the different options available in the rendering manager
  98187. * regarding Auto Clear between groups.
  98188. */
  98189. export interface IRenderingManagerAutoClearSetup {
  98190. /**
  98191. * Defines whether or not autoclear is enable.
  98192. */
  98193. autoClear: boolean;
  98194. /**
  98195. * Defines whether or not to autoclear the depth buffer.
  98196. */
  98197. depth: boolean;
  98198. /**
  98199. * Defines whether or not to autoclear the stencil buffer.
  98200. */
  98201. stencil: boolean;
  98202. }
  98203. /**
  98204. * This class is used by the onRenderingGroupObservable
  98205. */
  98206. export class RenderingGroupInfo {
  98207. /**
  98208. * The Scene that being rendered
  98209. */
  98210. scene: Scene;
  98211. /**
  98212. * The camera currently used for the rendering pass
  98213. */
  98214. camera: Nullable<Camera>;
  98215. /**
  98216. * The ID of the renderingGroup being processed
  98217. */
  98218. renderingGroupId: number;
  98219. }
  98220. /**
  98221. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98222. * It is enable to manage the different groups as well as the different necessary sort functions.
  98223. * This should not be used directly aside of the few static configurations
  98224. */
  98225. export class RenderingManager {
  98226. /**
  98227. * The max id used for rendering groups (not included)
  98228. */
  98229. static MAX_RENDERINGGROUPS: number;
  98230. /**
  98231. * The min id used for rendering groups (included)
  98232. */
  98233. static MIN_RENDERINGGROUPS: number;
  98234. /**
  98235. * Used to globally prevent autoclearing scenes.
  98236. */
  98237. static AUTOCLEAR: boolean;
  98238. /**
  98239. * @hidden
  98240. */
  98241. _useSceneAutoClearSetup: boolean;
  98242. private _scene;
  98243. private _renderingGroups;
  98244. private _depthStencilBufferAlreadyCleaned;
  98245. private _autoClearDepthStencil;
  98246. private _customOpaqueSortCompareFn;
  98247. private _customAlphaTestSortCompareFn;
  98248. private _customTransparentSortCompareFn;
  98249. private _renderingGroupInfo;
  98250. /**
  98251. * Instantiates a new rendering group for a particular scene
  98252. * @param scene Defines the scene the groups belongs to
  98253. */
  98254. constructor(scene: Scene);
  98255. private _clearDepthStencilBuffer;
  98256. /**
  98257. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98258. * @hidden
  98259. */
  98260. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98261. /**
  98262. * Resets the different information of the group to prepare a new frame
  98263. * @hidden
  98264. */
  98265. reset(): void;
  98266. /**
  98267. * Dispose and release the group and its associated resources.
  98268. * @hidden
  98269. */
  98270. dispose(): void;
  98271. /**
  98272. * Clear the info related to rendering groups preventing retention points during dispose.
  98273. */
  98274. freeRenderingGroups(): void;
  98275. private _prepareRenderingGroup;
  98276. /**
  98277. * Add a sprite manager to the rendering manager in order to render it this frame.
  98278. * @param spriteManager Define the sprite manager to render
  98279. */
  98280. dispatchSprites(spriteManager: ISpriteManager): void;
  98281. /**
  98282. * Add a particle system to the rendering manager in order to render it this frame.
  98283. * @param particleSystem Define the particle system to render
  98284. */
  98285. dispatchParticles(particleSystem: IParticleSystem): void;
  98286. /**
  98287. * Add a submesh to the manager in order to render it this frame
  98288. * @param subMesh The submesh to dispatch
  98289. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98290. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98291. */
  98292. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98293. /**
  98294. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98295. * This allowed control for front to back rendering or reversly depending of the special needs.
  98296. *
  98297. * @param renderingGroupId The rendering group id corresponding to its index
  98298. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98299. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98300. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98301. */
  98302. 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;
  98303. /**
  98304. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98305. *
  98306. * @param renderingGroupId The rendering group id corresponding to its index
  98307. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98308. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98309. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98310. */
  98311. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98312. /**
  98313. * Gets the current auto clear configuration for one rendering group of the rendering
  98314. * manager.
  98315. * @param index the rendering group index to get the information for
  98316. * @returns The auto clear setup for the requested rendering group
  98317. */
  98318. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98319. }
  98320. }
  98321. declare module BABYLON {
  98322. /**
  98323. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98324. */
  98325. export interface ICustomShaderOptions {
  98326. /**
  98327. * Gets or sets the custom shader name to use
  98328. */
  98329. shaderName: string;
  98330. /**
  98331. * The list of attribute names used in the shader
  98332. */
  98333. attributes?: string[];
  98334. /**
  98335. * The list of unifrom names used in the shader
  98336. */
  98337. uniforms?: string[];
  98338. /**
  98339. * The list of sampler names used in the shader
  98340. */
  98341. samplers?: string[];
  98342. /**
  98343. * The list of defines used in the shader
  98344. */
  98345. defines?: string[];
  98346. }
  98347. /**
  98348. * Interface to implement to create a shadow generator compatible with BJS.
  98349. */
  98350. export interface IShadowGenerator {
  98351. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98352. id: string;
  98353. /**
  98354. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98355. * @returns The render target texture if present otherwise, null
  98356. */
  98357. getShadowMap(): Nullable<RenderTargetTexture>;
  98358. /**
  98359. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98360. * @param subMesh The submesh we want to render in the shadow map
  98361. * @param useInstances Defines wether will draw in the map using instances
  98362. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98363. * @returns true if ready otherwise, false
  98364. */
  98365. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98366. /**
  98367. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98368. * @param defines Defines of the material we want to update
  98369. * @param lightIndex Index of the light in the enabled light list of the material
  98370. */
  98371. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98372. /**
  98373. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98374. * defined in the generator but impacting the effect).
  98375. * It implies the unifroms available on the materials are the standard BJS ones.
  98376. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98377. * @param effect The effect we are binfing the information for
  98378. */
  98379. bindShadowLight(lightIndex: string, effect: Effect): void;
  98380. /**
  98381. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98382. * (eq to shadow prjection matrix * light transform matrix)
  98383. * @returns The transform matrix used to create the shadow map
  98384. */
  98385. getTransformMatrix(): Matrix;
  98386. /**
  98387. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98388. * Cube and 2D textures for instance.
  98389. */
  98390. recreateShadowMap(): void;
  98391. /**
  98392. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98393. * @param onCompiled Callback triggered at the and of the effects compilation
  98394. * @param options Sets of optional options forcing the compilation with different modes
  98395. */
  98396. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98397. useInstances: boolean;
  98398. }>): void;
  98399. /**
  98400. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98401. * @param options Sets of optional options forcing the compilation with different modes
  98402. * @returns A promise that resolves when the compilation completes
  98403. */
  98404. forceCompilationAsync(options?: Partial<{
  98405. useInstances: boolean;
  98406. }>): Promise<void>;
  98407. /**
  98408. * Serializes the shadow generator setup to a json object.
  98409. * @returns The serialized JSON object
  98410. */
  98411. serialize(): any;
  98412. /**
  98413. * Disposes the Shadow map and related Textures and effects.
  98414. */
  98415. dispose(): void;
  98416. }
  98417. /**
  98418. * Default implementation IShadowGenerator.
  98419. * This is the main object responsible of generating shadows in the framework.
  98420. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98421. */
  98422. export class ShadowGenerator implements IShadowGenerator {
  98423. /**
  98424. * Name of the shadow generator class
  98425. */
  98426. static CLASSNAME: string;
  98427. /**
  98428. * Shadow generator mode None: no filtering applied.
  98429. */
  98430. static readonly FILTER_NONE: number;
  98431. /**
  98432. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98433. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98434. */
  98435. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98436. /**
  98437. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98438. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98439. */
  98440. static readonly FILTER_POISSONSAMPLING: number;
  98441. /**
  98442. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98443. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98444. */
  98445. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98446. /**
  98447. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98448. * edge artifacts on steep falloff.
  98449. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98450. */
  98451. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98452. /**
  98453. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98454. * edge artifacts on steep falloff.
  98455. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98456. */
  98457. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98458. /**
  98459. * Shadow generator mode PCF: Percentage Closer Filtering
  98460. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98461. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98462. */
  98463. static readonly FILTER_PCF: number;
  98464. /**
  98465. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98466. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98467. * Contact Hardening
  98468. */
  98469. static readonly FILTER_PCSS: number;
  98470. /**
  98471. * Reserved for PCF and PCSS
  98472. * Highest Quality.
  98473. *
  98474. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98475. *
  98476. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98477. */
  98478. static readonly QUALITY_HIGH: number;
  98479. /**
  98480. * Reserved for PCF and PCSS
  98481. * Good tradeoff for quality/perf cross devices
  98482. *
  98483. * Execute PCF on a 3*3 kernel.
  98484. *
  98485. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98486. */
  98487. static readonly QUALITY_MEDIUM: number;
  98488. /**
  98489. * Reserved for PCF and PCSS
  98490. * The lowest quality but the fastest.
  98491. *
  98492. * Execute PCF on a 1*1 kernel.
  98493. *
  98494. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98495. */
  98496. static readonly QUALITY_LOW: number;
  98497. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98498. id: string;
  98499. /** Gets or sets the custom shader name to use */
  98500. customShaderOptions: ICustomShaderOptions;
  98501. /**
  98502. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98503. */
  98504. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98505. /**
  98506. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98507. */
  98508. onAfterShadowMapRenderObservable: Observable<Effect>;
  98509. /**
  98510. * Observable triggered before a mesh is rendered in the shadow map.
  98511. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98512. */
  98513. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98514. /**
  98515. * Observable triggered after a mesh is rendered in the shadow map.
  98516. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98517. */
  98518. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98519. protected _bias: number;
  98520. /**
  98521. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98522. */
  98523. get bias(): number;
  98524. /**
  98525. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98526. */
  98527. set bias(bias: number);
  98528. protected _normalBias: number;
  98529. /**
  98530. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98531. */
  98532. get normalBias(): number;
  98533. /**
  98534. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98535. */
  98536. set normalBias(normalBias: number);
  98537. protected _blurBoxOffset: number;
  98538. /**
  98539. * Gets the blur box offset: offset applied during the blur pass.
  98540. * Only useful if useKernelBlur = false
  98541. */
  98542. get blurBoxOffset(): number;
  98543. /**
  98544. * Sets the blur box offset: offset applied during the blur pass.
  98545. * Only useful if useKernelBlur = false
  98546. */
  98547. set blurBoxOffset(value: number);
  98548. protected _blurScale: number;
  98549. /**
  98550. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98551. * 2 means half of the size.
  98552. */
  98553. get blurScale(): number;
  98554. /**
  98555. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98556. * 2 means half of the size.
  98557. */
  98558. set blurScale(value: number);
  98559. protected _blurKernel: number;
  98560. /**
  98561. * Gets the blur kernel: kernel size of the blur pass.
  98562. * Only useful if useKernelBlur = true
  98563. */
  98564. get blurKernel(): number;
  98565. /**
  98566. * Sets the blur kernel: kernel size of the blur pass.
  98567. * Only useful if useKernelBlur = true
  98568. */
  98569. set blurKernel(value: number);
  98570. protected _useKernelBlur: boolean;
  98571. /**
  98572. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98573. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98574. */
  98575. get useKernelBlur(): boolean;
  98576. /**
  98577. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98578. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98579. */
  98580. set useKernelBlur(value: boolean);
  98581. protected _depthScale: number;
  98582. /**
  98583. * Gets the depth scale used in ESM mode.
  98584. */
  98585. get depthScale(): number;
  98586. /**
  98587. * Sets the depth scale used in ESM mode.
  98588. * This can override the scale stored on the light.
  98589. */
  98590. set depthScale(value: number);
  98591. protected _validateFilter(filter: number): number;
  98592. protected _filter: number;
  98593. /**
  98594. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98595. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98596. */
  98597. get filter(): number;
  98598. /**
  98599. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98600. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98601. */
  98602. set filter(value: number);
  98603. /**
  98604. * Gets if the current filter is set to Poisson Sampling.
  98605. */
  98606. get usePoissonSampling(): boolean;
  98607. /**
  98608. * Sets the current filter to Poisson Sampling.
  98609. */
  98610. set usePoissonSampling(value: boolean);
  98611. /**
  98612. * Gets if the current filter is set to ESM.
  98613. */
  98614. get useExponentialShadowMap(): boolean;
  98615. /**
  98616. * Sets the current filter is to ESM.
  98617. */
  98618. set useExponentialShadowMap(value: boolean);
  98619. /**
  98620. * Gets if the current filter is set to filtered ESM.
  98621. */
  98622. get useBlurExponentialShadowMap(): boolean;
  98623. /**
  98624. * Gets if the current filter is set to filtered ESM.
  98625. */
  98626. set useBlurExponentialShadowMap(value: boolean);
  98627. /**
  98628. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98629. * exponential to prevent steep falloff artifacts).
  98630. */
  98631. get useCloseExponentialShadowMap(): boolean;
  98632. /**
  98633. * Sets the current filter to "close ESM" (using the inverse of the
  98634. * exponential to prevent steep falloff artifacts).
  98635. */
  98636. set useCloseExponentialShadowMap(value: boolean);
  98637. /**
  98638. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98639. * exponential to prevent steep falloff artifacts).
  98640. */
  98641. get useBlurCloseExponentialShadowMap(): boolean;
  98642. /**
  98643. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98644. * exponential to prevent steep falloff artifacts).
  98645. */
  98646. set useBlurCloseExponentialShadowMap(value: boolean);
  98647. /**
  98648. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98649. */
  98650. get usePercentageCloserFiltering(): boolean;
  98651. /**
  98652. * Sets the current filter to "PCF" (percentage closer filtering).
  98653. */
  98654. set usePercentageCloserFiltering(value: boolean);
  98655. protected _filteringQuality: number;
  98656. /**
  98657. * Gets the PCF or PCSS Quality.
  98658. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98659. */
  98660. get filteringQuality(): number;
  98661. /**
  98662. * Sets the PCF or PCSS Quality.
  98663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98664. */
  98665. set filteringQuality(filteringQuality: number);
  98666. /**
  98667. * Gets if the current filter is set to "PCSS" (contact hardening).
  98668. */
  98669. get useContactHardeningShadow(): boolean;
  98670. /**
  98671. * Sets the current filter to "PCSS" (contact hardening).
  98672. */
  98673. set useContactHardeningShadow(value: boolean);
  98674. protected _contactHardeningLightSizeUVRatio: number;
  98675. /**
  98676. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98677. * Using a ratio helps keeping shape stability independently of the map size.
  98678. *
  98679. * It does not account for the light projection as it was having too much
  98680. * instability during the light setup or during light position changes.
  98681. *
  98682. * Only valid if useContactHardeningShadow is true.
  98683. */
  98684. get contactHardeningLightSizeUVRatio(): number;
  98685. /**
  98686. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98687. * Using a ratio helps keeping shape stability independently of the map size.
  98688. *
  98689. * It does not account for the light projection as it was having too much
  98690. * instability during the light setup or during light position changes.
  98691. *
  98692. * Only valid if useContactHardeningShadow is true.
  98693. */
  98694. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98695. protected _darkness: number;
  98696. /** Gets or sets the actual darkness of a shadow */
  98697. get darkness(): number;
  98698. set darkness(value: number);
  98699. /**
  98700. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98701. * 0 means strongest and 1 would means no shadow.
  98702. * @returns the darkness.
  98703. */
  98704. getDarkness(): number;
  98705. /**
  98706. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98707. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98708. * @returns the shadow generator allowing fluent coding.
  98709. */
  98710. setDarkness(darkness: number): ShadowGenerator;
  98711. protected _transparencyShadow: boolean;
  98712. /** Gets or sets the ability to have transparent shadow */
  98713. get transparencyShadow(): boolean;
  98714. set transparencyShadow(value: boolean);
  98715. /**
  98716. * Sets the ability to have transparent shadow (boolean).
  98717. * @param transparent True if transparent else False
  98718. * @returns the shadow generator allowing fluent coding
  98719. */
  98720. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98721. /**
  98722. * Enables or disables shadows with varying strength based on the transparency
  98723. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98724. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98725. * mesh.visibility * alphaTexture.a
  98726. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98727. */
  98728. enableSoftTransparentShadow: boolean;
  98729. protected _shadowMap: Nullable<RenderTargetTexture>;
  98730. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98731. /**
  98732. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98733. * @returns The render target texture if present otherwise, null
  98734. */
  98735. getShadowMap(): Nullable<RenderTargetTexture>;
  98736. /**
  98737. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98738. * @returns The render target texture if the shadow map is present otherwise, null
  98739. */
  98740. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98741. /**
  98742. * Gets the class name of that object
  98743. * @returns "ShadowGenerator"
  98744. */
  98745. getClassName(): string;
  98746. /**
  98747. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98748. * @param mesh Mesh to add
  98749. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98750. * @returns the Shadow Generator itself
  98751. */
  98752. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98753. /**
  98754. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98755. * @param mesh Mesh to remove
  98756. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98757. * @returns the Shadow Generator itself
  98758. */
  98759. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98760. /**
  98761. * Controls the extent to which the shadows fade out at the edge of the frustum
  98762. */
  98763. frustumEdgeFalloff: number;
  98764. protected _light: IShadowLight;
  98765. /**
  98766. * Returns the associated light object.
  98767. * @returns the light generating the shadow
  98768. */
  98769. getLight(): IShadowLight;
  98770. /**
  98771. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98772. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98773. * It might on the other hand introduce peter panning.
  98774. */
  98775. forceBackFacesOnly: boolean;
  98776. protected _scene: Scene;
  98777. protected _lightDirection: Vector3;
  98778. protected _effect: Effect;
  98779. protected _viewMatrix: Matrix;
  98780. protected _projectionMatrix: Matrix;
  98781. protected _transformMatrix: Matrix;
  98782. protected _cachedPosition: Vector3;
  98783. protected _cachedDirection: Vector3;
  98784. protected _cachedDefines: string;
  98785. protected _currentRenderID: number;
  98786. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98787. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98788. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98789. protected _blurPostProcesses: PostProcess[];
  98790. protected _mapSize: number;
  98791. protected _currentFaceIndex: number;
  98792. protected _currentFaceIndexCache: number;
  98793. protected _textureType: number;
  98794. protected _defaultTextureMatrix: Matrix;
  98795. protected _storedUniqueId: Nullable<number>;
  98796. /** @hidden */
  98797. static _SceneComponentInitialization: (scene: Scene) => void;
  98798. /**
  98799. * Gets or sets the size of the texture what stores the shadows
  98800. */
  98801. get mapSize(): number;
  98802. set mapSize(size: number);
  98803. /**
  98804. * Creates a ShadowGenerator object.
  98805. * A ShadowGenerator is the required tool to use the shadows.
  98806. * Each light casting shadows needs to use its own ShadowGenerator.
  98807. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98808. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98809. * @param light The light object generating the shadows.
  98810. * @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.
  98811. */
  98812. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98813. protected _initializeGenerator(): void;
  98814. protected _createTargetRenderTexture(): void;
  98815. protected _initializeShadowMap(): void;
  98816. protected _initializeBlurRTTAndPostProcesses(): void;
  98817. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98818. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98819. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98820. protected _applyFilterValues(): void;
  98821. /**
  98822. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98823. * @param onCompiled Callback triggered at the and of the effects compilation
  98824. * @param options Sets of optional options forcing the compilation with different modes
  98825. */
  98826. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98827. useInstances: boolean;
  98828. }>): void;
  98829. /**
  98830. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98831. * @param options Sets of optional options forcing the compilation with different modes
  98832. * @returns A promise that resolves when the compilation completes
  98833. */
  98834. forceCompilationAsync(options?: Partial<{
  98835. useInstances: boolean;
  98836. }>): Promise<void>;
  98837. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98838. private _prepareShadowDefines;
  98839. /**
  98840. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98841. * @param subMesh The submesh we want to render in the shadow map
  98842. * @param useInstances Defines wether will draw in the map using instances
  98843. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98844. * @returns true if ready otherwise, false
  98845. */
  98846. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98847. /**
  98848. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98849. * @param defines Defines of the material we want to update
  98850. * @param lightIndex Index of the light in the enabled light list of the material
  98851. */
  98852. prepareDefines(defines: any, lightIndex: number): void;
  98853. /**
  98854. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98855. * defined in the generator but impacting the effect).
  98856. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98857. * @param effect The effect we are binfing the information for
  98858. */
  98859. bindShadowLight(lightIndex: string, effect: Effect): void;
  98860. /**
  98861. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98862. * (eq to shadow prjection matrix * light transform matrix)
  98863. * @returns The transform matrix used to create the shadow map
  98864. */
  98865. getTransformMatrix(): Matrix;
  98866. /**
  98867. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98868. * Cube and 2D textures for instance.
  98869. */
  98870. recreateShadowMap(): void;
  98871. protected _disposeBlurPostProcesses(): void;
  98872. protected _disposeRTTandPostProcesses(): void;
  98873. /**
  98874. * Disposes the ShadowGenerator.
  98875. * Returns nothing.
  98876. */
  98877. dispose(): void;
  98878. /**
  98879. * Serializes the shadow generator setup to a json object.
  98880. * @returns The serialized JSON object
  98881. */
  98882. serialize(): any;
  98883. /**
  98884. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98885. * @param parsedShadowGenerator The JSON object to parse
  98886. * @param scene The scene to create the shadow map for
  98887. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98888. * @returns The parsed shadow generator
  98889. */
  98890. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98891. }
  98892. }
  98893. declare module BABYLON {
  98894. /**
  98895. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98896. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98897. * 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.
  98898. */
  98899. export abstract class Light extends Node {
  98900. /**
  98901. * Falloff Default: light is falling off following the material specification:
  98902. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98903. */
  98904. static readonly FALLOFF_DEFAULT: number;
  98905. /**
  98906. * Falloff Physical: light is falling off following the inverse squared distance law.
  98907. */
  98908. static readonly FALLOFF_PHYSICAL: number;
  98909. /**
  98910. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98911. * to enhance interoperability with other engines.
  98912. */
  98913. static readonly FALLOFF_GLTF: number;
  98914. /**
  98915. * Falloff Standard: light is falling off like in the standard material
  98916. * to enhance interoperability with other materials.
  98917. */
  98918. static readonly FALLOFF_STANDARD: number;
  98919. /**
  98920. * If every light affecting the material is in this lightmapMode,
  98921. * material.lightmapTexture adds or multiplies
  98922. * (depends on material.useLightmapAsShadowmap)
  98923. * after every other light calculations.
  98924. */
  98925. static readonly LIGHTMAP_DEFAULT: number;
  98926. /**
  98927. * material.lightmapTexture as only diffuse lighting from this light
  98928. * adds only specular lighting from this light
  98929. * adds dynamic shadows
  98930. */
  98931. static readonly LIGHTMAP_SPECULAR: number;
  98932. /**
  98933. * material.lightmapTexture as only lighting
  98934. * no light calculation from this light
  98935. * only adds dynamic shadows from this light
  98936. */
  98937. static readonly LIGHTMAP_SHADOWSONLY: number;
  98938. /**
  98939. * Each light type uses the default quantity according to its type:
  98940. * point/spot lights use luminous intensity
  98941. * directional lights use illuminance
  98942. */
  98943. static readonly INTENSITYMODE_AUTOMATIC: number;
  98944. /**
  98945. * lumen (lm)
  98946. */
  98947. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98948. /**
  98949. * candela (lm/sr)
  98950. */
  98951. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98952. /**
  98953. * lux (lm/m^2)
  98954. */
  98955. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98956. /**
  98957. * nit (cd/m^2)
  98958. */
  98959. static readonly INTENSITYMODE_LUMINANCE: number;
  98960. /**
  98961. * Light type const id of the point light.
  98962. */
  98963. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98964. /**
  98965. * Light type const id of the directional light.
  98966. */
  98967. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98968. /**
  98969. * Light type const id of the spot light.
  98970. */
  98971. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98972. /**
  98973. * Light type const id of the hemispheric light.
  98974. */
  98975. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98976. /**
  98977. * Diffuse gives the basic color to an object.
  98978. */
  98979. diffuse: Color3;
  98980. /**
  98981. * Specular produces a highlight color on an object.
  98982. * Note: This is note affecting PBR materials.
  98983. */
  98984. specular: Color3;
  98985. /**
  98986. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98987. * falling off base on range or angle.
  98988. * This can be set to any values in Light.FALLOFF_x.
  98989. *
  98990. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98991. * other types of materials.
  98992. */
  98993. falloffType: number;
  98994. /**
  98995. * Strength of the light.
  98996. * Note: By default it is define in the framework own unit.
  98997. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98998. */
  98999. intensity: number;
  99000. private _range;
  99001. protected _inverseSquaredRange: number;
  99002. /**
  99003. * Defines how far from the source the light is impacting in scene units.
  99004. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99005. */
  99006. get range(): number;
  99007. /**
  99008. * Defines how far from the source the light is impacting in scene units.
  99009. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99010. */
  99011. set range(value: number);
  99012. /**
  99013. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  99014. * of light.
  99015. */
  99016. private _photometricScale;
  99017. private _intensityMode;
  99018. /**
  99019. * Gets the photometric scale used to interpret the intensity.
  99020. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99021. */
  99022. get intensityMode(): number;
  99023. /**
  99024. * Sets the photometric scale used to interpret the intensity.
  99025. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99026. */
  99027. set intensityMode(value: number);
  99028. private _radius;
  99029. /**
  99030. * Gets the light radius used by PBR Materials to simulate soft area lights.
  99031. */
  99032. get radius(): number;
  99033. /**
  99034. * sets the light radius used by PBR Materials to simulate soft area lights.
  99035. */
  99036. set radius(value: number);
  99037. private _renderPriority;
  99038. /**
  99039. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  99040. * exceeding the number allowed of the materials.
  99041. */
  99042. renderPriority: number;
  99043. private _shadowEnabled;
  99044. /**
  99045. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99046. * the current shadow generator.
  99047. */
  99048. get shadowEnabled(): boolean;
  99049. /**
  99050. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99051. * the current shadow generator.
  99052. */
  99053. set shadowEnabled(value: boolean);
  99054. private _includedOnlyMeshes;
  99055. /**
  99056. * Gets the only meshes impacted by this light.
  99057. */
  99058. get includedOnlyMeshes(): AbstractMesh[];
  99059. /**
  99060. * Sets the only meshes impacted by this light.
  99061. */
  99062. set includedOnlyMeshes(value: AbstractMesh[]);
  99063. private _excludedMeshes;
  99064. /**
  99065. * Gets the meshes not impacted by this light.
  99066. */
  99067. get excludedMeshes(): AbstractMesh[];
  99068. /**
  99069. * Sets the meshes not impacted by this light.
  99070. */
  99071. set excludedMeshes(value: AbstractMesh[]);
  99072. private _excludeWithLayerMask;
  99073. /**
  99074. * Gets the layer id use to find what meshes are not impacted by the light.
  99075. * Inactive if 0
  99076. */
  99077. get excludeWithLayerMask(): number;
  99078. /**
  99079. * Sets the layer id use to find what meshes are not impacted by the light.
  99080. * Inactive if 0
  99081. */
  99082. set excludeWithLayerMask(value: number);
  99083. private _includeOnlyWithLayerMask;
  99084. /**
  99085. * Gets the layer id use to find what meshes are impacted by the light.
  99086. * Inactive if 0
  99087. */
  99088. get includeOnlyWithLayerMask(): number;
  99089. /**
  99090. * Sets the layer id use to find what meshes are impacted by the light.
  99091. * Inactive if 0
  99092. */
  99093. set includeOnlyWithLayerMask(value: number);
  99094. private _lightmapMode;
  99095. /**
  99096. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99097. */
  99098. get lightmapMode(): number;
  99099. /**
  99100. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99101. */
  99102. set lightmapMode(value: number);
  99103. /**
  99104. * Shadow generator associted to the light.
  99105. * @hidden Internal use only.
  99106. */
  99107. _shadowGenerator: Nullable<IShadowGenerator>;
  99108. /**
  99109. * @hidden Internal use only.
  99110. */
  99111. _excludedMeshesIds: string[];
  99112. /**
  99113. * @hidden Internal use only.
  99114. */
  99115. _includedOnlyMeshesIds: string[];
  99116. /**
  99117. * The current light unifom buffer.
  99118. * @hidden Internal use only.
  99119. */
  99120. _uniformBuffer: UniformBuffer;
  99121. /** @hidden */
  99122. _renderId: number;
  99123. /**
  99124. * Creates a Light object in the scene.
  99125. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99126. * @param name The firendly name of the light
  99127. * @param scene The scene the light belongs too
  99128. */
  99129. constructor(name: string, scene: Scene);
  99130. protected abstract _buildUniformLayout(): void;
  99131. /**
  99132. * Sets the passed Effect "effect" with the Light information.
  99133. * @param effect The effect to update
  99134. * @param lightIndex The index of the light in the effect to update
  99135. * @returns The light
  99136. */
  99137. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99138. /**
  99139. * Sets the passed Effect "effect" with the Light textures.
  99140. * @param effect The effect to update
  99141. * @param lightIndex The index of the light in the effect to update
  99142. * @returns The light
  99143. */
  99144. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99145. /**
  99146. * Binds the lights information from the scene to the effect for the given mesh.
  99147. * @param lightIndex Light index
  99148. * @param scene The scene where the light belongs to
  99149. * @param effect The effect we are binding the data to
  99150. * @param useSpecular Defines if specular is supported
  99151. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99152. */
  99153. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99154. /**
  99155. * Sets the passed Effect "effect" with the Light information.
  99156. * @param effect The effect to update
  99157. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99158. * @returns The light
  99159. */
  99160. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99161. /**
  99162. * Returns the string "Light".
  99163. * @returns the class name
  99164. */
  99165. getClassName(): string;
  99166. /** @hidden */
  99167. readonly _isLight: boolean;
  99168. /**
  99169. * Converts the light information to a readable string for debug purpose.
  99170. * @param fullDetails Supports for multiple levels of logging within scene loading
  99171. * @returns the human readable light info
  99172. */
  99173. toString(fullDetails?: boolean): string;
  99174. /** @hidden */
  99175. protected _syncParentEnabledState(): void;
  99176. /**
  99177. * Set the enabled state of this node.
  99178. * @param value - the new enabled state
  99179. */
  99180. setEnabled(value: boolean): void;
  99181. /**
  99182. * Returns the Light associated shadow generator if any.
  99183. * @return the associated shadow generator.
  99184. */
  99185. getShadowGenerator(): Nullable<IShadowGenerator>;
  99186. /**
  99187. * Returns a Vector3, the absolute light position in the World.
  99188. * @returns the world space position of the light
  99189. */
  99190. getAbsolutePosition(): Vector3;
  99191. /**
  99192. * Specifies if the light will affect the passed mesh.
  99193. * @param mesh The mesh to test against the light
  99194. * @return true the mesh is affected otherwise, false.
  99195. */
  99196. canAffectMesh(mesh: AbstractMesh): boolean;
  99197. /**
  99198. * Sort function to order lights for rendering.
  99199. * @param a First Light object to compare to second.
  99200. * @param b Second Light object to compare first.
  99201. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99202. */
  99203. static CompareLightsPriority(a: Light, b: Light): number;
  99204. /**
  99205. * Releases resources associated with this node.
  99206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99208. */
  99209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99210. /**
  99211. * Returns the light type ID (integer).
  99212. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99213. */
  99214. getTypeID(): number;
  99215. /**
  99216. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99217. * @returns the scaled intensity in intensity mode unit
  99218. */
  99219. getScaledIntensity(): number;
  99220. /**
  99221. * Returns a new Light object, named "name", from the current one.
  99222. * @param name The name of the cloned light
  99223. * @param newParent The parent of this light, if it has one
  99224. * @returns the new created light
  99225. */
  99226. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99227. /**
  99228. * Serializes the current light into a Serialization object.
  99229. * @returns the serialized object.
  99230. */
  99231. serialize(): any;
  99232. /**
  99233. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99234. * This new light is named "name" and added to the passed scene.
  99235. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99236. * @param name The friendly name of the light
  99237. * @param scene The scene the new light will belong to
  99238. * @returns the constructor function
  99239. */
  99240. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99241. /**
  99242. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99243. * @param parsedLight The JSON representation of the light
  99244. * @param scene The scene to create the parsed light in
  99245. * @returns the created light after parsing
  99246. */
  99247. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99248. private _hookArrayForExcluded;
  99249. private _hookArrayForIncludedOnly;
  99250. private _resyncMeshes;
  99251. /**
  99252. * Forces the meshes to update their light related information in their rendering used effects
  99253. * @hidden Internal Use Only
  99254. */
  99255. _markMeshesAsLightDirty(): void;
  99256. /**
  99257. * Recomputes the cached photometric scale if needed.
  99258. */
  99259. private _computePhotometricScale;
  99260. /**
  99261. * Returns the Photometric Scale according to the light type and intensity mode.
  99262. */
  99263. private _getPhotometricScale;
  99264. /**
  99265. * Reorder the light in the scene according to their defined priority.
  99266. * @hidden Internal Use Only
  99267. */
  99268. _reorderLightsInScene(): void;
  99269. /**
  99270. * Prepares the list of defines specific to the light type.
  99271. * @param defines the list of defines
  99272. * @param lightIndex defines the index of the light for the effect
  99273. */
  99274. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99275. }
  99276. }
  99277. declare module BABYLON {
  99278. /**
  99279. * Configuration needed for prepass-capable materials
  99280. */
  99281. export class PrePassConfiguration {
  99282. /**
  99283. * Previous world matrices of meshes carrying this material
  99284. * Used for computing velocity
  99285. */
  99286. previousWorldMatrices: {
  99287. [index: number]: Matrix;
  99288. };
  99289. /**
  99290. * Previous view project matrix
  99291. * Used for computing velocity
  99292. */
  99293. previousViewProjection: Matrix;
  99294. /**
  99295. * Previous bones of meshes carrying this material
  99296. * Used for computing velocity
  99297. */
  99298. previousBones: {
  99299. [index: number]: Float32Array;
  99300. };
  99301. /**
  99302. * Add the required uniforms to the current list.
  99303. * @param uniforms defines the current uniform list.
  99304. */
  99305. static AddUniforms(uniforms: string[]): void;
  99306. /**
  99307. * Add the required samplers to the current list.
  99308. * @param samplers defines the current sampler list.
  99309. */
  99310. static AddSamplers(samplers: string[]): void;
  99311. /**
  99312. * Binds the material data.
  99313. * @param effect defines the effect to update
  99314. * @param scene defines the scene the material belongs to.
  99315. * @param mesh The mesh
  99316. * @param world World matrix of this mesh
  99317. * @param isFrozen Is the material frozen
  99318. */
  99319. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99320. }
  99321. }
  99322. declare module BABYLON {
  99323. /**
  99324. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99325. * This is the base of the follow, arc rotate cameras and Free camera
  99326. * @see https://doc.babylonjs.com/features/cameras
  99327. */
  99328. export class TargetCamera extends Camera {
  99329. private static _RigCamTransformMatrix;
  99330. private static _TargetTransformMatrix;
  99331. private static _TargetFocalPoint;
  99332. private _tmpUpVector;
  99333. private _tmpTargetVector;
  99334. /**
  99335. * Define the current direction the camera is moving to
  99336. */
  99337. cameraDirection: Vector3;
  99338. /**
  99339. * Define the current rotation the camera is rotating to
  99340. */
  99341. cameraRotation: Vector2;
  99342. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99343. ignoreParentScaling: boolean;
  99344. /**
  99345. * When set, the up vector of the camera will be updated by the rotation of the camera
  99346. */
  99347. updateUpVectorFromRotation: boolean;
  99348. private _tmpQuaternion;
  99349. /**
  99350. * Define the current rotation of the camera
  99351. */
  99352. rotation: Vector3;
  99353. /**
  99354. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99355. */
  99356. rotationQuaternion: Quaternion;
  99357. /**
  99358. * Define the current speed of the camera
  99359. */
  99360. speed: number;
  99361. /**
  99362. * Add constraint to the camera to prevent it to move freely in all directions and
  99363. * around all axis.
  99364. */
  99365. noRotationConstraint: boolean;
  99366. /**
  99367. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99368. * panning
  99369. */
  99370. invertRotation: boolean;
  99371. /**
  99372. * Speed multiplier for inverse camera panning
  99373. */
  99374. inverseRotationSpeed: number;
  99375. /**
  99376. * Define the current target of the camera as an object or a position.
  99377. */
  99378. lockedTarget: any;
  99379. /** @hidden */
  99380. _currentTarget: Vector3;
  99381. /** @hidden */
  99382. _initialFocalDistance: number;
  99383. /** @hidden */
  99384. _viewMatrix: Matrix;
  99385. /** @hidden */
  99386. _camMatrix: Matrix;
  99387. /** @hidden */
  99388. _cameraTransformMatrix: Matrix;
  99389. /** @hidden */
  99390. _cameraRotationMatrix: Matrix;
  99391. /** @hidden */
  99392. _referencePoint: Vector3;
  99393. /** @hidden */
  99394. _transformedReferencePoint: Vector3;
  99395. /** @hidden */
  99396. _reset: () => void;
  99397. private _defaultUp;
  99398. /**
  99399. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99400. * This is the base of the follow, arc rotate cameras and Free camera
  99401. * @see https://doc.babylonjs.com/features/cameras
  99402. * @param name Defines the name of the camera in the scene
  99403. * @param position Defines the start position of the camera in the scene
  99404. * @param scene Defines the scene the camera belongs to
  99405. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99406. */
  99407. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99408. /**
  99409. * Gets the position in front of the camera at a given distance.
  99410. * @param distance The distance from the camera we want the position to be
  99411. * @returns the position
  99412. */
  99413. getFrontPosition(distance: number): Vector3;
  99414. /** @hidden */
  99415. _getLockedTargetPosition(): Nullable<Vector3>;
  99416. private _storedPosition;
  99417. private _storedRotation;
  99418. private _storedRotationQuaternion;
  99419. /**
  99420. * Store current camera state of the camera (fov, position, rotation, etc..)
  99421. * @returns the camera
  99422. */
  99423. storeState(): Camera;
  99424. /**
  99425. * Restored camera state. You must call storeState() first
  99426. * @returns whether it was successful or not
  99427. * @hidden
  99428. */
  99429. _restoreStateValues(): boolean;
  99430. /** @hidden */
  99431. _initCache(): void;
  99432. /** @hidden */
  99433. _updateCache(ignoreParentClass?: boolean): void;
  99434. /** @hidden */
  99435. _isSynchronizedViewMatrix(): boolean;
  99436. /** @hidden */
  99437. _computeLocalCameraSpeed(): number;
  99438. /**
  99439. * Defines the target the camera should look at.
  99440. * @param target Defines the new target as a Vector or a mesh
  99441. */
  99442. setTarget(target: Vector3): void;
  99443. /**
  99444. * Defines the target point of the camera.
  99445. * The camera looks towards it form the radius distance.
  99446. */
  99447. get target(): Vector3;
  99448. set target(value: Vector3);
  99449. /**
  99450. * Return the current target position of the camera. This value is expressed in local space.
  99451. * @returns the target position
  99452. */
  99453. getTarget(): Vector3;
  99454. /** @hidden */
  99455. _decideIfNeedsToMove(): boolean;
  99456. /** @hidden */
  99457. _updatePosition(): void;
  99458. /** @hidden */
  99459. _checkInputs(): void;
  99460. protected _updateCameraRotationMatrix(): void;
  99461. /**
  99462. * 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)
  99463. * @returns the current camera
  99464. */
  99465. private _rotateUpVectorWithCameraRotationMatrix;
  99466. private _cachedRotationZ;
  99467. private _cachedQuaternionRotationZ;
  99468. /** @hidden */
  99469. _getViewMatrix(): Matrix;
  99470. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99471. /**
  99472. * @hidden
  99473. */
  99474. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99475. /**
  99476. * @hidden
  99477. */
  99478. _updateRigCameras(): void;
  99479. private _getRigCamPositionAndTarget;
  99480. /**
  99481. * Gets the current object class name.
  99482. * @return the class name
  99483. */
  99484. getClassName(): string;
  99485. }
  99486. }
  99487. declare module BABYLON {
  99488. /**
  99489. * Gather the list of keyboard event types as constants.
  99490. */
  99491. export class KeyboardEventTypes {
  99492. /**
  99493. * The keydown event is fired when a key becomes active (pressed).
  99494. */
  99495. static readonly KEYDOWN: number;
  99496. /**
  99497. * The keyup event is fired when a key has been released.
  99498. */
  99499. static readonly KEYUP: number;
  99500. }
  99501. /**
  99502. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99503. */
  99504. export class KeyboardInfo {
  99505. /**
  99506. * Defines the type of event (KeyboardEventTypes)
  99507. */
  99508. type: number;
  99509. /**
  99510. * Defines the related dom event
  99511. */
  99512. event: KeyboardEvent;
  99513. /**
  99514. * Instantiates a new keyboard info.
  99515. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99516. * @param type Defines the type of event (KeyboardEventTypes)
  99517. * @param event Defines the related dom event
  99518. */
  99519. constructor(
  99520. /**
  99521. * Defines the type of event (KeyboardEventTypes)
  99522. */
  99523. type: number,
  99524. /**
  99525. * Defines the related dom event
  99526. */
  99527. event: KeyboardEvent);
  99528. }
  99529. /**
  99530. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99531. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99532. */
  99533. export class KeyboardInfoPre extends KeyboardInfo {
  99534. /**
  99535. * Defines the type of event (KeyboardEventTypes)
  99536. */
  99537. type: number;
  99538. /**
  99539. * Defines the related dom event
  99540. */
  99541. event: KeyboardEvent;
  99542. /**
  99543. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99544. */
  99545. skipOnPointerObservable: boolean;
  99546. /**
  99547. * Instantiates a new keyboard pre info.
  99548. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99549. * @param type Defines the type of event (KeyboardEventTypes)
  99550. * @param event Defines the related dom event
  99551. */
  99552. constructor(
  99553. /**
  99554. * Defines the type of event (KeyboardEventTypes)
  99555. */
  99556. type: number,
  99557. /**
  99558. * Defines the related dom event
  99559. */
  99560. event: KeyboardEvent);
  99561. }
  99562. }
  99563. declare module BABYLON {
  99564. /**
  99565. * Manage the keyboard inputs to control the movement of a free camera.
  99566. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99567. */
  99568. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99569. /**
  99570. * Defines the camera the input is attached to.
  99571. */
  99572. camera: FreeCamera;
  99573. /**
  99574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99575. */
  99576. keysUp: number[];
  99577. /**
  99578. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99579. */
  99580. keysUpward: number[];
  99581. /**
  99582. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99583. */
  99584. keysDown: number[];
  99585. /**
  99586. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99587. */
  99588. keysDownward: number[];
  99589. /**
  99590. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99591. */
  99592. keysLeft: number[];
  99593. /**
  99594. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99595. */
  99596. keysRight: number[];
  99597. private _keys;
  99598. private _onCanvasBlurObserver;
  99599. private _onKeyboardObserver;
  99600. private _engine;
  99601. private _scene;
  99602. /**
  99603. * Attach the input controls to a specific dom element to get the input from.
  99604. * @param element Defines the element the controls should be listened from
  99605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99606. */
  99607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99608. /**
  99609. * Detach the current controls from the specified dom element.
  99610. * @param element Defines the element to stop listening the inputs from
  99611. */
  99612. detachControl(element: Nullable<HTMLElement>): void;
  99613. /**
  99614. * Update the current camera state depending on the inputs that have been used this frame.
  99615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99616. */
  99617. checkInputs(): void;
  99618. /**
  99619. * Gets the class name of the current intput.
  99620. * @returns the class name
  99621. */
  99622. getClassName(): string;
  99623. /** @hidden */
  99624. _onLostFocus(): void;
  99625. /**
  99626. * Get the friendly name associated with the input class.
  99627. * @returns the input friendly name
  99628. */
  99629. getSimpleName(): string;
  99630. }
  99631. }
  99632. declare module BABYLON {
  99633. /**
  99634. * Gather the list of pointer event types as constants.
  99635. */
  99636. export class PointerEventTypes {
  99637. /**
  99638. * 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.
  99639. */
  99640. static readonly POINTERDOWN: number;
  99641. /**
  99642. * The pointerup event is fired when a pointer is no longer active.
  99643. */
  99644. static readonly POINTERUP: number;
  99645. /**
  99646. * The pointermove event is fired when a pointer changes coordinates.
  99647. */
  99648. static readonly POINTERMOVE: number;
  99649. /**
  99650. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99651. */
  99652. static readonly POINTERWHEEL: number;
  99653. /**
  99654. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99655. */
  99656. static readonly POINTERPICK: number;
  99657. /**
  99658. * The pointertap event is fired when a the object has been touched and released without drag.
  99659. */
  99660. static readonly POINTERTAP: number;
  99661. /**
  99662. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99663. */
  99664. static readonly POINTERDOUBLETAP: number;
  99665. }
  99666. /**
  99667. * Base class of pointer info types.
  99668. */
  99669. export class PointerInfoBase {
  99670. /**
  99671. * Defines the type of event (PointerEventTypes)
  99672. */
  99673. type: number;
  99674. /**
  99675. * Defines the related dom event
  99676. */
  99677. event: PointerEvent | MouseWheelEvent;
  99678. /**
  99679. * Instantiates the base class of pointers info.
  99680. * @param type Defines the type of event (PointerEventTypes)
  99681. * @param event Defines the related dom event
  99682. */
  99683. constructor(
  99684. /**
  99685. * Defines the type of event (PointerEventTypes)
  99686. */
  99687. type: number,
  99688. /**
  99689. * Defines the related dom event
  99690. */
  99691. event: PointerEvent | MouseWheelEvent);
  99692. }
  99693. /**
  99694. * This class is used to store pointer related info for the onPrePointerObservable event.
  99695. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99696. */
  99697. export class PointerInfoPre extends PointerInfoBase {
  99698. /**
  99699. * Ray from a pointer if availible (eg. 6dof controller)
  99700. */
  99701. ray: Nullable<Ray>;
  99702. /**
  99703. * Defines the local position of the pointer on the canvas.
  99704. */
  99705. localPosition: Vector2;
  99706. /**
  99707. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99708. */
  99709. skipOnPointerObservable: boolean;
  99710. /**
  99711. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99712. * @param type Defines the type of event (PointerEventTypes)
  99713. * @param event Defines the related dom event
  99714. * @param localX Defines the local x coordinates of the pointer when the event occured
  99715. * @param localY Defines the local y coordinates of the pointer when the event occured
  99716. */
  99717. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99718. }
  99719. /**
  99720. * This type contains all the data related to a pointer event in Babylon.js.
  99721. * 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.
  99722. */
  99723. export class PointerInfo extends PointerInfoBase {
  99724. /**
  99725. * Defines the picking info associated to the info (if any)\
  99726. */
  99727. pickInfo: Nullable<PickingInfo>;
  99728. /**
  99729. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99730. * @param type Defines the type of event (PointerEventTypes)
  99731. * @param event Defines the related dom event
  99732. * @param pickInfo Defines the picking info associated to the info (if any)\
  99733. */
  99734. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99735. /**
  99736. * Defines the picking info associated to the info (if any)\
  99737. */
  99738. pickInfo: Nullable<PickingInfo>);
  99739. }
  99740. /**
  99741. * Data relating to a touch event on the screen.
  99742. */
  99743. export interface PointerTouch {
  99744. /**
  99745. * X coordinate of touch.
  99746. */
  99747. x: number;
  99748. /**
  99749. * Y coordinate of touch.
  99750. */
  99751. y: number;
  99752. /**
  99753. * Id of touch. Unique for each finger.
  99754. */
  99755. pointerId: number;
  99756. /**
  99757. * Event type passed from DOM.
  99758. */
  99759. type: any;
  99760. }
  99761. }
  99762. declare module BABYLON {
  99763. /**
  99764. * Manage the mouse inputs to control the movement of a free camera.
  99765. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99766. */
  99767. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99768. /**
  99769. * Define if touch is enabled in the mouse input
  99770. */
  99771. touchEnabled: boolean;
  99772. /**
  99773. * Defines the camera the input is attached to.
  99774. */
  99775. camera: FreeCamera;
  99776. /**
  99777. * Defines the buttons associated with the input to handle camera move.
  99778. */
  99779. buttons: number[];
  99780. /**
  99781. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99782. */
  99783. angularSensibility: number;
  99784. private _pointerInput;
  99785. private _onMouseMove;
  99786. private _observer;
  99787. private previousPosition;
  99788. /**
  99789. * Observable for when a pointer move event occurs containing the move offset
  99790. */
  99791. onPointerMovedObservable: Observable<{
  99792. offsetX: number;
  99793. offsetY: number;
  99794. }>;
  99795. /**
  99796. * @hidden
  99797. * If the camera should be rotated automatically based on pointer movement
  99798. */
  99799. _allowCameraRotation: boolean;
  99800. /**
  99801. * Manage the mouse inputs to control the movement of a free camera.
  99802. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99803. * @param touchEnabled Defines if touch is enabled or not
  99804. */
  99805. constructor(
  99806. /**
  99807. * Define if touch is enabled in the mouse input
  99808. */
  99809. touchEnabled?: boolean);
  99810. /**
  99811. * Attach the input controls to a specific dom element to get the input from.
  99812. * @param element Defines the element the controls should be listened from
  99813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99814. */
  99815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99816. /**
  99817. * Called on JS contextmenu event.
  99818. * Override this method to provide functionality.
  99819. */
  99820. protected onContextMenu(evt: PointerEvent): void;
  99821. /**
  99822. * Detach the current controls from the specified dom element.
  99823. * @param element Defines the element to stop listening the inputs from
  99824. */
  99825. detachControl(element: Nullable<HTMLElement>): void;
  99826. /**
  99827. * Gets the class name of the current intput.
  99828. * @returns the class name
  99829. */
  99830. getClassName(): string;
  99831. /**
  99832. * Get the friendly name associated with the input class.
  99833. * @returns the input friendly name
  99834. */
  99835. getSimpleName(): string;
  99836. }
  99837. }
  99838. declare module BABYLON {
  99839. /**
  99840. * Manage the touch inputs to control the movement of a free camera.
  99841. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99842. */
  99843. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99844. /**
  99845. * Define if mouse events can be treated as touch events
  99846. */
  99847. allowMouse: boolean;
  99848. /**
  99849. * Defines the camera the input is attached to.
  99850. */
  99851. camera: FreeCamera;
  99852. /**
  99853. * Defines the touch sensibility for rotation.
  99854. * The higher the faster.
  99855. */
  99856. touchAngularSensibility: number;
  99857. /**
  99858. * Defines the touch sensibility for move.
  99859. * The higher the faster.
  99860. */
  99861. touchMoveSensibility: number;
  99862. private _offsetX;
  99863. private _offsetY;
  99864. private _pointerPressed;
  99865. private _pointerInput;
  99866. private _observer;
  99867. private _onLostFocus;
  99868. /**
  99869. * Manage the touch inputs to control the movement of a free camera.
  99870. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99871. * @param allowMouse Defines if mouse events can be treated as touch events
  99872. */
  99873. constructor(
  99874. /**
  99875. * Define if mouse events can be treated as touch events
  99876. */
  99877. allowMouse?: boolean);
  99878. /**
  99879. * Attach the input controls to a specific dom element to get the input from.
  99880. * @param element Defines the element the controls should be listened from
  99881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99882. */
  99883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99884. /**
  99885. * Detach the current controls from the specified dom element.
  99886. * @param element Defines the element to stop listening the inputs from
  99887. */
  99888. detachControl(element: Nullable<HTMLElement>): void;
  99889. /**
  99890. * Update the current camera state depending on the inputs that have been used this frame.
  99891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99892. */
  99893. checkInputs(): void;
  99894. /**
  99895. * Gets the class name of the current intput.
  99896. * @returns the class name
  99897. */
  99898. getClassName(): string;
  99899. /**
  99900. * Get the friendly name associated with the input class.
  99901. * @returns the input friendly name
  99902. */
  99903. getSimpleName(): string;
  99904. }
  99905. }
  99906. declare module BABYLON {
  99907. /**
  99908. * Default Inputs manager for the FreeCamera.
  99909. * It groups all the default supported inputs for ease of use.
  99910. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99911. */
  99912. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99913. /**
  99914. * @hidden
  99915. */
  99916. _mouseInput: Nullable<FreeCameraMouseInput>;
  99917. /**
  99918. * Instantiates a new FreeCameraInputsManager.
  99919. * @param camera Defines the camera the inputs belong to
  99920. */
  99921. constructor(camera: FreeCamera);
  99922. /**
  99923. * Add keyboard input support to the input manager.
  99924. * @returns the current input manager
  99925. */
  99926. addKeyboard(): FreeCameraInputsManager;
  99927. /**
  99928. * Add mouse input support to the input manager.
  99929. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99930. * @returns the current input manager
  99931. */
  99932. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99933. /**
  99934. * Removes the mouse input support from the manager
  99935. * @returns the current input manager
  99936. */
  99937. removeMouse(): FreeCameraInputsManager;
  99938. /**
  99939. * Add touch input support to the input manager.
  99940. * @returns the current input manager
  99941. */
  99942. addTouch(): FreeCameraInputsManager;
  99943. /**
  99944. * Remove all attached input methods from a camera
  99945. */
  99946. clear(): void;
  99947. }
  99948. }
  99949. declare module BABYLON {
  99950. /**
  99951. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99952. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99953. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99954. */
  99955. export class FreeCamera extends TargetCamera {
  99956. /**
  99957. * Define the collision ellipsoid of the camera.
  99958. * This is helpful to simulate a camera body like the player body around the camera
  99959. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99960. */
  99961. ellipsoid: Vector3;
  99962. /**
  99963. * Define an offset for the position of the ellipsoid around the camera.
  99964. * This can be helpful to determine the center of the body near the gravity center of the body
  99965. * instead of its head.
  99966. */
  99967. ellipsoidOffset: Vector3;
  99968. /**
  99969. * Enable or disable collisions of the camera with the rest of the scene objects.
  99970. */
  99971. checkCollisions: boolean;
  99972. /**
  99973. * Enable or disable gravity on the camera.
  99974. */
  99975. applyGravity: boolean;
  99976. /**
  99977. * Define the input manager associated to the camera.
  99978. */
  99979. inputs: FreeCameraInputsManager;
  99980. /**
  99981. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99982. * Higher values reduce sensitivity.
  99983. */
  99984. get angularSensibility(): number;
  99985. /**
  99986. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99987. * Higher values reduce sensitivity.
  99988. */
  99989. set angularSensibility(value: number);
  99990. /**
  99991. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99992. */
  99993. get keysUp(): number[];
  99994. set keysUp(value: number[]);
  99995. /**
  99996. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99997. */
  99998. get keysUpward(): number[];
  99999. set keysUpward(value: number[]);
  100000. /**
  100001. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100002. */
  100003. get keysDown(): number[];
  100004. set keysDown(value: number[]);
  100005. /**
  100006. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100007. */
  100008. get keysDownward(): number[];
  100009. set keysDownward(value: number[]);
  100010. /**
  100011. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100012. */
  100013. get keysLeft(): number[];
  100014. set keysLeft(value: number[]);
  100015. /**
  100016. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100017. */
  100018. get keysRight(): number[];
  100019. set keysRight(value: number[]);
  100020. /**
  100021. * Event raised when the camera collide with a mesh in the scene.
  100022. */
  100023. onCollide: (collidedMesh: AbstractMesh) => void;
  100024. private _collider;
  100025. private _needMoveForGravity;
  100026. private _oldPosition;
  100027. private _diffPosition;
  100028. private _newPosition;
  100029. /** @hidden */
  100030. _localDirection: Vector3;
  100031. /** @hidden */
  100032. _transformedDirection: Vector3;
  100033. /**
  100034. * Instantiates a Free Camera.
  100035. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100036. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  100037. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100038. * @param name Define the name of the camera in the scene
  100039. * @param position Define the start position of the camera in the scene
  100040. * @param scene Define the scene the camera belongs to
  100041. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100042. */
  100043. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100044. /**
  100045. * Attached controls to the current camera.
  100046. * @param element Defines the element the controls should be listened from
  100047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100048. */
  100049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100050. /**
  100051. * Detach the current controls from the camera.
  100052. * The camera will stop reacting to inputs.
  100053. * @param element Defines the element to stop listening the inputs from
  100054. */
  100055. detachControl(element: HTMLElement): void;
  100056. private _collisionMask;
  100057. /**
  100058. * Define a collision mask to limit the list of object the camera can collide with
  100059. */
  100060. get collisionMask(): number;
  100061. set collisionMask(mask: number);
  100062. /** @hidden */
  100063. _collideWithWorld(displacement: Vector3): void;
  100064. private _onCollisionPositionChange;
  100065. /** @hidden */
  100066. _checkInputs(): void;
  100067. /** @hidden */
  100068. _decideIfNeedsToMove(): boolean;
  100069. /** @hidden */
  100070. _updatePosition(): void;
  100071. /**
  100072. * Destroy the camera and release the current resources hold by it.
  100073. */
  100074. dispose(): void;
  100075. /**
  100076. * Gets the current object class name.
  100077. * @return the class name
  100078. */
  100079. getClassName(): string;
  100080. }
  100081. }
  100082. declare module BABYLON {
  100083. /**
  100084. * Represents a gamepad control stick position
  100085. */
  100086. export class StickValues {
  100087. /**
  100088. * The x component of the control stick
  100089. */
  100090. x: number;
  100091. /**
  100092. * The y component of the control stick
  100093. */
  100094. y: number;
  100095. /**
  100096. * Initializes the gamepad x and y control stick values
  100097. * @param x The x component of the gamepad control stick value
  100098. * @param y The y component of the gamepad control stick value
  100099. */
  100100. constructor(
  100101. /**
  100102. * The x component of the control stick
  100103. */
  100104. x: number,
  100105. /**
  100106. * The y component of the control stick
  100107. */
  100108. y: number);
  100109. }
  100110. /**
  100111. * An interface which manages callbacks for gamepad button changes
  100112. */
  100113. export interface GamepadButtonChanges {
  100114. /**
  100115. * Called when a gamepad has been changed
  100116. */
  100117. changed: boolean;
  100118. /**
  100119. * Called when a gamepad press event has been triggered
  100120. */
  100121. pressChanged: boolean;
  100122. /**
  100123. * Called when a touch event has been triggered
  100124. */
  100125. touchChanged: boolean;
  100126. /**
  100127. * Called when a value has changed
  100128. */
  100129. valueChanged: boolean;
  100130. }
  100131. /**
  100132. * Represents a gamepad
  100133. */
  100134. export class Gamepad {
  100135. /**
  100136. * The id of the gamepad
  100137. */
  100138. id: string;
  100139. /**
  100140. * The index of the gamepad
  100141. */
  100142. index: number;
  100143. /**
  100144. * The browser gamepad
  100145. */
  100146. browserGamepad: any;
  100147. /**
  100148. * Specifies what type of gamepad this represents
  100149. */
  100150. type: number;
  100151. private _leftStick;
  100152. private _rightStick;
  100153. /** @hidden */
  100154. _isConnected: boolean;
  100155. private _leftStickAxisX;
  100156. private _leftStickAxisY;
  100157. private _rightStickAxisX;
  100158. private _rightStickAxisY;
  100159. /**
  100160. * Triggered when the left control stick has been changed
  100161. */
  100162. private _onleftstickchanged;
  100163. /**
  100164. * Triggered when the right control stick has been changed
  100165. */
  100166. private _onrightstickchanged;
  100167. /**
  100168. * Represents a gamepad controller
  100169. */
  100170. static GAMEPAD: number;
  100171. /**
  100172. * Represents a generic controller
  100173. */
  100174. static GENERIC: number;
  100175. /**
  100176. * Represents an XBox controller
  100177. */
  100178. static XBOX: number;
  100179. /**
  100180. * Represents a pose-enabled controller
  100181. */
  100182. static POSE_ENABLED: number;
  100183. /**
  100184. * Represents an Dual Shock controller
  100185. */
  100186. static DUALSHOCK: number;
  100187. /**
  100188. * Specifies whether the left control stick should be Y-inverted
  100189. */
  100190. protected _invertLeftStickY: boolean;
  100191. /**
  100192. * Specifies if the gamepad has been connected
  100193. */
  100194. get isConnected(): boolean;
  100195. /**
  100196. * Initializes the gamepad
  100197. * @param id The id of the gamepad
  100198. * @param index The index of the gamepad
  100199. * @param browserGamepad The browser gamepad
  100200. * @param leftStickX The x component of the left joystick
  100201. * @param leftStickY The y component of the left joystick
  100202. * @param rightStickX The x component of the right joystick
  100203. * @param rightStickY The y component of the right joystick
  100204. */
  100205. constructor(
  100206. /**
  100207. * The id of the gamepad
  100208. */
  100209. id: string,
  100210. /**
  100211. * The index of the gamepad
  100212. */
  100213. index: number,
  100214. /**
  100215. * The browser gamepad
  100216. */
  100217. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100218. /**
  100219. * Callback triggered when the left joystick has changed
  100220. * @param callback
  100221. */
  100222. onleftstickchanged(callback: (values: StickValues) => void): void;
  100223. /**
  100224. * Callback triggered when the right joystick has changed
  100225. * @param callback
  100226. */
  100227. onrightstickchanged(callback: (values: StickValues) => void): void;
  100228. /**
  100229. * Gets the left joystick
  100230. */
  100231. get leftStick(): StickValues;
  100232. /**
  100233. * Sets the left joystick values
  100234. */
  100235. set leftStick(newValues: StickValues);
  100236. /**
  100237. * Gets the right joystick
  100238. */
  100239. get rightStick(): StickValues;
  100240. /**
  100241. * Sets the right joystick value
  100242. */
  100243. set rightStick(newValues: StickValues);
  100244. /**
  100245. * Updates the gamepad joystick positions
  100246. */
  100247. update(): void;
  100248. /**
  100249. * Disposes the gamepad
  100250. */
  100251. dispose(): void;
  100252. }
  100253. /**
  100254. * Represents a generic gamepad
  100255. */
  100256. export class GenericPad extends Gamepad {
  100257. private _buttons;
  100258. private _onbuttondown;
  100259. private _onbuttonup;
  100260. /**
  100261. * Observable triggered when a button has been pressed
  100262. */
  100263. onButtonDownObservable: Observable<number>;
  100264. /**
  100265. * Observable triggered when a button has been released
  100266. */
  100267. onButtonUpObservable: Observable<number>;
  100268. /**
  100269. * Callback triggered when a button has been pressed
  100270. * @param callback Called when a button has been pressed
  100271. */
  100272. onbuttondown(callback: (buttonPressed: number) => void): void;
  100273. /**
  100274. * Callback triggered when a button has been released
  100275. * @param callback Called when a button has been released
  100276. */
  100277. onbuttonup(callback: (buttonReleased: number) => void): void;
  100278. /**
  100279. * Initializes the generic gamepad
  100280. * @param id The id of the generic gamepad
  100281. * @param index The index of the generic gamepad
  100282. * @param browserGamepad The browser gamepad
  100283. */
  100284. constructor(id: string, index: number, browserGamepad: any);
  100285. private _setButtonValue;
  100286. /**
  100287. * Updates the generic gamepad
  100288. */
  100289. update(): void;
  100290. /**
  100291. * Disposes the generic gamepad
  100292. */
  100293. dispose(): void;
  100294. }
  100295. }
  100296. declare module BABYLON {
  100297. /**
  100298. * Defines the types of pose enabled controllers that are supported
  100299. */
  100300. export enum PoseEnabledControllerType {
  100301. /**
  100302. * HTC Vive
  100303. */
  100304. VIVE = 0,
  100305. /**
  100306. * Oculus Rift
  100307. */
  100308. OCULUS = 1,
  100309. /**
  100310. * Windows mixed reality
  100311. */
  100312. WINDOWS = 2,
  100313. /**
  100314. * Samsung gear VR
  100315. */
  100316. GEAR_VR = 3,
  100317. /**
  100318. * Google Daydream
  100319. */
  100320. DAYDREAM = 4,
  100321. /**
  100322. * Generic
  100323. */
  100324. GENERIC = 5
  100325. }
  100326. /**
  100327. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100328. */
  100329. export interface MutableGamepadButton {
  100330. /**
  100331. * Value of the button/trigger
  100332. */
  100333. value: number;
  100334. /**
  100335. * If the button/trigger is currently touched
  100336. */
  100337. touched: boolean;
  100338. /**
  100339. * If the button/trigger is currently pressed
  100340. */
  100341. pressed: boolean;
  100342. }
  100343. /**
  100344. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100345. * @hidden
  100346. */
  100347. export interface ExtendedGamepadButton extends GamepadButton {
  100348. /**
  100349. * If the button/trigger is currently pressed
  100350. */
  100351. readonly pressed: boolean;
  100352. /**
  100353. * If the button/trigger is currently touched
  100354. */
  100355. readonly touched: boolean;
  100356. /**
  100357. * Value of the button/trigger
  100358. */
  100359. readonly value: number;
  100360. }
  100361. /** @hidden */
  100362. export interface _GamePadFactory {
  100363. /**
  100364. * Returns whether or not the current gamepad can be created for this type of controller.
  100365. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100366. * @returns true if it can be created, otherwise false
  100367. */
  100368. canCreate(gamepadInfo: any): boolean;
  100369. /**
  100370. * Creates a new instance of the Gamepad.
  100371. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100372. * @returns the new gamepad instance
  100373. */
  100374. create(gamepadInfo: any): Gamepad;
  100375. }
  100376. /**
  100377. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100378. */
  100379. export class PoseEnabledControllerHelper {
  100380. /** @hidden */
  100381. static _ControllerFactories: _GamePadFactory[];
  100382. /** @hidden */
  100383. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100384. /**
  100385. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100386. * @param vrGamepad the gamepad to initialized
  100387. * @returns a vr controller of the type the gamepad identified as
  100388. */
  100389. static InitiateController(vrGamepad: any): Gamepad;
  100390. }
  100391. /**
  100392. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100393. */
  100394. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100395. /**
  100396. * If the controller is used in a webXR session
  100397. */
  100398. isXR: boolean;
  100399. private _deviceRoomPosition;
  100400. private _deviceRoomRotationQuaternion;
  100401. /**
  100402. * The device position in babylon space
  100403. */
  100404. devicePosition: Vector3;
  100405. /**
  100406. * The device rotation in babylon space
  100407. */
  100408. deviceRotationQuaternion: Quaternion;
  100409. /**
  100410. * The scale factor of the device in babylon space
  100411. */
  100412. deviceScaleFactor: number;
  100413. /**
  100414. * (Likely devicePosition should be used instead) The device position in its room space
  100415. */
  100416. position: Vector3;
  100417. /**
  100418. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100419. */
  100420. rotationQuaternion: Quaternion;
  100421. /**
  100422. * The type of controller (Eg. Windows mixed reality)
  100423. */
  100424. controllerType: PoseEnabledControllerType;
  100425. protected _calculatedPosition: Vector3;
  100426. private _calculatedRotation;
  100427. /**
  100428. * The raw pose from the device
  100429. */
  100430. rawPose: DevicePose;
  100431. private _trackPosition;
  100432. private _maxRotationDistFromHeadset;
  100433. private _draggedRoomRotation;
  100434. /**
  100435. * @hidden
  100436. */
  100437. _disableTrackPosition(fixedPosition: Vector3): void;
  100438. /**
  100439. * Internal, the mesh attached to the controller
  100440. * @hidden
  100441. */
  100442. _mesh: Nullable<AbstractMesh>;
  100443. private _poseControlledCamera;
  100444. private _leftHandSystemQuaternion;
  100445. /**
  100446. * Internal, matrix used to convert room space to babylon space
  100447. * @hidden
  100448. */
  100449. _deviceToWorld: Matrix;
  100450. /**
  100451. * Node to be used when casting a ray from the controller
  100452. * @hidden
  100453. */
  100454. _pointingPoseNode: Nullable<TransformNode>;
  100455. /**
  100456. * Name of the child mesh that can be used to cast a ray from the controller
  100457. */
  100458. static readonly POINTING_POSE: string;
  100459. /**
  100460. * Creates a new PoseEnabledController from a gamepad
  100461. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100462. */
  100463. constructor(browserGamepad: any);
  100464. private _workingMatrix;
  100465. /**
  100466. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100467. */
  100468. update(): void;
  100469. /**
  100470. * Updates only the pose device and mesh without doing any button event checking
  100471. */
  100472. protected _updatePoseAndMesh(): void;
  100473. /**
  100474. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100475. * @param poseData raw pose fromthe device
  100476. */
  100477. updateFromDevice(poseData: DevicePose): void;
  100478. /**
  100479. * @hidden
  100480. */
  100481. _meshAttachedObservable: Observable<AbstractMesh>;
  100482. /**
  100483. * Attaches a mesh to the controller
  100484. * @param mesh the mesh to be attached
  100485. */
  100486. attachToMesh(mesh: AbstractMesh): void;
  100487. /**
  100488. * Attaches the controllers mesh to a camera
  100489. * @param camera the camera the mesh should be attached to
  100490. */
  100491. attachToPoseControlledCamera(camera: TargetCamera): void;
  100492. /**
  100493. * Disposes of the controller
  100494. */
  100495. dispose(): void;
  100496. /**
  100497. * The mesh that is attached to the controller
  100498. */
  100499. get mesh(): Nullable<AbstractMesh>;
  100500. /**
  100501. * Gets the ray of the controller in the direction the controller is pointing
  100502. * @param length the length the resulting ray should be
  100503. * @returns a ray in the direction the controller is pointing
  100504. */
  100505. getForwardRay(length?: number): Ray;
  100506. }
  100507. }
  100508. declare module BABYLON {
  100509. /**
  100510. * Defines the WebVRController object that represents controllers tracked in 3D space
  100511. */
  100512. export abstract class WebVRController extends PoseEnabledController {
  100513. /**
  100514. * Internal, the default controller model for the controller
  100515. */
  100516. protected _defaultModel: Nullable<AbstractMesh>;
  100517. /**
  100518. * Fired when the trigger state has changed
  100519. */
  100520. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100521. /**
  100522. * Fired when the main button state has changed
  100523. */
  100524. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100525. /**
  100526. * Fired when the secondary button state has changed
  100527. */
  100528. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100529. /**
  100530. * Fired when the pad state has changed
  100531. */
  100532. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100533. /**
  100534. * Fired when controllers stick values have changed
  100535. */
  100536. onPadValuesChangedObservable: Observable<StickValues>;
  100537. /**
  100538. * Array of button availible on the controller
  100539. */
  100540. protected _buttons: Array<MutableGamepadButton>;
  100541. private _onButtonStateChange;
  100542. /**
  100543. * Fired when a controller button's state has changed
  100544. * @param callback the callback containing the button that was modified
  100545. */
  100546. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100547. /**
  100548. * X and Y axis corresponding to the controllers joystick
  100549. */
  100550. pad: StickValues;
  100551. /**
  100552. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100553. */
  100554. hand: string;
  100555. /**
  100556. * The default controller model for the controller
  100557. */
  100558. get defaultModel(): Nullable<AbstractMesh>;
  100559. /**
  100560. * Creates a new WebVRController from a gamepad
  100561. * @param vrGamepad the gamepad that the WebVRController should be created from
  100562. */
  100563. constructor(vrGamepad: any);
  100564. /**
  100565. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100566. */
  100567. update(): void;
  100568. /**
  100569. * Function to be called when a button is modified
  100570. */
  100571. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100572. /**
  100573. * Loads a mesh and attaches it to the controller
  100574. * @param scene the scene the mesh should be added to
  100575. * @param meshLoaded callback for when the mesh has been loaded
  100576. */
  100577. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100578. private _setButtonValue;
  100579. private _changes;
  100580. private _checkChanges;
  100581. /**
  100582. * Disposes of th webVRCOntroller
  100583. */
  100584. dispose(): void;
  100585. }
  100586. }
  100587. declare module BABYLON {
  100588. /**
  100589. * The HemisphericLight simulates the ambient environment light,
  100590. * so the passed direction is the light reflection direction, not the incoming direction.
  100591. */
  100592. export class HemisphericLight extends Light {
  100593. /**
  100594. * The groundColor is the light in the opposite direction to the one specified during creation.
  100595. * 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.
  100596. */
  100597. groundColor: Color3;
  100598. /**
  100599. * The light reflection direction, not the incoming direction.
  100600. */
  100601. direction: Vector3;
  100602. /**
  100603. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100604. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100605. * The HemisphericLight can't cast shadows.
  100606. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100607. * @param name The friendly name of the light
  100608. * @param direction The direction of the light reflection
  100609. * @param scene The scene the light belongs to
  100610. */
  100611. constructor(name: string, direction: Vector3, scene: Scene);
  100612. protected _buildUniformLayout(): void;
  100613. /**
  100614. * Returns the string "HemisphericLight".
  100615. * @return The class name
  100616. */
  100617. getClassName(): string;
  100618. /**
  100619. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100620. * Returns the updated direction.
  100621. * @param target The target the direction should point to
  100622. * @return The computed direction
  100623. */
  100624. setDirectionToTarget(target: Vector3): Vector3;
  100625. /**
  100626. * Returns the shadow generator associated to the light.
  100627. * @returns Always null for hemispheric lights because it does not support shadows.
  100628. */
  100629. getShadowGenerator(): Nullable<IShadowGenerator>;
  100630. /**
  100631. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100632. * @param effect The effect to update
  100633. * @param lightIndex The index of the light in the effect to update
  100634. * @returns The hemispheric light
  100635. */
  100636. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100637. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100638. /**
  100639. * Computes the world matrix of the node
  100640. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100641. * @param useWasUpdatedFlag defines a reserved property
  100642. * @returns the world matrix
  100643. */
  100644. computeWorldMatrix(): Matrix;
  100645. /**
  100646. * Returns the integer 3.
  100647. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100648. */
  100649. getTypeID(): number;
  100650. /**
  100651. * Prepares the list of defines specific to the light type.
  100652. * @param defines the list of defines
  100653. * @param lightIndex defines the index of the light for the effect
  100654. */
  100655. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100656. }
  100657. }
  100658. declare module BABYLON {
  100659. /** @hidden */
  100660. export var vrMultiviewToSingleviewPixelShader: {
  100661. name: string;
  100662. shader: string;
  100663. };
  100664. }
  100665. declare module BABYLON {
  100666. /**
  100667. * Renders to multiple views with a single draw call
  100668. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100669. */
  100670. export class MultiviewRenderTarget extends RenderTargetTexture {
  100671. /**
  100672. * Creates a multiview render target
  100673. * @param scene scene used with the render target
  100674. * @param size the size of the render target (used for each view)
  100675. */
  100676. constructor(scene: Scene, size?: number | {
  100677. width: number;
  100678. height: number;
  100679. } | {
  100680. ratio: number;
  100681. });
  100682. /**
  100683. * @hidden
  100684. * @param faceIndex the face index, if its a cube texture
  100685. */
  100686. _bindFrameBuffer(faceIndex?: number): void;
  100687. /**
  100688. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100689. * @returns the view count
  100690. */
  100691. getViewCount(): number;
  100692. }
  100693. }
  100694. declare module BABYLON {
  100695. interface Engine {
  100696. /**
  100697. * Creates a new multiview render target
  100698. * @param width defines the width of the texture
  100699. * @param height defines the height of the texture
  100700. * @returns the created multiview texture
  100701. */
  100702. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100703. /**
  100704. * Binds a multiview framebuffer to be drawn to
  100705. * @param multiviewTexture texture to bind
  100706. */
  100707. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100708. }
  100709. interface Camera {
  100710. /**
  100711. * @hidden
  100712. * 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)
  100713. */
  100714. _useMultiviewToSingleView: boolean;
  100715. /**
  100716. * @hidden
  100717. * 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)
  100718. */
  100719. _multiviewTexture: Nullable<RenderTargetTexture>;
  100720. /**
  100721. * @hidden
  100722. * ensures the multiview texture of the camera exists and has the specified width/height
  100723. * @param width height to set on the multiview texture
  100724. * @param height width to set on the multiview texture
  100725. */
  100726. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100727. }
  100728. interface Scene {
  100729. /** @hidden */
  100730. _transformMatrixR: Matrix;
  100731. /** @hidden */
  100732. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100733. /** @hidden */
  100734. _createMultiviewUbo(): void;
  100735. /** @hidden */
  100736. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100737. /** @hidden */
  100738. _renderMultiviewToSingleView(camera: Camera): void;
  100739. }
  100740. }
  100741. declare module BABYLON {
  100742. /**
  100743. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100744. * This will not be used for webXR as it supports displaying texture arrays directly
  100745. */
  100746. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100747. /**
  100748. * Gets a string identifying the name of the class
  100749. * @returns "VRMultiviewToSingleviewPostProcess" string
  100750. */
  100751. getClassName(): string;
  100752. /**
  100753. * Initializes a VRMultiviewToSingleview
  100754. * @param name name of the post process
  100755. * @param camera camera to be applied to
  100756. * @param scaleFactor scaling factor to the size of the output texture
  100757. */
  100758. constructor(name: string, camera: Camera, scaleFactor: number);
  100759. }
  100760. }
  100761. declare module BABYLON {
  100762. /**
  100763. * Interface used to define additional presentation attributes
  100764. */
  100765. export interface IVRPresentationAttributes {
  100766. /**
  100767. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100768. */
  100769. highRefreshRate: boolean;
  100770. /**
  100771. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100772. */
  100773. foveationLevel: number;
  100774. }
  100775. interface Engine {
  100776. /** @hidden */
  100777. _vrDisplay: any;
  100778. /** @hidden */
  100779. _vrSupported: boolean;
  100780. /** @hidden */
  100781. _oldSize: Size;
  100782. /** @hidden */
  100783. _oldHardwareScaleFactor: number;
  100784. /** @hidden */
  100785. _vrExclusivePointerMode: boolean;
  100786. /** @hidden */
  100787. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100788. /** @hidden */
  100789. _onVRDisplayPointerRestricted: () => void;
  100790. /** @hidden */
  100791. _onVRDisplayPointerUnrestricted: () => void;
  100792. /** @hidden */
  100793. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100794. /** @hidden */
  100795. _onVrDisplayDisconnect: Nullable<() => void>;
  100796. /** @hidden */
  100797. _onVrDisplayPresentChange: Nullable<() => void>;
  100798. /**
  100799. * Observable signaled when VR display mode changes
  100800. */
  100801. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100802. /**
  100803. * Observable signaled when VR request present is complete
  100804. */
  100805. onVRRequestPresentComplete: Observable<boolean>;
  100806. /**
  100807. * Observable signaled when VR request present starts
  100808. */
  100809. onVRRequestPresentStart: Observable<Engine>;
  100810. /**
  100811. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100812. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100813. */
  100814. isInVRExclusivePointerMode: boolean;
  100815. /**
  100816. * Gets a boolean indicating if a webVR device was detected
  100817. * @returns true if a webVR device was detected
  100818. */
  100819. isVRDevicePresent(): boolean;
  100820. /**
  100821. * Gets the current webVR device
  100822. * @returns the current webVR device (or null)
  100823. */
  100824. getVRDevice(): any;
  100825. /**
  100826. * Initializes a webVR display and starts listening to display change events
  100827. * The onVRDisplayChangedObservable will be notified upon these changes
  100828. * @returns A promise containing a VRDisplay and if vr is supported
  100829. */
  100830. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100831. /** @hidden */
  100832. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100833. /**
  100834. * Gets or sets the presentation attributes used to configure VR rendering
  100835. */
  100836. vrPresentationAttributes?: IVRPresentationAttributes;
  100837. /**
  100838. * Call this function to switch to webVR mode
  100839. * Will do nothing if webVR is not supported or if there is no webVR device
  100840. * @param options the webvr options provided to the camera. mainly used for multiview
  100841. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100842. */
  100843. enableVR(options: WebVROptions): void;
  100844. /** @hidden */
  100845. _onVRFullScreenTriggered(): void;
  100846. }
  100847. }
  100848. declare module BABYLON {
  100849. /**
  100850. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100851. * IMPORTANT!! The data is right-hand data.
  100852. * @export
  100853. * @interface DevicePose
  100854. */
  100855. export interface DevicePose {
  100856. /**
  100857. * The position of the device, values in array are [x,y,z].
  100858. */
  100859. readonly position: Nullable<Float32Array>;
  100860. /**
  100861. * The linearVelocity of the device, values in array are [x,y,z].
  100862. */
  100863. readonly linearVelocity: Nullable<Float32Array>;
  100864. /**
  100865. * The linearAcceleration of the device, values in array are [x,y,z].
  100866. */
  100867. readonly linearAcceleration: Nullable<Float32Array>;
  100868. /**
  100869. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100870. */
  100871. readonly orientation: Nullable<Float32Array>;
  100872. /**
  100873. * The angularVelocity of the device, values in array are [x,y,z].
  100874. */
  100875. readonly angularVelocity: Nullable<Float32Array>;
  100876. /**
  100877. * The angularAcceleration of the device, values in array are [x,y,z].
  100878. */
  100879. readonly angularAcceleration: Nullable<Float32Array>;
  100880. }
  100881. /**
  100882. * Interface representing a pose controlled object in Babylon.
  100883. * A pose controlled object has both regular pose values as well as pose values
  100884. * from an external device such as a VR head mounted display
  100885. */
  100886. export interface PoseControlled {
  100887. /**
  100888. * The position of the object in babylon space.
  100889. */
  100890. position: Vector3;
  100891. /**
  100892. * The rotation quaternion of the object in babylon space.
  100893. */
  100894. rotationQuaternion: Quaternion;
  100895. /**
  100896. * The position of the device in babylon space.
  100897. */
  100898. devicePosition?: Vector3;
  100899. /**
  100900. * The rotation quaternion of the device in babylon space.
  100901. */
  100902. deviceRotationQuaternion: Quaternion;
  100903. /**
  100904. * The raw pose coming from the device.
  100905. */
  100906. rawPose: Nullable<DevicePose>;
  100907. /**
  100908. * The scale of the device to be used when translating from device space to babylon space.
  100909. */
  100910. deviceScaleFactor: number;
  100911. /**
  100912. * Updates the poseControlled values based on the input device pose.
  100913. * @param poseData the pose data to update the object with
  100914. */
  100915. updateFromDevice(poseData: DevicePose): void;
  100916. }
  100917. /**
  100918. * Set of options to customize the webVRCamera
  100919. */
  100920. export interface WebVROptions {
  100921. /**
  100922. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100923. */
  100924. trackPosition?: boolean;
  100925. /**
  100926. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100927. */
  100928. positionScale?: number;
  100929. /**
  100930. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100931. */
  100932. displayName?: string;
  100933. /**
  100934. * Should the native controller meshes be initialized. (default: true)
  100935. */
  100936. controllerMeshes?: boolean;
  100937. /**
  100938. * Creating a default HemiLight only on controllers. (default: true)
  100939. */
  100940. defaultLightingOnControllers?: boolean;
  100941. /**
  100942. * If you don't want to use the default VR button of the helper. (default: false)
  100943. */
  100944. useCustomVRButton?: boolean;
  100945. /**
  100946. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100947. */
  100948. customVRButton?: HTMLButtonElement;
  100949. /**
  100950. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100951. */
  100952. rayLength?: number;
  100953. /**
  100954. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100955. */
  100956. defaultHeight?: number;
  100957. /**
  100958. * If multiview should be used if availible (default: false)
  100959. */
  100960. useMultiview?: boolean;
  100961. }
  100962. /**
  100963. * This represents a WebVR camera.
  100964. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100965. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100966. */
  100967. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100968. private webVROptions;
  100969. /**
  100970. * @hidden
  100971. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100972. */
  100973. _vrDevice: any;
  100974. /**
  100975. * The rawPose of the vrDevice.
  100976. */
  100977. rawPose: Nullable<DevicePose>;
  100978. private _onVREnabled;
  100979. private _specsVersion;
  100980. private _attached;
  100981. private _frameData;
  100982. protected _descendants: Array<Node>;
  100983. private _deviceRoomPosition;
  100984. /** @hidden */
  100985. _deviceRoomRotationQuaternion: Quaternion;
  100986. private _standingMatrix;
  100987. /**
  100988. * Represents device position in babylon space.
  100989. */
  100990. devicePosition: Vector3;
  100991. /**
  100992. * Represents device rotation in babylon space.
  100993. */
  100994. deviceRotationQuaternion: Quaternion;
  100995. /**
  100996. * The scale of the device to be used when translating from device space to babylon space.
  100997. */
  100998. deviceScaleFactor: number;
  100999. private _deviceToWorld;
  101000. private _worldToDevice;
  101001. /**
  101002. * References to the webVR controllers for the vrDevice.
  101003. */
  101004. controllers: Array<WebVRController>;
  101005. /**
  101006. * Emits an event when a controller is attached.
  101007. */
  101008. onControllersAttachedObservable: Observable<WebVRController[]>;
  101009. /**
  101010. * Emits an event when a controller's mesh has been loaded;
  101011. */
  101012. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101013. /**
  101014. * Emits an event when the HMD's pose has been updated.
  101015. */
  101016. onPoseUpdatedFromDeviceObservable: Observable<any>;
  101017. private _poseSet;
  101018. /**
  101019. * If the rig cameras be used as parent instead of this camera.
  101020. */
  101021. rigParenting: boolean;
  101022. private _lightOnControllers;
  101023. private _defaultHeight?;
  101024. /**
  101025. * Instantiates a WebVRFreeCamera.
  101026. * @param name The name of the WebVRFreeCamera
  101027. * @param position The starting anchor position for the camera
  101028. * @param scene The scene the camera belongs to
  101029. * @param webVROptions a set of customizable options for the webVRCamera
  101030. */
  101031. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  101032. /**
  101033. * Gets the device distance from the ground in meters.
  101034. * @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.
  101035. */
  101036. deviceDistanceToRoomGround(): number;
  101037. /**
  101038. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101039. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  101040. */
  101041. useStandingMatrix(callback?: (bool: boolean) => void): void;
  101042. /**
  101043. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101044. * @returns A promise with a boolean set to if the standing matrix is supported.
  101045. */
  101046. useStandingMatrixAsync(): Promise<boolean>;
  101047. /**
  101048. * Disposes the camera
  101049. */
  101050. dispose(): void;
  101051. /**
  101052. * Gets a vrController by name.
  101053. * @param name The name of the controller to retreive
  101054. * @returns the controller matching the name specified or null if not found
  101055. */
  101056. getControllerByName(name: string): Nullable<WebVRController>;
  101057. private _leftController;
  101058. /**
  101059. * The controller corresponding to the users left hand.
  101060. */
  101061. get leftController(): Nullable<WebVRController>;
  101062. private _rightController;
  101063. /**
  101064. * The controller corresponding to the users right hand.
  101065. */
  101066. get rightController(): Nullable<WebVRController>;
  101067. /**
  101068. * Casts a ray forward from the vrCamera's gaze.
  101069. * @param length Length of the ray (default: 100)
  101070. * @returns the ray corresponding to the gaze
  101071. */
  101072. getForwardRay(length?: number): Ray;
  101073. /**
  101074. * @hidden
  101075. * Updates the camera based on device's frame data
  101076. */
  101077. _checkInputs(): void;
  101078. /**
  101079. * Updates the poseControlled values based on the input device pose.
  101080. * @param poseData Pose coming from the device
  101081. */
  101082. updateFromDevice(poseData: DevicePose): void;
  101083. private _htmlElementAttached;
  101084. private _detachIfAttached;
  101085. /**
  101086. * WebVR's attach control will start broadcasting frames to the device.
  101087. * Note that in certain browsers (chrome for example) this function must be called
  101088. * within a user-interaction callback. Example:
  101089. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101090. *
  101091. * @param element html element to attach the vrDevice to
  101092. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101093. */
  101094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101095. /**
  101096. * Detaches the camera from the html element and disables VR
  101097. *
  101098. * @param element html element to detach from
  101099. */
  101100. detachControl(element: HTMLElement): void;
  101101. /**
  101102. * @returns the name of this class
  101103. */
  101104. getClassName(): string;
  101105. /**
  101106. * Calls resetPose on the vrDisplay
  101107. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101108. */
  101109. resetToCurrentRotation(): void;
  101110. /**
  101111. * @hidden
  101112. * Updates the rig cameras (left and right eye)
  101113. */
  101114. _updateRigCameras(): void;
  101115. private _workingVector;
  101116. private _oneVector;
  101117. private _workingMatrix;
  101118. private updateCacheCalled;
  101119. private _correctPositionIfNotTrackPosition;
  101120. /**
  101121. * @hidden
  101122. * Updates the cached values of the camera
  101123. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101124. */
  101125. _updateCache(ignoreParentClass?: boolean): void;
  101126. /**
  101127. * @hidden
  101128. * Get current device position in babylon world
  101129. */
  101130. _computeDevicePosition(): void;
  101131. /**
  101132. * Updates the current device position and rotation in the babylon world
  101133. */
  101134. update(): void;
  101135. /**
  101136. * @hidden
  101137. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101138. * @returns an identity matrix
  101139. */
  101140. _getViewMatrix(): Matrix;
  101141. private _tmpMatrix;
  101142. /**
  101143. * This function is called by the two RIG cameras.
  101144. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101145. * @hidden
  101146. */
  101147. _getWebVRViewMatrix(): Matrix;
  101148. /** @hidden */
  101149. _getWebVRProjectionMatrix(): Matrix;
  101150. private _onGamepadConnectedObserver;
  101151. private _onGamepadDisconnectedObserver;
  101152. private _updateCacheWhenTrackingDisabledObserver;
  101153. /**
  101154. * Initializes the controllers and their meshes
  101155. */
  101156. initControllers(): void;
  101157. }
  101158. }
  101159. declare module BABYLON {
  101160. /**
  101161. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101162. *
  101163. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101164. *
  101165. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101166. */
  101167. export class MaterialHelper {
  101168. /**
  101169. * Bind the current view position to an effect.
  101170. * @param effect The effect to be bound
  101171. * @param scene The scene the eyes position is used from
  101172. * @param variableName name of the shader variable that will hold the eye position
  101173. */
  101174. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101175. /**
  101176. * Helps preparing the defines values about the UVs in used in the effect.
  101177. * UVs are shared as much as we can accross channels in the shaders.
  101178. * @param texture The texture we are preparing the UVs for
  101179. * @param defines The defines to update
  101180. * @param key The channel key "diffuse", "specular"... used in the shader
  101181. */
  101182. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101183. /**
  101184. * Binds a texture matrix value to its corrsponding uniform
  101185. * @param texture The texture to bind the matrix for
  101186. * @param uniformBuffer The uniform buffer receivin the data
  101187. * @param key The channel key "diffuse", "specular"... used in the shader
  101188. */
  101189. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101190. /**
  101191. * Gets the current status of the fog (should it be enabled?)
  101192. * @param mesh defines the mesh to evaluate for fog support
  101193. * @param scene defines the hosting scene
  101194. * @returns true if fog must be enabled
  101195. */
  101196. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101197. /**
  101198. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101199. * @param mesh defines the current mesh
  101200. * @param scene defines the current scene
  101201. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101202. * @param pointsCloud defines if point cloud rendering has to be turned on
  101203. * @param fogEnabled defines if fog has to be turned on
  101204. * @param alphaTest defines if alpha testing has to be turned on
  101205. * @param defines defines the current list of defines
  101206. */
  101207. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101208. /**
  101209. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101210. * @param scene defines the current scene
  101211. * @param engine defines the current engine
  101212. * @param defines specifies the list of active defines
  101213. * @param useInstances defines if instances have to be turned on
  101214. * @param useClipPlane defines if clip plane have to be turned on
  101215. * @param useInstances defines if instances have to be turned on
  101216. * @param useThinInstances defines if thin instances have to be turned on
  101217. */
  101218. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101219. /**
  101220. * Prepares the defines for bones
  101221. * @param mesh The mesh containing the geometry data we will draw
  101222. * @param defines The defines to update
  101223. */
  101224. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101225. /**
  101226. * Prepares the defines for morph targets
  101227. * @param mesh The mesh containing the geometry data we will draw
  101228. * @param defines The defines to update
  101229. */
  101230. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101231. /**
  101232. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101233. * @param mesh The mesh containing the geometry data we will draw
  101234. * @param defines The defines to update
  101235. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101236. * @param useBones Precise whether bones should be used or not (override mesh info)
  101237. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101238. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101239. * @returns false if defines are considered not dirty and have not been checked
  101240. */
  101241. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101242. /**
  101243. * Prepares the defines related to multiview
  101244. * @param scene The scene we are intending to draw
  101245. * @param defines The defines to update
  101246. */
  101247. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101248. /**
  101249. * Prepares the defines related to the prepass
  101250. * @param scene The scene we are intending to draw
  101251. * @param defines The defines to update
  101252. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101253. */
  101254. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101255. /**
  101256. * Prepares the defines related to the light information passed in parameter
  101257. * @param scene The scene we are intending to draw
  101258. * @param mesh The mesh the effect is compiling for
  101259. * @param light The light the effect is compiling for
  101260. * @param lightIndex The index of the light
  101261. * @param defines The defines to update
  101262. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101263. * @param state Defines the current state regarding what is needed (normals, etc...)
  101264. */
  101265. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101266. needNormals: boolean;
  101267. needRebuild: boolean;
  101268. shadowEnabled: boolean;
  101269. specularEnabled: boolean;
  101270. lightmapMode: boolean;
  101271. }): void;
  101272. /**
  101273. * Prepares the defines related to the light information passed in parameter
  101274. * @param scene The scene we are intending to draw
  101275. * @param mesh The mesh the effect is compiling for
  101276. * @param defines The defines to update
  101277. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101278. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101279. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101280. * @returns true if normals will be required for the rest of the effect
  101281. */
  101282. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101283. /**
  101284. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101285. * @param lightIndex defines the light index
  101286. * @param uniformsList The uniform list
  101287. * @param samplersList The sampler list
  101288. * @param projectedLightTexture defines if projected texture must be used
  101289. * @param uniformBuffersList defines an optional list of uniform buffers
  101290. */
  101291. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101292. /**
  101293. * Prepares the uniforms and samplers list to be used in the effect
  101294. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101295. * @param samplersList The sampler list
  101296. * @param defines The defines helping in the list generation
  101297. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101298. */
  101299. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101300. /**
  101301. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101302. * @param defines The defines to update while falling back
  101303. * @param fallbacks The authorized effect fallbacks
  101304. * @param maxSimultaneousLights The maximum number of lights allowed
  101305. * @param rank the current rank of the Effect
  101306. * @returns The newly affected rank
  101307. */
  101308. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101309. private static _TmpMorphInfluencers;
  101310. /**
  101311. * Prepares the list of attributes required for morph targets according to the effect defines.
  101312. * @param attribs The current list of supported attribs
  101313. * @param mesh The mesh to prepare the morph targets attributes for
  101314. * @param influencers The number of influencers
  101315. */
  101316. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101317. /**
  101318. * Prepares the list of attributes required for morph targets according to the effect defines.
  101319. * @param attribs The current list of supported attribs
  101320. * @param mesh The mesh to prepare the morph targets attributes for
  101321. * @param defines The current Defines of the effect
  101322. */
  101323. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101324. /**
  101325. * Prepares the list of attributes required for bones according to the effect defines.
  101326. * @param attribs The current list of supported attribs
  101327. * @param mesh The mesh to prepare the bones attributes for
  101328. * @param defines The current Defines of the effect
  101329. * @param fallbacks The current efffect fallback strategy
  101330. */
  101331. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101332. /**
  101333. * Check and prepare the list of attributes required for instances according to the effect defines.
  101334. * @param attribs The current list of supported attribs
  101335. * @param defines The current MaterialDefines of the effect
  101336. */
  101337. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101338. /**
  101339. * Add the list of attributes required for instances to the attribs array.
  101340. * @param attribs The current list of supported attribs
  101341. */
  101342. static PushAttributesForInstances(attribs: string[]): void;
  101343. /**
  101344. * Binds the light information to the effect.
  101345. * @param light The light containing the generator
  101346. * @param effect The effect we are binding the data to
  101347. * @param lightIndex The light index in the effect used to render
  101348. */
  101349. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101350. /**
  101351. * Binds the lights information from the scene to the effect for the given mesh.
  101352. * @param light Light to bind
  101353. * @param lightIndex Light index
  101354. * @param scene The scene where the light belongs to
  101355. * @param effect The effect we are binding the data to
  101356. * @param useSpecular Defines if specular is supported
  101357. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101358. */
  101359. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101360. /**
  101361. * Binds the lights information from the scene to the effect for the given mesh.
  101362. * @param scene The scene the lights belongs to
  101363. * @param mesh The mesh we are binding the information to render
  101364. * @param effect The effect we are binding the data to
  101365. * @param defines The generated defines for the effect
  101366. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101367. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101368. */
  101369. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101370. private static _tempFogColor;
  101371. /**
  101372. * Binds the fog information from the scene to the effect for the given mesh.
  101373. * @param scene The scene the lights belongs to
  101374. * @param mesh The mesh we are binding the information to render
  101375. * @param effect The effect we are binding the data to
  101376. * @param linearSpace Defines if the fog effect is applied in linear space
  101377. */
  101378. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101379. /**
  101380. * Binds the bones information from the mesh to the effect.
  101381. * @param mesh The mesh we are binding the information to render
  101382. * @param effect The effect we are binding the data to
  101383. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101384. */
  101385. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101386. private static _CopyBonesTransformationMatrices;
  101387. /**
  101388. * Binds the morph targets information from the mesh to the effect.
  101389. * @param abstractMesh The mesh we are binding the information to render
  101390. * @param effect The effect we are binding the data to
  101391. */
  101392. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101393. /**
  101394. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101395. * @param defines The generated defines used in the effect
  101396. * @param effect The effect we are binding the data to
  101397. * @param scene The scene we are willing to render with logarithmic scale for
  101398. */
  101399. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101400. /**
  101401. * Binds the clip plane information from the scene to the effect.
  101402. * @param scene The scene the clip plane information are extracted from
  101403. * @param effect The effect we are binding the data to
  101404. */
  101405. static BindClipPlane(effect: Effect, scene: Scene): void;
  101406. }
  101407. }
  101408. declare module BABYLON {
  101409. /**
  101410. * Block used to expose an input value
  101411. */
  101412. export class InputBlock extends NodeMaterialBlock {
  101413. private _mode;
  101414. private _associatedVariableName;
  101415. private _storedValue;
  101416. private _valueCallback;
  101417. private _type;
  101418. private _animationType;
  101419. /** Gets or set a value used to limit the range of float values */
  101420. min: number;
  101421. /** Gets or set a value used to limit the range of float values */
  101422. max: number;
  101423. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101424. isBoolean: boolean;
  101425. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101426. matrixMode: number;
  101427. /** @hidden */
  101428. _systemValue: Nullable<NodeMaterialSystemValues>;
  101429. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101430. isConstant: boolean;
  101431. /** Gets or sets the group to use to display this block in the Inspector */
  101432. groupInInspector: string;
  101433. /** Gets an observable raised when the value is changed */
  101434. onValueChangedObservable: Observable<InputBlock>;
  101435. /**
  101436. * Gets or sets the connection point type (default is float)
  101437. */
  101438. get type(): NodeMaterialBlockConnectionPointTypes;
  101439. /**
  101440. * Creates a new InputBlock
  101441. * @param name defines the block name
  101442. * @param target defines the target of that block (Vertex by default)
  101443. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101444. */
  101445. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101446. /**
  101447. * Validates if a name is a reserve word.
  101448. * @param newName the new name to be given to the node.
  101449. * @returns false if the name is a reserve word, else true.
  101450. */
  101451. validateBlockName(newName: string): boolean;
  101452. /**
  101453. * Gets the output component
  101454. */
  101455. get output(): NodeMaterialConnectionPoint;
  101456. /**
  101457. * Set the source of this connection point to a vertex attribute
  101458. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101459. * @returns the current connection point
  101460. */
  101461. setAsAttribute(attributeName?: string): InputBlock;
  101462. /**
  101463. * Set the source of this connection point to a system value
  101464. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101465. * @returns the current connection point
  101466. */
  101467. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101468. /**
  101469. * Gets or sets the value of that point.
  101470. * Please note that this value will be ignored if valueCallback is defined
  101471. */
  101472. get value(): any;
  101473. set value(value: any);
  101474. /**
  101475. * Gets or sets a callback used to get the value of that point.
  101476. * Please note that setting this value will force the connection point to ignore the value property
  101477. */
  101478. get valueCallback(): () => any;
  101479. set valueCallback(value: () => any);
  101480. /**
  101481. * Gets or sets the associated variable name in the shader
  101482. */
  101483. get associatedVariableName(): string;
  101484. set associatedVariableName(value: string);
  101485. /** Gets or sets the type of animation applied to the input */
  101486. get animationType(): AnimatedInputBlockTypes;
  101487. set animationType(value: AnimatedInputBlockTypes);
  101488. /**
  101489. * Gets a boolean indicating that this connection point not defined yet
  101490. */
  101491. get isUndefined(): boolean;
  101492. /**
  101493. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101494. * In this case the connection point name must be the name of the uniform to use.
  101495. * Can only be set on inputs
  101496. */
  101497. get isUniform(): boolean;
  101498. set isUniform(value: boolean);
  101499. /**
  101500. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101501. * In this case the connection point name must be the name of the attribute to use
  101502. * Can only be set on inputs
  101503. */
  101504. get isAttribute(): boolean;
  101505. set isAttribute(value: boolean);
  101506. /**
  101507. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101508. * Can only be set on exit points
  101509. */
  101510. get isVarying(): boolean;
  101511. set isVarying(value: boolean);
  101512. /**
  101513. * Gets a boolean indicating that the current connection point is a system value
  101514. */
  101515. get isSystemValue(): boolean;
  101516. /**
  101517. * Gets or sets the current well known value or null if not defined as a system value
  101518. */
  101519. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101520. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101521. /**
  101522. * Gets the current class name
  101523. * @returns the class name
  101524. */
  101525. getClassName(): string;
  101526. /**
  101527. * Animate the input if animationType !== None
  101528. * @param scene defines the rendering scene
  101529. */
  101530. animate(scene: Scene): void;
  101531. private _emitDefine;
  101532. initialize(state: NodeMaterialBuildState): void;
  101533. /**
  101534. * Set the input block to its default value (based on its type)
  101535. */
  101536. setDefaultValue(): void;
  101537. private _emitConstant;
  101538. /** @hidden */
  101539. get _noContextSwitch(): boolean;
  101540. private _emit;
  101541. /** @hidden */
  101542. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101543. /** @hidden */
  101544. _transmit(effect: Effect, scene: Scene): void;
  101545. protected _buildBlock(state: NodeMaterialBuildState): void;
  101546. protected _dumpPropertiesCode(): string;
  101547. dispose(): void;
  101548. serialize(): any;
  101549. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101550. }
  101551. }
  101552. declare module BABYLON {
  101553. /**
  101554. * Enum used to define the compatibility state between two connection points
  101555. */
  101556. export enum NodeMaterialConnectionPointCompatibilityStates {
  101557. /** Points are compatibles */
  101558. Compatible = 0,
  101559. /** Points are incompatible because of their types */
  101560. TypeIncompatible = 1,
  101561. /** Points are incompatible because of their targets (vertex vs fragment) */
  101562. TargetIncompatible = 2
  101563. }
  101564. /**
  101565. * Defines the direction of a connection point
  101566. */
  101567. export enum NodeMaterialConnectionPointDirection {
  101568. /** Input */
  101569. Input = 0,
  101570. /** Output */
  101571. Output = 1
  101572. }
  101573. /**
  101574. * Defines a connection point for a block
  101575. */
  101576. export class NodeMaterialConnectionPoint {
  101577. /** @hidden */
  101578. _ownerBlock: NodeMaterialBlock;
  101579. /** @hidden */
  101580. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101581. private _endpoints;
  101582. private _associatedVariableName;
  101583. private _direction;
  101584. /** @hidden */
  101585. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101586. /** @hidden */
  101587. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101588. private _type;
  101589. /** @hidden */
  101590. _enforceAssociatedVariableName: boolean;
  101591. /** Gets the direction of the point */
  101592. get direction(): NodeMaterialConnectionPointDirection;
  101593. /** Indicates that this connection point needs dual validation before being connected to another point */
  101594. needDualDirectionValidation: boolean;
  101595. /**
  101596. * Gets or sets the additional types supported by this connection point
  101597. */
  101598. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101599. /**
  101600. * Gets or sets the additional types excluded by this connection point
  101601. */
  101602. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101603. /**
  101604. * Observable triggered when this point is connected
  101605. */
  101606. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101607. /**
  101608. * Gets or sets the associated variable name in the shader
  101609. */
  101610. get associatedVariableName(): string;
  101611. set associatedVariableName(value: string);
  101612. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101613. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101614. /**
  101615. * Gets or sets the connection point type (default is float)
  101616. */
  101617. get type(): NodeMaterialBlockConnectionPointTypes;
  101618. set type(value: NodeMaterialBlockConnectionPointTypes);
  101619. /**
  101620. * Gets or sets the connection point name
  101621. */
  101622. name: string;
  101623. /**
  101624. * Gets or sets the connection point name
  101625. */
  101626. displayName: string;
  101627. /**
  101628. * Gets or sets a boolean indicating that this connection point can be omitted
  101629. */
  101630. isOptional: boolean;
  101631. /**
  101632. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101633. */
  101634. isExposedOnFrame: boolean;
  101635. /**
  101636. * Gets or sets number indicating the position that the port is exposed to on a frame
  101637. */
  101638. exposedPortPosition: number;
  101639. /**
  101640. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101641. */
  101642. define: string;
  101643. /** @hidden */
  101644. _prioritizeVertex: boolean;
  101645. private _target;
  101646. /** Gets or sets the target of that connection point */
  101647. get target(): NodeMaterialBlockTargets;
  101648. set target(value: NodeMaterialBlockTargets);
  101649. /**
  101650. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101651. */
  101652. get isConnected(): boolean;
  101653. /**
  101654. * Gets a boolean indicating that the current point is connected to an input block
  101655. */
  101656. get isConnectedToInputBlock(): boolean;
  101657. /**
  101658. * Gets a the connected input block (if any)
  101659. */
  101660. get connectInputBlock(): Nullable<InputBlock>;
  101661. /** Get the other side of the connection (if any) */
  101662. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101663. /** Get the block that owns this connection point */
  101664. get ownerBlock(): NodeMaterialBlock;
  101665. /** Get the block connected on the other side of this connection (if any) */
  101666. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101667. /** Get the block connected on the endpoints of this connection (if any) */
  101668. get connectedBlocks(): Array<NodeMaterialBlock>;
  101669. /** Gets the list of connected endpoints */
  101670. get endpoints(): NodeMaterialConnectionPoint[];
  101671. /** Gets a boolean indicating if that output point is connected to at least one input */
  101672. get hasEndpoints(): boolean;
  101673. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101674. get isConnectedInVertexShader(): boolean;
  101675. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101676. get isConnectedInFragmentShader(): boolean;
  101677. /**
  101678. * Creates a block suitable to be used as an input for this input point.
  101679. * If null is returned, a block based on the point type will be created.
  101680. * @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
  101681. */
  101682. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101683. /**
  101684. * Creates a new connection point
  101685. * @param name defines the connection point name
  101686. * @param ownerBlock defines the block hosting this connection point
  101687. * @param direction defines the direction of the connection point
  101688. */
  101689. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101690. /**
  101691. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101692. * @returns the class name
  101693. */
  101694. getClassName(): string;
  101695. /**
  101696. * Gets a boolean indicating if the current point can be connected to another point
  101697. * @param connectionPoint defines the other connection point
  101698. * @returns a boolean
  101699. */
  101700. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101701. /**
  101702. * Gets a number indicating if the current point can be connected to another point
  101703. * @param connectionPoint defines the other connection point
  101704. * @returns a number defining the compatibility state
  101705. */
  101706. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101707. /**
  101708. * Connect this point to another connection point
  101709. * @param connectionPoint defines the other connection point
  101710. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101711. * @returns the current connection point
  101712. */
  101713. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101714. /**
  101715. * Disconnect this point from one of his endpoint
  101716. * @param endpoint defines the other connection point
  101717. * @returns the current connection point
  101718. */
  101719. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101720. /**
  101721. * Serializes this point in a JSON representation
  101722. * @param isInput defines if the connection point is an input (default is true)
  101723. * @returns the serialized point object
  101724. */
  101725. serialize(isInput?: boolean): any;
  101726. /**
  101727. * Release resources
  101728. */
  101729. dispose(): void;
  101730. }
  101731. }
  101732. declare module BABYLON {
  101733. /**
  101734. * Enum used to define the material modes
  101735. */
  101736. export enum NodeMaterialModes {
  101737. /** Regular material */
  101738. Material = 0,
  101739. /** For post process */
  101740. PostProcess = 1,
  101741. /** For particle system */
  101742. Particle = 2,
  101743. /** For procedural texture */
  101744. ProceduralTexture = 3
  101745. }
  101746. }
  101747. declare module BABYLON {
  101748. /**
  101749. * Block used to read a texture from a sampler
  101750. */
  101751. export class TextureBlock extends NodeMaterialBlock {
  101752. private _defineName;
  101753. private _linearDefineName;
  101754. private _gammaDefineName;
  101755. private _tempTextureRead;
  101756. private _samplerName;
  101757. private _transformedUVName;
  101758. private _textureTransformName;
  101759. private _textureInfoName;
  101760. private _mainUVName;
  101761. private _mainUVDefineName;
  101762. private _fragmentOnly;
  101763. /**
  101764. * Gets or sets the texture associated with the node
  101765. */
  101766. texture: Nullable<Texture>;
  101767. /**
  101768. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101769. */
  101770. convertToGammaSpace: boolean;
  101771. /**
  101772. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101773. */
  101774. convertToLinearSpace: boolean;
  101775. /**
  101776. * Create a new TextureBlock
  101777. * @param name defines the block name
  101778. */
  101779. constructor(name: string, fragmentOnly?: boolean);
  101780. /**
  101781. * Gets the current class name
  101782. * @returns the class name
  101783. */
  101784. getClassName(): string;
  101785. /**
  101786. * Gets the uv input component
  101787. */
  101788. get uv(): NodeMaterialConnectionPoint;
  101789. /**
  101790. * Gets the rgba output component
  101791. */
  101792. get rgba(): NodeMaterialConnectionPoint;
  101793. /**
  101794. * Gets the rgb output component
  101795. */
  101796. get rgb(): NodeMaterialConnectionPoint;
  101797. /**
  101798. * Gets the r output component
  101799. */
  101800. get r(): NodeMaterialConnectionPoint;
  101801. /**
  101802. * Gets the g output component
  101803. */
  101804. get g(): NodeMaterialConnectionPoint;
  101805. /**
  101806. * Gets the b output component
  101807. */
  101808. get b(): NodeMaterialConnectionPoint;
  101809. /**
  101810. * Gets the a output component
  101811. */
  101812. get a(): NodeMaterialConnectionPoint;
  101813. get target(): NodeMaterialBlockTargets;
  101814. autoConfigure(material: NodeMaterial): void;
  101815. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101817. isReady(): boolean;
  101818. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101819. private get _isMixed();
  101820. private _injectVertexCode;
  101821. private _writeTextureRead;
  101822. private _writeOutput;
  101823. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101824. protected _dumpPropertiesCode(): string;
  101825. serialize(): any;
  101826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101827. }
  101828. }
  101829. declare module BABYLON {
  101830. /** @hidden */
  101831. export var reflectionFunction: {
  101832. name: string;
  101833. shader: string;
  101834. };
  101835. }
  101836. declare module BABYLON {
  101837. /**
  101838. * Base block used to read a reflection texture from a sampler
  101839. */
  101840. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101841. /** @hidden */
  101842. _define3DName: string;
  101843. /** @hidden */
  101844. _defineCubicName: string;
  101845. /** @hidden */
  101846. _defineExplicitName: string;
  101847. /** @hidden */
  101848. _defineProjectionName: string;
  101849. /** @hidden */
  101850. _defineLocalCubicName: string;
  101851. /** @hidden */
  101852. _defineSphericalName: string;
  101853. /** @hidden */
  101854. _definePlanarName: string;
  101855. /** @hidden */
  101856. _defineEquirectangularName: string;
  101857. /** @hidden */
  101858. _defineMirroredEquirectangularFixedName: string;
  101859. /** @hidden */
  101860. _defineEquirectangularFixedName: string;
  101861. /** @hidden */
  101862. _defineSkyboxName: string;
  101863. /** @hidden */
  101864. _defineOppositeZ: string;
  101865. /** @hidden */
  101866. _cubeSamplerName: string;
  101867. /** @hidden */
  101868. _2DSamplerName: string;
  101869. protected _positionUVWName: string;
  101870. protected _directionWName: string;
  101871. protected _reflectionVectorName: string;
  101872. /** @hidden */
  101873. _reflectionCoordsName: string;
  101874. /** @hidden */
  101875. _reflectionMatrixName: string;
  101876. protected _reflectionColorName: string;
  101877. /**
  101878. * Gets or sets the texture associated with the node
  101879. */
  101880. texture: Nullable<BaseTexture>;
  101881. /**
  101882. * Create a new ReflectionTextureBaseBlock
  101883. * @param name defines the block name
  101884. */
  101885. constructor(name: string);
  101886. /**
  101887. * Gets the current class name
  101888. * @returns the class name
  101889. */
  101890. getClassName(): string;
  101891. /**
  101892. * Gets the world position input component
  101893. */
  101894. abstract get position(): NodeMaterialConnectionPoint;
  101895. /**
  101896. * Gets the world position input component
  101897. */
  101898. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101899. /**
  101900. * Gets the world normal input component
  101901. */
  101902. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101903. /**
  101904. * Gets the world input component
  101905. */
  101906. abstract get world(): NodeMaterialConnectionPoint;
  101907. /**
  101908. * Gets the camera (or eye) position component
  101909. */
  101910. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101911. /**
  101912. * Gets the view input component
  101913. */
  101914. abstract get view(): NodeMaterialConnectionPoint;
  101915. protected _getTexture(): Nullable<BaseTexture>;
  101916. autoConfigure(material: NodeMaterial): void;
  101917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101918. isReady(): boolean;
  101919. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101920. /**
  101921. * Gets the code to inject in the vertex shader
  101922. * @param state current state of the node material building
  101923. * @returns the shader code
  101924. */
  101925. handleVertexSide(state: NodeMaterialBuildState): string;
  101926. /**
  101927. * Handles the inits for the fragment code path
  101928. * @param state node material build state
  101929. */
  101930. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101931. /**
  101932. * Generates the reflection coords code for the fragment code path
  101933. * @param worldNormalVarName name of the world normal variable
  101934. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101935. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101936. * @returns the shader code
  101937. */
  101938. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101939. /**
  101940. * Generates the reflection color code for the fragment code path
  101941. * @param lodVarName name of the lod variable
  101942. * @param swizzleLookupTexture swizzle to use for the final color variable
  101943. * @returns the shader code
  101944. */
  101945. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101946. /**
  101947. * Generates the code corresponding to the connected output points
  101948. * @param state node material build state
  101949. * @param varName name of the variable to output
  101950. * @returns the shader code
  101951. */
  101952. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101953. protected _buildBlock(state: NodeMaterialBuildState): this;
  101954. protected _dumpPropertiesCode(): string;
  101955. serialize(): any;
  101956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101957. }
  101958. }
  101959. declare module BABYLON {
  101960. /**
  101961. * Defines a connection point to be used for points with a custom object type
  101962. */
  101963. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101964. private _blockType;
  101965. private _blockName;
  101966. private _nameForCheking?;
  101967. /**
  101968. * Creates a new connection point
  101969. * @param name defines the connection point name
  101970. * @param ownerBlock defines the block hosting this connection point
  101971. * @param direction defines the direction of the connection point
  101972. */
  101973. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101974. /**
  101975. * Gets a number indicating if the current point can be connected to another point
  101976. * @param connectionPoint defines the other connection point
  101977. * @returns a number defining the compatibility state
  101978. */
  101979. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101980. /**
  101981. * Creates a block suitable to be used as an input for this input point.
  101982. * If null is returned, a block based on the point type will be created.
  101983. * @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
  101984. */
  101985. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101986. }
  101987. }
  101988. declare module BABYLON {
  101989. /**
  101990. * Enum defining the type of properties that can be edited in the property pages in the NME
  101991. */
  101992. export enum PropertyTypeForEdition {
  101993. /** property is a boolean */
  101994. Boolean = 0,
  101995. /** property is a float */
  101996. Float = 1,
  101997. /** property is a Vector2 */
  101998. Vector2 = 2,
  101999. /** property is a list of values */
  102000. List = 3
  102001. }
  102002. /**
  102003. * Interface that defines an option in a variable of type list
  102004. */
  102005. export interface IEditablePropertyListOption {
  102006. /** label of the option */
  102007. "label": string;
  102008. /** value of the option */
  102009. "value": number;
  102010. }
  102011. /**
  102012. * Interface that defines the options available for an editable property
  102013. */
  102014. export interface IEditablePropertyOption {
  102015. /** min value */
  102016. "min"?: number;
  102017. /** max value */
  102018. "max"?: number;
  102019. /** notifiers: indicates which actions to take when the property is changed */
  102020. "notifiers"?: {
  102021. /** the material should be rebuilt */
  102022. "rebuild"?: boolean;
  102023. /** the preview should be updated */
  102024. "update"?: boolean;
  102025. };
  102026. /** list of the options for a variable of type list */
  102027. "options"?: IEditablePropertyListOption[];
  102028. }
  102029. /**
  102030. * Interface that describes an editable property
  102031. */
  102032. export interface IPropertyDescriptionForEdition {
  102033. /** name of the property */
  102034. "propertyName": string;
  102035. /** display name of the property */
  102036. "displayName": string;
  102037. /** type of the property */
  102038. "type": PropertyTypeForEdition;
  102039. /** group of the property - all properties with the same group value will be displayed in a specific section */
  102040. "groupName": string;
  102041. /** options for the property */
  102042. "options": IEditablePropertyOption;
  102043. }
  102044. /**
  102045. * Decorator that flags a property in a node material block as being editable
  102046. */
  102047. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102048. }
  102049. declare module BABYLON {
  102050. /**
  102051. * Block used to implement the refraction part of the sub surface module of the PBR material
  102052. */
  102053. export class RefractionBlock extends NodeMaterialBlock {
  102054. /** @hidden */
  102055. _define3DName: string;
  102056. /** @hidden */
  102057. _refractionMatrixName: string;
  102058. /** @hidden */
  102059. _defineLODRefractionAlpha: string;
  102060. /** @hidden */
  102061. _defineLinearSpecularRefraction: string;
  102062. /** @hidden */
  102063. _defineOppositeZ: string;
  102064. /** @hidden */
  102065. _cubeSamplerName: string;
  102066. /** @hidden */
  102067. _2DSamplerName: string;
  102068. /** @hidden */
  102069. _vRefractionMicrosurfaceInfosName: string;
  102070. /** @hidden */
  102071. _vRefractionInfosName: string;
  102072. private _scene;
  102073. /**
  102074. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102075. * Materials half opaque for instance using refraction could benefit from this control.
  102076. */
  102077. linkRefractionWithTransparency: boolean;
  102078. /**
  102079. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102080. */
  102081. invertRefractionY: boolean;
  102082. /**
  102083. * Gets or sets the texture associated with the node
  102084. */
  102085. texture: Nullable<BaseTexture>;
  102086. /**
  102087. * Create a new RefractionBlock
  102088. * @param name defines the block name
  102089. */
  102090. constructor(name: string);
  102091. /**
  102092. * Gets the current class name
  102093. * @returns the class name
  102094. */
  102095. getClassName(): string;
  102096. /**
  102097. * Gets the intensity input component
  102098. */
  102099. get intensity(): NodeMaterialConnectionPoint;
  102100. /**
  102101. * Gets the index of refraction input component
  102102. */
  102103. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102104. /**
  102105. * Gets the tint at distance input component
  102106. */
  102107. get tintAtDistance(): NodeMaterialConnectionPoint;
  102108. /**
  102109. * Gets the view input component
  102110. */
  102111. get view(): NodeMaterialConnectionPoint;
  102112. /**
  102113. * Gets the refraction object output component
  102114. */
  102115. get refraction(): NodeMaterialConnectionPoint;
  102116. /**
  102117. * Returns true if the block has a texture
  102118. */
  102119. get hasTexture(): boolean;
  102120. protected _getTexture(): Nullable<BaseTexture>;
  102121. autoConfigure(material: NodeMaterial): void;
  102122. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102123. isReady(): boolean;
  102124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102125. /**
  102126. * Gets the main code of the block (fragment side)
  102127. * @param state current state of the node material building
  102128. * @returns the shader code
  102129. */
  102130. getCode(state: NodeMaterialBuildState): string;
  102131. protected _buildBlock(state: NodeMaterialBuildState): this;
  102132. protected _dumpPropertiesCode(): string;
  102133. serialize(): any;
  102134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102135. }
  102136. }
  102137. declare module BABYLON {
  102138. /**
  102139. * Base block used as input for post process
  102140. */
  102141. export class CurrentScreenBlock extends NodeMaterialBlock {
  102142. private _samplerName;
  102143. private _linearDefineName;
  102144. private _gammaDefineName;
  102145. private _mainUVName;
  102146. private _tempTextureRead;
  102147. /**
  102148. * Gets or sets the texture associated with the node
  102149. */
  102150. texture: Nullable<BaseTexture>;
  102151. /**
  102152. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102153. */
  102154. convertToGammaSpace: boolean;
  102155. /**
  102156. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102157. */
  102158. convertToLinearSpace: boolean;
  102159. /**
  102160. * Create a new CurrentScreenBlock
  102161. * @param name defines the block name
  102162. */
  102163. constructor(name: string);
  102164. /**
  102165. * Gets the current class name
  102166. * @returns the class name
  102167. */
  102168. getClassName(): string;
  102169. /**
  102170. * Gets the uv input component
  102171. */
  102172. get uv(): NodeMaterialConnectionPoint;
  102173. /**
  102174. * Gets the rgba output component
  102175. */
  102176. get rgba(): NodeMaterialConnectionPoint;
  102177. /**
  102178. * Gets the rgb output component
  102179. */
  102180. get rgb(): NodeMaterialConnectionPoint;
  102181. /**
  102182. * Gets the r output component
  102183. */
  102184. get r(): NodeMaterialConnectionPoint;
  102185. /**
  102186. * Gets the g output component
  102187. */
  102188. get g(): NodeMaterialConnectionPoint;
  102189. /**
  102190. * Gets the b output component
  102191. */
  102192. get b(): NodeMaterialConnectionPoint;
  102193. /**
  102194. * Gets the a output component
  102195. */
  102196. get a(): NodeMaterialConnectionPoint;
  102197. /**
  102198. * Initialize the block and prepare the context for build
  102199. * @param state defines the state that will be used for the build
  102200. */
  102201. initialize(state: NodeMaterialBuildState): void;
  102202. get target(): NodeMaterialBlockTargets;
  102203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102204. isReady(): boolean;
  102205. private _injectVertexCode;
  102206. private _writeTextureRead;
  102207. private _writeOutput;
  102208. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102209. serialize(): any;
  102210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102211. }
  102212. }
  102213. declare module BABYLON {
  102214. /**
  102215. * Base block used for the particle texture
  102216. */
  102217. export class ParticleTextureBlock extends NodeMaterialBlock {
  102218. private _samplerName;
  102219. private _linearDefineName;
  102220. private _gammaDefineName;
  102221. private _tempTextureRead;
  102222. /**
  102223. * Gets or sets the texture associated with the node
  102224. */
  102225. texture: Nullable<BaseTexture>;
  102226. /**
  102227. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102228. */
  102229. convertToGammaSpace: boolean;
  102230. /**
  102231. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102232. */
  102233. convertToLinearSpace: boolean;
  102234. /**
  102235. * Create a new ParticleTextureBlock
  102236. * @param name defines the block name
  102237. */
  102238. constructor(name: string);
  102239. /**
  102240. * Gets the current class name
  102241. * @returns the class name
  102242. */
  102243. getClassName(): string;
  102244. /**
  102245. * Gets the uv input component
  102246. */
  102247. get uv(): NodeMaterialConnectionPoint;
  102248. /**
  102249. * Gets the rgba output component
  102250. */
  102251. get rgba(): NodeMaterialConnectionPoint;
  102252. /**
  102253. * Gets the rgb output component
  102254. */
  102255. get rgb(): NodeMaterialConnectionPoint;
  102256. /**
  102257. * Gets the r output component
  102258. */
  102259. get r(): NodeMaterialConnectionPoint;
  102260. /**
  102261. * Gets the g output component
  102262. */
  102263. get g(): NodeMaterialConnectionPoint;
  102264. /**
  102265. * Gets the b output component
  102266. */
  102267. get b(): NodeMaterialConnectionPoint;
  102268. /**
  102269. * Gets the a output component
  102270. */
  102271. get a(): NodeMaterialConnectionPoint;
  102272. /**
  102273. * Initialize the block and prepare the context for build
  102274. * @param state defines the state that will be used for the build
  102275. */
  102276. initialize(state: NodeMaterialBuildState): void;
  102277. autoConfigure(material: NodeMaterial): void;
  102278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102279. isReady(): boolean;
  102280. private _writeOutput;
  102281. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102282. serialize(): any;
  102283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102284. }
  102285. }
  102286. declare module BABYLON {
  102287. /**
  102288. * Class used to store shared data between 2 NodeMaterialBuildState
  102289. */
  102290. export class NodeMaterialBuildStateSharedData {
  102291. /**
  102292. * Gets the list of emitted varyings
  102293. */
  102294. temps: string[];
  102295. /**
  102296. * Gets the list of emitted varyings
  102297. */
  102298. varyings: string[];
  102299. /**
  102300. * Gets the varying declaration string
  102301. */
  102302. varyingDeclaration: string;
  102303. /**
  102304. * Input blocks
  102305. */
  102306. inputBlocks: InputBlock[];
  102307. /**
  102308. * Input blocks
  102309. */
  102310. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102311. /**
  102312. * Bindable blocks (Blocks that need to set data to the effect)
  102313. */
  102314. bindableBlocks: NodeMaterialBlock[];
  102315. /**
  102316. * List of blocks that can provide a compilation fallback
  102317. */
  102318. blocksWithFallbacks: NodeMaterialBlock[];
  102319. /**
  102320. * List of blocks that can provide a define update
  102321. */
  102322. blocksWithDefines: NodeMaterialBlock[];
  102323. /**
  102324. * List of blocks that can provide a repeatable content
  102325. */
  102326. repeatableContentBlocks: NodeMaterialBlock[];
  102327. /**
  102328. * List of blocks that can provide a dynamic list of uniforms
  102329. */
  102330. dynamicUniformBlocks: NodeMaterialBlock[];
  102331. /**
  102332. * List of blocks that can block the isReady function for the material
  102333. */
  102334. blockingBlocks: NodeMaterialBlock[];
  102335. /**
  102336. * Gets the list of animated inputs
  102337. */
  102338. animatedInputs: InputBlock[];
  102339. /**
  102340. * Build Id used to avoid multiple recompilations
  102341. */
  102342. buildId: number;
  102343. /** List of emitted variables */
  102344. variableNames: {
  102345. [key: string]: number;
  102346. };
  102347. /** List of emitted defines */
  102348. defineNames: {
  102349. [key: string]: number;
  102350. };
  102351. /** Should emit comments? */
  102352. emitComments: boolean;
  102353. /** Emit build activity */
  102354. verbose: boolean;
  102355. /** Gets or sets the hosting scene */
  102356. scene: Scene;
  102357. /**
  102358. * Gets the compilation hints emitted at compilation time
  102359. */
  102360. hints: {
  102361. needWorldViewMatrix: boolean;
  102362. needWorldViewProjectionMatrix: boolean;
  102363. needAlphaBlending: boolean;
  102364. needAlphaTesting: boolean;
  102365. };
  102366. /**
  102367. * List of compilation checks
  102368. */
  102369. checks: {
  102370. emitVertex: boolean;
  102371. emitFragment: boolean;
  102372. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102373. };
  102374. /**
  102375. * Is vertex program allowed to be empty?
  102376. */
  102377. allowEmptyVertexProgram: boolean;
  102378. /** Creates a new shared data */
  102379. constructor();
  102380. /**
  102381. * Emits console errors and exceptions if there is a failing check
  102382. */
  102383. emitErrors(): void;
  102384. }
  102385. }
  102386. declare module BABYLON {
  102387. /**
  102388. * Class used to store node based material build state
  102389. */
  102390. export class NodeMaterialBuildState {
  102391. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102392. supportUniformBuffers: boolean;
  102393. /**
  102394. * Gets the list of emitted attributes
  102395. */
  102396. attributes: string[];
  102397. /**
  102398. * Gets the list of emitted uniforms
  102399. */
  102400. uniforms: string[];
  102401. /**
  102402. * Gets the list of emitted constants
  102403. */
  102404. constants: string[];
  102405. /**
  102406. * Gets the list of emitted samplers
  102407. */
  102408. samplers: string[];
  102409. /**
  102410. * Gets the list of emitted functions
  102411. */
  102412. functions: {
  102413. [key: string]: string;
  102414. };
  102415. /**
  102416. * Gets the list of emitted extensions
  102417. */
  102418. extensions: {
  102419. [key: string]: string;
  102420. };
  102421. /**
  102422. * Gets the target of the compilation state
  102423. */
  102424. target: NodeMaterialBlockTargets;
  102425. /**
  102426. * Gets the list of emitted counters
  102427. */
  102428. counters: {
  102429. [key: string]: number;
  102430. };
  102431. /**
  102432. * Shared data between multiple NodeMaterialBuildState instances
  102433. */
  102434. sharedData: NodeMaterialBuildStateSharedData;
  102435. /** @hidden */
  102436. _vertexState: NodeMaterialBuildState;
  102437. /** @hidden */
  102438. _attributeDeclaration: string;
  102439. /** @hidden */
  102440. _uniformDeclaration: string;
  102441. /** @hidden */
  102442. _constantDeclaration: string;
  102443. /** @hidden */
  102444. _samplerDeclaration: string;
  102445. /** @hidden */
  102446. _varyingTransfer: string;
  102447. /** @hidden */
  102448. _injectAtEnd: string;
  102449. private _repeatableContentAnchorIndex;
  102450. /** @hidden */
  102451. _builtCompilationString: string;
  102452. /**
  102453. * Gets the emitted compilation strings
  102454. */
  102455. compilationString: string;
  102456. /**
  102457. * Finalize the compilation strings
  102458. * @param state defines the current compilation state
  102459. */
  102460. finalize(state: NodeMaterialBuildState): void;
  102461. /** @hidden */
  102462. get _repeatableContentAnchor(): string;
  102463. /** @hidden */
  102464. _getFreeVariableName(prefix: string): string;
  102465. /** @hidden */
  102466. _getFreeDefineName(prefix: string): string;
  102467. /** @hidden */
  102468. _excludeVariableName(name: string): void;
  102469. /** @hidden */
  102470. _emit2DSampler(name: string): void;
  102471. /** @hidden */
  102472. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102473. /** @hidden */
  102474. _emitExtension(name: string, extension: string, define?: string): void;
  102475. /** @hidden */
  102476. _emitFunction(name: string, code: string, comments: string): void;
  102477. /** @hidden */
  102478. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102479. replaceStrings?: {
  102480. search: RegExp;
  102481. replace: string;
  102482. }[];
  102483. repeatKey?: string;
  102484. }): string;
  102485. /** @hidden */
  102486. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102487. repeatKey?: string;
  102488. removeAttributes?: boolean;
  102489. removeUniforms?: boolean;
  102490. removeVaryings?: boolean;
  102491. removeIfDef?: boolean;
  102492. replaceStrings?: {
  102493. search: RegExp;
  102494. replace: string;
  102495. }[];
  102496. }, storeKey?: string): void;
  102497. /** @hidden */
  102498. _registerTempVariable(name: string): boolean;
  102499. /** @hidden */
  102500. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102501. /** @hidden */
  102502. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102503. /** @hidden */
  102504. _emitFloat(value: number): string;
  102505. }
  102506. }
  102507. declare module BABYLON {
  102508. /**
  102509. * Helper class used to generate session unique ID
  102510. */
  102511. export class UniqueIdGenerator {
  102512. private static _UniqueIdCounter;
  102513. /**
  102514. * Gets an unique (relatively to the current scene) Id
  102515. */
  102516. static get UniqueId(): number;
  102517. }
  102518. }
  102519. declare module BABYLON {
  102520. /**
  102521. * Defines a block that can be used inside a node based material
  102522. */
  102523. export class NodeMaterialBlock {
  102524. private _buildId;
  102525. private _buildTarget;
  102526. private _target;
  102527. private _isFinalMerger;
  102528. private _isInput;
  102529. private _name;
  102530. protected _isUnique: boolean;
  102531. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102532. inputsAreExclusive: boolean;
  102533. /** @hidden */
  102534. _codeVariableName: string;
  102535. /** @hidden */
  102536. _inputs: NodeMaterialConnectionPoint[];
  102537. /** @hidden */
  102538. _outputs: NodeMaterialConnectionPoint[];
  102539. /** @hidden */
  102540. _preparationId: number;
  102541. /**
  102542. * Gets the name of the block
  102543. */
  102544. get name(): string;
  102545. /**
  102546. * Sets the name of the block. Will check if the name is valid.
  102547. */
  102548. set name(newName: string);
  102549. /**
  102550. * Gets or sets the unique id of the node
  102551. */
  102552. uniqueId: number;
  102553. /**
  102554. * Gets or sets the comments associated with this block
  102555. */
  102556. comments: string;
  102557. /**
  102558. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102559. */
  102560. get isUnique(): boolean;
  102561. /**
  102562. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102563. */
  102564. get isFinalMerger(): boolean;
  102565. /**
  102566. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102567. */
  102568. get isInput(): boolean;
  102569. /**
  102570. * Gets or sets the build Id
  102571. */
  102572. get buildId(): number;
  102573. set buildId(value: number);
  102574. /**
  102575. * Gets or sets the target of the block
  102576. */
  102577. get target(): NodeMaterialBlockTargets;
  102578. set target(value: NodeMaterialBlockTargets);
  102579. /**
  102580. * Gets the list of input points
  102581. */
  102582. get inputs(): NodeMaterialConnectionPoint[];
  102583. /** Gets the list of output points */
  102584. get outputs(): NodeMaterialConnectionPoint[];
  102585. /**
  102586. * Find an input by its name
  102587. * @param name defines the name of the input to look for
  102588. * @returns the input or null if not found
  102589. */
  102590. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102591. /**
  102592. * Find an output by its name
  102593. * @param name defines the name of the outputto look for
  102594. * @returns the output or null if not found
  102595. */
  102596. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102597. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102598. visibleInInspector: boolean;
  102599. /**
  102600. * Creates a new NodeMaterialBlock
  102601. * @param name defines the block name
  102602. * @param target defines the target of that block (Vertex by default)
  102603. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102604. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102605. */
  102606. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102607. /**
  102608. * Initialize the block and prepare the context for build
  102609. * @param state defines the state that will be used for the build
  102610. */
  102611. initialize(state: NodeMaterialBuildState): void;
  102612. /**
  102613. * Bind data to effect. Will only be called for blocks with isBindable === true
  102614. * @param effect defines the effect to bind data to
  102615. * @param nodeMaterial defines the hosting NodeMaterial
  102616. * @param mesh defines the mesh that will be rendered
  102617. * @param subMesh defines the submesh that will be rendered
  102618. */
  102619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102620. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102621. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102622. protected _writeFloat(value: number): string;
  102623. /**
  102624. * Gets the current class name e.g. "NodeMaterialBlock"
  102625. * @returns the class name
  102626. */
  102627. getClassName(): string;
  102628. /**
  102629. * Register a new input. Must be called inside a block constructor
  102630. * @param name defines the connection point name
  102631. * @param type defines the connection point type
  102632. * @param isOptional defines a boolean indicating that this input can be omitted
  102633. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102634. * @param point an already created connection point. If not provided, create a new one
  102635. * @returns the current block
  102636. */
  102637. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102638. /**
  102639. * Register a new output. Must be called inside a block constructor
  102640. * @param name defines the connection point name
  102641. * @param type defines the connection point type
  102642. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102643. * @param point an already created connection point. If not provided, create a new one
  102644. * @returns the current block
  102645. */
  102646. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102647. /**
  102648. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102649. * @param forOutput defines an optional connection point to check compatibility with
  102650. * @returns the first available input or null
  102651. */
  102652. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102653. /**
  102654. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102655. * @param forBlock defines an optional block to check compatibility with
  102656. * @returns the first available input or null
  102657. */
  102658. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102659. /**
  102660. * Gets the sibling of the given output
  102661. * @param current defines the current output
  102662. * @returns the next output in the list or null
  102663. */
  102664. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102665. /**
  102666. * Connect current block with another block
  102667. * @param other defines the block to connect with
  102668. * @param options define the various options to help pick the right connections
  102669. * @returns the current block
  102670. */
  102671. connectTo(other: NodeMaterialBlock, options?: {
  102672. input?: string;
  102673. output?: string;
  102674. outputSwizzle?: string;
  102675. }): this | undefined;
  102676. protected _buildBlock(state: NodeMaterialBuildState): void;
  102677. /**
  102678. * Add uniforms, samplers and uniform buffers at compilation time
  102679. * @param state defines the state to update
  102680. * @param nodeMaterial defines the node material requesting the update
  102681. * @param defines defines the material defines to update
  102682. * @param uniformBuffers defines the list of uniform buffer names
  102683. */
  102684. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102685. /**
  102686. * Add potential fallbacks if shader compilation fails
  102687. * @param mesh defines the mesh to be rendered
  102688. * @param fallbacks defines the current prioritized list of fallbacks
  102689. */
  102690. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102691. /**
  102692. * Initialize defines for shader compilation
  102693. * @param mesh defines the mesh to be rendered
  102694. * @param nodeMaterial defines the node material requesting the update
  102695. * @param defines defines the material defines to update
  102696. * @param useInstances specifies that instances should be used
  102697. */
  102698. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102699. /**
  102700. * Update defines for shader compilation
  102701. * @param mesh defines the mesh to be rendered
  102702. * @param nodeMaterial defines the node material requesting the update
  102703. * @param defines defines the material defines to update
  102704. * @param useInstances specifies that instances should be used
  102705. * @param subMesh defines which submesh to render
  102706. */
  102707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102708. /**
  102709. * Lets the block try to connect some inputs automatically
  102710. * @param material defines the hosting NodeMaterial
  102711. */
  102712. autoConfigure(material: NodeMaterial): void;
  102713. /**
  102714. * Function called when a block is declared as repeatable content generator
  102715. * @param vertexShaderState defines the current compilation state for the vertex shader
  102716. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102717. * @param mesh defines the mesh to be rendered
  102718. * @param defines defines the material defines to update
  102719. */
  102720. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102721. /**
  102722. * Checks if the block is ready
  102723. * @param mesh defines the mesh to be rendered
  102724. * @param nodeMaterial defines the node material requesting the update
  102725. * @param defines defines the material defines to update
  102726. * @param useInstances specifies that instances should be used
  102727. * @returns true if the block is ready
  102728. */
  102729. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102730. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102731. private _processBuild;
  102732. /**
  102733. * Validates the new name for the block node.
  102734. * @param newName the new name to be given to the node.
  102735. * @returns false if the name is a reserve word, else true.
  102736. */
  102737. validateBlockName(newName: string): boolean;
  102738. /**
  102739. * Compile the current node and generate the shader code
  102740. * @param state defines the current compilation state (uniforms, samplers, current string)
  102741. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102742. * @returns true if already built
  102743. */
  102744. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102745. protected _inputRename(name: string): string;
  102746. protected _outputRename(name: string): string;
  102747. protected _dumpPropertiesCode(): string;
  102748. /** @hidden */
  102749. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102750. /** @hidden */
  102751. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102752. /**
  102753. * Clone the current block to a new identical block
  102754. * @param scene defines the hosting scene
  102755. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102756. * @returns a copy of the current block
  102757. */
  102758. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102759. /**
  102760. * Serializes this block in a JSON representation
  102761. * @returns the serialized block object
  102762. */
  102763. serialize(): any;
  102764. /** @hidden */
  102765. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102766. private _deserializePortDisplayNamesAndExposedOnFrame;
  102767. /**
  102768. * Release resources
  102769. */
  102770. dispose(): void;
  102771. }
  102772. }
  102773. declare module BABYLON {
  102774. /**
  102775. * Base class of materials working in push mode in babylon JS
  102776. * @hidden
  102777. */
  102778. export class PushMaterial extends Material {
  102779. protected _activeEffect: Effect;
  102780. protected _normalMatrix: Matrix;
  102781. constructor(name: string, scene: Scene);
  102782. getEffect(): Effect;
  102783. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102784. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102785. /**
  102786. * Binds the given world matrix to the active effect
  102787. *
  102788. * @param world the matrix to bind
  102789. */
  102790. bindOnlyWorldMatrix(world: Matrix): void;
  102791. /**
  102792. * Binds the given normal matrix to the active effect
  102793. *
  102794. * @param normalMatrix the matrix to bind
  102795. */
  102796. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102797. bind(world: Matrix, mesh?: Mesh): void;
  102798. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102799. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102800. }
  102801. }
  102802. declare module BABYLON {
  102803. /**
  102804. * Root class for all node material optimizers
  102805. */
  102806. export class NodeMaterialOptimizer {
  102807. /**
  102808. * Function used to optimize a NodeMaterial graph
  102809. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102810. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102811. */
  102812. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102813. }
  102814. }
  102815. declare module BABYLON {
  102816. /**
  102817. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102818. */
  102819. export class TransformBlock extends NodeMaterialBlock {
  102820. /**
  102821. * Defines the value to use to complement W value to transform it to a Vector4
  102822. */
  102823. complementW: number;
  102824. /**
  102825. * Defines the value to use to complement z value to transform it to a Vector4
  102826. */
  102827. complementZ: number;
  102828. /**
  102829. * Creates a new TransformBlock
  102830. * @param name defines the block name
  102831. */
  102832. constructor(name: string);
  102833. /**
  102834. * Gets the current class name
  102835. * @returns the class name
  102836. */
  102837. getClassName(): string;
  102838. /**
  102839. * Gets the vector input
  102840. */
  102841. get vector(): NodeMaterialConnectionPoint;
  102842. /**
  102843. * Gets the output component
  102844. */
  102845. get output(): NodeMaterialConnectionPoint;
  102846. /**
  102847. * Gets the xyz output component
  102848. */
  102849. get xyz(): NodeMaterialConnectionPoint;
  102850. /**
  102851. * Gets the matrix transform input
  102852. */
  102853. get transform(): NodeMaterialConnectionPoint;
  102854. protected _buildBlock(state: NodeMaterialBuildState): this;
  102855. /**
  102856. * Update defines for shader compilation
  102857. * @param mesh defines the mesh to be rendered
  102858. * @param nodeMaterial defines the node material requesting the update
  102859. * @param defines defines the material defines to update
  102860. * @param useInstances specifies that instances should be used
  102861. * @param subMesh defines which submesh to render
  102862. */
  102863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102864. serialize(): any;
  102865. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102866. protected _dumpPropertiesCode(): string;
  102867. }
  102868. }
  102869. declare module BABYLON {
  102870. /**
  102871. * Block used to output the vertex position
  102872. */
  102873. export class VertexOutputBlock extends NodeMaterialBlock {
  102874. /**
  102875. * Creates a new VertexOutputBlock
  102876. * @param name defines the block name
  102877. */
  102878. constructor(name: string);
  102879. /**
  102880. * Gets the current class name
  102881. * @returns the class name
  102882. */
  102883. getClassName(): string;
  102884. /**
  102885. * Gets the vector input component
  102886. */
  102887. get vector(): NodeMaterialConnectionPoint;
  102888. protected _buildBlock(state: NodeMaterialBuildState): this;
  102889. }
  102890. }
  102891. declare module BABYLON {
  102892. /**
  102893. * Block used to output the final color
  102894. */
  102895. export class FragmentOutputBlock extends NodeMaterialBlock {
  102896. /**
  102897. * Create a new FragmentOutputBlock
  102898. * @param name defines the block name
  102899. */
  102900. constructor(name: string);
  102901. /**
  102902. * Gets the current class name
  102903. * @returns the class name
  102904. */
  102905. getClassName(): string;
  102906. /**
  102907. * Gets the rgba input component
  102908. */
  102909. get rgba(): NodeMaterialConnectionPoint;
  102910. /**
  102911. * Gets the rgb input component
  102912. */
  102913. get rgb(): NodeMaterialConnectionPoint;
  102914. /**
  102915. * Gets the a input component
  102916. */
  102917. get a(): NodeMaterialConnectionPoint;
  102918. protected _buildBlock(state: NodeMaterialBuildState): this;
  102919. }
  102920. }
  102921. declare module BABYLON {
  102922. /**
  102923. * Block used for the particle ramp gradient section
  102924. */
  102925. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102926. /**
  102927. * Create a new ParticleRampGradientBlock
  102928. * @param name defines the block name
  102929. */
  102930. constructor(name: string);
  102931. /**
  102932. * Gets the current class name
  102933. * @returns the class name
  102934. */
  102935. getClassName(): string;
  102936. /**
  102937. * Gets the color input component
  102938. */
  102939. get color(): NodeMaterialConnectionPoint;
  102940. /**
  102941. * Gets the rampColor output component
  102942. */
  102943. get rampColor(): NodeMaterialConnectionPoint;
  102944. /**
  102945. * Initialize the block and prepare the context for build
  102946. * @param state defines the state that will be used for the build
  102947. */
  102948. initialize(state: NodeMaterialBuildState): void;
  102949. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102950. }
  102951. }
  102952. declare module BABYLON {
  102953. /**
  102954. * Block used for the particle blend multiply section
  102955. */
  102956. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102957. /**
  102958. * Create a new ParticleBlendMultiplyBlock
  102959. * @param name defines the block name
  102960. */
  102961. constructor(name: string);
  102962. /**
  102963. * Gets the current class name
  102964. * @returns the class name
  102965. */
  102966. getClassName(): string;
  102967. /**
  102968. * Gets the color input component
  102969. */
  102970. get color(): NodeMaterialConnectionPoint;
  102971. /**
  102972. * Gets the alphaTexture input component
  102973. */
  102974. get alphaTexture(): NodeMaterialConnectionPoint;
  102975. /**
  102976. * Gets the alphaColor input component
  102977. */
  102978. get alphaColor(): NodeMaterialConnectionPoint;
  102979. /**
  102980. * Gets the blendColor output component
  102981. */
  102982. get blendColor(): NodeMaterialConnectionPoint;
  102983. /**
  102984. * Initialize the block and prepare the context for build
  102985. * @param state defines the state that will be used for the build
  102986. */
  102987. initialize(state: NodeMaterialBuildState): void;
  102988. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102989. }
  102990. }
  102991. declare module BABYLON {
  102992. /**
  102993. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102994. */
  102995. export class VectorMergerBlock extends NodeMaterialBlock {
  102996. /**
  102997. * Create a new VectorMergerBlock
  102998. * @param name defines the block name
  102999. */
  103000. constructor(name: string);
  103001. /**
  103002. * Gets the current class name
  103003. * @returns the class name
  103004. */
  103005. getClassName(): string;
  103006. /**
  103007. * Gets the xyz component (input)
  103008. */
  103009. get xyzIn(): NodeMaterialConnectionPoint;
  103010. /**
  103011. * Gets the xy component (input)
  103012. */
  103013. get xyIn(): NodeMaterialConnectionPoint;
  103014. /**
  103015. * Gets the x component (input)
  103016. */
  103017. get x(): NodeMaterialConnectionPoint;
  103018. /**
  103019. * Gets the y component (input)
  103020. */
  103021. get y(): NodeMaterialConnectionPoint;
  103022. /**
  103023. * Gets the z component (input)
  103024. */
  103025. get z(): NodeMaterialConnectionPoint;
  103026. /**
  103027. * Gets the w component (input)
  103028. */
  103029. get w(): NodeMaterialConnectionPoint;
  103030. /**
  103031. * Gets the xyzw component (output)
  103032. */
  103033. get xyzw(): NodeMaterialConnectionPoint;
  103034. /**
  103035. * Gets the xyz component (output)
  103036. */
  103037. get xyzOut(): NodeMaterialConnectionPoint;
  103038. /**
  103039. * Gets the xy component (output)
  103040. */
  103041. get xyOut(): NodeMaterialConnectionPoint;
  103042. /**
  103043. * Gets the xy component (output)
  103044. * @deprecated Please use xyOut instead.
  103045. */
  103046. get xy(): NodeMaterialConnectionPoint;
  103047. /**
  103048. * Gets the xyz component (output)
  103049. * @deprecated Please use xyzOut instead.
  103050. */
  103051. get xyz(): NodeMaterialConnectionPoint;
  103052. protected _buildBlock(state: NodeMaterialBuildState): this;
  103053. }
  103054. }
  103055. declare module BABYLON {
  103056. /**
  103057. * Block used to remap a float from a range to a new one
  103058. */
  103059. export class RemapBlock extends NodeMaterialBlock {
  103060. /**
  103061. * Gets or sets the source range
  103062. */
  103063. sourceRange: Vector2;
  103064. /**
  103065. * Gets or sets the target range
  103066. */
  103067. targetRange: Vector2;
  103068. /**
  103069. * Creates a new RemapBlock
  103070. * @param name defines the block name
  103071. */
  103072. constructor(name: string);
  103073. /**
  103074. * Gets the current class name
  103075. * @returns the class name
  103076. */
  103077. getClassName(): string;
  103078. /**
  103079. * Gets the input component
  103080. */
  103081. get input(): NodeMaterialConnectionPoint;
  103082. /**
  103083. * Gets the source min input component
  103084. */
  103085. get sourceMin(): NodeMaterialConnectionPoint;
  103086. /**
  103087. * Gets the source max input component
  103088. */
  103089. get sourceMax(): NodeMaterialConnectionPoint;
  103090. /**
  103091. * Gets the target min input component
  103092. */
  103093. get targetMin(): NodeMaterialConnectionPoint;
  103094. /**
  103095. * Gets the target max input component
  103096. */
  103097. get targetMax(): NodeMaterialConnectionPoint;
  103098. /**
  103099. * Gets the output component
  103100. */
  103101. get output(): NodeMaterialConnectionPoint;
  103102. protected _buildBlock(state: NodeMaterialBuildState): this;
  103103. protected _dumpPropertiesCode(): string;
  103104. serialize(): any;
  103105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103106. }
  103107. }
  103108. declare module BABYLON {
  103109. /**
  103110. * Block used to multiply 2 values
  103111. */
  103112. export class MultiplyBlock extends NodeMaterialBlock {
  103113. /**
  103114. * Creates a new MultiplyBlock
  103115. * @param name defines the block name
  103116. */
  103117. constructor(name: string);
  103118. /**
  103119. * Gets the current class name
  103120. * @returns the class name
  103121. */
  103122. getClassName(): string;
  103123. /**
  103124. * Gets the left operand input component
  103125. */
  103126. get left(): NodeMaterialConnectionPoint;
  103127. /**
  103128. * Gets the right operand input component
  103129. */
  103130. get right(): NodeMaterialConnectionPoint;
  103131. /**
  103132. * Gets the output component
  103133. */
  103134. get output(): NodeMaterialConnectionPoint;
  103135. protected _buildBlock(state: NodeMaterialBuildState): this;
  103136. }
  103137. }
  103138. declare module BABYLON {
  103139. /**
  103140. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103141. */
  103142. export class ColorSplitterBlock extends NodeMaterialBlock {
  103143. /**
  103144. * Create a new ColorSplitterBlock
  103145. * @param name defines the block name
  103146. */
  103147. constructor(name: string);
  103148. /**
  103149. * Gets the current class name
  103150. * @returns the class name
  103151. */
  103152. getClassName(): string;
  103153. /**
  103154. * Gets the rgba component (input)
  103155. */
  103156. get rgba(): NodeMaterialConnectionPoint;
  103157. /**
  103158. * Gets the rgb component (input)
  103159. */
  103160. get rgbIn(): NodeMaterialConnectionPoint;
  103161. /**
  103162. * Gets the rgb component (output)
  103163. */
  103164. get rgbOut(): NodeMaterialConnectionPoint;
  103165. /**
  103166. * Gets the r component (output)
  103167. */
  103168. get r(): NodeMaterialConnectionPoint;
  103169. /**
  103170. * Gets the g component (output)
  103171. */
  103172. get g(): NodeMaterialConnectionPoint;
  103173. /**
  103174. * Gets the b component (output)
  103175. */
  103176. get b(): NodeMaterialConnectionPoint;
  103177. /**
  103178. * Gets the a component (output)
  103179. */
  103180. get a(): NodeMaterialConnectionPoint;
  103181. protected _inputRename(name: string): string;
  103182. protected _outputRename(name: string): string;
  103183. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103184. }
  103185. }
  103186. declare module BABYLON {
  103187. /**
  103188. * Operations supported by the Trigonometry block
  103189. */
  103190. export enum TrigonometryBlockOperations {
  103191. /** Cos */
  103192. Cos = 0,
  103193. /** Sin */
  103194. Sin = 1,
  103195. /** Abs */
  103196. Abs = 2,
  103197. /** Exp */
  103198. Exp = 3,
  103199. /** Exp2 */
  103200. Exp2 = 4,
  103201. /** Round */
  103202. Round = 5,
  103203. /** Floor */
  103204. Floor = 6,
  103205. /** Ceiling */
  103206. Ceiling = 7,
  103207. /** Square root */
  103208. Sqrt = 8,
  103209. /** Log */
  103210. Log = 9,
  103211. /** Tangent */
  103212. Tan = 10,
  103213. /** Arc tangent */
  103214. ArcTan = 11,
  103215. /** Arc cosinus */
  103216. ArcCos = 12,
  103217. /** Arc sinus */
  103218. ArcSin = 13,
  103219. /** Fraction */
  103220. Fract = 14,
  103221. /** Sign */
  103222. Sign = 15,
  103223. /** To radians (from degrees) */
  103224. Radians = 16,
  103225. /** To degrees (from radians) */
  103226. Degrees = 17
  103227. }
  103228. /**
  103229. * Block used to apply trigonometry operation to floats
  103230. */
  103231. export class TrigonometryBlock extends NodeMaterialBlock {
  103232. /**
  103233. * Gets or sets the operation applied by the block
  103234. */
  103235. operation: TrigonometryBlockOperations;
  103236. /**
  103237. * Creates a new TrigonometryBlock
  103238. * @param name defines the block name
  103239. */
  103240. constructor(name: string);
  103241. /**
  103242. * Gets the current class name
  103243. * @returns the class name
  103244. */
  103245. getClassName(): string;
  103246. /**
  103247. * Gets the input component
  103248. */
  103249. get input(): NodeMaterialConnectionPoint;
  103250. /**
  103251. * Gets the output component
  103252. */
  103253. get output(): NodeMaterialConnectionPoint;
  103254. protected _buildBlock(state: NodeMaterialBuildState): this;
  103255. serialize(): any;
  103256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103257. protected _dumpPropertiesCode(): string;
  103258. }
  103259. }
  103260. declare module BABYLON {
  103261. /**
  103262. * Interface used to configure the node material editor
  103263. */
  103264. export interface INodeMaterialEditorOptions {
  103265. /** Define the URl to load node editor script */
  103266. editorURL?: string;
  103267. }
  103268. /** @hidden */
  103269. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103270. NORMAL: boolean;
  103271. TANGENT: boolean;
  103272. UV1: boolean;
  103273. /** BONES */
  103274. NUM_BONE_INFLUENCERS: number;
  103275. BonesPerMesh: number;
  103276. BONETEXTURE: boolean;
  103277. /** MORPH TARGETS */
  103278. MORPHTARGETS: boolean;
  103279. MORPHTARGETS_NORMAL: boolean;
  103280. MORPHTARGETS_TANGENT: boolean;
  103281. MORPHTARGETS_UV: boolean;
  103282. NUM_MORPH_INFLUENCERS: number;
  103283. /** IMAGE PROCESSING */
  103284. IMAGEPROCESSING: boolean;
  103285. VIGNETTE: boolean;
  103286. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103287. VIGNETTEBLENDMODEOPAQUE: boolean;
  103288. TONEMAPPING: boolean;
  103289. TONEMAPPING_ACES: boolean;
  103290. CONTRAST: boolean;
  103291. EXPOSURE: boolean;
  103292. COLORCURVES: boolean;
  103293. COLORGRADING: boolean;
  103294. COLORGRADING3D: boolean;
  103295. SAMPLER3DGREENDEPTH: boolean;
  103296. SAMPLER3DBGRMAP: boolean;
  103297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103298. /** MISC. */
  103299. BUMPDIRECTUV: number;
  103300. constructor();
  103301. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103302. }
  103303. /**
  103304. * Class used to configure NodeMaterial
  103305. */
  103306. export interface INodeMaterialOptions {
  103307. /**
  103308. * Defines if blocks should emit comments
  103309. */
  103310. emitComments: boolean;
  103311. }
  103312. /**
  103313. * Class used to create a node based material built by assembling shader blocks
  103314. */
  103315. export class NodeMaterial extends PushMaterial {
  103316. private static _BuildIdGenerator;
  103317. private _options;
  103318. private _vertexCompilationState;
  103319. private _fragmentCompilationState;
  103320. private _sharedData;
  103321. private _buildId;
  103322. private _buildWasSuccessful;
  103323. private _cachedWorldViewMatrix;
  103324. private _cachedWorldViewProjectionMatrix;
  103325. private _optimizers;
  103326. private _animationFrame;
  103327. /** Define the Url to load node editor script */
  103328. static EditorURL: string;
  103329. /** Define the Url to load snippets */
  103330. static SnippetUrl: string;
  103331. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103332. static IgnoreTexturesAtLoadTime: boolean;
  103333. private BJSNODEMATERIALEDITOR;
  103334. /** Get the inspector from bundle or global */
  103335. private _getGlobalNodeMaterialEditor;
  103336. /**
  103337. * Snippet ID if the material was created from the snippet server
  103338. */
  103339. snippetId: string;
  103340. /**
  103341. * Gets or sets data used by visual editor
  103342. * @see https://nme.babylonjs.com
  103343. */
  103344. editorData: any;
  103345. /**
  103346. * 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)
  103347. */
  103348. ignoreAlpha: boolean;
  103349. /**
  103350. * Defines the maximum number of lights that can be used in the material
  103351. */
  103352. maxSimultaneousLights: number;
  103353. /**
  103354. * Observable raised when the material is built
  103355. */
  103356. onBuildObservable: Observable<NodeMaterial>;
  103357. /**
  103358. * Gets or sets the root nodes of the material vertex shader
  103359. */
  103360. _vertexOutputNodes: NodeMaterialBlock[];
  103361. /**
  103362. * Gets or sets the root nodes of the material fragment (pixel) shader
  103363. */
  103364. _fragmentOutputNodes: NodeMaterialBlock[];
  103365. /** Gets or sets options to control the node material overall behavior */
  103366. get options(): INodeMaterialOptions;
  103367. set options(options: INodeMaterialOptions);
  103368. /**
  103369. * Default configuration related to image processing available in the standard Material.
  103370. */
  103371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103372. /**
  103373. * Gets the image processing configuration used either in this material.
  103374. */
  103375. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103376. /**
  103377. * Sets the Default image processing configuration used either in the this material.
  103378. *
  103379. * If sets to null, the scene one is in use.
  103380. */
  103381. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103382. /**
  103383. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103384. */
  103385. attachedBlocks: NodeMaterialBlock[];
  103386. /**
  103387. * Specifies the mode of the node material
  103388. * @hidden
  103389. */
  103390. _mode: NodeMaterialModes;
  103391. /**
  103392. * Gets the mode property
  103393. */
  103394. get mode(): NodeMaterialModes;
  103395. /**
  103396. * Create a new node based material
  103397. * @param name defines the material name
  103398. * @param scene defines the hosting scene
  103399. * @param options defines creation option
  103400. */
  103401. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103402. /**
  103403. * Gets the current class name of the material e.g. "NodeMaterial"
  103404. * @returns the class name
  103405. */
  103406. getClassName(): string;
  103407. /**
  103408. * Keep track of the image processing observer to allow dispose and replace.
  103409. */
  103410. private _imageProcessingObserver;
  103411. /**
  103412. * Attaches a new image processing configuration to the Standard Material.
  103413. * @param configuration
  103414. */
  103415. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103416. /**
  103417. * Get a block by its name
  103418. * @param name defines the name of the block to retrieve
  103419. * @returns the required block or null if not found
  103420. */
  103421. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103422. /**
  103423. * Get a block by its name
  103424. * @param predicate defines the predicate used to find the good candidate
  103425. * @returns the required block or null if not found
  103426. */
  103427. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103428. /**
  103429. * Get an input block by its name
  103430. * @param predicate defines the predicate used to find the good candidate
  103431. * @returns the required input block or null if not found
  103432. */
  103433. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103434. /**
  103435. * Gets the list of input blocks attached to this material
  103436. * @returns an array of InputBlocks
  103437. */
  103438. getInputBlocks(): InputBlock[];
  103439. /**
  103440. * Adds a new optimizer to the list of optimizers
  103441. * @param optimizer defines the optimizers to add
  103442. * @returns the current material
  103443. */
  103444. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103445. /**
  103446. * Remove an optimizer from the list of optimizers
  103447. * @param optimizer defines the optimizers to remove
  103448. * @returns the current material
  103449. */
  103450. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103451. /**
  103452. * Add a new block to the list of output nodes
  103453. * @param node defines the node to add
  103454. * @returns the current material
  103455. */
  103456. addOutputNode(node: NodeMaterialBlock): this;
  103457. /**
  103458. * Remove a block from the list of root nodes
  103459. * @param node defines the node to remove
  103460. * @returns the current material
  103461. */
  103462. removeOutputNode(node: NodeMaterialBlock): this;
  103463. private _addVertexOutputNode;
  103464. private _removeVertexOutputNode;
  103465. private _addFragmentOutputNode;
  103466. private _removeFragmentOutputNode;
  103467. /**
  103468. * Specifies if the material will require alpha blending
  103469. * @returns a boolean specifying if alpha blending is needed
  103470. */
  103471. needAlphaBlending(): boolean;
  103472. /**
  103473. * Specifies if this material should be rendered in alpha test mode
  103474. * @returns a boolean specifying if an alpha test is needed.
  103475. */
  103476. needAlphaTesting(): boolean;
  103477. private _initializeBlock;
  103478. private _resetDualBlocks;
  103479. /**
  103480. * Remove a block from the current node material
  103481. * @param block defines the block to remove
  103482. */
  103483. removeBlock(block: NodeMaterialBlock): void;
  103484. /**
  103485. * Build the material and generates the inner effect
  103486. * @param verbose defines if the build should log activity
  103487. */
  103488. build(verbose?: boolean): void;
  103489. /**
  103490. * Runs an otpimization phase to try to improve the shader code
  103491. */
  103492. optimize(): void;
  103493. private _prepareDefinesForAttributes;
  103494. /**
  103495. * Create a post process from the material
  103496. * @param camera The camera to apply the render pass to.
  103497. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103499. * @param engine The engine which the post process will be applied. (default: current engine)
  103500. * @param reusable If the post process can be reused on the same frame. (default: false)
  103501. * @param textureType Type of textures used when performing the post process. (default: 0)
  103502. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103503. * @returns the post process created
  103504. */
  103505. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103506. /**
  103507. * Create the post process effect from the material
  103508. * @param postProcess The post process to create the effect for
  103509. */
  103510. createEffectForPostProcess(postProcess: PostProcess): void;
  103511. private _createEffectForPostProcess;
  103512. /**
  103513. * Create a new procedural texture based on this node material
  103514. * @param size defines the size of the texture
  103515. * @param scene defines the hosting scene
  103516. * @returns the new procedural texture attached to this node material
  103517. */
  103518. createProceduralTexture(size: number | {
  103519. width: number;
  103520. height: number;
  103521. layers?: number;
  103522. }, scene: Scene): Nullable<ProceduralTexture>;
  103523. private _createEffectForParticles;
  103524. private _checkInternals;
  103525. /**
  103526. * Create the effect to be used as the custom effect for a particle system
  103527. * @param particleSystem Particle system to create the effect for
  103528. * @param onCompiled defines a function to call when the effect creation is successful
  103529. * @param onError defines a function to call when the effect creation has failed
  103530. */
  103531. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103532. private _processDefines;
  103533. /**
  103534. * Get if the submesh is ready to be used and all its information available.
  103535. * Child classes can use it to update shaders
  103536. * @param mesh defines the mesh to check
  103537. * @param subMesh defines which submesh to check
  103538. * @param useInstances specifies that instances should be used
  103539. * @returns a boolean indicating that the submesh is ready or not
  103540. */
  103541. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103542. /**
  103543. * Get a string representing the shaders built by the current node graph
  103544. */
  103545. get compiledShaders(): string;
  103546. /**
  103547. * Binds the world matrix to the material
  103548. * @param world defines the world transformation matrix
  103549. */
  103550. bindOnlyWorldMatrix(world: Matrix): void;
  103551. /**
  103552. * Binds the submesh to this material by preparing the effect and shader to draw
  103553. * @param world defines the world transformation matrix
  103554. * @param mesh defines the mesh containing the submesh
  103555. * @param subMesh defines the submesh to bind the material to
  103556. */
  103557. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103558. /**
  103559. * Gets the active textures from the material
  103560. * @returns an array of textures
  103561. */
  103562. getActiveTextures(): BaseTexture[];
  103563. /**
  103564. * Gets the list of texture blocks
  103565. * @returns an array of texture blocks
  103566. */
  103567. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103568. /**
  103569. * Specifies if the material uses a texture
  103570. * @param texture defines the texture to check against the material
  103571. * @returns a boolean specifying if the material uses the texture
  103572. */
  103573. hasTexture(texture: BaseTexture): boolean;
  103574. /**
  103575. * Disposes the material
  103576. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103577. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103578. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103579. */
  103580. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103581. /** Creates the node editor window. */
  103582. private _createNodeEditor;
  103583. /**
  103584. * Launch the node material editor
  103585. * @param config Define the configuration of the editor
  103586. * @return a promise fulfilled when the node editor is visible
  103587. */
  103588. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103589. /**
  103590. * Clear the current material
  103591. */
  103592. clear(): void;
  103593. /**
  103594. * Clear the current material and set it to a default state
  103595. */
  103596. setToDefault(): void;
  103597. /**
  103598. * Clear the current material and set it to a default state for post process
  103599. */
  103600. setToDefaultPostProcess(): void;
  103601. /**
  103602. * Clear the current material and set it to a default state for procedural texture
  103603. */
  103604. setToDefaultProceduralTexture(): void;
  103605. /**
  103606. * Clear the current material and set it to a default state for particle
  103607. */
  103608. setToDefaultParticle(): void;
  103609. /**
  103610. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103611. * @param url defines the url to load from
  103612. * @returns a promise that will fullfil when the material is fully loaded
  103613. */
  103614. loadAsync(url: string): Promise<void>;
  103615. private _gatherBlocks;
  103616. /**
  103617. * Generate a string containing the code declaration required to create an equivalent of this material
  103618. * @returns a string
  103619. */
  103620. generateCode(): string;
  103621. /**
  103622. * Serializes this material in a JSON representation
  103623. * @returns the serialized material object
  103624. */
  103625. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103626. private _restoreConnections;
  103627. /**
  103628. * Clear the current graph and load a new one from a serialization object
  103629. * @param source defines the JSON representation of the material
  103630. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103631. * @param merge defines whether or not the source must be merged or replace the current content
  103632. */
  103633. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103634. /**
  103635. * Makes a duplicate of the current material.
  103636. * @param name - name to use for the new material.
  103637. */
  103638. clone(name: string): NodeMaterial;
  103639. /**
  103640. * Creates a node material from parsed material data
  103641. * @param source defines the JSON representation of the material
  103642. * @param scene defines the hosting scene
  103643. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103644. * @returns a new node material
  103645. */
  103646. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103647. /**
  103648. * Creates a node material from a snippet saved in a remote file
  103649. * @param name defines the name of the material to create
  103650. * @param url defines the url to load from
  103651. * @param scene defines the hosting scene
  103652. * @returns a promise that will resolve to the new node material
  103653. */
  103654. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103655. /**
  103656. * Creates a node material from a snippet saved by the node material editor
  103657. * @param snippetId defines the snippet to load
  103658. * @param scene defines the hosting scene
  103659. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103660. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103661. * @returns a promise that will resolve to the new node material
  103662. */
  103663. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103664. /**
  103665. * Creates a new node material set to default basic configuration
  103666. * @param name defines the name of the material
  103667. * @param scene defines the hosting scene
  103668. * @returns a new NodeMaterial
  103669. */
  103670. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103671. }
  103672. }
  103673. declare module BABYLON {
  103674. interface ThinEngine {
  103675. /**
  103676. * Unbind a list of render target textures from the webGL context
  103677. * This is used only when drawBuffer extension or webGL2 are active
  103678. * @param textures defines the render target textures to unbind
  103679. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103680. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103681. */
  103682. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103683. /**
  103684. * Create a multi render target texture
  103685. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103686. * @param size defines the size of the texture
  103687. * @param options defines the creation options
  103688. * @returns the cube texture as an InternalTexture
  103689. */
  103690. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103691. /**
  103692. * Update the sample count for a given multiple render target texture
  103693. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103694. * @param textures defines the textures to update
  103695. * @param samples defines the sample count to set
  103696. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103697. */
  103698. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103699. /**
  103700. * Select a subsets of attachments to draw to.
  103701. * @param attachments gl attachments
  103702. */
  103703. bindAttachments(attachments: number[]): void;
  103704. /**
  103705. * Creates a layout object to draw/clear on specific textures in a MRT
  103706. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103707. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103708. */
  103709. buildTextureLayout(textureStatus: boolean[]): number[];
  103710. /**
  103711. * Restores the webgl state to only draw on the main color attachment
  103712. */
  103713. restoreSingleAttachment(): void;
  103714. }
  103715. }
  103716. declare module BABYLON {
  103717. /**
  103718. * Creation options of the multi render target texture.
  103719. */
  103720. export interface IMultiRenderTargetOptions {
  103721. /**
  103722. * Define if the texture needs to create mip maps after render.
  103723. */
  103724. generateMipMaps?: boolean;
  103725. /**
  103726. * Define the types of all the draw buffers we want to create
  103727. */
  103728. types?: number[];
  103729. /**
  103730. * Define the sampling modes of all the draw buffers we want to create
  103731. */
  103732. samplingModes?: number[];
  103733. /**
  103734. * Define if a depth buffer is required
  103735. */
  103736. generateDepthBuffer?: boolean;
  103737. /**
  103738. * Define if a stencil buffer is required
  103739. */
  103740. generateStencilBuffer?: boolean;
  103741. /**
  103742. * Define if a depth texture is required instead of a depth buffer
  103743. */
  103744. generateDepthTexture?: boolean;
  103745. /**
  103746. * Define the number of desired draw buffers
  103747. */
  103748. textureCount?: number;
  103749. /**
  103750. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103751. */
  103752. doNotChangeAspectRatio?: boolean;
  103753. /**
  103754. * Define the default type of the buffers we are creating
  103755. */
  103756. defaultType?: number;
  103757. }
  103758. /**
  103759. * A multi render target, like a render target provides the ability to render to a texture.
  103760. * Unlike the render target, it can render to several draw buffers in one draw.
  103761. * This is specially interesting in deferred rendering or for any effects requiring more than
  103762. * just one color from a single pass.
  103763. */
  103764. export class MultiRenderTarget extends RenderTargetTexture {
  103765. private _internalTextures;
  103766. private _textures;
  103767. private _multiRenderTargetOptions;
  103768. private _count;
  103769. /**
  103770. * Get if draw buffers are currently supported by the used hardware and browser.
  103771. */
  103772. get isSupported(): boolean;
  103773. /**
  103774. * Get the list of textures generated by the multi render target.
  103775. */
  103776. get textures(): Texture[];
  103777. /**
  103778. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103779. */
  103780. get count(): number;
  103781. /**
  103782. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103783. */
  103784. get depthTexture(): Texture;
  103785. /**
  103786. * Set the wrapping mode on U of all the textures we are rendering to.
  103787. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103788. */
  103789. set wrapU(wrap: number);
  103790. /**
  103791. * Set the wrapping mode on V of all the textures we are rendering to.
  103792. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103793. */
  103794. set wrapV(wrap: number);
  103795. /**
  103796. * Instantiate a new multi render target texture.
  103797. * A multi render target, like a render target provides the ability to render to a texture.
  103798. * Unlike the render target, it can render to several draw buffers in one draw.
  103799. * This is specially interesting in deferred rendering or for any effects requiring more than
  103800. * just one color from a single pass.
  103801. * @param name Define the name of the texture
  103802. * @param size Define the size of the buffers to render to
  103803. * @param count Define the number of target we are rendering into
  103804. * @param scene Define the scene the texture belongs to
  103805. * @param options Define the options used to create the multi render target
  103806. */
  103807. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103808. private _initTypes;
  103809. /** @hidden */
  103810. _rebuild(forceFullRebuild?: boolean): void;
  103811. private _createInternalTextures;
  103812. private _createTextures;
  103813. /**
  103814. * Replaces a texture within the MRT.
  103815. * @param texture The new texture to insert in the MRT
  103816. * @param index The index of the texture to replace
  103817. */
  103818. replaceTexture(texture: Texture, index: number): void;
  103819. /**
  103820. * Define the number of samples used if MSAA is enabled.
  103821. */
  103822. get samples(): number;
  103823. set samples(value: number);
  103824. /**
  103825. * Resize all the textures in the multi render target.
  103826. * Be careful as it will recreate all the data in the new texture.
  103827. * @param size Define the new size
  103828. */
  103829. resize(size: any): void;
  103830. /**
  103831. * Changes the number of render targets in this MRT
  103832. * Be careful as it will recreate all the data in the new texture.
  103833. * @param count new texture count
  103834. * @param options Specifies texture types and sampling modes for new textures
  103835. */
  103836. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103837. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103838. /**
  103839. * Dispose the render targets and their associated resources
  103840. */
  103841. dispose(): void;
  103842. /**
  103843. * Release all the underlying texture used as draw buffers.
  103844. */
  103845. releaseInternalTextures(): void;
  103846. }
  103847. }
  103848. declare module BABYLON {
  103849. /** @hidden */
  103850. export var imageProcessingPixelShader: {
  103851. name: string;
  103852. shader: string;
  103853. };
  103854. }
  103855. declare module BABYLON {
  103856. /**
  103857. * ImageProcessingPostProcess
  103858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103859. */
  103860. export class ImageProcessingPostProcess extends PostProcess {
  103861. /**
  103862. * Default configuration related to image processing available in the PBR Material.
  103863. */
  103864. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103865. /**
  103866. * Gets the image processing configuration used either in this material.
  103867. */
  103868. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103869. /**
  103870. * Sets the Default image processing configuration used either in the this material.
  103871. *
  103872. * If sets to null, the scene one is in use.
  103873. */
  103874. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103875. /**
  103876. * Keep track of the image processing observer to allow dispose and replace.
  103877. */
  103878. private _imageProcessingObserver;
  103879. /**
  103880. * Attaches a new image processing configuration to the PBR Material.
  103881. * @param configuration
  103882. */
  103883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103884. /**
  103885. * If the post process is supported.
  103886. */
  103887. get isSupported(): boolean;
  103888. /**
  103889. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103890. */
  103891. get colorCurves(): Nullable<ColorCurves>;
  103892. /**
  103893. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103894. */
  103895. set colorCurves(value: Nullable<ColorCurves>);
  103896. /**
  103897. * Gets wether the color curves effect is enabled.
  103898. */
  103899. get colorCurvesEnabled(): boolean;
  103900. /**
  103901. * Sets wether the color curves effect is enabled.
  103902. */
  103903. set colorCurvesEnabled(value: boolean);
  103904. /**
  103905. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103906. */
  103907. get colorGradingTexture(): Nullable<BaseTexture>;
  103908. /**
  103909. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103910. */
  103911. set colorGradingTexture(value: Nullable<BaseTexture>);
  103912. /**
  103913. * Gets wether the color grading effect is enabled.
  103914. */
  103915. get colorGradingEnabled(): boolean;
  103916. /**
  103917. * Gets wether the color grading effect is enabled.
  103918. */
  103919. set colorGradingEnabled(value: boolean);
  103920. /**
  103921. * Gets exposure used in the effect.
  103922. */
  103923. get exposure(): number;
  103924. /**
  103925. * Sets exposure used in the effect.
  103926. */
  103927. set exposure(value: number);
  103928. /**
  103929. * Gets wether tonemapping is enabled or not.
  103930. */
  103931. get toneMappingEnabled(): boolean;
  103932. /**
  103933. * Sets wether tonemapping is enabled or not
  103934. */
  103935. set toneMappingEnabled(value: boolean);
  103936. /**
  103937. * Gets the type of tone mapping effect.
  103938. */
  103939. get toneMappingType(): number;
  103940. /**
  103941. * Sets the type of tone mapping effect.
  103942. */
  103943. set toneMappingType(value: number);
  103944. /**
  103945. * Gets contrast used in the effect.
  103946. */
  103947. get contrast(): number;
  103948. /**
  103949. * Sets contrast used in the effect.
  103950. */
  103951. set contrast(value: number);
  103952. /**
  103953. * Gets Vignette stretch size.
  103954. */
  103955. get vignetteStretch(): number;
  103956. /**
  103957. * Sets Vignette stretch size.
  103958. */
  103959. set vignetteStretch(value: number);
  103960. /**
  103961. * Gets Vignette centre X Offset.
  103962. */
  103963. get vignetteCentreX(): number;
  103964. /**
  103965. * Sets Vignette centre X Offset.
  103966. */
  103967. set vignetteCentreX(value: number);
  103968. /**
  103969. * Gets Vignette centre Y Offset.
  103970. */
  103971. get vignetteCentreY(): number;
  103972. /**
  103973. * Sets Vignette centre Y Offset.
  103974. */
  103975. set vignetteCentreY(value: number);
  103976. /**
  103977. * Gets Vignette weight or intensity of the vignette effect.
  103978. */
  103979. get vignetteWeight(): number;
  103980. /**
  103981. * Sets Vignette weight or intensity of the vignette effect.
  103982. */
  103983. set vignetteWeight(value: number);
  103984. /**
  103985. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103986. * if vignetteEnabled is set to true.
  103987. */
  103988. get vignetteColor(): Color4;
  103989. /**
  103990. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103991. * if vignetteEnabled is set to true.
  103992. */
  103993. set vignetteColor(value: Color4);
  103994. /**
  103995. * Gets Camera field of view used by the Vignette effect.
  103996. */
  103997. get vignetteCameraFov(): number;
  103998. /**
  103999. * Sets Camera field of view used by the Vignette effect.
  104000. */
  104001. set vignetteCameraFov(value: number);
  104002. /**
  104003. * Gets the vignette blend mode allowing different kind of effect.
  104004. */
  104005. get vignetteBlendMode(): number;
  104006. /**
  104007. * Sets the vignette blend mode allowing different kind of effect.
  104008. */
  104009. set vignetteBlendMode(value: number);
  104010. /**
  104011. * Gets wether the vignette effect is enabled.
  104012. */
  104013. get vignetteEnabled(): boolean;
  104014. /**
  104015. * Sets wether the vignette effect is enabled.
  104016. */
  104017. set vignetteEnabled(value: boolean);
  104018. private _fromLinearSpace;
  104019. /**
  104020. * Gets wether the input of the processing is in Gamma or Linear Space.
  104021. */
  104022. get fromLinearSpace(): boolean;
  104023. /**
  104024. * Sets wether the input of the processing is in Gamma or Linear Space.
  104025. */
  104026. set fromLinearSpace(value: boolean);
  104027. /**
  104028. * Defines cache preventing GC.
  104029. */
  104030. private _defines;
  104031. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104032. /**
  104033. * "ImageProcessingPostProcess"
  104034. * @returns "ImageProcessingPostProcess"
  104035. */
  104036. getClassName(): string;
  104037. /**
  104038. * @hidden
  104039. */
  104040. _updateParameters(): void;
  104041. dispose(camera?: Camera): void;
  104042. }
  104043. }
  104044. declare module BABYLON {
  104045. /**
  104046. * Interface for defining prepass effects in the prepass post-process pipeline
  104047. */
  104048. export interface PrePassEffectConfiguration {
  104049. /**
  104050. * Name of the effect
  104051. */
  104052. name: string;
  104053. /**
  104054. * Post process to attach for this effect
  104055. */
  104056. postProcess?: PostProcess;
  104057. /**
  104058. * Textures required in the MRT
  104059. */
  104060. texturesRequired: number[];
  104061. /**
  104062. * Is the effect enabled
  104063. */
  104064. enabled: boolean;
  104065. /**
  104066. * Disposes the effect configuration
  104067. */
  104068. dispose?: () => void;
  104069. /**
  104070. * Creates the associated post process
  104071. */
  104072. createPostProcess?: () => PostProcess;
  104073. }
  104074. }
  104075. declare module BABYLON {
  104076. /**
  104077. * Options to be used when creating a FresnelParameters.
  104078. */
  104079. export type IFresnelParametersCreationOptions = {
  104080. /**
  104081. * Define the color used on edges (grazing angle)
  104082. */
  104083. leftColor?: Color3;
  104084. /**
  104085. * Define the color used on center
  104086. */
  104087. rightColor?: Color3;
  104088. /**
  104089. * Define bias applied to computed fresnel term
  104090. */
  104091. bias?: number;
  104092. /**
  104093. * Defined the power exponent applied to fresnel term
  104094. */
  104095. power?: number;
  104096. /**
  104097. * Define if the fresnel effect is enable or not.
  104098. */
  104099. isEnabled?: boolean;
  104100. };
  104101. /**
  104102. * Serialized format for FresnelParameters.
  104103. */
  104104. export type IFresnelParametersSerialized = {
  104105. /**
  104106. * Define the color used on edges (grazing angle) [as an array]
  104107. */
  104108. leftColor: number[];
  104109. /**
  104110. * Define the color used on center [as an array]
  104111. */
  104112. rightColor: number[];
  104113. /**
  104114. * Define bias applied to computed fresnel term
  104115. */
  104116. bias: number;
  104117. /**
  104118. * Defined the power exponent applied to fresnel term
  104119. */
  104120. power?: number;
  104121. /**
  104122. * Define if the fresnel effect is enable or not.
  104123. */
  104124. isEnabled: boolean;
  104125. };
  104126. /**
  104127. * This represents all the required information to add a fresnel effect on a material:
  104128. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104129. */
  104130. export class FresnelParameters {
  104131. private _isEnabled;
  104132. /**
  104133. * Define if the fresnel effect is enable or not.
  104134. */
  104135. get isEnabled(): boolean;
  104136. set isEnabled(value: boolean);
  104137. /**
  104138. * Define the color used on edges (grazing angle)
  104139. */
  104140. leftColor: Color3;
  104141. /**
  104142. * Define the color used on center
  104143. */
  104144. rightColor: Color3;
  104145. /**
  104146. * Define bias applied to computed fresnel term
  104147. */
  104148. bias: number;
  104149. /**
  104150. * Defined the power exponent applied to fresnel term
  104151. */
  104152. power: number;
  104153. /**
  104154. * Creates a new FresnelParameters object.
  104155. *
  104156. * @param options provide your own settings to optionally to override defaults
  104157. */
  104158. constructor(options?: IFresnelParametersCreationOptions);
  104159. /**
  104160. * Clones the current fresnel and its valuues
  104161. * @returns a clone fresnel configuration
  104162. */
  104163. clone(): FresnelParameters;
  104164. /**
  104165. * Determines equality between FresnelParameters objects
  104166. * @param otherFresnelParameters defines the second operand
  104167. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104168. */
  104169. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104170. /**
  104171. * Serializes the current fresnel parameters to a JSON representation.
  104172. * @return the JSON serialization
  104173. */
  104174. serialize(): IFresnelParametersSerialized;
  104175. /**
  104176. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104177. * @param parsedFresnelParameters Define the JSON representation
  104178. * @returns the parsed parameters
  104179. */
  104180. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104181. }
  104182. }
  104183. declare module BABYLON {
  104184. /**
  104185. * This groups all the flags used to control the materials channel.
  104186. */
  104187. export class MaterialFlags {
  104188. private static _DiffuseTextureEnabled;
  104189. /**
  104190. * Are diffuse textures enabled in the application.
  104191. */
  104192. static get DiffuseTextureEnabled(): boolean;
  104193. static set DiffuseTextureEnabled(value: boolean);
  104194. private static _DetailTextureEnabled;
  104195. /**
  104196. * Are detail textures enabled in the application.
  104197. */
  104198. static get DetailTextureEnabled(): boolean;
  104199. static set DetailTextureEnabled(value: boolean);
  104200. private static _AmbientTextureEnabled;
  104201. /**
  104202. * Are ambient textures enabled in the application.
  104203. */
  104204. static get AmbientTextureEnabled(): boolean;
  104205. static set AmbientTextureEnabled(value: boolean);
  104206. private static _OpacityTextureEnabled;
  104207. /**
  104208. * Are opacity textures enabled in the application.
  104209. */
  104210. static get OpacityTextureEnabled(): boolean;
  104211. static set OpacityTextureEnabled(value: boolean);
  104212. private static _ReflectionTextureEnabled;
  104213. /**
  104214. * Are reflection textures enabled in the application.
  104215. */
  104216. static get ReflectionTextureEnabled(): boolean;
  104217. static set ReflectionTextureEnabled(value: boolean);
  104218. private static _EmissiveTextureEnabled;
  104219. /**
  104220. * Are emissive textures enabled in the application.
  104221. */
  104222. static get EmissiveTextureEnabled(): boolean;
  104223. static set EmissiveTextureEnabled(value: boolean);
  104224. private static _SpecularTextureEnabled;
  104225. /**
  104226. * Are specular textures enabled in the application.
  104227. */
  104228. static get SpecularTextureEnabled(): boolean;
  104229. static set SpecularTextureEnabled(value: boolean);
  104230. private static _BumpTextureEnabled;
  104231. /**
  104232. * Are bump textures enabled in the application.
  104233. */
  104234. static get BumpTextureEnabled(): boolean;
  104235. static set BumpTextureEnabled(value: boolean);
  104236. private static _LightmapTextureEnabled;
  104237. /**
  104238. * Are lightmap textures enabled in the application.
  104239. */
  104240. static get LightmapTextureEnabled(): boolean;
  104241. static set LightmapTextureEnabled(value: boolean);
  104242. private static _RefractionTextureEnabled;
  104243. /**
  104244. * Are refraction textures enabled in the application.
  104245. */
  104246. static get RefractionTextureEnabled(): boolean;
  104247. static set RefractionTextureEnabled(value: boolean);
  104248. private static _ColorGradingTextureEnabled;
  104249. /**
  104250. * Are color grading textures enabled in the application.
  104251. */
  104252. static get ColorGradingTextureEnabled(): boolean;
  104253. static set ColorGradingTextureEnabled(value: boolean);
  104254. private static _FresnelEnabled;
  104255. /**
  104256. * Are fresnels enabled in the application.
  104257. */
  104258. static get FresnelEnabled(): boolean;
  104259. static set FresnelEnabled(value: boolean);
  104260. private static _ClearCoatTextureEnabled;
  104261. /**
  104262. * Are clear coat textures enabled in the application.
  104263. */
  104264. static get ClearCoatTextureEnabled(): boolean;
  104265. static set ClearCoatTextureEnabled(value: boolean);
  104266. private static _ClearCoatBumpTextureEnabled;
  104267. /**
  104268. * Are clear coat bump textures enabled in the application.
  104269. */
  104270. static get ClearCoatBumpTextureEnabled(): boolean;
  104271. static set ClearCoatBumpTextureEnabled(value: boolean);
  104272. private static _ClearCoatTintTextureEnabled;
  104273. /**
  104274. * Are clear coat tint textures enabled in the application.
  104275. */
  104276. static get ClearCoatTintTextureEnabled(): boolean;
  104277. static set ClearCoatTintTextureEnabled(value: boolean);
  104278. private static _SheenTextureEnabled;
  104279. /**
  104280. * Are sheen textures enabled in the application.
  104281. */
  104282. static get SheenTextureEnabled(): boolean;
  104283. static set SheenTextureEnabled(value: boolean);
  104284. private static _AnisotropicTextureEnabled;
  104285. /**
  104286. * Are anisotropic textures enabled in the application.
  104287. */
  104288. static get AnisotropicTextureEnabled(): boolean;
  104289. static set AnisotropicTextureEnabled(value: boolean);
  104290. private static _ThicknessTextureEnabled;
  104291. /**
  104292. * Are thickness textures enabled in the application.
  104293. */
  104294. static get ThicknessTextureEnabled(): boolean;
  104295. static set ThicknessTextureEnabled(value: boolean);
  104296. }
  104297. }
  104298. declare module BABYLON {
  104299. /** @hidden */
  104300. export var defaultFragmentDeclaration: {
  104301. name: string;
  104302. shader: string;
  104303. };
  104304. }
  104305. declare module BABYLON {
  104306. /** @hidden */
  104307. export var defaultUboDeclaration: {
  104308. name: string;
  104309. shader: string;
  104310. };
  104311. }
  104312. declare module BABYLON {
  104313. /** @hidden */
  104314. export var prePassDeclaration: {
  104315. name: string;
  104316. shader: string;
  104317. };
  104318. }
  104319. declare module BABYLON {
  104320. /** @hidden */
  104321. export var lightFragmentDeclaration: {
  104322. name: string;
  104323. shader: string;
  104324. };
  104325. }
  104326. declare module BABYLON {
  104327. /** @hidden */
  104328. export var lightUboDeclaration: {
  104329. name: string;
  104330. shader: string;
  104331. };
  104332. }
  104333. declare module BABYLON {
  104334. /** @hidden */
  104335. export var lightsFragmentFunctions: {
  104336. name: string;
  104337. shader: string;
  104338. };
  104339. }
  104340. declare module BABYLON {
  104341. /** @hidden */
  104342. export var shadowsFragmentFunctions: {
  104343. name: string;
  104344. shader: string;
  104345. };
  104346. }
  104347. declare module BABYLON {
  104348. /** @hidden */
  104349. export var fresnelFunction: {
  104350. name: string;
  104351. shader: string;
  104352. };
  104353. }
  104354. declare module BABYLON {
  104355. /** @hidden */
  104356. export var bumpFragmentMainFunctions: {
  104357. name: string;
  104358. shader: string;
  104359. };
  104360. }
  104361. declare module BABYLON {
  104362. /** @hidden */
  104363. export var bumpFragmentFunctions: {
  104364. name: string;
  104365. shader: string;
  104366. };
  104367. }
  104368. declare module BABYLON {
  104369. /** @hidden */
  104370. export var logDepthDeclaration: {
  104371. name: string;
  104372. shader: string;
  104373. };
  104374. }
  104375. declare module BABYLON {
  104376. /** @hidden */
  104377. export var bumpFragment: {
  104378. name: string;
  104379. shader: string;
  104380. };
  104381. }
  104382. declare module BABYLON {
  104383. /** @hidden */
  104384. export var depthPrePass: {
  104385. name: string;
  104386. shader: string;
  104387. };
  104388. }
  104389. declare module BABYLON {
  104390. /** @hidden */
  104391. export var lightFragment: {
  104392. name: string;
  104393. shader: string;
  104394. };
  104395. }
  104396. declare module BABYLON {
  104397. /** @hidden */
  104398. export var logDepthFragment: {
  104399. name: string;
  104400. shader: string;
  104401. };
  104402. }
  104403. declare module BABYLON {
  104404. /** @hidden */
  104405. export var defaultPixelShader: {
  104406. name: string;
  104407. shader: string;
  104408. };
  104409. }
  104410. declare module BABYLON {
  104411. /** @hidden */
  104412. export var defaultVertexDeclaration: {
  104413. name: string;
  104414. shader: string;
  104415. };
  104416. }
  104417. declare module BABYLON {
  104418. /** @hidden */
  104419. export var prePassVertexDeclaration: {
  104420. name: string;
  104421. shader: string;
  104422. };
  104423. }
  104424. declare module BABYLON {
  104425. /** @hidden */
  104426. export var bumpVertexDeclaration: {
  104427. name: string;
  104428. shader: string;
  104429. };
  104430. }
  104431. declare module BABYLON {
  104432. /** @hidden */
  104433. export var prePassVertex: {
  104434. name: string;
  104435. shader: string;
  104436. };
  104437. }
  104438. declare module BABYLON {
  104439. /** @hidden */
  104440. export var bumpVertex: {
  104441. name: string;
  104442. shader: string;
  104443. };
  104444. }
  104445. declare module BABYLON {
  104446. /** @hidden */
  104447. export var fogVertex: {
  104448. name: string;
  104449. shader: string;
  104450. };
  104451. }
  104452. declare module BABYLON {
  104453. /** @hidden */
  104454. export var shadowsVertex: {
  104455. name: string;
  104456. shader: string;
  104457. };
  104458. }
  104459. declare module BABYLON {
  104460. /** @hidden */
  104461. export var pointCloudVertex: {
  104462. name: string;
  104463. shader: string;
  104464. };
  104465. }
  104466. declare module BABYLON {
  104467. /** @hidden */
  104468. export var logDepthVertex: {
  104469. name: string;
  104470. shader: string;
  104471. };
  104472. }
  104473. declare module BABYLON {
  104474. /** @hidden */
  104475. export var defaultVertexShader: {
  104476. name: string;
  104477. shader: string;
  104478. };
  104479. }
  104480. declare module BABYLON {
  104481. /**
  104482. * @hidden
  104483. */
  104484. export interface IMaterialDetailMapDefines {
  104485. DETAIL: boolean;
  104486. DETAILDIRECTUV: number;
  104487. DETAIL_NORMALBLENDMETHOD: number;
  104488. /** @hidden */
  104489. _areTexturesDirty: boolean;
  104490. }
  104491. /**
  104492. * Define the code related to the detail map parameters of a material
  104493. *
  104494. * Inspired from:
  104495. * 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
  104496. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104497. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104498. */
  104499. export class DetailMapConfiguration {
  104500. private _texture;
  104501. /**
  104502. * The detail texture of the material.
  104503. */
  104504. texture: Nullable<BaseTexture>;
  104505. /**
  104506. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104507. * Bigger values mean stronger blending
  104508. */
  104509. diffuseBlendLevel: number;
  104510. /**
  104511. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104512. * Bigger values mean stronger blending. Only used with PBR materials
  104513. */
  104514. roughnessBlendLevel: number;
  104515. /**
  104516. * Defines how strong the bump effect from the detail map is
  104517. * Bigger values mean stronger effect
  104518. */
  104519. bumpLevel: number;
  104520. private _normalBlendMethod;
  104521. /**
  104522. * The method used to blend the bump and detail normals together
  104523. */
  104524. normalBlendMethod: number;
  104525. private _isEnabled;
  104526. /**
  104527. * Enable or disable the detail map on this material
  104528. */
  104529. isEnabled: boolean;
  104530. /** @hidden */
  104531. private _internalMarkAllSubMeshesAsTexturesDirty;
  104532. /** @hidden */
  104533. _markAllSubMeshesAsTexturesDirty(): void;
  104534. /**
  104535. * Instantiate a new detail map
  104536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104537. */
  104538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104539. /**
  104540. * Gets whether the submesh is ready to be used or not.
  104541. * @param defines the list of "defines" to update.
  104542. * @param scene defines the scene the material belongs to.
  104543. * @returns - boolean indicating that the submesh is ready or not.
  104544. */
  104545. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104546. /**
  104547. * Update the defines for detail map usage
  104548. * @param defines the list of "defines" to update.
  104549. * @param scene defines the scene the material belongs to.
  104550. */
  104551. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104552. /**
  104553. * Binds the material data.
  104554. * @param uniformBuffer defines the Uniform buffer to fill in.
  104555. * @param scene defines the scene the material belongs to.
  104556. * @param isFrozen defines whether the material is frozen or not.
  104557. */
  104558. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104559. /**
  104560. * Checks to see if a texture is used in the material.
  104561. * @param texture - Base texture to use.
  104562. * @returns - Boolean specifying if a texture is used in the material.
  104563. */
  104564. hasTexture(texture: BaseTexture): boolean;
  104565. /**
  104566. * Returns an array of the actively used textures.
  104567. * @param activeTextures Array of BaseTextures
  104568. */
  104569. getActiveTextures(activeTextures: BaseTexture[]): void;
  104570. /**
  104571. * Returns the animatable textures.
  104572. * @param animatables Array of animatable textures.
  104573. */
  104574. getAnimatables(animatables: IAnimatable[]): void;
  104575. /**
  104576. * Disposes the resources of the material.
  104577. * @param forceDisposeTextures - Forces the disposal of all textures.
  104578. */
  104579. dispose(forceDisposeTextures?: boolean): void;
  104580. /**
  104581. * Get the current class name useful for serialization or dynamic coding.
  104582. * @returns "DetailMap"
  104583. */
  104584. getClassName(): string;
  104585. /**
  104586. * Add the required uniforms to the current list.
  104587. * @param uniforms defines the current uniform list.
  104588. */
  104589. static AddUniforms(uniforms: string[]): void;
  104590. /**
  104591. * Add the required samplers to the current list.
  104592. * @param samplers defines the current sampler list.
  104593. */
  104594. static AddSamplers(samplers: string[]): void;
  104595. /**
  104596. * Add the required uniforms to the current buffer.
  104597. * @param uniformBuffer defines the current uniform buffer.
  104598. */
  104599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104600. /**
  104601. * Makes a duplicate of the current instance into another one.
  104602. * @param detailMap define the instance where to copy the info
  104603. */
  104604. copyTo(detailMap: DetailMapConfiguration): void;
  104605. /**
  104606. * Serializes this detail map instance
  104607. * @returns - An object with the serialized instance.
  104608. */
  104609. serialize(): any;
  104610. /**
  104611. * Parses a detail map setting from a serialized object.
  104612. * @param source - Serialized object.
  104613. * @param scene Defines the scene we are parsing for
  104614. * @param rootUrl Defines the rootUrl to load from
  104615. */
  104616. parse(source: any, scene: Scene, rootUrl: string): void;
  104617. }
  104618. }
  104619. declare module BABYLON {
  104620. /** @hidden */
  104621. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104622. MAINUV1: boolean;
  104623. MAINUV2: boolean;
  104624. DIFFUSE: boolean;
  104625. DIFFUSEDIRECTUV: number;
  104626. DETAIL: boolean;
  104627. DETAILDIRECTUV: number;
  104628. DETAIL_NORMALBLENDMETHOD: number;
  104629. AMBIENT: boolean;
  104630. AMBIENTDIRECTUV: number;
  104631. OPACITY: boolean;
  104632. OPACITYDIRECTUV: number;
  104633. OPACITYRGB: boolean;
  104634. REFLECTION: boolean;
  104635. EMISSIVE: boolean;
  104636. EMISSIVEDIRECTUV: number;
  104637. SPECULAR: boolean;
  104638. SPECULARDIRECTUV: number;
  104639. BUMP: boolean;
  104640. BUMPDIRECTUV: number;
  104641. PARALLAX: boolean;
  104642. PARALLAXOCCLUSION: boolean;
  104643. SPECULAROVERALPHA: boolean;
  104644. CLIPPLANE: boolean;
  104645. CLIPPLANE2: boolean;
  104646. CLIPPLANE3: boolean;
  104647. CLIPPLANE4: boolean;
  104648. CLIPPLANE5: boolean;
  104649. CLIPPLANE6: boolean;
  104650. ALPHATEST: boolean;
  104651. DEPTHPREPASS: boolean;
  104652. ALPHAFROMDIFFUSE: boolean;
  104653. POINTSIZE: boolean;
  104654. FOG: boolean;
  104655. SPECULARTERM: boolean;
  104656. DIFFUSEFRESNEL: boolean;
  104657. OPACITYFRESNEL: boolean;
  104658. REFLECTIONFRESNEL: boolean;
  104659. REFRACTIONFRESNEL: boolean;
  104660. EMISSIVEFRESNEL: boolean;
  104661. FRESNEL: boolean;
  104662. NORMAL: boolean;
  104663. UV1: boolean;
  104664. UV2: boolean;
  104665. VERTEXCOLOR: boolean;
  104666. VERTEXALPHA: boolean;
  104667. NUM_BONE_INFLUENCERS: number;
  104668. BonesPerMesh: number;
  104669. BONETEXTURE: boolean;
  104670. BONES_VELOCITY_ENABLED: boolean;
  104671. INSTANCES: boolean;
  104672. THIN_INSTANCES: boolean;
  104673. GLOSSINESS: boolean;
  104674. ROUGHNESS: boolean;
  104675. EMISSIVEASILLUMINATION: boolean;
  104676. LINKEMISSIVEWITHDIFFUSE: boolean;
  104677. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104678. LIGHTMAP: boolean;
  104679. LIGHTMAPDIRECTUV: number;
  104680. OBJECTSPACE_NORMALMAP: boolean;
  104681. USELIGHTMAPASSHADOWMAP: boolean;
  104682. REFLECTIONMAP_3D: boolean;
  104683. REFLECTIONMAP_SPHERICAL: boolean;
  104684. REFLECTIONMAP_PLANAR: boolean;
  104685. REFLECTIONMAP_CUBIC: boolean;
  104686. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104687. REFLECTIONMAP_PROJECTION: boolean;
  104688. REFLECTIONMAP_SKYBOX: boolean;
  104689. REFLECTIONMAP_EXPLICIT: boolean;
  104690. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104691. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104692. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104693. INVERTCUBICMAP: boolean;
  104694. LOGARITHMICDEPTH: boolean;
  104695. REFRACTION: boolean;
  104696. REFRACTIONMAP_3D: boolean;
  104697. REFLECTIONOVERALPHA: boolean;
  104698. TWOSIDEDLIGHTING: boolean;
  104699. SHADOWFLOAT: boolean;
  104700. MORPHTARGETS: boolean;
  104701. MORPHTARGETS_NORMAL: boolean;
  104702. MORPHTARGETS_TANGENT: boolean;
  104703. MORPHTARGETS_UV: boolean;
  104704. NUM_MORPH_INFLUENCERS: number;
  104705. NONUNIFORMSCALING: boolean;
  104706. PREMULTIPLYALPHA: boolean;
  104707. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104708. ALPHABLEND: boolean;
  104709. PREPASS: boolean;
  104710. PREPASS_IRRADIANCE: boolean;
  104711. PREPASS_IRRADIANCE_INDEX: number;
  104712. PREPASS_ALBEDO: boolean;
  104713. PREPASS_ALBEDO_INDEX: number;
  104714. PREPASS_DEPTHNORMAL: boolean;
  104715. PREPASS_DEPTHNORMAL_INDEX: number;
  104716. PREPASS_POSITION: boolean;
  104717. PREPASS_POSITION_INDEX: number;
  104718. PREPASS_VELOCITY: boolean;
  104719. PREPASS_VELOCITY_INDEX: number;
  104720. PREPASS_REFLECTIVITY: boolean;
  104721. PREPASS_REFLECTIVITY_INDEX: number;
  104722. SCENE_MRT_COUNT: number;
  104723. RGBDLIGHTMAP: boolean;
  104724. RGBDREFLECTION: boolean;
  104725. RGBDREFRACTION: boolean;
  104726. IMAGEPROCESSING: boolean;
  104727. VIGNETTE: boolean;
  104728. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104729. VIGNETTEBLENDMODEOPAQUE: boolean;
  104730. TONEMAPPING: boolean;
  104731. TONEMAPPING_ACES: boolean;
  104732. CONTRAST: boolean;
  104733. COLORCURVES: boolean;
  104734. COLORGRADING: boolean;
  104735. COLORGRADING3D: boolean;
  104736. SAMPLER3DGREENDEPTH: boolean;
  104737. SAMPLER3DBGRMAP: boolean;
  104738. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104739. MULTIVIEW: boolean;
  104740. /**
  104741. * If the reflection texture on this material is in linear color space
  104742. * @hidden
  104743. */
  104744. IS_REFLECTION_LINEAR: boolean;
  104745. /**
  104746. * If the refraction texture on this material is in linear color space
  104747. * @hidden
  104748. */
  104749. IS_REFRACTION_LINEAR: boolean;
  104750. EXPOSURE: boolean;
  104751. constructor();
  104752. setReflectionMode(modeToEnable: string): void;
  104753. }
  104754. /**
  104755. * This is the default material used in Babylon. It is the best trade off between quality
  104756. * and performances.
  104757. * @see https://doc.babylonjs.com/babylon101/materials
  104758. */
  104759. export class StandardMaterial extends PushMaterial {
  104760. private _diffuseTexture;
  104761. /**
  104762. * The basic texture of the material as viewed under a light.
  104763. */
  104764. diffuseTexture: Nullable<BaseTexture>;
  104765. private _ambientTexture;
  104766. /**
  104767. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104768. */
  104769. ambientTexture: Nullable<BaseTexture>;
  104770. private _opacityTexture;
  104771. /**
  104772. * Define the transparency of the material from a texture.
  104773. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104774. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104775. */
  104776. opacityTexture: Nullable<BaseTexture>;
  104777. private _reflectionTexture;
  104778. /**
  104779. * Define the texture used to display the reflection.
  104780. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104781. */
  104782. reflectionTexture: Nullable<BaseTexture>;
  104783. private _emissiveTexture;
  104784. /**
  104785. * Define texture of the material as if self lit.
  104786. * This will be mixed in the final result even in the absence of light.
  104787. */
  104788. emissiveTexture: Nullable<BaseTexture>;
  104789. private _specularTexture;
  104790. /**
  104791. * Define how the color and intensity of the highlight given by the light in the material.
  104792. */
  104793. specularTexture: Nullable<BaseTexture>;
  104794. private _bumpTexture;
  104795. /**
  104796. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104797. * 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.
  104798. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104799. */
  104800. bumpTexture: Nullable<BaseTexture>;
  104801. private _lightmapTexture;
  104802. /**
  104803. * Complex lighting can be computationally expensive to compute at runtime.
  104804. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104805. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104806. */
  104807. lightmapTexture: Nullable<BaseTexture>;
  104808. private _refractionTexture;
  104809. /**
  104810. * Define the texture used to display the refraction.
  104811. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104812. */
  104813. refractionTexture: Nullable<BaseTexture>;
  104814. /**
  104815. * The color of the material lit by the environmental background lighting.
  104816. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104817. */
  104818. ambientColor: Color3;
  104819. /**
  104820. * The basic color of the material as viewed under a light.
  104821. */
  104822. diffuseColor: Color3;
  104823. /**
  104824. * Define how the color and intensity of the highlight given by the light in the material.
  104825. */
  104826. specularColor: Color3;
  104827. /**
  104828. * Define the color of the material as if self lit.
  104829. * This will be mixed in the final result even in the absence of light.
  104830. */
  104831. emissiveColor: Color3;
  104832. /**
  104833. * Defines how sharp are the highlights in the material.
  104834. * The bigger the value the sharper giving a more glossy feeling to the result.
  104835. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104836. */
  104837. specularPower: number;
  104838. private _useAlphaFromDiffuseTexture;
  104839. /**
  104840. * Does the transparency come from the diffuse texture alpha channel.
  104841. */
  104842. useAlphaFromDiffuseTexture: boolean;
  104843. private _useEmissiveAsIllumination;
  104844. /**
  104845. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104846. */
  104847. useEmissiveAsIllumination: boolean;
  104848. private _linkEmissiveWithDiffuse;
  104849. /**
  104850. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104851. * the emissive level when the final color is close to one.
  104852. */
  104853. linkEmissiveWithDiffuse: boolean;
  104854. private _useSpecularOverAlpha;
  104855. /**
  104856. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104857. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104858. */
  104859. useSpecularOverAlpha: boolean;
  104860. private _useReflectionOverAlpha;
  104861. /**
  104862. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104863. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104864. */
  104865. useReflectionOverAlpha: boolean;
  104866. private _disableLighting;
  104867. /**
  104868. * Does lights from the scene impacts this material.
  104869. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104870. */
  104871. disableLighting: boolean;
  104872. private _useObjectSpaceNormalMap;
  104873. /**
  104874. * Allows using an object space normal map (instead of tangent space).
  104875. */
  104876. useObjectSpaceNormalMap: boolean;
  104877. private _useParallax;
  104878. /**
  104879. * Is parallax enabled or not.
  104880. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104881. */
  104882. useParallax: boolean;
  104883. private _useParallaxOcclusion;
  104884. /**
  104885. * Is parallax occlusion enabled or not.
  104886. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104887. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104888. */
  104889. useParallaxOcclusion: boolean;
  104890. /**
  104891. * 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.
  104892. */
  104893. parallaxScaleBias: number;
  104894. private _roughness;
  104895. /**
  104896. * Helps to define how blurry the reflections should appears in the material.
  104897. */
  104898. roughness: number;
  104899. /**
  104900. * In case of refraction, define the value of the index of refraction.
  104901. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104902. */
  104903. indexOfRefraction: number;
  104904. /**
  104905. * Invert the refraction texture alongside the y axis.
  104906. * It can be useful with procedural textures or probe for instance.
  104907. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104908. */
  104909. invertRefractionY: boolean;
  104910. /**
  104911. * Defines the alpha limits in alpha test mode.
  104912. */
  104913. alphaCutOff: number;
  104914. private _useLightmapAsShadowmap;
  104915. /**
  104916. * In case of light mapping, define whether the map contains light or shadow informations.
  104917. */
  104918. useLightmapAsShadowmap: boolean;
  104919. private _diffuseFresnelParameters;
  104920. /**
  104921. * Define the diffuse fresnel parameters of the material.
  104922. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104923. */
  104924. diffuseFresnelParameters: FresnelParameters;
  104925. private _opacityFresnelParameters;
  104926. /**
  104927. * Define the opacity fresnel parameters of the material.
  104928. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104929. */
  104930. opacityFresnelParameters: FresnelParameters;
  104931. private _reflectionFresnelParameters;
  104932. /**
  104933. * Define the reflection fresnel parameters of the material.
  104934. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104935. */
  104936. reflectionFresnelParameters: FresnelParameters;
  104937. private _refractionFresnelParameters;
  104938. /**
  104939. * Define the refraction fresnel parameters of the material.
  104940. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104941. */
  104942. refractionFresnelParameters: FresnelParameters;
  104943. private _emissiveFresnelParameters;
  104944. /**
  104945. * Define the emissive fresnel parameters of the material.
  104946. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104947. */
  104948. emissiveFresnelParameters: FresnelParameters;
  104949. private _useReflectionFresnelFromSpecular;
  104950. /**
  104951. * If true automatically deducts the fresnels values from the material specularity.
  104952. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104953. */
  104954. useReflectionFresnelFromSpecular: boolean;
  104955. private _useGlossinessFromSpecularMapAlpha;
  104956. /**
  104957. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104958. */
  104959. useGlossinessFromSpecularMapAlpha: boolean;
  104960. private _maxSimultaneousLights;
  104961. /**
  104962. * Defines the maximum number of lights that can be used in the material
  104963. */
  104964. maxSimultaneousLights: number;
  104965. private _invertNormalMapX;
  104966. /**
  104967. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104968. */
  104969. invertNormalMapX: boolean;
  104970. private _invertNormalMapY;
  104971. /**
  104972. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104973. */
  104974. invertNormalMapY: boolean;
  104975. private _twoSidedLighting;
  104976. /**
  104977. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104978. */
  104979. twoSidedLighting: boolean;
  104980. /**
  104981. * Default configuration related to image processing available in the standard Material.
  104982. */
  104983. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104984. /**
  104985. * Gets the image processing configuration used either in this material.
  104986. */
  104987. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104988. /**
  104989. * Sets the Default image processing configuration used either in the this material.
  104990. *
  104991. * If sets to null, the scene one is in use.
  104992. */
  104993. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104994. /**
  104995. * Keep track of the image processing observer to allow dispose and replace.
  104996. */
  104997. private _imageProcessingObserver;
  104998. /**
  104999. * Attaches a new image processing configuration to the Standard Material.
  105000. * @param configuration
  105001. */
  105002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105003. /**
  105004. * Defines additionnal PrePass parameters for the material.
  105005. */
  105006. readonly prePassConfiguration: PrePassConfiguration;
  105007. /**
  105008. * Gets wether the color curves effect is enabled.
  105009. */
  105010. get cameraColorCurvesEnabled(): boolean;
  105011. /**
  105012. * Sets wether the color curves effect is enabled.
  105013. */
  105014. set cameraColorCurvesEnabled(value: boolean);
  105015. /**
  105016. * Gets wether the color grading effect is enabled.
  105017. */
  105018. get cameraColorGradingEnabled(): boolean;
  105019. /**
  105020. * Gets wether the color grading effect is enabled.
  105021. */
  105022. set cameraColorGradingEnabled(value: boolean);
  105023. /**
  105024. * Gets wether tonemapping is enabled or not.
  105025. */
  105026. get cameraToneMappingEnabled(): boolean;
  105027. /**
  105028. * Sets wether tonemapping is enabled or not
  105029. */
  105030. set cameraToneMappingEnabled(value: boolean);
  105031. /**
  105032. * The camera exposure used on this material.
  105033. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105034. * This corresponds to a photographic exposure.
  105035. */
  105036. get cameraExposure(): number;
  105037. /**
  105038. * The camera exposure used on this material.
  105039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105040. * This corresponds to a photographic exposure.
  105041. */
  105042. set cameraExposure(value: number);
  105043. /**
  105044. * Gets The camera contrast used on this material.
  105045. */
  105046. get cameraContrast(): number;
  105047. /**
  105048. * Sets The camera contrast used on this material.
  105049. */
  105050. set cameraContrast(value: number);
  105051. /**
  105052. * Gets the Color Grading 2D Lookup Texture.
  105053. */
  105054. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105055. /**
  105056. * Sets the Color Grading 2D Lookup Texture.
  105057. */
  105058. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105059. /**
  105060. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105061. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105062. * 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;
  105063. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105064. */
  105065. get cameraColorCurves(): Nullable<ColorCurves>;
  105066. /**
  105067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105069. * 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;
  105070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105071. */
  105072. set cameraColorCurves(value: Nullable<ColorCurves>);
  105073. /**
  105074. * Can this material render to several textures at once
  105075. */
  105076. get canRenderToMRT(): boolean;
  105077. /**
  105078. * Defines the detail map parameters for the material.
  105079. */
  105080. readonly detailMap: DetailMapConfiguration;
  105081. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105082. protected _worldViewProjectionMatrix: Matrix;
  105083. protected _globalAmbientColor: Color3;
  105084. protected _useLogarithmicDepth: boolean;
  105085. protected _rebuildInParallel: boolean;
  105086. /**
  105087. * Instantiates a new standard material.
  105088. * This is the default material used in Babylon. It is the best trade off between quality
  105089. * and performances.
  105090. * @see https://doc.babylonjs.com/babylon101/materials
  105091. * @param name Define the name of the material in the scene
  105092. * @param scene Define the scene the material belong to
  105093. */
  105094. constructor(name: string, scene: Scene);
  105095. /**
  105096. * Gets a boolean indicating that current material needs to register RTT
  105097. */
  105098. get hasRenderTargetTextures(): boolean;
  105099. /**
  105100. * Gets the current class name of the material e.g. "StandardMaterial"
  105101. * Mainly use in serialization.
  105102. * @returns the class name
  105103. */
  105104. getClassName(): string;
  105105. /**
  105106. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105107. * You can try switching to logarithmic depth.
  105108. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105109. */
  105110. get useLogarithmicDepth(): boolean;
  105111. set useLogarithmicDepth(value: boolean);
  105112. /**
  105113. * Specifies if the material will require alpha blending
  105114. * @returns a boolean specifying if alpha blending is needed
  105115. */
  105116. needAlphaBlending(): boolean;
  105117. /**
  105118. * Specifies if this material should be rendered in alpha test mode
  105119. * @returns a boolean specifying if an alpha test is needed.
  105120. */
  105121. needAlphaTesting(): boolean;
  105122. /**
  105123. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105124. */
  105125. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105126. /**
  105127. * Specifies whether or not there is a usable alpha channel for transparency.
  105128. */
  105129. protected _hasAlphaChannel(): boolean;
  105130. /**
  105131. * Get the texture used for alpha test purpose.
  105132. * @returns the diffuse texture in case of the standard material.
  105133. */
  105134. getAlphaTestTexture(): Nullable<BaseTexture>;
  105135. /**
  105136. * Get if the submesh is ready to be used and all its information available.
  105137. * Child classes can use it to update shaders
  105138. * @param mesh defines the mesh to check
  105139. * @param subMesh defines which submesh to check
  105140. * @param useInstances specifies that instances should be used
  105141. * @returns a boolean indicating that the submesh is ready or not
  105142. */
  105143. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105144. /**
  105145. * Builds the material UBO layouts.
  105146. * Used internally during the effect preparation.
  105147. */
  105148. buildUniformLayout(): void;
  105149. /**
  105150. * Unbinds the material from the mesh
  105151. */
  105152. unbind(): void;
  105153. /**
  105154. * Binds the submesh to this material by preparing the effect and shader to draw
  105155. * @param world defines the world transformation matrix
  105156. * @param mesh defines the mesh containing the submesh
  105157. * @param subMesh defines the submesh to bind the material to
  105158. */
  105159. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105160. /**
  105161. * Get the list of animatables in the material.
  105162. * @returns the list of animatables object used in the material
  105163. */
  105164. getAnimatables(): IAnimatable[];
  105165. /**
  105166. * Gets the active textures from the material
  105167. * @returns an array of textures
  105168. */
  105169. getActiveTextures(): BaseTexture[];
  105170. /**
  105171. * Specifies if the material uses a texture
  105172. * @param texture defines the texture to check against the material
  105173. * @returns a boolean specifying if the material uses the texture
  105174. */
  105175. hasTexture(texture: BaseTexture): boolean;
  105176. /**
  105177. * Disposes the material
  105178. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105179. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105180. */
  105181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105182. /**
  105183. * Makes a duplicate of the material, and gives it a new name
  105184. * @param name defines the new name for the duplicated material
  105185. * @returns the cloned material
  105186. */
  105187. clone(name: string): StandardMaterial;
  105188. /**
  105189. * Serializes this material in a JSON representation
  105190. * @returns the serialized material object
  105191. */
  105192. serialize(): any;
  105193. /**
  105194. * Creates a standard material from parsed material data
  105195. * @param source defines the JSON representation of the material
  105196. * @param scene defines the hosting scene
  105197. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105198. * @returns a new standard material
  105199. */
  105200. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105201. /**
  105202. * Are diffuse textures enabled in the application.
  105203. */
  105204. static get DiffuseTextureEnabled(): boolean;
  105205. static set DiffuseTextureEnabled(value: boolean);
  105206. /**
  105207. * Are detail textures enabled in the application.
  105208. */
  105209. static get DetailTextureEnabled(): boolean;
  105210. static set DetailTextureEnabled(value: boolean);
  105211. /**
  105212. * Are ambient textures enabled in the application.
  105213. */
  105214. static get AmbientTextureEnabled(): boolean;
  105215. static set AmbientTextureEnabled(value: boolean);
  105216. /**
  105217. * Are opacity textures enabled in the application.
  105218. */
  105219. static get OpacityTextureEnabled(): boolean;
  105220. static set OpacityTextureEnabled(value: boolean);
  105221. /**
  105222. * Are reflection textures enabled in the application.
  105223. */
  105224. static get ReflectionTextureEnabled(): boolean;
  105225. static set ReflectionTextureEnabled(value: boolean);
  105226. /**
  105227. * Are emissive textures enabled in the application.
  105228. */
  105229. static get EmissiveTextureEnabled(): boolean;
  105230. static set EmissiveTextureEnabled(value: boolean);
  105231. /**
  105232. * Are specular textures enabled in the application.
  105233. */
  105234. static get SpecularTextureEnabled(): boolean;
  105235. static set SpecularTextureEnabled(value: boolean);
  105236. /**
  105237. * Are bump textures enabled in the application.
  105238. */
  105239. static get BumpTextureEnabled(): boolean;
  105240. static set BumpTextureEnabled(value: boolean);
  105241. /**
  105242. * Are lightmap textures enabled in the application.
  105243. */
  105244. static get LightmapTextureEnabled(): boolean;
  105245. static set LightmapTextureEnabled(value: boolean);
  105246. /**
  105247. * Are refraction textures enabled in the application.
  105248. */
  105249. static get RefractionTextureEnabled(): boolean;
  105250. static set RefractionTextureEnabled(value: boolean);
  105251. /**
  105252. * Are color grading textures enabled in the application.
  105253. */
  105254. static get ColorGradingTextureEnabled(): boolean;
  105255. static set ColorGradingTextureEnabled(value: boolean);
  105256. /**
  105257. * Are fresnels enabled in the application.
  105258. */
  105259. static get FresnelEnabled(): boolean;
  105260. static set FresnelEnabled(value: boolean);
  105261. }
  105262. }
  105263. declare module BABYLON {
  105264. /** @hidden */
  105265. export var rgbdDecodePixelShader: {
  105266. name: string;
  105267. shader: string;
  105268. };
  105269. }
  105270. declare module BABYLON {
  105271. /**
  105272. * Class used to host RGBD texture specific utilities
  105273. */
  105274. export class RGBDTextureTools {
  105275. /**
  105276. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105277. * @param texture the texture to expand.
  105278. */
  105279. static ExpandRGBDTexture(texture: Texture): void;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * Class used to host texture specific utilities
  105285. */
  105286. export class BRDFTextureTools {
  105287. /**
  105288. * Prevents texture cache collision
  105289. */
  105290. private static _instanceNumber;
  105291. /**
  105292. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105293. * @param scene defines the hosting scene
  105294. * @returns the environment BRDF texture
  105295. */
  105296. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105297. private static _environmentBRDFBase64Texture;
  105298. }
  105299. }
  105300. declare module BABYLON {
  105301. /**
  105302. * @hidden
  105303. */
  105304. export interface IMaterialClearCoatDefines {
  105305. CLEARCOAT: boolean;
  105306. CLEARCOAT_DEFAULTIOR: boolean;
  105307. CLEARCOAT_TEXTURE: boolean;
  105308. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105309. CLEARCOAT_TEXTUREDIRECTUV: number;
  105310. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105311. CLEARCOAT_BUMP: boolean;
  105312. CLEARCOAT_BUMPDIRECTUV: number;
  105313. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105314. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105315. CLEARCOAT_REMAP_F0: boolean;
  105316. CLEARCOAT_TINT: boolean;
  105317. CLEARCOAT_TINT_TEXTURE: boolean;
  105318. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105319. /** @hidden */
  105320. _areTexturesDirty: boolean;
  105321. }
  105322. /**
  105323. * Define the code related to the clear coat parameters of the pbr material.
  105324. */
  105325. export class PBRClearCoatConfiguration {
  105326. /**
  105327. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105328. * The default fits with a polyurethane material.
  105329. */
  105330. private static readonly _DefaultIndexOfRefraction;
  105331. private _isEnabled;
  105332. /**
  105333. * Defines if the clear coat is enabled in the material.
  105334. */
  105335. isEnabled: boolean;
  105336. /**
  105337. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105338. */
  105339. intensity: number;
  105340. /**
  105341. * Defines the clear coat layer roughness.
  105342. */
  105343. roughness: number;
  105344. private _indexOfRefraction;
  105345. /**
  105346. * Defines the index of refraction of the clear coat.
  105347. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105348. * The default fits with a polyurethane material.
  105349. * Changing the default value is more performance intensive.
  105350. */
  105351. indexOfRefraction: number;
  105352. private _texture;
  105353. /**
  105354. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105355. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105356. * if textureRoughness is not empty, else no texture roughness is used
  105357. */
  105358. texture: Nullable<BaseTexture>;
  105359. private _useRoughnessFromMainTexture;
  105360. /**
  105361. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105362. * If false, the green channel from textureRoughness is used for roughness
  105363. */
  105364. useRoughnessFromMainTexture: boolean;
  105365. private _textureRoughness;
  105366. /**
  105367. * Stores the clear coat roughness in a texture (green channel)
  105368. * Not used if useRoughnessFromMainTexture is true
  105369. */
  105370. textureRoughness: Nullable<BaseTexture>;
  105371. private _remapF0OnInterfaceChange;
  105372. /**
  105373. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105374. */
  105375. remapF0OnInterfaceChange: boolean;
  105376. private _bumpTexture;
  105377. /**
  105378. * Define the clear coat specific bump texture.
  105379. */
  105380. bumpTexture: Nullable<BaseTexture>;
  105381. private _isTintEnabled;
  105382. /**
  105383. * Defines if the clear coat tint is enabled in the material.
  105384. */
  105385. isTintEnabled: boolean;
  105386. /**
  105387. * Defines the clear coat tint of the material.
  105388. * This is only use if tint is enabled
  105389. */
  105390. tintColor: Color3;
  105391. /**
  105392. * Defines the distance at which the tint color should be found in the
  105393. * clear coat media.
  105394. * This is only use if tint is enabled
  105395. */
  105396. tintColorAtDistance: number;
  105397. /**
  105398. * Defines the clear coat layer thickness.
  105399. * This is only use if tint is enabled
  105400. */
  105401. tintThickness: number;
  105402. private _tintTexture;
  105403. /**
  105404. * Stores the clear tint values in a texture.
  105405. * rgb is tint
  105406. * a is a thickness factor
  105407. */
  105408. tintTexture: Nullable<BaseTexture>;
  105409. /** @hidden */
  105410. private _internalMarkAllSubMeshesAsTexturesDirty;
  105411. /** @hidden */
  105412. _markAllSubMeshesAsTexturesDirty(): void;
  105413. /**
  105414. * Instantiate a new istance of clear coat configuration.
  105415. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105416. */
  105417. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105418. /**
  105419. * Gets wehter the submesh is ready to be used or not.
  105420. * @param defines the list of "defines" to update.
  105421. * @param scene defines the scene the material belongs to.
  105422. * @param engine defines the engine the material belongs to.
  105423. * @param disableBumpMap defines wether the material disables bump or not.
  105424. * @returns - boolean indicating that the submesh is ready or not.
  105425. */
  105426. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105427. /**
  105428. * Checks to see if a texture is used in the material.
  105429. * @param defines the list of "defines" to update.
  105430. * @param scene defines the scene to the material belongs to.
  105431. */
  105432. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105433. /**
  105434. * Binds the material data.
  105435. * @param uniformBuffer defines the Uniform buffer to fill in.
  105436. * @param scene defines the scene the material belongs to.
  105437. * @param engine defines the engine the material belongs to.
  105438. * @param disableBumpMap defines wether the material disables bump or not.
  105439. * @param isFrozen defines wether the material is frozen or not.
  105440. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105441. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105442. * @param subMesh the submesh to bind data for
  105443. */
  105444. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105445. /**
  105446. * Checks to see if a texture is used in the material.
  105447. * @param texture - Base texture to use.
  105448. * @returns - Boolean specifying if a texture is used in the material.
  105449. */
  105450. hasTexture(texture: BaseTexture): boolean;
  105451. /**
  105452. * Returns an array of the actively used textures.
  105453. * @param activeTextures Array of BaseTextures
  105454. */
  105455. getActiveTextures(activeTextures: BaseTexture[]): void;
  105456. /**
  105457. * Returns the animatable textures.
  105458. * @param animatables Array of animatable textures.
  105459. */
  105460. getAnimatables(animatables: IAnimatable[]): void;
  105461. /**
  105462. * Disposes the resources of the material.
  105463. * @param forceDisposeTextures - Forces the disposal of all textures.
  105464. */
  105465. dispose(forceDisposeTextures?: boolean): void;
  105466. /**
  105467. * Get the current class name of the texture useful for serialization or dynamic coding.
  105468. * @returns "PBRClearCoatConfiguration"
  105469. */
  105470. getClassName(): string;
  105471. /**
  105472. * Add fallbacks to the effect fallbacks list.
  105473. * @param defines defines the Base texture to use.
  105474. * @param fallbacks defines the current fallback list.
  105475. * @param currentRank defines the current fallback rank.
  105476. * @returns the new fallback rank.
  105477. */
  105478. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105479. /**
  105480. * Add the required uniforms to the current list.
  105481. * @param uniforms defines the current uniform list.
  105482. */
  105483. static AddUniforms(uniforms: string[]): void;
  105484. /**
  105485. * Add the required samplers to the current list.
  105486. * @param samplers defines the current sampler list.
  105487. */
  105488. static AddSamplers(samplers: string[]): void;
  105489. /**
  105490. * Add the required uniforms to the current buffer.
  105491. * @param uniformBuffer defines the current uniform buffer.
  105492. */
  105493. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105494. /**
  105495. * Makes a duplicate of the current configuration into another one.
  105496. * @param clearCoatConfiguration define the config where to copy the info
  105497. */
  105498. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105499. /**
  105500. * Serializes this clear coat configuration.
  105501. * @returns - An object with the serialized config.
  105502. */
  105503. serialize(): any;
  105504. /**
  105505. * Parses a anisotropy Configuration from a serialized object.
  105506. * @param source - Serialized object.
  105507. * @param scene Defines the scene we are parsing for
  105508. * @param rootUrl Defines the rootUrl to load from
  105509. */
  105510. parse(source: any, scene: Scene, rootUrl: string): void;
  105511. }
  105512. }
  105513. declare module BABYLON {
  105514. /**
  105515. * @hidden
  105516. */
  105517. export interface IMaterialAnisotropicDefines {
  105518. ANISOTROPIC: boolean;
  105519. ANISOTROPIC_TEXTURE: boolean;
  105520. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105521. MAINUV1: boolean;
  105522. _areTexturesDirty: boolean;
  105523. _needUVs: boolean;
  105524. }
  105525. /**
  105526. * Define the code related to the anisotropic parameters of the pbr material.
  105527. */
  105528. export class PBRAnisotropicConfiguration {
  105529. private _isEnabled;
  105530. /**
  105531. * Defines if the anisotropy is enabled in the material.
  105532. */
  105533. isEnabled: boolean;
  105534. /**
  105535. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105536. */
  105537. intensity: number;
  105538. /**
  105539. * Defines if the effect is along the tangents, bitangents or in between.
  105540. * By default, the effect is "strectching" the highlights along the tangents.
  105541. */
  105542. direction: Vector2;
  105543. private _texture;
  105544. /**
  105545. * Stores the anisotropy values in a texture.
  105546. * rg is direction (like normal from -1 to 1)
  105547. * b is a intensity
  105548. */
  105549. texture: Nullable<BaseTexture>;
  105550. /** @hidden */
  105551. private _internalMarkAllSubMeshesAsTexturesDirty;
  105552. /** @hidden */
  105553. _markAllSubMeshesAsTexturesDirty(): void;
  105554. /**
  105555. * Instantiate a new istance of anisotropy configuration.
  105556. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105557. */
  105558. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105559. /**
  105560. * Specifies that the submesh is ready to be used.
  105561. * @param defines the list of "defines" to update.
  105562. * @param scene defines the scene the material belongs to.
  105563. * @returns - boolean indicating that the submesh is ready or not.
  105564. */
  105565. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105566. /**
  105567. * Checks to see if a texture is used in the material.
  105568. * @param defines the list of "defines" to update.
  105569. * @param mesh the mesh we are preparing the defines for.
  105570. * @param scene defines the scene the material belongs to.
  105571. */
  105572. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105573. /**
  105574. * Binds the material data.
  105575. * @param uniformBuffer defines the Uniform buffer to fill in.
  105576. * @param scene defines the scene the material belongs to.
  105577. * @param isFrozen defines wether the material is frozen or not.
  105578. */
  105579. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105580. /**
  105581. * Checks to see if a texture is used in the material.
  105582. * @param texture - Base texture to use.
  105583. * @returns - Boolean specifying if a texture is used in the material.
  105584. */
  105585. hasTexture(texture: BaseTexture): boolean;
  105586. /**
  105587. * Returns an array of the actively used textures.
  105588. * @param activeTextures Array of BaseTextures
  105589. */
  105590. getActiveTextures(activeTextures: BaseTexture[]): void;
  105591. /**
  105592. * Returns the animatable textures.
  105593. * @param animatables Array of animatable textures.
  105594. */
  105595. getAnimatables(animatables: IAnimatable[]): void;
  105596. /**
  105597. * Disposes the resources of the material.
  105598. * @param forceDisposeTextures - Forces the disposal of all textures.
  105599. */
  105600. dispose(forceDisposeTextures?: boolean): void;
  105601. /**
  105602. * Get the current class name of the texture useful for serialization or dynamic coding.
  105603. * @returns "PBRAnisotropicConfiguration"
  105604. */
  105605. getClassName(): string;
  105606. /**
  105607. * Add fallbacks to the effect fallbacks list.
  105608. * @param defines defines the Base texture to use.
  105609. * @param fallbacks defines the current fallback list.
  105610. * @param currentRank defines the current fallback rank.
  105611. * @returns the new fallback rank.
  105612. */
  105613. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105614. /**
  105615. * Add the required uniforms to the current list.
  105616. * @param uniforms defines the current uniform list.
  105617. */
  105618. static AddUniforms(uniforms: string[]): void;
  105619. /**
  105620. * Add the required uniforms to the current buffer.
  105621. * @param uniformBuffer defines the current uniform buffer.
  105622. */
  105623. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105624. /**
  105625. * Add the required samplers to the current list.
  105626. * @param samplers defines the current sampler list.
  105627. */
  105628. static AddSamplers(samplers: string[]): void;
  105629. /**
  105630. * Makes a duplicate of the current configuration into another one.
  105631. * @param anisotropicConfiguration define the config where to copy the info
  105632. */
  105633. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105634. /**
  105635. * Serializes this anisotropy configuration.
  105636. * @returns - An object with the serialized config.
  105637. */
  105638. serialize(): any;
  105639. /**
  105640. * Parses a anisotropy Configuration from a serialized object.
  105641. * @param source - Serialized object.
  105642. * @param scene Defines the scene we are parsing for
  105643. * @param rootUrl Defines the rootUrl to load from
  105644. */
  105645. parse(source: any, scene: Scene, rootUrl: string): void;
  105646. }
  105647. }
  105648. declare module BABYLON {
  105649. /**
  105650. * @hidden
  105651. */
  105652. export interface IMaterialBRDFDefines {
  105653. BRDF_V_HEIGHT_CORRELATED: boolean;
  105654. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105655. SPHERICAL_HARMONICS: boolean;
  105656. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105657. /** @hidden */
  105658. _areMiscDirty: boolean;
  105659. }
  105660. /**
  105661. * Define the code related to the BRDF parameters of the pbr material.
  105662. */
  105663. export class PBRBRDFConfiguration {
  105664. /**
  105665. * Default value used for the energy conservation.
  105666. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105667. */
  105668. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105669. /**
  105670. * Default value used for the Smith Visibility Height Correlated mode.
  105671. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105672. */
  105673. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105674. /**
  105675. * Default value used for the IBL diffuse part.
  105676. * This can help switching back to the polynomials mode globally which is a tiny bit
  105677. * less GPU intensive at the drawback of a lower quality.
  105678. */
  105679. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105680. /**
  105681. * Default value used for activating energy conservation for the specular workflow.
  105682. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105683. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105684. */
  105685. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105686. private _useEnergyConservation;
  105687. /**
  105688. * Defines if the material uses energy conservation.
  105689. */
  105690. useEnergyConservation: boolean;
  105691. private _useSmithVisibilityHeightCorrelated;
  105692. /**
  105693. * LEGACY Mode set to false
  105694. * Defines if the material uses height smith correlated visibility term.
  105695. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105696. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105697. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105698. * Not relying on height correlated will also disable energy conservation.
  105699. */
  105700. useSmithVisibilityHeightCorrelated: boolean;
  105701. private _useSphericalHarmonics;
  105702. /**
  105703. * LEGACY Mode set to false
  105704. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105705. * diffuse part of the IBL.
  105706. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105707. * to the ground truth.
  105708. */
  105709. useSphericalHarmonics: boolean;
  105710. private _useSpecularGlossinessInputEnergyConservation;
  105711. /**
  105712. * Defines if the material uses energy conservation, when the specular workflow is active.
  105713. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105714. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105715. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105716. */
  105717. useSpecularGlossinessInputEnergyConservation: boolean;
  105718. /** @hidden */
  105719. private _internalMarkAllSubMeshesAsMiscDirty;
  105720. /** @hidden */
  105721. _markAllSubMeshesAsMiscDirty(): void;
  105722. /**
  105723. * Instantiate a new istance of clear coat configuration.
  105724. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105725. */
  105726. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105727. /**
  105728. * Checks to see if a texture is used in the material.
  105729. * @param defines the list of "defines" to update.
  105730. */
  105731. prepareDefines(defines: IMaterialBRDFDefines): void;
  105732. /**
  105733. * Get the current class name of the texture useful for serialization or dynamic coding.
  105734. * @returns "PBRClearCoatConfiguration"
  105735. */
  105736. getClassName(): string;
  105737. /**
  105738. * Makes a duplicate of the current configuration into another one.
  105739. * @param brdfConfiguration define the config where to copy the info
  105740. */
  105741. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105742. /**
  105743. * Serializes this BRDF configuration.
  105744. * @returns - An object with the serialized config.
  105745. */
  105746. serialize(): any;
  105747. /**
  105748. * Parses a anisotropy Configuration from a serialized object.
  105749. * @param source - Serialized object.
  105750. * @param scene Defines the scene we are parsing for
  105751. * @param rootUrl Defines the rootUrl to load from
  105752. */
  105753. parse(source: any, scene: Scene, rootUrl: string): void;
  105754. }
  105755. }
  105756. declare module BABYLON {
  105757. /**
  105758. * @hidden
  105759. */
  105760. export interface IMaterialSheenDefines {
  105761. SHEEN: boolean;
  105762. SHEEN_TEXTURE: boolean;
  105763. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105764. SHEEN_TEXTUREDIRECTUV: number;
  105765. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105766. SHEEN_LINKWITHALBEDO: boolean;
  105767. SHEEN_ROUGHNESS: boolean;
  105768. SHEEN_ALBEDOSCALING: boolean;
  105769. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105770. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105771. /** @hidden */
  105772. _areTexturesDirty: boolean;
  105773. }
  105774. /**
  105775. * Define the code related to the Sheen parameters of the pbr material.
  105776. */
  105777. export class PBRSheenConfiguration {
  105778. private _isEnabled;
  105779. /**
  105780. * Defines if the material uses sheen.
  105781. */
  105782. isEnabled: boolean;
  105783. private _linkSheenWithAlbedo;
  105784. /**
  105785. * Defines if the sheen is linked to the sheen color.
  105786. */
  105787. linkSheenWithAlbedo: boolean;
  105788. /**
  105789. * Defines the sheen intensity.
  105790. */
  105791. intensity: number;
  105792. /**
  105793. * Defines the sheen color.
  105794. */
  105795. color: Color3;
  105796. private _texture;
  105797. /**
  105798. * Stores the sheen tint values in a texture.
  105799. * rgb is tint
  105800. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  105801. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105802. */
  105803. texture: Nullable<BaseTexture>;
  105804. private _useRoughnessFromMainTexture;
  105805. /**
  105806. * Indicates that the alpha channel of the texture property will be used for roughness.
  105807. * Has no effect if the roughness (and texture!) property is not defined
  105808. */
  105809. useRoughnessFromMainTexture: boolean;
  105810. private _roughness;
  105811. /**
  105812. * Defines the sheen roughness.
  105813. * It is not taken into account if linkSheenWithAlbedo is true.
  105814. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105815. */
  105816. roughness: Nullable<number>;
  105817. private _textureRoughness;
  105818. /**
  105819. * Stores the sheen roughness in a texture.
  105820. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105821. */
  105822. textureRoughness: Nullable<BaseTexture>;
  105823. private _albedoScaling;
  105824. /**
  105825. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105826. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105827. * making it easier to setup and tweak the effect
  105828. */
  105829. albedoScaling: boolean;
  105830. /** @hidden */
  105831. private _internalMarkAllSubMeshesAsTexturesDirty;
  105832. /** @hidden */
  105833. _markAllSubMeshesAsTexturesDirty(): void;
  105834. /**
  105835. * Instantiate a new istance of clear coat configuration.
  105836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105837. */
  105838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105839. /**
  105840. * Specifies that the submesh is ready to be used.
  105841. * @param defines the list of "defines" to update.
  105842. * @param scene defines the scene the material belongs to.
  105843. * @returns - boolean indicating that the submesh is ready or not.
  105844. */
  105845. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105846. /**
  105847. * Checks to see if a texture is used in the material.
  105848. * @param defines the list of "defines" to update.
  105849. * @param scene defines the scene the material belongs to.
  105850. */
  105851. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105852. /**
  105853. * Binds the material data.
  105854. * @param uniformBuffer defines the Uniform buffer to fill in.
  105855. * @param scene defines the scene the material belongs to.
  105856. * @param isFrozen defines wether the material is frozen or not.
  105857. * @param subMesh the submesh to bind data for
  105858. */
  105859. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105860. /**
  105861. * Checks to see if a texture is used in the material.
  105862. * @param texture - Base texture to use.
  105863. * @returns - Boolean specifying if a texture is used in the material.
  105864. */
  105865. hasTexture(texture: BaseTexture): boolean;
  105866. /**
  105867. * Returns an array of the actively used textures.
  105868. * @param activeTextures Array of BaseTextures
  105869. */
  105870. getActiveTextures(activeTextures: BaseTexture[]): void;
  105871. /**
  105872. * Returns the animatable textures.
  105873. * @param animatables Array of animatable textures.
  105874. */
  105875. getAnimatables(animatables: IAnimatable[]): void;
  105876. /**
  105877. * Disposes the resources of the material.
  105878. * @param forceDisposeTextures - Forces the disposal of all textures.
  105879. */
  105880. dispose(forceDisposeTextures?: boolean): void;
  105881. /**
  105882. * Get the current class name of the texture useful for serialization or dynamic coding.
  105883. * @returns "PBRSheenConfiguration"
  105884. */
  105885. getClassName(): string;
  105886. /**
  105887. * Add fallbacks to the effect fallbacks list.
  105888. * @param defines defines the Base texture to use.
  105889. * @param fallbacks defines the current fallback list.
  105890. * @param currentRank defines the current fallback rank.
  105891. * @returns the new fallback rank.
  105892. */
  105893. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105894. /**
  105895. * Add the required uniforms to the current list.
  105896. * @param uniforms defines the current uniform list.
  105897. */
  105898. static AddUniforms(uniforms: string[]): void;
  105899. /**
  105900. * Add the required uniforms to the current buffer.
  105901. * @param uniformBuffer defines the current uniform buffer.
  105902. */
  105903. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105904. /**
  105905. * Add the required samplers to the current list.
  105906. * @param samplers defines the current sampler list.
  105907. */
  105908. static AddSamplers(samplers: string[]): void;
  105909. /**
  105910. * Makes a duplicate of the current configuration into another one.
  105911. * @param sheenConfiguration define the config where to copy the info
  105912. */
  105913. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105914. /**
  105915. * Serializes this BRDF configuration.
  105916. * @returns - An object with the serialized config.
  105917. */
  105918. serialize(): any;
  105919. /**
  105920. * Parses a anisotropy Configuration from a serialized object.
  105921. * @param source - Serialized object.
  105922. * @param scene Defines the scene we are parsing for
  105923. * @param rootUrl Defines the rootUrl to load from
  105924. */
  105925. parse(source: any, scene: Scene, rootUrl: string): void;
  105926. }
  105927. }
  105928. declare module BABYLON {
  105929. /**
  105930. * @hidden
  105931. */
  105932. export interface IMaterialSubSurfaceDefines {
  105933. SUBSURFACE: boolean;
  105934. SS_REFRACTION: boolean;
  105935. SS_TRANSLUCENCY: boolean;
  105936. SS_SCATTERING: boolean;
  105937. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105938. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105939. SS_REFRACTIONMAP_3D: boolean;
  105940. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105941. SS_LODINREFRACTIONALPHA: boolean;
  105942. SS_GAMMAREFRACTION: boolean;
  105943. SS_RGBDREFRACTION: boolean;
  105944. SS_LINEARSPECULARREFRACTION: boolean;
  105945. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105946. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105947. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105948. /** @hidden */
  105949. _areTexturesDirty: boolean;
  105950. }
  105951. /**
  105952. * Define the code related to the sub surface parameters of the pbr material.
  105953. */
  105954. export class PBRSubSurfaceConfiguration {
  105955. private _isRefractionEnabled;
  105956. /**
  105957. * Defines if the refraction is enabled in the material.
  105958. */
  105959. isRefractionEnabled: boolean;
  105960. private _isTranslucencyEnabled;
  105961. /**
  105962. * Defines if the translucency is enabled in the material.
  105963. */
  105964. isTranslucencyEnabled: boolean;
  105965. private _isScatteringEnabled;
  105966. /**
  105967. * Defines if the sub surface scattering is enabled in the material.
  105968. */
  105969. isScatteringEnabled: boolean;
  105970. private _scatteringDiffusionProfileIndex;
  105971. /**
  105972. * Diffusion profile for subsurface scattering.
  105973. * Useful for better scattering in the skins or foliages.
  105974. */
  105975. get scatteringDiffusionProfile(): Nullable<Color3>;
  105976. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105977. /**
  105978. * Defines the refraction intensity of the material.
  105979. * The refraction when enabled replaces the Diffuse part of the material.
  105980. * The intensity helps transitionning between diffuse and refraction.
  105981. */
  105982. refractionIntensity: number;
  105983. /**
  105984. * Defines the translucency intensity of the material.
  105985. * When translucency has been enabled, this defines how much of the "translucency"
  105986. * is addded to the diffuse part of the material.
  105987. */
  105988. translucencyIntensity: number;
  105989. /**
  105990. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105991. */
  105992. useAlbedoToTintRefraction: boolean;
  105993. private _thicknessTexture;
  105994. /**
  105995. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105996. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105997. * 0 would mean minimumThickness
  105998. * 1 would mean maximumThickness
  105999. * The other channels might be use as a mask to vary the different effects intensity.
  106000. */
  106001. thicknessTexture: Nullable<BaseTexture>;
  106002. private _refractionTexture;
  106003. /**
  106004. * Defines the texture to use for refraction.
  106005. */
  106006. refractionTexture: Nullable<BaseTexture>;
  106007. private _indexOfRefraction;
  106008. /**
  106009. * Index of refraction of the material base layer.
  106010. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106011. *
  106012. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106013. *
  106014. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106015. */
  106016. indexOfRefraction: number;
  106017. private _volumeIndexOfRefraction;
  106018. /**
  106019. * Index of refraction of the material's volume.
  106020. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106021. *
  106022. * This ONLY impacts refraction. If not provided or given a non-valid value,
  106023. * the volume will use the same IOR as the surface.
  106024. */
  106025. get volumeIndexOfRefraction(): number;
  106026. set volumeIndexOfRefraction(value: number);
  106027. private _invertRefractionY;
  106028. /**
  106029. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106030. */
  106031. invertRefractionY: boolean;
  106032. private _linkRefractionWithTransparency;
  106033. /**
  106034. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106035. * Materials half opaque for instance using refraction could benefit from this control.
  106036. */
  106037. linkRefractionWithTransparency: boolean;
  106038. /**
  106039. * Defines the minimum thickness stored in the thickness map.
  106040. * If no thickness map is defined, this value will be used to simulate thickness.
  106041. */
  106042. minimumThickness: number;
  106043. /**
  106044. * Defines the maximum thickness stored in the thickness map.
  106045. */
  106046. maximumThickness: number;
  106047. /**
  106048. * Defines the volume tint of the material.
  106049. * This is used for both translucency and scattering.
  106050. */
  106051. tintColor: Color3;
  106052. /**
  106053. * Defines the distance at which the tint color should be found in the media.
  106054. * This is used for refraction only.
  106055. */
  106056. tintColorAtDistance: number;
  106057. /**
  106058. * Defines how far each channel transmit through the media.
  106059. * It is defined as a color to simplify it selection.
  106060. */
  106061. diffusionDistance: Color3;
  106062. private _useMaskFromThicknessTexture;
  106063. /**
  106064. * Stores the intensity of the different subsurface effects in the thickness texture.
  106065. * * the green channel is the translucency intensity.
  106066. * * the blue channel is the scattering intensity.
  106067. * * the alpha channel is the refraction intensity.
  106068. */
  106069. useMaskFromThicknessTexture: boolean;
  106070. private _scene;
  106071. /** @hidden */
  106072. private _internalMarkAllSubMeshesAsTexturesDirty;
  106073. private _internalMarkScenePrePassDirty;
  106074. /** @hidden */
  106075. _markAllSubMeshesAsTexturesDirty(): void;
  106076. /** @hidden */
  106077. _markScenePrePassDirty(): void;
  106078. /**
  106079. * Instantiate a new istance of sub surface configuration.
  106080. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106081. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106082. * @param scene The scene
  106083. */
  106084. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106085. /**
  106086. * Gets wehter the submesh is ready to be used or not.
  106087. * @param defines the list of "defines" to update.
  106088. * @param scene defines the scene the material belongs to.
  106089. * @returns - boolean indicating that the submesh is ready or not.
  106090. */
  106091. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106092. /**
  106093. * Checks to see if a texture is used in the material.
  106094. * @param defines the list of "defines" to update.
  106095. * @param scene defines the scene to the material belongs to.
  106096. */
  106097. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106098. /**
  106099. * Binds the material data.
  106100. * @param uniformBuffer defines the Uniform buffer to fill in.
  106101. * @param scene defines the scene the material belongs to.
  106102. * @param engine defines the engine the material belongs to.
  106103. * @param isFrozen defines whether the material is frozen or not.
  106104. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106105. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106106. */
  106107. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106108. /**
  106109. * Unbinds the material from the mesh.
  106110. * @param activeEffect defines the effect that should be unbound from.
  106111. * @returns true if unbound, otherwise false
  106112. */
  106113. unbind(activeEffect: Effect): boolean;
  106114. /**
  106115. * Returns the texture used for refraction or null if none is used.
  106116. * @param scene defines the scene the material belongs to.
  106117. * @returns - Refraction texture if present. If no refraction texture and refraction
  106118. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106119. */
  106120. private _getRefractionTexture;
  106121. /**
  106122. * Returns true if alpha blending should be disabled.
  106123. */
  106124. get disableAlphaBlending(): boolean;
  106125. /**
  106126. * Fills the list of render target textures.
  106127. * @param renderTargets the list of render targets to update
  106128. */
  106129. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106130. /**
  106131. * Checks to see if a texture is used in the material.
  106132. * @param texture - Base texture to use.
  106133. * @returns - Boolean specifying if a texture is used in the material.
  106134. */
  106135. hasTexture(texture: BaseTexture): boolean;
  106136. /**
  106137. * Gets a boolean indicating that current material needs to register RTT
  106138. * @returns true if this uses a render target otherwise false.
  106139. */
  106140. hasRenderTargetTextures(): boolean;
  106141. /**
  106142. * Returns an array of the actively used textures.
  106143. * @param activeTextures Array of BaseTextures
  106144. */
  106145. getActiveTextures(activeTextures: BaseTexture[]): void;
  106146. /**
  106147. * Returns the animatable textures.
  106148. * @param animatables Array of animatable textures.
  106149. */
  106150. getAnimatables(animatables: IAnimatable[]): void;
  106151. /**
  106152. * Disposes the resources of the material.
  106153. * @param forceDisposeTextures - Forces the disposal of all textures.
  106154. */
  106155. dispose(forceDisposeTextures?: boolean): void;
  106156. /**
  106157. * Get the current class name of the texture useful for serialization or dynamic coding.
  106158. * @returns "PBRSubSurfaceConfiguration"
  106159. */
  106160. getClassName(): string;
  106161. /**
  106162. * Add fallbacks to the effect fallbacks list.
  106163. * @param defines defines the Base texture to use.
  106164. * @param fallbacks defines the current fallback list.
  106165. * @param currentRank defines the current fallback rank.
  106166. * @returns the new fallback rank.
  106167. */
  106168. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106169. /**
  106170. * Add the required uniforms to the current list.
  106171. * @param uniforms defines the current uniform list.
  106172. */
  106173. static AddUniforms(uniforms: string[]): void;
  106174. /**
  106175. * Add the required samplers to the current list.
  106176. * @param samplers defines the current sampler list.
  106177. */
  106178. static AddSamplers(samplers: string[]): void;
  106179. /**
  106180. * Add the required uniforms to the current buffer.
  106181. * @param uniformBuffer defines the current uniform buffer.
  106182. */
  106183. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106184. /**
  106185. * Makes a duplicate of the current configuration into another one.
  106186. * @param configuration define the config where to copy the info
  106187. */
  106188. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106189. /**
  106190. * Serializes this Sub Surface configuration.
  106191. * @returns - An object with the serialized config.
  106192. */
  106193. serialize(): any;
  106194. /**
  106195. * Parses a anisotropy Configuration from a serialized object.
  106196. * @param source - Serialized object.
  106197. * @param scene Defines the scene we are parsing for
  106198. * @param rootUrl Defines the rootUrl to load from
  106199. */
  106200. parse(source: any, scene: Scene, rootUrl: string): void;
  106201. }
  106202. }
  106203. declare module BABYLON {
  106204. /**
  106205. * Class representing spherical harmonics coefficients to the 3rd degree
  106206. */
  106207. export class SphericalHarmonics {
  106208. /**
  106209. * Defines whether or not the harmonics have been prescaled for rendering.
  106210. */
  106211. preScaled: boolean;
  106212. /**
  106213. * The l0,0 coefficients of the spherical harmonics
  106214. */
  106215. l00: Vector3;
  106216. /**
  106217. * The l1,-1 coefficients of the spherical harmonics
  106218. */
  106219. l1_1: Vector3;
  106220. /**
  106221. * The l1,0 coefficients of the spherical harmonics
  106222. */
  106223. l10: Vector3;
  106224. /**
  106225. * The l1,1 coefficients of the spherical harmonics
  106226. */
  106227. l11: Vector3;
  106228. /**
  106229. * The l2,-2 coefficients of the spherical harmonics
  106230. */
  106231. l2_2: Vector3;
  106232. /**
  106233. * The l2,-1 coefficients of the spherical harmonics
  106234. */
  106235. l2_1: Vector3;
  106236. /**
  106237. * The l2,0 coefficients of the spherical harmonics
  106238. */
  106239. l20: Vector3;
  106240. /**
  106241. * The l2,1 coefficients of the spherical harmonics
  106242. */
  106243. l21: Vector3;
  106244. /**
  106245. * The l2,2 coefficients of the spherical harmonics
  106246. */
  106247. l22: Vector3;
  106248. /**
  106249. * Adds a light to the spherical harmonics
  106250. * @param direction the direction of the light
  106251. * @param color the color of the light
  106252. * @param deltaSolidAngle the delta solid angle of the light
  106253. */
  106254. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106255. /**
  106256. * Scales the spherical harmonics by the given amount
  106257. * @param scale the amount to scale
  106258. */
  106259. scaleInPlace(scale: number): void;
  106260. /**
  106261. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106262. *
  106263. * ```
  106264. * E_lm = A_l * L_lm
  106265. * ```
  106266. *
  106267. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106268. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106269. * the scaling factors are given in equation 9.
  106270. */
  106271. convertIncidentRadianceToIrradiance(): void;
  106272. /**
  106273. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106274. *
  106275. * ```
  106276. * L = (1/pi) * E * rho
  106277. * ```
  106278. *
  106279. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106280. */
  106281. convertIrradianceToLambertianRadiance(): void;
  106282. /**
  106283. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106284. * required operations at run time.
  106285. *
  106286. * This is simply done by scaling back the SH with Ylm constants parameter.
  106287. * The trigonometric part being applied by the shader at run time.
  106288. */
  106289. preScaleForRendering(): void;
  106290. /**
  106291. * Constructs a spherical harmonics from an array.
  106292. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106293. * @returns the spherical harmonics
  106294. */
  106295. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106296. /**
  106297. * Gets the spherical harmonics from polynomial
  106298. * @param polynomial the spherical polynomial
  106299. * @returns the spherical harmonics
  106300. */
  106301. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106302. }
  106303. /**
  106304. * Class representing spherical polynomial coefficients to the 3rd degree
  106305. */
  106306. export class SphericalPolynomial {
  106307. private _harmonics;
  106308. /**
  106309. * The spherical harmonics used to create the polynomials.
  106310. */
  106311. get preScaledHarmonics(): SphericalHarmonics;
  106312. /**
  106313. * The x coefficients of the spherical polynomial
  106314. */
  106315. x: Vector3;
  106316. /**
  106317. * The y coefficients of the spherical polynomial
  106318. */
  106319. y: Vector3;
  106320. /**
  106321. * The z coefficients of the spherical polynomial
  106322. */
  106323. z: Vector3;
  106324. /**
  106325. * The xx coefficients of the spherical polynomial
  106326. */
  106327. xx: Vector3;
  106328. /**
  106329. * The yy coefficients of the spherical polynomial
  106330. */
  106331. yy: Vector3;
  106332. /**
  106333. * The zz coefficients of the spherical polynomial
  106334. */
  106335. zz: Vector3;
  106336. /**
  106337. * The xy coefficients of the spherical polynomial
  106338. */
  106339. xy: Vector3;
  106340. /**
  106341. * The yz coefficients of the spherical polynomial
  106342. */
  106343. yz: Vector3;
  106344. /**
  106345. * The zx coefficients of the spherical polynomial
  106346. */
  106347. zx: Vector3;
  106348. /**
  106349. * Adds an ambient color to the spherical polynomial
  106350. * @param color the color to add
  106351. */
  106352. addAmbient(color: Color3): void;
  106353. /**
  106354. * Scales the spherical polynomial by the given amount
  106355. * @param scale the amount to scale
  106356. */
  106357. scaleInPlace(scale: number): void;
  106358. /**
  106359. * Gets the spherical polynomial from harmonics
  106360. * @param harmonics the spherical harmonics
  106361. * @returns the spherical polynomial
  106362. */
  106363. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106364. /**
  106365. * Constructs a spherical polynomial from an array.
  106366. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106367. * @returns the spherical polynomial
  106368. */
  106369. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106370. }
  106371. }
  106372. declare module BABYLON {
  106373. /**
  106374. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106375. */
  106376. export interface CubeMapInfo {
  106377. /**
  106378. * The pixel array for the front face.
  106379. * This is stored in format, left to right, up to down format.
  106380. */
  106381. front: Nullable<ArrayBufferView>;
  106382. /**
  106383. * The pixel array for the back face.
  106384. * This is stored in format, left to right, up to down format.
  106385. */
  106386. back: Nullable<ArrayBufferView>;
  106387. /**
  106388. * The pixel array for the left face.
  106389. * This is stored in format, left to right, up to down format.
  106390. */
  106391. left: Nullable<ArrayBufferView>;
  106392. /**
  106393. * The pixel array for the right face.
  106394. * This is stored in format, left to right, up to down format.
  106395. */
  106396. right: Nullable<ArrayBufferView>;
  106397. /**
  106398. * The pixel array for the up face.
  106399. * This is stored in format, left to right, up to down format.
  106400. */
  106401. up: Nullable<ArrayBufferView>;
  106402. /**
  106403. * The pixel array for the down face.
  106404. * This is stored in format, left to right, up to down format.
  106405. */
  106406. down: Nullable<ArrayBufferView>;
  106407. /**
  106408. * The size of the cubemap stored.
  106409. *
  106410. * Each faces will be size * size pixels.
  106411. */
  106412. size: number;
  106413. /**
  106414. * The format of the texture.
  106415. *
  106416. * RGBA, RGB.
  106417. */
  106418. format: number;
  106419. /**
  106420. * The type of the texture data.
  106421. *
  106422. * UNSIGNED_INT, FLOAT.
  106423. */
  106424. type: number;
  106425. /**
  106426. * Specifies whether the texture is in gamma space.
  106427. */
  106428. gammaSpace: boolean;
  106429. }
  106430. /**
  106431. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106432. */
  106433. export class PanoramaToCubeMapTools {
  106434. private static FACE_LEFT;
  106435. private static FACE_RIGHT;
  106436. private static FACE_FRONT;
  106437. private static FACE_BACK;
  106438. private static FACE_DOWN;
  106439. private static FACE_UP;
  106440. /**
  106441. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106442. *
  106443. * @param float32Array The source data.
  106444. * @param inputWidth The width of the input panorama.
  106445. * @param inputHeight The height of the input panorama.
  106446. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106447. * @return The cubemap data
  106448. */
  106449. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106450. private static CreateCubemapTexture;
  106451. private static CalcProjectionSpherical;
  106452. }
  106453. }
  106454. declare module BABYLON {
  106455. /**
  106456. * Helper class dealing with the extraction of spherical polynomial dataArray
  106457. * from a cube map.
  106458. */
  106459. export class CubeMapToSphericalPolynomialTools {
  106460. private static FileFaces;
  106461. /**
  106462. * Converts a texture to the according Spherical Polynomial data.
  106463. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106464. *
  106465. * @param texture The texture to extract the information from.
  106466. * @return The Spherical Polynomial data.
  106467. */
  106468. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106469. /**
  106470. * Converts a cubemap to the according Spherical Polynomial data.
  106471. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106472. *
  106473. * @param cubeInfo The Cube map to extract the information from.
  106474. * @return The Spherical Polynomial data.
  106475. */
  106476. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106477. }
  106478. }
  106479. declare module BABYLON {
  106480. interface BaseTexture {
  106481. /**
  106482. * Get the polynomial representation of the texture data.
  106483. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106484. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106485. */
  106486. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106487. }
  106488. }
  106489. declare module BABYLON {
  106490. /** @hidden */
  106491. export var pbrFragmentDeclaration: {
  106492. name: string;
  106493. shader: string;
  106494. };
  106495. }
  106496. declare module BABYLON {
  106497. /** @hidden */
  106498. export var pbrUboDeclaration: {
  106499. name: string;
  106500. shader: string;
  106501. };
  106502. }
  106503. declare module BABYLON {
  106504. /** @hidden */
  106505. export var pbrFragmentExtraDeclaration: {
  106506. name: string;
  106507. shader: string;
  106508. };
  106509. }
  106510. declare module BABYLON {
  106511. /** @hidden */
  106512. export var pbrFragmentSamplersDeclaration: {
  106513. name: string;
  106514. shader: string;
  106515. };
  106516. }
  106517. declare module BABYLON {
  106518. /** @hidden */
  106519. export var subSurfaceScatteringFunctions: {
  106520. name: string;
  106521. shader: string;
  106522. };
  106523. }
  106524. declare module BABYLON {
  106525. /** @hidden */
  106526. export var importanceSampling: {
  106527. name: string;
  106528. shader: string;
  106529. };
  106530. }
  106531. declare module BABYLON {
  106532. /** @hidden */
  106533. export var pbrHelperFunctions: {
  106534. name: string;
  106535. shader: string;
  106536. };
  106537. }
  106538. declare module BABYLON {
  106539. /** @hidden */
  106540. export var harmonicsFunctions: {
  106541. name: string;
  106542. shader: string;
  106543. };
  106544. }
  106545. declare module BABYLON {
  106546. /** @hidden */
  106547. export var pbrDirectLightingSetupFunctions: {
  106548. name: string;
  106549. shader: string;
  106550. };
  106551. }
  106552. declare module BABYLON {
  106553. /** @hidden */
  106554. export var pbrDirectLightingFalloffFunctions: {
  106555. name: string;
  106556. shader: string;
  106557. };
  106558. }
  106559. declare module BABYLON {
  106560. /** @hidden */
  106561. export var pbrBRDFFunctions: {
  106562. name: string;
  106563. shader: string;
  106564. };
  106565. }
  106566. declare module BABYLON {
  106567. /** @hidden */
  106568. export var hdrFilteringFunctions: {
  106569. name: string;
  106570. shader: string;
  106571. };
  106572. }
  106573. declare module BABYLON {
  106574. /** @hidden */
  106575. export var pbrDirectLightingFunctions: {
  106576. name: string;
  106577. shader: string;
  106578. };
  106579. }
  106580. declare module BABYLON {
  106581. /** @hidden */
  106582. export var pbrIBLFunctions: {
  106583. name: string;
  106584. shader: string;
  106585. };
  106586. }
  106587. declare module BABYLON {
  106588. /** @hidden */
  106589. export var pbrBlockAlbedoOpacity: {
  106590. name: string;
  106591. shader: string;
  106592. };
  106593. }
  106594. declare module BABYLON {
  106595. /** @hidden */
  106596. export var pbrBlockReflectivity: {
  106597. name: string;
  106598. shader: string;
  106599. };
  106600. }
  106601. declare module BABYLON {
  106602. /** @hidden */
  106603. export var pbrBlockAmbientOcclusion: {
  106604. name: string;
  106605. shader: string;
  106606. };
  106607. }
  106608. declare module BABYLON {
  106609. /** @hidden */
  106610. export var pbrBlockAlphaFresnel: {
  106611. name: string;
  106612. shader: string;
  106613. };
  106614. }
  106615. declare module BABYLON {
  106616. /** @hidden */
  106617. export var pbrBlockAnisotropic: {
  106618. name: string;
  106619. shader: string;
  106620. };
  106621. }
  106622. declare module BABYLON {
  106623. /** @hidden */
  106624. export var pbrBlockReflection: {
  106625. name: string;
  106626. shader: string;
  106627. };
  106628. }
  106629. declare module BABYLON {
  106630. /** @hidden */
  106631. export var pbrBlockSheen: {
  106632. name: string;
  106633. shader: string;
  106634. };
  106635. }
  106636. declare module BABYLON {
  106637. /** @hidden */
  106638. export var pbrBlockClearcoat: {
  106639. name: string;
  106640. shader: string;
  106641. };
  106642. }
  106643. declare module BABYLON {
  106644. /** @hidden */
  106645. export var pbrBlockSubSurface: {
  106646. name: string;
  106647. shader: string;
  106648. };
  106649. }
  106650. declare module BABYLON {
  106651. /** @hidden */
  106652. export var pbrBlockNormalGeometric: {
  106653. name: string;
  106654. shader: string;
  106655. };
  106656. }
  106657. declare module BABYLON {
  106658. /** @hidden */
  106659. export var pbrBlockNormalFinal: {
  106660. name: string;
  106661. shader: string;
  106662. };
  106663. }
  106664. declare module BABYLON {
  106665. /** @hidden */
  106666. export var pbrBlockLightmapInit: {
  106667. name: string;
  106668. shader: string;
  106669. };
  106670. }
  106671. declare module BABYLON {
  106672. /** @hidden */
  106673. export var pbrBlockGeometryInfo: {
  106674. name: string;
  106675. shader: string;
  106676. };
  106677. }
  106678. declare module BABYLON {
  106679. /** @hidden */
  106680. export var pbrBlockReflectance0: {
  106681. name: string;
  106682. shader: string;
  106683. };
  106684. }
  106685. declare module BABYLON {
  106686. /** @hidden */
  106687. export var pbrBlockReflectance: {
  106688. name: string;
  106689. shader: string;
  106690. };
  106691. }
  106692. declare module BABYLON {
  106693. /** @hidden */
  106694. export var pbrBlockDirectLighting: {
  106695. name: string;
  106696. shader: string;
  106697. };
  106698. }
  106699. declare module BABYLON {
  106700. /** @hidden */
  106701. export var pbrBlockFinalLitComponents: {
  106702. name: string;
  106703. shader: string;
  106704. };
  106705. }
  106706. declare module BABYLON {
  106707. /** @hidden */
  106708. export var pbrBlockFinalUnlitComponents: {
  106709. name: string;
  106710. shader: string;
  106711. };
  106712. }
  106713. declare module BABYLON {
  106714. /** @hidden */
  106715. export var pbrBlockFinalColorComposition: {
  106716. name: string;
  106717. shader: string;
  106718. };
  106719. }
  106720. declare module BABYLON {
  106721. /** @hidden */
  106722. export var pbrBlockImageProcessing: {
  106723. name: string;
  106724. shader: string;
  106725. };
  106726. }
  106727. declare module BABYLON {
  106728. /** @hidden */
  106729. export var pbrDebug: {
  106730. name: string;
  106731. shader: string;
  106732. };
  106733. }
  106734. declare module BABYLON {
  106735. /** @hidden */
  106736. export var pbrPixelShader: {
  106737. name: string;
  106738. shader: string;
  106739. };
  106740. }
  106741. declare module BABYLON {
  106742. /** @hidden */
  106743. export var pbrVertexDeclaration: {
  106744. name: string;
  106745. shader: string;
  106746. };
  106747. }
  106748. declare module BABYLON {
  106749. /** @hidden */
  106750. export var pbrVertexShader: {
  106751. name: string;
  106752. shader: string;
  106753. };
  106754. }
  106755. declare module BABYLON {
  106756. /**
  106757. * Manages the defines for the PBR Material.
  106758. * @hidden
  106759. */
  106760. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106761. PBR: boolean;
  106762. NUM_SAMPLES: string;
  106763. REALTIME_FILTERING: boolean;
  106764. MAINUV1: boolean;
  106765. MAINUV2: boolean;
  106766. UV1: boolean;
  106767. UV2: boolean;
  106768. ALBEDO: boolean;
  106769. GAMMAALBEDO: boolean;
  106770. ALBEDODIRECTUV: number;
  106771. VERTEXCOLOR: boolean;
  106772. DETAIL: boolean;
  106773. DETAILDIRECTUV: number;
  106774. DETAIL_NORMALBLENDMETHOD: number;
  106775. AMBIENT: boolean;
  106776. AMBIENTDIRECTUV: number;
  106777. AMBIENTINGRAYSCALE: boolean;
  106778. OPACITY: boolean;
  106779. VERTEXALPHA: boolean;
  106780. OPACITYDIRECTUV: number;
  106781. OPACITYRGB: boolean;
  106782. ALPHATEST: boolean;
  106783. DEPTHPREPASS: boolean;
  106784. ALPHABLEND: boolean;
  106785. ALPHAFROMALBEDO: boolean;
  106786. ALPHATESTVALUE: string;
  106787. SPECULAROVERALPHA: boolean;
  106788. RADIANCEOVERALPHA: boolean;
  106789. ALPHAFRESNEL: boolean;
  106790. LINEARALPHAFRESNEL: boolean;
  106791. PREMULTIPLYALPHA: boolean;
  106792. EMISSIVE: boolean;
  106793. EMISSIVEDIRECTUV: number;
  106794. REFLECTIVITY: boolean;
  106795. REFLECTIVITYDIRECTUV: number;
  106796. SPECULARTERM: boolean;
  106797. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106798. MICROSURFACEAUTOMATIC: boolean;
  106799. LODBASEDMICROSFURACE: boolean;
  106800. MICROSURFACEMAP: boolean;
  106801. MICROSURFACEMAPDIRECTUV: number;
  106802. METALLICWORKFLOW: boolean;
  106803. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106804. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106805. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106806. AOSTOREINMETALMAPRED: boolean;
  106807. METALLIC_REFLECTANCE: boolean;
  106808. METALLIC_REFLECTANCEDIRECTUV: number;
  106809. ENVIRONMENTBRDF: boolean;
  106810. ENVIRONMENTBRDF_RGBD: boolean;
  106811. NORMAL: boolean;
  106812. TANGENT: boolean;
  106813. BUMP: boolean;
  106814. BUMPDIRECTUV: number;
  106815. OBJECTSPACE_NORMALMAP: boolean;
  106816. PARALLAX: boolean;
  106817. PARALLAXOCCLUSION: boolean;
  106818. NORMALXYSCALE: boolean;
  106819. LIGHTMAP: boolean;
  106820. LIGHTMAPDIRECTUV: number;
  106821. USELIGHTMAPASSHADOWMAP: boolean;
  106822. GAMMALIGHTMAP: boolean;
  106823. RGBDLIGHTMAP: boolean;
  106824. REFLECTION: boolean;
  106825. REFLECTIONMAP_3D: boolean;
  106826. REFLECTIONMAP_SPHERICAL: boolean;
  106827. REFLECTIONMAP_PLANAR: boolean;
  106828. REFLECTIONMAP_CUBIC: boolean;
  106829. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106830. REFLECTIONMAP_PROJECTION: boolean;
  106831. REFLECTIONMAP_SKYBOX: boolean;
  106832. REFLECTIONMAP_EXPLICIT: boolean;
  106833. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106834. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106835. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106836. INVERTCUBICMAP: boolean;
  106837. USESPHERICALFROMREFLECTIONMAP: boolean;
  106838. USEIRRADIANCEMAP: boolean;
  106839. SPHERICAL_HARMONICS: boolean;
  106840. USESPHERICALINVERTEX: boolean;
  106841. REFLECTIONMAP_OPPOSITEZ: boolean;
  106842. LODINREFLECTIONALPHA: boolean;
  106843. GAMMAREFLECTION: boolean;
  106844. RGBDREFLECTION: boolean;
  106845. LINEARSPECULARREFLECTION: boolean;
  106846. RADIANCEOCCLUSION: boolean;
  106847. HORIZONOCCLUSION: boolean;
  106848. INSTANCES: boolean;
  106849. THIN_INSTANCES: boolean;
  106850. PREPASS: boolean;
  106851. PREPASS_IRRADIANCE: boolean;
  106852. PREPASS_IRRADIANCE_INDEX: number;
  106853. PREPASS_ALBEDO: boolean;
  106854. PREPASS_ALBEDO_INDEX: number;
  106855. PREPASS_DEPTHNORMAL: boolean;
  106856. PREPASS_DEPTHNORMAL_INDEX: number;
  106857. PREPASS_POSITION: boolean;
  106858. PREPASS_POSITION_INDEX: number;
  106859. PREPASS_VELOCITY: boolean;
  106860. PREPASS_VELOCITY_INDEX: number;
  106861. PREPASS_REFLECTIVITY: boolean;
  106862. PREPASS_REFLECTIVITY_INDEX: number;
  106863. SCENE_MRT_COUNT: number;
  106864. NUM_BONE_INFLUENCERS: number;
  106865. BonesPerMesh: number;
  106866. BONETEXTURE: boolean;
  106867. BONES_VELOCITY_ENABLED: boolean;
  106868. NONUNIFORMSCALING: boolean;
  106869. MORPHTARGETS: boolean;
  106870. MORPHTARGETS_NORMAL: boolean;
  106871. MORPHTARGETS_TANGENT: boolean;
  106872. MORPHTARGETS_UV: boolean;
  106873. NUM_MORPH_INFLUENCERS: number;
  106874. IMAGEPROCESSING: boolean;
  106875. VIGNETTE: boolean;
  106876. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106877. VIGNETTEBLENDMODEOPAQUE: boolean;
  106878. TONEMAPPING: boolean;
  106879. TONEMAPPING_ACES: boolean;
  106880. CONTRAST: boolean;
  106881. COLORCURVES: boolean;
  106882. COLORGRADING: boolean;
  106883. COLORGRADING3D: boolean;
  106884. SAMPLER3DGREENDEPTH: boolean;
  106885. SAMPLER3DBGRMAP: boolean;
  106886. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106887. EXPOSURE: boolean;
  106888. MULTIVIEW: boolean;
  106889. USEPHYSICALLIGHTFALLOFF: boolean;
  106890. USEGLTFLIGHTFALLOFF: boolean;
  106891. TWOSIDEDLIGHTING: boolean;
  106892. SHADOWFLOAT: boolean;
  106893. CLIPPLANE: boolean;
  106894. CLIPPLANE2: boolean;
  106895. CLIPPLANE3: boolean;
  106896. CLIPPLANE4: boolean;
  106897. CLIPPLANE5: boolean;
  106898. CLIPPLANE6: boolean;
  106899. POINTSIZE: boolean;
  106900. FOG: boolean;
  106901. LOGARITHMICDEPTH: boolean;
  106902. FORCENORMALFORWARD: boolean;
  106903. SPECULARAA: boolean;
  106904. CLEARCOAT: boolean;
  106905. CLEARCOAT_DEFAULTIOR: boolean;
  106906. CLEARCOAT_TEXTURE: boolean;
  106907. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106908. CLEARCOAT_TEXTUREDIRECTUV: number;
  106909. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106910. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106911. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106912. CLEARCOAT_BUMP: boolean;
  106913. CLEARCOAT_BUMPDIRECTUV: number;
  106914. CLEARCOAT_REMAP_F0: boolean;
  106915. CLEARCOAT_TINT: boolean;
  106916. CLEARCOAT_TINT_TEXTURE: boolean;
  106917. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106918. ANISOTROPIC: boolean;
  106919. ANISOTROPIC_TEXTURE: boolean;
  106920. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106921. BRDF_V_HEIGHT_CORRELATED: boolean;
  106922. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106923. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106924. SHEEN: boolean;
  106925. SHEEN_TEXTURE: boolean;
  106926. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106927. SHEEN_TEXTUREDIRECTUV: number;
  106928. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106929. SHEEN_LINKWITHALBEDO: boolean;
  106930. SHEEN_ROUGHNESS: boolean;
  106931. SHEEN_ALBEDOSCALING: boolean;
  106932. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106933. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106934. SUBSURFACE: boolean;
  106935. SS_REFRACTION: boolean;
  106936. SS_TRANSLUCENCY: boolean;
  106937. SS_SCATTERING: boolean;
  106938. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106939. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106940. SS_REFRACTIONMAP_3D: boolean;
  106941. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106942. SS_LODINREFRACTIONALPHA: boolean;
  106943. SS_GAMMAREFRACTION: boolean;
  106944. SS_RGBDREFRACTION: boolean;
  106945. SS_LINEARSPECULARREFRACTION: boolean;
  106946. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106947. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106948. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106949. UNLIT: boolean;
  106950. DEBUGMODE: number;
  106951. /**
  106952. * Initializes the PBR Material defines.
  106953. */
  106954. constructor();
  106955. /**
  106956. * Resets the PBR Material defines.
  106957. */
  106958. reset(): void;
  106959. }
  106960. /**
  106961. * The Physically based material base class of BJS.
  106962. *
  106963. * This offers the main features of a standard PBR material.
  106964. * For more information, please refer to the documentation :
  106965. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106966. */
  106967. export abstract class PBRBaseMaterial extends PushMaterial {
  106968. /**
  106969. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106970. */
  106971. static readonly PBRMATERIAL_OPAQUE: number;
  106972. /**
  106973. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106974. */
  106975. static readonly PBRMATERIAL_ALPHATEST: number;
  106976. /**
  106977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106978. */
  106979. static readonly PBRMATERIAL_ALPHABLEND: number;
  106980. /**
  106981. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106982. * They are also discarded below the alpha cutoff threshold to improve performances.
  106983. */
  106984. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106985. /**
  106986. * Defines the default value of how much AO map is occluding the analytical lights
  106987. * (point spot...).
  106988. */
  106989. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106990. /**
  106991. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106992. */
  106993. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106994. /**
  106995. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106996. * to enhance interoperability with other engines.
  106997. */
  106998. static readonly LIGHTFALLOFF_GLTF: number;
  106999. /**
  107000. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107001. * to enhance interoperability with other materials.
  107002. */
  107003. static readonly LIGHTFALLOFF_STANDARD: number;
  107004. /**
  107005. * Intensity of the direct lights e.g. the four lights available in your scene.
  107006. * This impacts both the direct diffuse and specular highlights.
  107007. */
  107008. protected _directIntensity: number;
  107009. /**
  107010. * Intensity of the emissive part of the material.
  107011. * This helps controlling the emissive effect without modifying the emissive color.
  107012. */
  107013. protected _emissiveIntensity: number;
  107014. /**
  107015. * Intensity of the environment e.g. how much the environment will light the object
  107016. * either through harmonics for rough material or through the refelction for shiny ones.
  107017. */
  107018. protected _environmentIntensity: number;
  107019. /**
  107020. * This is a special control allowing the reduction of the specular highlights coming from the
  107021. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107022. */
  107023. protected _specularIntensity: number;
  107024. /**
  107025. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107026. */
  107027. private _lightingInfos;
  107028. /**
  107029. * Debug Control allowing disabling the bump map on this material.
  107030. */
  107031. protected _disableBumpMap: boolean;
  107032. /**
  107033. * AKA Diffuse Texture in standard nomenclature.
  107034. */
  107035. protected _albedoTexture: Nullable<BaseTexture>;
  107036. /**
  107037. * AKA Occlusion Texture in other nomenclature.
  107038. */
  107039. protected _ambientTexture: Nullable<BaseTexture>;
  107040. /**
  107041. * AKA Occlusion Texture Intensity in other nomenclature.
  107042. */
  107043. protected _ambientTextureStrength: number;
  107044. /**
  107045. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107046. * 1 means it completely occludes it
  107047. * 0 mean it has no impact
  107048. */
  107049. protected _ambientTextureImpactOnAnalyticalLights: number;
  107050. /**
  107051. * Stores the alpha values in a texture.
  107052. */
  107053. protected _opacityTexture: Nullable<BaseTexture>;
  107054. /**
  107055. * Stores the reflection values in a texture.
  107056. */
  107057. protected _reflectionTexture: Nullable<BaseTexture>;
  107058. /**
  107059. * Stores the emissive values in a texture.
  107060. */
  107061. protected _emissiveTexture: Nullable<BaseTexture>;
  107062. /**
  107063. * AKA Specular texture in other nomenclature.
  107064. */
  107065. protected _reflectivityTexture: Nullable<BaseTexture>;
  107066. /**
  107067. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107068. */
  107069. protected _metallicTexture: Nullable<BaseTexture>;
  107070. /**
  107071. * Specifies the metallic scalar of the metallic/roughness workflow.
  107072. * Can also be used to scale the metalness values of the metallic texture.
  107073. */
  107074. protected _metallic: Nullable<number>;
  107075. /**
  107076. * Specifies the roughness scalar of the metallic/roughness workflow.
  107077. * Can also be used to scale the roughness values of the metallic texture.
  107078. */
  107079. protected _roughness: Nullable<number>;
  107080. /**
  107081. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107082. * By default the indexOfrefraction is used to compute F0;
  107083. *
  107084. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107085. *
  107086. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107087. * F90 = metallicReflectanceColor;
  107088. */
  107089. protected _metallicF0Factor: number;
  107090. /**
  107091. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107092. * By default the F90 is always 1;
  107093. *
  107094. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107095. *
  107096. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107097. * F90 = metallicReflectanceColor;
  107098. */
  107099. protected _metallicReflectanceColor: Color3;
  107100. /**
  107101. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107102. * This is multiply against the scalar values defined in the material.
  107103. */
  107104. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107105. /**
  107106. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107107. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107108. */
  107109. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107110. /**
  107111. * Stores surface normal data used to displace a mesh in a texture.
  107112. */
  107113. protected _bumpTexture: Nullable<BaseTexture>;
  107114. /**
  107115. * Stores the pre-calculated light information of a mesh in a texture.
  107116. */
  107117. protected _lightmapTexture: Nullable<BaseTexture>;
  107118. /**
  107119. * The color of a material in ambient lighting.
  107120. */
  107121. protected _ambientColor: Color3;
  107122. /**
  107123. * AKA Diffuse Color in other nomenclature.
  107124. */
  107125. protected _albedoColor: Color3;
  107126. /**
  107127. * AKA Specular Color in other nomenclature.
  107128. */
  107129. protected _reflectivityColor: Color3;
  107130. /**
  107131. * The color applied when light is reflected from a material.
  107132. */
  107133. protected _reflectionColor: Color3;
  107134. /**
  107135. * The color applied when light is emitted from a material.
  107136. */
  107137. protected _emissiveColor: Color3;
  107138. /**
  107139. * AKA Glossiness in other nomenclature.
  107140. */
  107141. protected _microSurface: number;
  107142. /**
  107143. * Specifies that the material will use the light map as a show map.
  107144. */
  107145. protected _useLightmapAsShadowmap: boolean;
  107146. /**
  107147. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107148. * makes the reflect vector face the model (under horizon).
  107149. */
  107150. protected _useHorizonOcclusion: boolean;
  107151. /**
  107152. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107153. * too much the area relying on ambient texture to define their ambient occlusion.
  107154. */
  107155. protected _useRadianceOcclusion: boolean;
  107156. /**
  107157. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107158. */
  107159. protected _useAlphaFromAlbedoTexture: boolean;
  107160. /**
  107161. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107162. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107163. */
  107164. protected _useSpecularOverAlpha: boolean;
  107165. /**
  107166. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107167. */
  107168. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107169. /**
  107170. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107171. */
  107172. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107173. /**
  107174. * Specifies if the metallic texture contains the roughness information in its green channel.
  107175. */
  107176. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107177. /**
  107178. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107179. */
  107180. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107181. /**
  107182. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107183. */
  107184. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107185. /**
  107186. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107187. */
  107188. protected _useAmbientInGrayScale: boolean;
  107189. /**
  107190. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107191. * The material will try to infer what glossiness each pixel should be.
  107192. */
  107193. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107194. /**
  107195. * Defines the falloff type used in this material.
  107196. * It by default is Physical.
  107197. */
  107198. protected _lightFalloff: number;
  107199. /**
  107200. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107201. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107202. */
  107203. protected _useRadianceOverAlpha: boolean;
  107204. /**
  107205. * Allows using an object space normal map (instead of tangent space).
  107206. */
  107207. protected _useObjectSpaceNormalMap: boolean;
  107208. /**
  107209. * Allows using the bump map in parallax mode.
  107210. */
  107211. protected _useParallax: boolean;
  107212. /**
  107213. * Allows using the bump map in parallax occlusion mode.
  107214. */
  107215. protected _useParallaxOcclusion: boolean;
  107216. /**
  107217. * Controls the scale bias of the parallax mode.
  107218. */
  107219. protected _parallaxScaleBias: number;
  107220. /**
  107221. * If sets to true, disables all the lights affecting the material.
  107222. */
  107223. protected _disableLighting: boolean;
  107224. /**
  107225. * Number of Simultaneous lights allowed on the material.
  107226. */
  107227. protected _maxSimultaneousLights: number;
  107228. /**
  107229. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107230. */
  107231. protected _invertNormalMapX: boolean;
  107232. /**
  107233. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107234. */
  107235. protected _invertNormalMapY: boolean;
  107236. /**
  107237. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107238. */
  107239. protected _twoSidedLighting: boolean;
  107240. /**
  107241. * Defines the alpha limits in alpha test mode.
  107242. */
  107243. protected _alphaCutOff: number;
  107244. /**
  107245. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107246. */
  107247. protected _forceAlphaTest: boolean;
  107248. /**
  107249. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107250. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107251. */
  107252. protected _useAlphaFresnel: boolean;
  107253. /**
  107254. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107255. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107256. */
  107257. protected _useLinearAlphaFresnel: boolean;
  107258. /**
  107259. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107260. * from cos thetav and roughness:
  107261. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107262. */
  107263. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107264. /**
  107265. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107266. */
  107267. protected _forceIrradianceInFragment: boolean;
  107268. private _realTimeFiltering;
  107269. /**
  107270. * Enables realtime filtering on the texture.
  107271. */
  107272. get realTimeFiltering(): boolean;
  107273. set realTimeFiltering(b: boolean);
  107274. private _realTimeFilteringQuality;
  107275. /**
  107276. * Quality switch for realtime filtering
  107277. */
  107278. get realTimeFilteringQuality(): number;
  107279. set realTimeFilteringQuality(n: number);
  107280. /**
  107281. * Can this material render to several textures at once
  107282. */
  107283. get canRenderToMRT(): boolean;
  107284. /**
  107285. * Force normal to face away from face.
  107286. */
  107287. protected _forceNormalForward: boolean;
  107288. /**
  107289. * Enables specular anti aliasing in the PBR shader.
  107290. * It will both interacts on the Geometry for analytical and IBL lighting.
  107291. * It also prefilter the roughness map based on the bump values.
  107292. */
  107293. protected _enableSpecularAntiAliasing: boolean;
  107294. /**
  107295. * Default configuration related to image processing available in the PBR Material.
  107296. */
  107297. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107298. /**
  107299. * Keep track of the image processing observer to allow dispose and replace.
  107300. */
  107301. private _imageProcessingObserver;
  107302. /**
  107303. * Attaches a new image processing configuration to the PBR Material.
  107304. * @param configuration
  107305. */
  107306. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107307. /**
  107308. * Stores the available render targets.
  107309. */
  107310. private _renderTargets;
  107311. /**
  107312. * Sets the global ambient color for the material used in lighting calculations.
  107313. */
  107314. private _globalAmbientColor;
  107315. /**
  107316. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107317. */
  107318. private _useLogarithmicDepth;
  107319. /**
  107320. * If set to true, no lighting calculations will be applied.
  107321. */
  107322. private _unlit;
  107323. private _debugMode;
  107324. /**
  107325. * @hidden
  107326. * This is reserved for the inspector.
  107327. * Defines the material debug mode.
  107328. * It helps seeing only some components of the material while troubleshooting.
  107329. */
  107330. debugMode: number;
  107331. /**
  107332. * @hidden
  107333. * This is reserved for the inspector.
  107334. * Specify from where on screen the debug mode should start.
  107335. * The value goes from -1 (full screen) to 1 (not visible)
  107336. * It helps with side by side comparison against the final render
  107337. * This defaults to -1
  107338. */
  107339. private debugLimit;
  107340. /**
  107341. * @hidden
  107342. * This is reserved for the inspector.
  107343. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107344. * You can use the factor to better multiply the final value.
  107345. */
  107346. private debugFactor;
  107347. /**
  107348. * Defines the clear coat layer parameters for the material.
  107349. */
  107350. readonly clearCoat: PBRClearCoatConfiguration;
  107351. /**
  107352. * Defines the anisotropic parameters for the material.
  107353. */
  107354. readonly anisotropy: PBRAnisotropicConfiguration;
  107355. /**
  107356. * Defines the BRDF parameters for the material.
  107357. */
  107358. readonly brdf: PBRBRDFConfiguration;
  107359. /**
  107360. * Defines the Sheen parameters for the material.
  107361. */
  107362. readonly sheen: PBRSheenConfiguration;
  107363. /**
  107364. * Defines the SubSurface parameters for the material.
  107365. */
  107366. readonly subSurface: PBRSubSurfaceConfiguration;
  107367. /**
  107368. * Defines additionnal PrePass parameters for the material.
  107369. */
  107370. readonly prePassConfiguration: PrePassConfiguration;
  107371. /**
  107372. * Defines the detail map parameters for the material.
  107373. */
  107374. readonly detailMap: DetailMapConfiguration;
  107375. protected _rebuildInParallel: boolean;
  107376. /**
  107377. * Instantiates a new PBRMaterial instance.
  107378. *
  107379. * @param name The material name
  107380. * @param scene The scene the material will be use in.
  107381. */
  107382. constructor(name: string, scene: Scene);
  107383. /**
  107384. * Gets a boolean indicating that current material needs to register RTT
  107385. */
  107386. get hasRenderTargetTextures(): boolean;
  107387. /**
  107388. * Gets the name of the material class.
  107389. */
  107390. getClassName(): string;
  107391. /**
  107392. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107393. */
  107394. get useLogarithmicDepth(): boolean;
  107395. /**
  107396. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107397. */
  107398. set useLogarithmicDepth(value: boolean);
  107399. /**
  107400. * Returns true if alpha blending should be disabled.
  107401. */
  107402. protected get _disableAlphaBlending(): boolean;
  107403. /**
  107404. * Specifies whether or not this material should be rendered in alpha blend mode.
  107405. */
  107406. needAlphaBlending(): boolean;
  107407. /**
  107408. * Specifies whether or not this material should be rendered in alpha test mode.
  107409. */
  107410. needAlphaTesting(): boolean;
  107411. /**
  107412. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107413. */
  107414. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107415. /**
  107416. * Specifies whether or not there is a usable alpha channel for transparency.
  107417. */
  107418. protected _hasAlphaChannel(): boolean;
  107419. /**
  107420. * Gets the texture used for the alpha test.
  107421. */
  107422. getAlphaTestTexture(): Nullable<BaseTexture>;
  107423. /**
  107424. * Specifies that the submesh is ready to be used.
  107425. * @param mesh - BJS mesh.
  107426. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107427. * @param useInstances - Specifies that instances should be used.
  107428. * @returns - boolean indicating that the submesh is ready or not.
  107429. */
  107430. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107431. /**
  107432. * Specifies if the material uses metallic roughness workflow.
  107433. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107434. */
  107435. isMetallicWorkflow(): boolean;
  107436. private _prepareEffect;
  107437. private _prepareDefines;
  107438. /**
  107439. * Force shader compilation
  107440. */
  107441. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107442. /**
  107443. * Initializes the uniform buffer layout for the shader.
  107444. */
  107445. buildUniformLayout(): void;
  107446. /**
  107447. * Unbinds the material from the mesh
  107448. */
  107449. unbind(): void;
  107450. /**
  107451. * Binds the submesh data.
  107452. * @param world - The world matrix.
  107453. * @param mesh - The BJS mesh.
  107454. * @param subMesh - A submesh of the BJS mesh.
  107455. */
  107456. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107457. /**
  107458. * Returns the animatable textures.
  107459. * @returns - Array of animatable textures.
  107460. */
  107461. getAnimatables(): IAnimatable[];
  107462. /**
  107463. * Returns the texture used for reflections.
  107464. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107465. */
  107466. private _getReflectionTexture;
  107467. /**
  107468. * Returns an array of the actively used textures.
  107469. * @returns - Array of BaseTextures
  107470. */
  107471. getActiveTextures(): BaseTexture[];
  107472. /**
  107473. * Checks to see if a texture is used in the material.
  107474. * @param texture - Base texture to use.
  107475. * @returns - Boolean specifying if a texture is used in the material.
  107476. */
  107477. hasTexture(texture: BaseTexture): boolean;
  107478. /**
  107479. * Sets the required values to the prepass renderer.
  107480. * @param prePassRenderer defines the prepass renderer to setup
  107481. */
  107482. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107483. /**
  107484. * Disposes the resources of the material.
  107485. * @param forceDisposeEffect - Forces the disposal of effects.
  107486. * @param forceDisposeTextures - Forces the disposal of all textures.
  107487. */
  107488. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107489. }
  107490. }
  107491. declare module BABYLON {
  107492. /**
  107493. * The Physically based material of BJS.
  107494. *
  107495. * This offers the main features of a standard PBR material.
  107496. * For more information, please refer to the documentation :
  107497. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107498. */
  107499. export class PBRMaterial extends PBRBaseMaterial {
  107500. /**
  107501. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107502. */
  107503. static readonly PBRMATERIAL_OPAQUE: number;
  107504. /**
  107505. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107506. */
  107507. static readonly PBRMATERIAL_ALPHATEST: number;
  107508. /**
  107509. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107510. */
  107511. static readonly PBRMATERIAL_ALPHABLEND: number;
  107512. /**
  107513. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107514. * They are also discarded below the alpha cutoff threshold to improve performances.
  107515. */
  107516. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107517. /**
  107518. * Defines the default value of how much AO map is occluding the analytical lights
  107519. * (point spot...).
  107520. */
  107521. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107522. /**
  107523. * Intensity of the direct lights e.g. the four lights available in your scene.
  107524. * This impacts both the direct diffuse and specular highlights.
  107525. */
  107526. directIntensity: number;
  107527. /**
  107528. * Intensity of the emissive part of the material.
  107529. * This helps controlling the emissive effect without modifying the emissive color.
  107530. */
  107531. emissiveIntensity: number;
  107532. /**
  107533. * Intensity of the environment e.g. how much the environment will light the object
  107534. * either through harmonics for rough material or through the refelction for shiny ones.
  107535. */
  107536. environmentIntensity: number;
  107537. /**
  107538. * This is a special control allowing the reduction of the specular highlights coming from the
  107539. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107540. */
  107541. specularIntensity: number;
  107542. /**
  107543. * Debug Control allowing disabling the bump map on this material.
  107544. */
  107545. disableBumpMap: boolean;
  107546. /**
  107547. * AKA Diffuse Texture in standard nomenclature.
  107548. */
  107549. albedoTexture: BaseTexture;
  107550. /**
  107551. * AKA Occlusion Texture in other nomenclature.
  107552. */
  107553. ambientTexture: BaseTexture;
  107554. /**
  107555. * AKA Occlusion Texture Intensity in other nomenclature.
  107556. */
  107557. ambientTextureStrength: number;
  107558. /**
  107559. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107560. * 1 means it completely occludes it
  107561. * 0 mean it has no impact
  107562. */
  107563. ambientTextureImpactOnAnalyticalLights: number;
  107564. /**
  107565. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107566. */
  107567. opacityTexture: BaseTexture;
  107568. /**
  107569. * Stores the reflection values in a texture.
  107570. */
  107571. reflectionTexture: Nullable<BaseTexture>;
  107572. /**
  107573. * Stores the emissive values in a texture.
  107574. */
  107575. emissiveTexture: BaseTexture;
  107576. /**
  107577. * AKA Specular texture in other nomenclature.
  107578. */
  107579. reflectivityTexture: BaseTexture;
  107580. /**
  107581. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107582. */
  107583. metallicTexture: BaseTexture;
  107584. /**
  107585. * Specifies the metallic scalar of the metallic/roughness workflow.
  107586. * Can also be used to scale the metalness values of the metallic texture.
  107587. */
  107588. metallic: Nullable<number>;
  107589. /**
  107590. * Specifies the roughness scalar of the metallic/roughness workflow.
  107591. * Can also be used to scale the roughness values of the metallic texture.
  107592. */
  107593. roughness: Nullable<number>;
  107594. /**
  107595. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107596. * By default the indexOfrefraction is used to compute F0;
  107597. *
  107598. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107599. *
  107600. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107601. * F90 = metallicReflectanceColor;
  107602. */
  107603. metallicF0Factor: number;
  107604. /**
  107605. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107606. * By default the F90 is always 1;
  107607. *
  107608. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107609. *
  107610. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107611. * F90 = metallicReflectanceColor;
  107612. */
  107613. metallicReflectanceColor: Color3;
  107614. /**
  107615. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107616. * This is multiply against the scalar values defined in the material.
  107617. */
  107618. metallicReflectanceTexture: Nullable<BaseTexture>;
  107619. /**
  107620. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107621. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107622. */
  107623. microSurfaceTexture: BaseTexture;
  107624. /**
  107625. * Stores surface normal data used to displace a mesh in a texture.
  107626. */
  107627. bumpTexture: BaseTexture;
  107628. /**
  107629. * Stores the pre-calculated light information of a mesh in a texture.
  107630. */
  107631. lightmapTexture: BaseTexture;
  107632. /**
  107633. * Stores the refracted light information in a texture.
  107634. */
  107635. get refractionTexture(): Nullable<BaseTexture>;
  107636. set refractionTexture(value: Nullable<BaseTexture>);
  107637. /**
  107638. * The color of a material in ambient lighting.
  107639. */
  107640. ambientColor: Color3;
  107641. /**
  107642. * AKA Diffuse Color in other nomenclature.
  107643. */
  107644. albedoColor: Color3;
  107645. /**
  107646. * AKA Specular Color in other nomenclature.
  107647. */
  107648. reflectivityColor: Color3;
  107649. /**
  107650. * The color reflected from the material.
  107651. */
  107652. reflectionColor: Color3;
  107653. /**
  107654. * The color emitted from the material.
  107655. */
  107656. emissiveColor: Color3;
  107657. /**
  107658. * AKA Glossiness in other nomenclature.
  107659. */
  107660. microSurface: number;
  107661. /**
  107662. * Index of refraction of the material base layer.
  107663. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107664. *
  107665. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107666. *
  107667. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107668. */
  107669. get indexOfRefraction(): number;
  107670. set indexOfRefraction(value: number);
  107671. /**
  107672. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107673. */
  107674. get invertRefractionY(): boolean;
  107675. set invertRefractionY(value: boolean);
  107676. /**
  107677. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107678. * Materials half opaque for instance using refraction could benefit from this control.
  107679. */
  107680. get linkRefractionWithTransparency(): boolean;
  107681. set linkRefractionWithTransparency(value: boolean);
  107682. /**
  107683. * If true, the light map contains occlusion information instead of lighting info.
  107684. */
  107685. useLightmapAsShadowmap: boolean;
  107686. /**
  107687. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107688. */
  107689. useAlphaFromAlbedoTexture: boolean;
  107690. /**
  107691. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107692. */
  107693. forceAlphaTest: boolean;
  107694. /**
  107695. * Defines the alpha limits in alpha test mode.
  107696. */
  107697. alphaCutOff: number;
  107698. /**
  107699. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107700. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107701. */
  107702. useSpecularOverAlpha: boolean;
  107703. /**
  107704. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107705. */
  107706. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107707. /**
  107708. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107709. */
  107710. useRoughnessFromMetallicTextureAlpha: boolean;
  107711. /**
  107712. * Specifies if the metallic texture contains the roughness information in its green channel.
  107713. */
  107714. useRoughnessFromMetallicTextureGreen: boolean;
  107715. /**
  107716. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107717. */
  107718. useMetallnessFromMetallicTextureBlue: boolean;
  107719. /**
  107720. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107721. */
  107722. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107723. /**
  107724. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107725. */
  107726. useAmbientInGrayScale: boolean;
  107727. /**
  107728. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107729. * The material will try to infer what glossiness each pixel should be.
  107730. */
  107731. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107732. /**
  107733. * BJS is using an harcoded light falloff based on a manually sets up range.
  107734. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107735. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107736. */
  107737. get usePhysicalLightFalloff(): boolean;
  107738. /**
  107739. * BJS is using an harcoded light falloff based on a manually sets up range.
  107740. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107741. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107742. */
  107743. set usePhysicalLightFalloff(value: boolean);
  107744. /**
  107745. * In order to support the falloff compatibility with gltf, a special mode has been added
  107746. * to reproduce the gltf light falloff.
  107747. */
  107748. get useGLTFLightFalloff(): boolean;
  107749. /**
  107750. * In order to support the falloff compatibility with gltf, a special mode has been added
  107751. * to reproduce the gltf light falloff.
  107752. */
  107753. set useGLTFLightFalloff(value: boolean);
  107754. /**
  107755. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107756. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107757. */
  107758. useRadianceOverAlpha: boolean;
  107759. /**
  107760. * Allows using an object space normal map (instead of tangent space).
  107761. */
  107762. useObjectSpaceNormalMap: boolean;
  107763. /**
  107764. * Allows using the bump map in parallax mode.
  107765. */
  107766. useParallax: boolean;
  107767. /**
  107768. * Allows using the bump map in parallax occlusion mode.
  107769. */
  107770. useParallaxOcclusion: boolean;
  107771. /**
  107772. * Controls the scale bias of the parallax mode.
  107773. */
  107774. parallaxScaleBias: number;
  107775. /**
  107776. * If sets to true, disables all the lights affecting the material.
  107777. */
  107778. disableLighting: boolean;
  107779. /**
  107780. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107781. */
  107782. forceIrradianceInFragment: boolean;
  107783. /**
  107784. * Number of Simultaneous lights allowed on the material.
  107785. */
  107786. maxSimultaneousLights: number;
  107787. /**
  107788. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107789. */
  107790. invertNormalMapX: boolean;
  107791. /**
  107792. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107793. */
  107794. invertNormalMapY: boolean;
  107795. /**
  107796. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107797. */
  107798. twoSidedLighting: boolean;
  107799. /**
  107800. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107801. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107802. */
  107803. useAlphaFresnel: boolean;
  107804. /**
  107805. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107806. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107807. */
  107808. useLinearAlphaFresnel: boolean;
  107809. /**
  107810. * Let user defines the brdf lookup texture used for IBL.
  107811. * A default 8bit version is embedded but you could point at :
  107812. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107813. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107814. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107815. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107816. */
  107817. environmentBRDFTexture: Nullable<BaseTexture>;
  107818. /**
  107819. * Force normal to face away from face.
  107820. */
  107821. forceNormalForward: boolean;
  107822. /**
  107823. * Enables specular anti aliasing in the PBR shader.
  107824. * It will both interacts on the Geometry for analytical and IBL lighting.
  107825. * It also prefilter the roughness map based on the bump values.
  107826. */
  107827. enableSpecularAntiAliasing: boolean;
  107828. /**
  107829. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107830. * makes the reflect vector face the model (under horizon).
  107831. */
  107832. useHorizonOcclusion: boolean;
  107833. /**
  107834. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107835. * too much the area relying on ambient texture to define their ambient occlusion.
  107836. */
  107837. useRadianceOcclusion: boolean;
  107838. /**
  107839. * If set to true, no lighting calculations will be applied.
  107840. */
  107841. unlit: boolean;
  107842. /**
  107843. * Gets the image processing configuration used either in this material.
  107844. */
  107845. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107846. /**
  107847. * Sets the Default image processing configuration used either in the this material.
  107848. *
  107849. * If sets to null, the scene one is in use.
  107850. */
  107851. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107852. /**
  107853. * Gets wether the color curves effect is enabled.
  107854. */
  107855. get cameraColorCurvesEnabled(): boolean;
  107856. /**
  107857. * Sets wether the color curves effect is enabled.
  107858. */
  107859. set cameraColorCurvesEnabled(value: boolean);
  107860. /**
  107861. * Gets wether the color grading effect is enabled.
  107862. */
  107863. get cameraColorGradingEnabled(): boolean;
  107864. /**
  107865. * Gets wether the color grading effect is enabled.
  107866. */
  107867. set cameraColorGradingEnabled(value: boolean);
  107868. /**
  107869. * Gets wether tonemapping is enabled or not.
  107870. */
  107871. get cameraToneMappingEnabled(): boolean;
  107872. /**
  107873. * Sets wether tonemapping is enabled or not
  107874. */
  107875. set cameraToneMappingEnabled(value: boolean);
  107876. /**
  107877. * The camera exposure used on this material.
  107878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107879. * This corresponds to a photographic exposure.
  107880. */
  107881. get cameraExposure(): number;
  107882. /**
  107883. * The camera exposure used on this material.
  107884. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107885. * This corresponds to a photographic exposure.
  107886. */
  107887. set cameraExposure(value: number);
  107888. /**
  107889. * Gets The camera contrast used on this material.
  107890. */
  107891. get cameraContrast(): number;
  107892. /**
  107893. * Sets The camera contrast used on this material.
  107894. */
  107895. set cameraContrast(value: number);
  107896. /**
  107897. * Gets the Color Grading 2D Lookup Texture.
  107898. */
  107899. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107900. /**
  107901. * Sets the Color Grading 2D Lookup Texture.
  107902. */
  107903. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107904. /**
  107905. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107906. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107907. * 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;
  107908. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107909. */
  107910. get cameraColorCurves(): Nullable<ColorCurves>;
  107911. /**
  107912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107914. * 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;
  107915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107916. */
  107917. set cameraColorCurves(value: Nullable<ColorCurves>);
  107918. /**
  107919. * Instantiates a new PBRMaterial instance.
  107920. *
  107921. * @param name The material name
  107922. * @param scene The scene the material will be use in.
  107923. */
  107924. constructor(name: string, scene: Scene);
  107925. /**
  107926. * Returns the name of this material class.
  107927. */
  107928. getClassName(): string;
  107929. /**
  107930. * Makes a duplicate of the current material.
  107931. * @param name - name to use for the new material.
  107932. */
  107933. clone(name: string): PBRMaterial;
  107934. /**
  107935. * Serializes this PBR Material.
  107936. * @returns - An object with the serialized material.
  107937. */
  107938. serialize(): any;
  107939. /**
  107940. * Parses a PBR Material from a serialized object.
  107941. * @param source - Serialized object.
  107942. * @param scene - BJS scene instance.
  107943. * @param rootUrl - url for the scene object
  107944. * @returns - PBRMaterial
  107945. */
  107946. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107947. }
  107948. }
  107949. declare module BABYLON {
  107950. /** @hidden */
  107951. export var mrtFragmentDeclaration: {
  107952. name: string;
  107953. shader: string;
  107954. };
  107955. }
  107956. declare module BABYLON {
  107957. /** @hidden */
  107958. export var geometryPixelShader: {
  107959. name: string;
  107960. shader: string;
  107961. };
  107962. }
  107963. declare module BABYLON {
  107964. /** @hidden */
  107965. export var geometryVertexShader: {
  107966. name: string;
  107967. shader: string;
  107968. };
  107969. }
  107970. declare module BABYLON {
  107971. /** @hidden */
  107972. interface ISavedTransformationMatrix {
  107973. world: Matrix;
  107974. viewProjection: Matrix;
  107975. }
  107976. /**
  107977. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107978. */
  107979. export class GeometryBufferRenderer {
  107980. /**
  107981. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107982. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107983. */
  107984. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107985. /**
  107986. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107987. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107988. */
  107989. static readonly POSITION_TEXTURE_TYPE: number;
  107990. /**
  107991. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107992. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107993. */
  107994. static readonly VELOCITY_TEXTURE_TYPE: number;
  107995. /**
  107996. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107997. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107998. */
  107999. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  108000. /**
  108001. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108002. * in order to compute objects velocities when enableVelocity is set to "true"
  108003. * @hidden
  108004. */
  108005. _previousTransformationMatrices: {
  108006. [index: number]: ISavedTransformationMatrix;
  108007. };
  108008. /**
  108009. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  108010. * in order to compute objects velocities when enableVelocity is set to "true"
  108011. * @hidden
  108012. */
  108013. _previousBonesTransformationMatrices: {
  108014. [index: number]: Float32Array;
  108015. };
  108016. /**
  108017. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  108018. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  108019. */
  108020. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  108021. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  108022. renderTransparentMeshes: boolean;
  108023. private _scene;
  108024. private _resizeObserver;
  108025. private _multiRenderTarget;
  108026. private _ratio;
  108027. private _enablePosition;
  108028. private _enableVelocity;
  108029. private _enableReflectivity;
  108030. private _positionIndex;
  108031. private _velocityIndex;
  108032. private _reflectivityIndex;
  108033. private _depthNormalIndex;
  108034. private _linkedWithPrePass;
  108035. private _prePassRenderer;
  108036. private _attachments;
  108037. protected _effect: Effect;
  108038. protected _cachedDefines: string;
  108039. /**
  108040. * @hidden
  108041. * Sets up internal structures to share outputs with PrePassRenderer
  108042. * This method should only be called by the PrePassRenderer itself
  108043. */
  108044. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108045. /**
  108046. * @hidden
  108047. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108048. * This method should only be called by the PrePassRenderer itself
  108049. */
  108050. _unlinkPrePassRenderer(): void;
  108051. /**
  108052. * @hidden
  108053. * Resets the geometry buffer layout
  108054. */
  108055. _resetLayout(): void;
  108056. /**
  108057. * @hidden
  108058. * Replaces a texture in the geometry buffer renderer
  108059. * Useful when linking textures of the prepass renderer
  108060. */
  108061. _forceTextureType(geometryBufferType: number, index: number): void;
  108062. /**
  108063. * @hidden
  108064. * Sets texture attachments
  108065. * Useful when linking textures of the prepass renderer
  108066. */
  108067. _setAttachments(attachments: number[]): void;
  108068. /**
  108069. * @hidden
  108070. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108071. * Useful when linking textures of the prepass renderer
  108072. */
  108073. _linkInternalTexture(internalTexture: InternalTexture): void;
  108074. /**
  108075. * Gets the render list (meshes to be rendered) used in the G buffer.
  108076. */
  108077. get renderList(): Nullable<AbstractMesh[]>;
  108078. /**
  108079. * Set the render list (meshes to be rendered) used in the G buffer.
  108080. */
  108081. set renderList(meshes: Nullable<AbstractMesh[]>);
  108082. /**
  108083. * Gets wether or not G buffer are supported by the running hardware.
  108084. * This requires draw buffer supports
  108085. */
  108086. get isSupported(): boolean;
  108087. /**
  108088. * Returns the index of the given texture type in the G-Buffer textures array
  108089. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108090. * @returns the index of the given texture type in the G-Buffer textures array
  108091. */
  108092. getTextureIndex(textureType: number): number;
  108093. /**
  108094. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108095. */
  108096. get enablePosition(): boolean;
  108097. /**
  108098. * Sets whether or not objects positions are enabled for the G buffer.
  108099. */
  108100. set enablePosition(enable: boolean);
  108101. /**
  108102. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108103. */
  108104. get enableVelocity(): boolean;
  108105. /**
  108106. * Sets wether or not objects velocities are enabled for the G buffer.
  108107. */
  108108. set enableVelocity(enable: boolean);
  108109. /**
  108110. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108111. */
  108112. get enableReflectivity(): boolean;
  108113. /**
  108114. * Sets wether or not objects roughness are enabled for the G buffer.
  108115. */
  108116. set enableReflectivity(enable: boolean);
  108117. /**
  108118. * Gets the scene associated with the buffer.
  108119. */
  108120. get scene(): Scene;
  108121. /**
  108122. * Gets the ratio used by the buffer during its creation.
  108123. * How big is the buffer related to the main canvas.
  108124. */
  108125. get ratio(): number;
  108126. /** @hidden */
  108127. static _SceneComponentInitialization: (scene: Scene) => void;
  108128. /**
  108129. * Creates a new G Buffer for the scene
  108130. * @param scene The scene the buffer belongs to
  108131. * @param ratio How big is the buffer related to the main canvas.
  108132. */
  108133. constructor(scene: Scene, ratio?: number);
  108134. /**
  108135. * Checks wether everything is ready to render a submesh to the G buffer.
  108136. * @param subMesh the submesh to check readiness for
  108137. * @param useInstances is the mesh drawn using instance or not
  108138. * @returns true if ready otherwise false
  108139. */
  108140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108141. /**
  108142. * Gets the current underlying G Buffer.
  108143. * @returns the buffer
  108144. */
  108145. getGBuffer(): MultiRenderTarget;
  108146. /**
  108147. * Gets the number of samples used to render the buffer (anti aliasing).
  108148. */
  108149. get samples(): number;
  108150. /**
  108151. * Sets the number of samples used to render the buffer (anti aliasing).
  108152. */
  108153. set samples(value: number);
  108154. /**
  108155. * Disposes the renderer and frees up associated resources.
  108156. */
  108157. dispose(): void;
  108158. private _assignRenderTargetIndices;
  108159. protected _createRenderTargets(): void;
  108160. private _copyBonesTransformationMatrices;
  108161. }
  108162. }
  108163. declare module BABYLON {
  108164. /**
  108165. * Renders a pre pass of the scene
  108166. * This means every mesh in the scene will be rendered to a render target texture
  108167. * And then this texture will be composited to the rendering canvas with post processes
  108168. * It is necessary for effects like subsurface scattering or deferred shading
  108169. */
  108170. export class PrePassRenderer {
  108171. /** @hidden */
  108172. static _SceneComponentInitialization: (scene: Scene) => void;
  108173. private _textureFormats;
  108174. /**
  108175. * To save performance, we can excluded skinned meshes from the prepass
  108176. */
  108177. excludedSkinnedMesh: AbstractMesh[];
  108178. /**
  108179. * Force material to be excluded from the prepass
  108180. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108181. * and you don't want a material to show in the effect.
  108182. */
  108183. excludedMaterials: Material[];
  108184. private _textureIndices;
  108185. private _scene;
  108186. private _engine;
  108187. private _isDirty;
  108188. /**
  108189. * Number of textures in the multi render target texture where the scene is directly rendered
  108190. */
  108191. mrtCount: number;
  108192. /**
  108193. * The render target where the scene is directly rendered
  108194. */
  108195. prePassRT: MultiRenderTarget;
  108196. private _multiRenderAttachments;
  108197. private _defaultAttachments;
  108198. private _clearAttachments;
  108199. private _postProcesses;
  108200. private readonly _clearColor;
  108201. /**
  108202. * Image processing post process for composition
  108203. */
  108204. imageProcessingPostProcess: ImageProcessingPostProcess;
  108205. /**
  108206. * Configuration for prepass effects
  108207. */
  108208. private _effectConfigurations;
  108209. private _mrtFormats;
  108210. private _mrtLayout;
  108211. private _enabled;
  108212. /**
  108213. * Indicates if the prepass is enabled
  108214. */
  108215. get enabled(): boolean;
  108216. /**
  108217. * How many samples are used for MSAA of the scene render target
  108218. */
  108219. get samples(): number;
  108220. set samples(n: number);
  108221. private _geometryBuffer;
  108222. private _useGeometryBufferFallback;
  108223. /**
  108224. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108225. */
  108226. get useGeometryBufferFallback(): boolean;
  108227. set useGeometryBufferFallback(value: boolean);
  108228. /**
  108229. * Instanciates a prepass renderer
  108230. * @param scene The scene
  108231. */
  108232. constructor(scene: Scene);
  108233. private _initializeAttachments;
  108234. private _createCompositionEffect;
  108235. /**
  108236. * Indicates if rendering a prepass is supported
  108237. */
  108238. get isSupported(): boolean;
  108239. /**
  108240. * Sets the proper output textures to draw in the engine.
  108241. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108242. * @param subMesh Submesh on which the effect is applied
  108243. */
  108244. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108245. /**
  108246. * @hidden
  108247. */
  108248. _beforeCameraDraw(): void;
  108249. /**
  108250. * @hidden
  108251. */
  108252. _afterCameraDraw(): void;
  108253. private _checkRTSize;
  108254. private _bindFrameBuffer;
  108255. /**
  108256. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108257. */
  108258. clear(): void;
  108259. private _setState;
  108260. private _updateGeometryBufferLayout;
  108261. /**
  108262. * Adds an effect configuration to the prepass.
  108263. * If an effect has already been added, it won't add it twice and will return the configuration
  108264. * already present.
  108265. * @param cfg the effect configuration
  108266. * @return the effect configuration now used by the prepass
  108267. */
  108268. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108269. /**
  108270. * Returns the index of a texture in the multi render target texture array.
  108271. * @param type Texture type
  108272. * @return The index
  108273. */
  108274. getIndex(type: number): number;
  108275. private _enable;
  108276. private _disable;
  108277. private _resetLayout;
  108278. private _resetPostProcessChain;
  108279. private _bindPostProcessChain;
  108280. /**
  108281. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108282. */
  108283. markAsDirty(): void;
  108284. /**
  108285. * Enables a texture on the MultiRenderTarget for prepass
  108286. */
  108287. private _enableTextures;
  108288. private _update;
  108289. private _markAllMaterialsAsPrePassDirty;
  108290. /**
  108291. * Disposes the prepass renderer.
  108292. */
  108293. dispose(): void;
  108294. }
  108295. }
  108296. declare module BABYLON {
  108297. /**
  108298. * Size options for a post process
  108299. */
  108300. export type PostProcessOptions = {
  108301. width: number;
  108302. height: number;
  108303. };
  108304. /**
  108305. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108306. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108307. */
  108308. export class PostProcess {
  108309. /**
  108310. * Gets or sets the unique id of the post process
  108311. */
  108312. uniqueId: number;
  108313. /** Name of the PostProcess. */
  108314. name: string;
  108315. /**
  108316. * Width of the texture to apply the post process on
  108317. */
  108318. width: number;
  108319. /**
  108320. * Height of the texture to apply the post process on
  108321. */
  108322. height: number;
  108323. /**
  108324. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108325. */
  108326. nodeMaterialSource: Nullable<NodeMaterial>;
  108327. /**
  108328. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108329. * @hidden
  108330. */
  108331. _outputTexture: Nullable<InternalTexture>;
  108332. /**
  108333. * Sampling mode used by the shader
  108334. * See https://doc.babylonjs.com/classes/3.1/texture
  108335. */
  108336. renderTargetSamplingMode: number;
  108337. /**
  108338. * Clear color to use when screen clearing
  108339. */
  108340. clearColor: Color4;
  108341. /**
  108342. * If the buffer needs to be cleared before applying the post process. (default: true)
  108343. * Should be set to false if shader will overwrite all previous pixels.
  108344. */
  108345. autoClear: boolean;
  108346. /**
  108347. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108348. */
  108349. alphaMode: number;
  108350. /**
  108351. * Sets the setAlphaBlendConstants of the babylon engine
  108352. */
  108353. alphaConstants: Color4;
  108354. /**
  108355. * Animations to be used for the post processing
  108356. */
  108357. animations: Animation[];
  108358. /**
  108359. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108360. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108361. */
  108362. enablePixelPerfectMode: boolean;
  108363. /**
  108364. * Force the postprocess to be applied without taking in account viewport
  108365. */
  108366. forceFullscreenViewport: boolean;
  108367. /**
  108368. * List of inspectable custom properties (used by the Inspector)
  108369. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108370. */
  108371. inspectableCustomProperties: IInspectable[];
  108372. /**
  108373. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108374. *
  108375. * | Value | Type | Description |
  108376. * | ----- | ----------------------------------- | ----------- |
  108377. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108378. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108379. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108380. *
  108381. */
  108382. scaleMode: number;
  108383. /**
  108384. * Force textures to be a power of two (default: false)
  108385. */
  108386. alwaysForcePOT: boolean;
  108387. private _samples;
  108388. /**
  108389. * Number of sample textures (default: 1)
  108390. */
  108391. get samples(): number;
  108392. set samples(n: number);
  108393. /**
  108394. * Modify the scale of the post process to be the same as the viewport (default: false)
  108395. */
  108396. adaptScaleToCurrentViewport: boolean;
  108397. private _camera;
  108398. protected _scene: Scene;
  108399. private _engine;
  108400. private _options;
  108401. private _reusable;
  108402. private _textureType;
  108403. private _textureFormat;
  108404. /**
  108405. * Smart array of input and output textures for the post process.
  108406. * @hidden
  108407. */
  108408. _textures: SmartArray<InternalTexture>;
  108409. /**
  108410. * The index in _textures that corresponds to the output texture.
  108411. * @hidden
  108412. */
  108413. _currentRenderTextureInd: number;
  108414. private _effect;
  108415. private _samplers;
  108416. private _fragmentUrl;
  108417. private _vertexUrl;
  108418. private _parameters;
  108419. private _scaleRatio;
  108420. protected _indexParameters: any;
  108421. private _shareOutputWithPostProcess;
  108422. private _texelSize;
  108423. private _forcedOutputTexture;
  108424. /**
  108425. * Prepass configuration in case this post process needs a texture from prepass
  108426. * @hidden
  108427. */
  108428. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108429. /**
  108430. * Returns the fragment url or shader name used in the post process.
  108431. * @returns the fragment url or name in the shader store.
  108432. */
  108433. getEffectName(): string;
  108434. /**
  108435. * An event triggered when the postprocess is activated.
  108436. */
  108437. onActivateObservable: Observable<Camera>;
  108438. private _onActivateObserver;
  108439. /**
  108440. * A function that is added to the onActivateObservable
  108441. */
  108442. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108443. /**
  108444. * An event triggered when the postprocess changes its size.
  108445. */
  108446. onSizeChangedObservable: Observable<PostProcess>;
  108447. private _onSizeChangedObserver;
  108448. /**
  108449. * A function that is added to the onSizeChangedObservable
  108450. */
  108451. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108452. /**
  108453. * An event triggered when the postprocess applies its effect.
  108454. */
  108455. onApplyObservable: Observable<Effect>;
  108456. private _onApplyObserver;
  108457. /**
  108458. * A function that is added to the onApplyObservable
  108459. */
  108460. set onApply(callback: (effect: Effect) => void);
  108461. /**
  108462. * An event triggered before rendering the postprocess
  108463. */
  108464. onBeforeRenderObservable: Observable<Effect>;
  108465. private _onBeforeRenderObserver;
  108466. /**
  108467. * A function that is added to the onBeforeRenderObservable
  108468. */
  108469. set onBeforeRender(callback: (effect: Effect) => void);
  108470. /**
  108471. * An event triggered after rendering the postprocess
  108472. */
  108473. onAfterRenderObservable: Observable<Effect>;
  108474. private _onAfterRenderObserver;
  108475. /**
  108476. * A function that is added to the onAfterRenderObservable
  108477. */
  108478. set onAfterRender(callback: (efect: Effect) => void);
  108479. /**
  108480. * 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
  108481. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108482. */
  108483. get inputTexture(): InternalTexture;
  108484. set inputTexture(value: InternalTexture);
  108485. /**
  108486. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108487. * the only way to unset it is to use this function to restore its internal state
  108488. */
  108489. restoreDefaultInputTexture(): void;
  108490. /**
  108491. * Gets the camera which post process is applied to.
  108492. * @returns The camera the post process is applied to.
  108493. */
  108494. getCamera(): Camera;
  108495. /**
  108496. * Gets the texel size of the postprocess.
  108497. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108498. */
  108499. get texelSize(): Vector2;
  108500. /**
  108501. * Creates a new instance PostProcess
  108502. * @param name The name of the PostProcess.
  108503. * @param fragmentUrl The url of the fragment shader to be used.
  108504. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108505. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108506. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108507. * @param camera The camera to apply the render pass to.
  108508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108509. * @param engine The engine which the post process will be applied. (default: current engine)
  108510. * @param reusable If the post process can be reused on the same frame. (default: false)
  108511. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108512. * @param textureType Type of textures used when performing the post process. (default: 0)
  108513. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108514. * @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
  108515. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108516. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108517. */
  108518. 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);
  108519. /**
  108520. * Gets a string identifying the name of the class
  108521. * @returns "PostProcess" string
  108522. */
  108523. getClassName(): string;
  108524. /**
  108525. * Gets the engine which this post process belongs to.
  108526. * @returns The engine the post process was enabled with.
  108527. */
  108528. getEngine(): Engine;
  108529. /**
  108530. * The effect that is created when initializing the post process.
  108531. * @returns The created effect corresponding the the postprocess.
  108532. */
  108533. getEffect(): Effect;
  108534. /**
  108535. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108536. * @param postProcess The post process to share the output with.
  108537. * @returns This post process.
  108538. */
  108539. shareOutputWith(postProcess: PostProcess): PostProcess;
  108540. /**
  108541. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108542. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108543. */
  108544. useOwnOutput(): void;
  108545. /**
  108546. * Updates the effect with the current post process compile time values and recompiles the shader.
  108547. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108548. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108549. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108550. * @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
  108551. * @param onCompiled Called when the shader has been compiled.
  108552. * @param onError Called if there is an error when compiling a shader.
  108553. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108554. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108555. */
  108556. 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;
  108557. /**
  108558. * The post process is reusable if it can be used multiple times within one frame.
  108559. * @returns If the post process is reusable
  108560. */
  108561. isReusable(): boolean;
  108562. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108563. markTextureDirty(): void;
  108564. /**
  108565. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108566. * 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.
  108567. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108568. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108569. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108570. * @returns The target texture that was bound to be written to.
  108571. */
  108572. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108573. /**
  108574. * If the post process is supported.
  108575. */
  108576. get isSupported(): boolean;
  108577. /**
  108578. * The aspect ratio of the output texture.
  108579. */
  108580. get aspectRatio(): number;
  108581. /**
  108582. * Get a value indicating if the post-process is ready to be used
  108583. * @returns true if the post-process is ready (shader is compiled)
  108584. */
  108585. isReady(): boolean;
  108586. /**
  108587. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108588. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108589. */
  108590. apply(): Nullable<Effect>;
  108591. private _disposeTextures;
  108592. /**
  108593. * Sets the required values to the prepass renderer.
  108594. * @param prePassRenderer defines the prepass renderer to setup.
  108595. * @returns true if the pre pass is needed.
  108596. */
  108597. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108598. /**
  108599. * Disposes the post process.
  108600. * @param camera The camera to dispose the post process on.
  108601. */
  108602. dispose(camera?: Camera): void;
  108603. /**
  108604. * Serializes the particle system to a JSON object
  108605. * @returns the JSON object
  108606. */
  108607. serialize(): any;
  108608. /**
  108609. * Creates a material from parsed material data
  108610. * @param parsedPostProcess defines parsed post process data
  108611. * @param scene defines the hosting scene
  108612. * @param rootUrl defines the root URL to use to load textures
  108613. * @returns a new post process
  108614. */
  108615. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108616. }
  108617. }
  108618. declare module BABYLON {
  108619. /** @hidden */
  108620. export var kernelBlurVaryingDeclaration: {
  108621. name: string;
  108622. shader: string;
  108623. };
  108624. }
  108625. declare module BABYLON {
  108626. /** @hidden */
  108627. export var kernelBlurFragment: {
  108628. name: string;
  108629. shader: string;
  108630. };
  108631. }
  108632. declare module BABYLON {
  108633. /** @hidden */
  108634. export var kernelBlurFragment2: {
  108635. name: string;
  108636. shader: string;
  108637. };
  108638. }
  108639. declare module BABYLON {
  108640. /** @hidden */
  108641. export var kernelBlurPixelShader: {
  108642. name: string;
  108643. shader: string;
  108644. };
  108645. }
  108646. declare module BABYLON {
  108647. /** @hidden */
  108648. export var kernelBlurVertex: {
  108649. name: string;
  108650. shader: string;
  108651. };
  108652. }
  108653. declare module BABYLON {
  108654. /** @hidden */
  108655. export var kernelBlurVertexShader: {
  108656. name: string;
  108657. shader: string;
  108658. };
  108659. }
  108660. declare module BABYLON {
  108661. /**
  108662. * The Blur Post Process which blurs an image based on a kernel and direction.
  108663. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108664. */
  108665. export class BlurPostProcess extends PostProcess {
  108666. private blockCompilation;
  108667. protected _kernel: number;
  108668. protected _idealKernel: number;
  108669. protected _packedFloat: boolean;
  108670. private _staticDefines;
  108671. /** The direction in which to blur the image. */
  108672. direction: Vector2;
  108673. /**
  108674. * Sets the length in pixels of the blur sample region
  108675. */
  108676. set kernel(v: number);
  108677. /**
  108678. * Gets the length in pixels of the blur sample region
  108679. */
  108680. get kernel(): number;
  108681. /**
  108682. * Sets wether or not the blur needs to unpack/repack floats
  108683. */
  108684. set packedFloat(v: boolean);
  108685. /**
  108686. * Gets wether or not the blur is unpacking/repacking floats
  108687. */
  108688. get packedFloat(): boolean;
  108689. /**
  108690. * Gets a string identifying the name of the class
  108691. * @returns "BlurPostProcess" string
  108692. */
  108693. getClassName(): string;
  108694. /**
  108695. * Creates a new instance BlurPostProcess
  108696. * @param name The name of the effect.
  108697. * @param direction The direction in which to blur the image.
  108698. * @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.
  108699. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108700. * @param camera The camera to apply the render pass to.
  108701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108702. * @param engine The engine which the post process will be applied. (default: current engine)
  108703. * @param reusable If the post process can be reused on the same frame. (default: false)
  108704. * @param textureType Type of textures used when performing the post process. (default: 0)
  108705. * @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)
  108706. */
  108707. 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);
  108708. /**
  108709. * Updates the effect with the current post process compile time values and recompiles the shader.
  108710. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108711. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108712. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108713. * @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
  108714. * @param onCompiled Called when the shader has been compiled.
  108715. * @param onError Called if there is an error when compiling a shader.
  108716. */
  108717. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108718. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108719. /**
  108720. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108721. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108722. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108723. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108724. * The gaps between physical kernels are compensated for in the weighting of the samples
  108725. * @param idealKernel Ideal blur kernel.
  108726. * @return Nearest best kernel.
  108727. */
  108728. protected _nearestBestKernel(idealKernel: number): number;
  108729. /**
  108730. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108731. * @param x The point on the Gaussian distribution to sample.
  108732. * @return the value of the Gaussian function at x.
  108733. */
  108734. protected _gaussianWeight(x: number): number;
  108735. /**
  108736. * Generates a string that can be used as a floating point number in GLSL.
  108737. * @param x Value to print.
  108738. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108739. * @return GLSL float string.
  108740. */
  108741. protected _glslFloat(x: number, decimalFigures?: number): string;
  108742. /** @hidden */
  108743. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108744. }
  108745. }
  108746. declare module BABYLON {
  108747. /**
  108748. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108749. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108750. * You can then easily use it as a reflectionTexture on a flat surface.
  108751. * In case the surface is not a plane, please consider relying on reflection probes.
  108752. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108753. */
  108754. export class MirrorTexture extends RenderTargetTexture {
  108755. private scene;
  108756. /**
  108757. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108758. * 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.
  108759. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108760. */
  108761. mirrorPlane: Plane;
  108762. /**
  108763. * Define the blur ratio used to blur the reflection if needed.
  108764. */
  108765. set blurRatio(value: number);
  108766. get blurRatio(): number;
  108767. /**
  108768. * Define the adaptive blur kernel used to blur the reflection if needed.
  108769. * This will autocompute the closest best match for the `blurKernel`
  108770. */
  108771. set adaptiveBlurKernel(value: number);
  108772. /**
  108773. * Define the blur kernel used to blur the reflection if needed.
  108774. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108775. */
  108776. set blurKernel(value: number);
  108777. /**
  108778. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108779. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108780. */
  108781. set blurKernelX(value: number);
  108782. get blurKernelX(): number;
  108783. /**
  108784. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108786. */
  108787. set blurKernelY(value: number);
  108788. get blurKernelY(): number;
  108789. private _autoComputeBlurKernel;
  108790. protected _onRatioRescale(): void;
  108791. private _updateGammaSpace;
  108792. private _imageProcessingConfigChangeObserver;
  108793. private _transformMatrix;
  108794. private _mirrorMatrix;
  108795. private _savedViewMatrix;
  108796. private _blurX;
  108797. private _blurY;
  108798. private _adaptiveBlurKernel;
  108799. private _blurKernelX;
  108800. private _blurKernelY;
  108801. private _blurRatio;
  108802. /**
  108803. * Instantiates a Mirror Texture.
  108804. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108805. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108806. * You can then easily use it as a reflectionTexture on a flat surface.
  108807. * In case the surface is not a plane, please consider relying on reflection probes.
  108808. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108809. * @param name
  108810. * @param size
  108811. * @param scene
  108812. * @param generateMipMaps
  108813. * @param type
  108814. * @param samplingMode
  108815. * @param generateDepthBuffer
  108816. */
  108817. constructor(name: string, size: number | {
  108818. width: number;
  108819. height: number;
  108820. } | {
  108821. ratio: number;
  108822. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108823. private _preparePostProcesses;
  108824. /**
  108825. * Clone the mirror texture.
  108826. * @returns the cloned texture
  108827. */
  108828. clone(): MirrorTexture;
  108829. /**
  108830. * Serialize the texture to a JSON representation you could use in Parse later on
  108831. * @returns the serialized JSON representation
  108832. */
  108833. serialize(): any;
  108834. /**
  108835. * Dispose the texture and release its associated resources.
  108836. */
  108837. dispose(): void;
  108838. }
  108839. }
  108840. declare module BABYLON {
  108841. /**
  108842. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108843. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108844. */
  108845. export class Texture extends BaseTexture {
  108846. /**
  108847. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108848. */
  108849. static SerializeBuffers: boolean;
  108850. /** @hidden */
  108851. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108852. /** @hidden */
  108853. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108854. /** @hidden */
  108855. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108856. /** nearest is mag = nearest and min = nearest and mip = linear */
  108857. static readonly NEAREST_SAMPLINGMODE: number;
  108858. /** nearest is mag = nearest and min = nearest and mip = linear */
  108859. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108860. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108861. static readonly BILINEAR_SAMPLINGMODE: number;
  108862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108863. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108864. /** Trilinear is mag = linear and min = linear and mip = linear */
  108865. static readonly TRILINEAR_SAMPLINGMODE: number;
  108866. /** Trilinear is mag = linear and min = linear and mip = linear */
  108867. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108868. /** mag = nearest and min = nearest and mip = nearest */
  108869. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108870. /** mag = nearest and min = linear and mip = nearest */
  108871. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108872. /** mag = nearest and min = linear and mip = linear */
  108873. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108874. /** mag = nearest and min = linear and mip = none */
  108875. static readonly NEAREST_LINEAR: number;
  108876. /** mag = nearest and min = nearest and mip = none */
  108877. static readonly NEAREST_NEAREST: number;
  108878. /** mag = linear and min = nearest and mip = nearest */
  108879. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108880. /** mag = linear and min = nearest and mip = linear */
  108881. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108882. /** mag = linear and min = linear and mip = none */
  108883. static readonly LINEAR_LINEAR: number;
  108884. /** mag = linear and min = nearest and mip = none */
  108885. static readonly LINEAR_NEAREST: number;
  108886. /** Explicit coordinates mode */
  108887. static readonly EXPLICIT_MODE: number;
  108888. /** Spherical coordinates mode */
  108889. static readonly SPHERICAL_MODE: number;
  108890. /** Planar coordinates mode */
  108891. static readonly PLANAR_MODE: number;
  108892. /** Cubic coordinates mode */
  108893. static readonly CUBIC_MODE: number;
  108894. /** Projection coordinates mode */
  108895. static readonly PROJECTION_MODE: number;
  108896. /** Inverse Cubic coordinates mode */
  108897. static readonly SKYBOX_MODE: number;
  108898. /** Inverse Cubic coordinates mode */
  108899. static readonly INVCUBIC_MODE: number;
  108900. /** Equirectangular coordinates mode */
  108901. static readonly EQUIRECTANGULAR_MODE: number;
  108902. /** Equirectangular Fixed coordinates mode */
  108903. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108904. /** Equirectangular Fixed Mirrored coordinates mode */
  108905. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108906. /** Texture is not repeating outside of 0..1 UVs */
  108907. static readonly CLAMP_ADDRESSMODE: number;
  108908. /** Texture is repeating outside of 0..1 UVs */
  108909. static readonly WRAP_ADDRESSMODE: number;
  108910. /** Texture is repeating and mirrored */
  108911. static readonly MIRROR_ADDRESSMODE: number;
  108912. /**
  108913. * 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
  108914. */
  108915. static UseSerializedUrlIfAny: boolean;
  108916. /**
  108917. * Define the url of the texture.
  108918. */
  108919. url: Nullable<string>;
  108920. /**
  108921. * Define an offset on the texture to offset the u coordinates of the UVs
  108922. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108923. */
  108924. uOffset: number;
  108925. /**
  108926. * Define an offset on the texture to offset the v coordinates of the UVs
  108927. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108928. */
  108929. vOffset: number;
  108930. /**
  108931. * Define an offset on the texture to scale the u coordinates of the UVs
  108932. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108933. */
  108934. uScale: number;
  108935. /**
  108936. * Define an offset on the texture to scale the v coordinates of the UVs
  108937. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108938. */
  108939. vScale: number;
  108940. /**
  108941. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108942. * @see https://doc.babylonjs.com/how_to/more_materials
  108943. */
  108944. uAng: number;
  108945. /**
  108946. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108947. * @see https://doc.babylonjs.com/how_to/more_materials
  108948. */
  108949. vAng: number;
  108950. /**
  108951. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108952. * @see https://doc.babylonjs.com/how_to/more_materials
  108953. */
  108954. wAng: number;
  108955. /**
  108956. * Defines the center of rotation (U)
  108957. */
  108958. uRotationCenter: number;
  108959. /**
  108960. * Defines the center of rotation (V)
  108961. */
  108962. vRotationCenter: number;
  108963. /**
  108964. * Defines the center of rotation (W)
  108965. */
  108966. wRotationCenter: number;
  108967. /**
  108968. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108969. */
  108970. homogeneousRotationInUVTransform: boolean;
  108971. /**
  108972. * Are mip maps generated for this texture or not.
  108973. */
  108974. get noMipmap(): boolean;
  108975. /**
  108976. * List of inspectable custom properties (used by the Inspector)
  108977. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108978. */
  108979. inspectableCustomProperties: Nullable<IInspectable[]>;
  108980. private _noMipmap;
  108981. /** @hidden */
  108982. _invertY: boolean;
  108983. private _rowGenerationMatrix;
  108984. private _cachedTextureMatrix;
  108985. private _projectionModeMatrix;
  108986. private _t0;
  108987. private _t1;
  108988. private _t2;
  108989. private _cachedUOffset;
  108990. private _cachedVOffset;
  108991. private _cachedUScale;
  108992. private _cachedVScale;
  108993. private _cachedUAng;
  108994. private _cachedVAng;
  108995. private _cachedWAng;
  108996. private _cachedProjectionMatrixId;
  108997. private _cachedURotationCenter;
  108998. private _cachedVRotationCenter;
  108999. private _cachedWRotationCenter;
  109000. private _cachedHomogeneousRotationInUVTransform;
  109001. private _cachedCoordinatesMode;
  109002. /** @hidden */
  109003. protected _initialSamplingMode: number;
  109004. /** @hidden */
  109005. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109006. private _deleteBuffer;
  109007. protected _format: Nullable<number>;
  109008. private _delayedOnLoad;
  109009. private _delayedOnError;
  109010. private _mimeType?;
  109011. private _loaderOptions?;
  109012. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  109013. get mimeType(): string | undefined;
  109014. /**
  109015. * Observable triggered once the texture has been loaded.
  109016. */
  109017. onLoadObservable: Observable<Texture>;
  109018. protected _isBlocking: boolean;
  109019. /**
  109020. * Is the texture preventing material to render while loading.
  109021. * If false, a default texture will be used instead of the loading one during the preparation step.
  109022. */
  109023. set isBlocking(value: boolean);
  109024. get isBlocking(): boolean;
  109025. /**
  109026. * Get the current sampling mode associated with the texture.
  109027. */
  109028. get samplingMode(): number;
  109029. /**
  109030. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109031. */
  109032. get invertY(): boolean;
  109033. /**
  109034. * Instantiates a new texture.
  109035. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109036. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109037. * @param url defines the url of the picture to load as a texture
  109038. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109039. * @param noMipmap defines if the texture will require mip maps or not
  109040. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109041. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109042. * @param onLoad defines a callback triggered when the texture has been loaded
  109043. * @param onError defines a callback triggered when an error occurred during the loading session
  109044. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109045. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109046. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109047. * @param mimeType defines an optional mime type information
  109048. * @param loaderOptions options to be passed to the loader
  109049. */
  109050. 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, loaderOptions?: any);
  109051. /**
  109052. * Update the url (and optional buffer) of this texture if url was null during construction.
  109053. * @param url the url of the texture
  109054. * @param buffer the buffer of the texture (defaults to null)
  109055. * @param onLoad callback called when the texture is loaded (defaults to null)
  109056. */
  109057. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109058. /**
  109059. * Finish the loading sequence of a texture flagged as delayed load.
  109060. * @hidden
  109061. */
  109062. delayLoad(): void;
  109063. private _prepareRowForTextureGeneration;
  109064. /**
  109065. * Checks if the texture has the same transform matrix than another texture
  109066. * @param texture texture to check against
  109067. * @returns true if the transforms are the same, else false
  109068. */
  109069. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109070. /**
  109071. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109072. * @returns the transform matrix of the texture.
  109073. */
  109074. getTextureMatrix(uBase?: number): Matrix;
  109075. /**
  109076. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109077. * @returns The reflection texture transform
  109078. */
  109079. getReflectionTextureMatrix(): Matrix;
  109080. /**
  109081. * Clones the texture.
  109082. * @returns the cloned texture
  109083. */
  109084. clone(): Texture;
  109085. /**
  109086. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109087. * @returns The JSON representation of the texture
  109088. */
  109089. serialize(): any;
  109090. /**
  109091. * Get the current class name of the texture useful for serialization or dynamic coding.
  109092. * @returns "Texture"
  109093. */
  109094. getClassName(): string;
  109095. /**
  109096. * Dispose the texture and release its associated resources.
  109097. */
  109098. dispose(): void;
  109099. /**
  109100. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109101. * @param parsedTexture Define the JSON representation of the texture
  109102. * @param scene Define the scene the parsed texture should be instantiated in
  109103. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109104. * @returns The parsed texture if successful
  109105. */
  109106. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109107. /**
  109108. * Creates a texture from its base 64 representation.
  109109. * @param data Define the base64 payload without the data: prefix
  109110. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109111. * @param scene Define the scene the texture should belong to
  109112. * @param noMipmap Forces the texture to not create mip map information if true
  109113. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109114. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109115. * @param onLoad define a callback triggered when the texture has been loaded
  109116. * @param onError define a callback triggered when an error occurred during the loading session
  109117. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109118. * @returns the created texture
  109119. */
  109120. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109121. /**
  109122. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109123. * @param data Define the base64 payload without the data: prefix
  109124. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109125. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109126. * @param scene Define the scene the texture should belong to
  109127. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109128. * @param noMipmap Forces the texture to not create mip map information if true
  109129. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109130. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109131. * @param onLoad define a callback triggered when the texture has been loaded
  109132. * @param onError define a callback triggered when an error occurred during the loading session
  109133. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109134. * @returns the created texture
  109135. */
  109136. 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;
  109137. }
  109138. }
  109139. declare module BABYLON {
  109140. /**
  109141. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109142. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109143. */
  109144. export class PostProcessManager {
  109145. private _scene;
  109146. private _indexBuffer;
  109147. private _vertexBuffers;
  109148. /**
  109149. * Creates a new instance PostProcess
  109150. * @param scene The scene that the post process is associated with.
  109151. */
  109152. constructor(scene: Scene);
  109153. private _prepareBuffers;
  109154. private _buildIndexBuffer;
  109155. /**
  109156. * Rebuilds the vertex buffers of the manager.
  109157. * @hidden
  109158. */
  109159. _rebuild(): void;
  109160. /**
  109161. * Prepares a frame to be run through a post process.
  109162. * @param sourceTexture The input texture to the post procesess. (default: null)
  109163. * @param postProcesses An array of post processes to be run. (default: null)
  109164. * @returns True if the post processes were able to be run.
  109165. * @hidden
  109166. */
  109167. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109168. /**
  109169. * Manually render a set of post processes to a texture.
  109170. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109171. * @param postProcesses An array of post processes to be run.
  109172. * @param targetTexture The target texture to render to.
  109173. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109174. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109175. * @param lodLevel defines which lod of the texture to render to
  109176. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109177. */
  109178. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109179. /**
  109180. * Finalize the result of the output of the postprocesses.
  109181. * @param doNotPresent If true the result will not be displayed to the screen.
  109182. * @param targetTexture The target texture to render to.
  109183. * @param faceIndex The index of the face to bind the target texture to.
  109184. * @param postProcesses The array of post processes to render.
  109185. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109186. * @hidden
  109187. */
  109188. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109189. /**
  109190. * Disposes of the post process manager.
  109191. */
  109192. dispose(): void;
  109193. }
  109194. }
  109195. declare module BABYLON {
  109196. /**
  109197. * This Helps creating a texture that will be created from a camera in your scene.
  109198. * It is basically a dynamic texture that could be used to create special effects for instance.
  109199. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109200. */
  109201. export class RenderTargetTexture extends Texture {
  109202. /**
  109203. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109204. */
  109205. static readonly REFRESHRATE_RENDER_ONCE: number;
  109206. /**
  109207. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109208. */
  109209. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109210. /**
  109211. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109212. * the central point of your effect and can save a lot of performances.
  109213. */
  109214. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109215. /**
  109216. * Use this predicate to dynamically define the list of mesh you want to render.
  109217. * If set, the renderList property will be overwritten.
  109218. */
  109219. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109220. private _renderList;
  109221. /**
  109222. * Use this list to define the list of mesh you want to render.
  109223. */
  109224. get renderList(): Nullable<Array<AbstractMesh>>;
  109225. set renderList(value: Nullable<Array<AbstractMesh>>);
  109226. /**
  109227. * Use this function to overload the renderList array at rendering time.
  109228. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109229. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109230. * the cube (if the RTT is a cube, else layerOrFace=0).
  109231. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109232. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109233. * hold dummy elements!
  109234. */
  109235. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109236. private _hookArray;
  109237. /**
  109238. * Define if particles should be rendered in your texture.
  109239. */
  109240. renderParticles: boolean;
  109241. /**
  109242. * Define if sprites should be rendered in your texture.
  109243. */
  109244. renderSprites: boolean;
  109245. /**
  109246. * Define the camera used to render the texture.
  109247. */
  109248. activeCamera: Nullable<Camera>;
  109249. /**
  109250. * Override the mesh isReady function with your own one.
  109251. */
  109252. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109253. /**
  109254. * Override the render function of the texture with your own one.
  109255. */
  109256. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109257. /**
  109258. * Define if camera post processes should be use while rendering the texture.
  109259. */
  109260. useCameraPostProcesses: boolean;
  109261. /**
  109262. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109263. */
  109264. ignoreCameraViewport: boolean;
  109265. private _postProcessManager;
  109266. private _postProcesses;
  109267. private _resizeObserver;
  109268. /**
  109269. * An event triggered when the texture is unbind.
  109270. */
  109271. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109272. /**
  109273. * An event triggered when the texture is unbind.
  109274. */
  109275. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109276. private _onAfterUnbindObserver;
  109277. /**
  109278. * Set a after unbind callback in the texture.
  109279. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109280. */
  109281. set onAfterUnbind(callback: () => void);
  109282. /**
  109283. * An event triggered before rendering the texture
  109284. */
  109285. onBeforeRenderObservable: Observable<number>;
  109286. private _onBeforeRenderObserver;
  109287. /**
  109288. * Set a before render callback in the texture.
  109289. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109290. */
  109291. set onBeforeRender(callback: (faceIndex: number) => void);
  109292. /**
  109293. * An event triggered after rendering the texture
  109294. */
  109295. onAfterRenderObservable: Observable<number>;
  109296. private _onAfterRenderObserver;
  109297. /**
  109298. * Set a after render callback in the texture.
  109299. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109300. */
  109301. set onAfterRender(callback: (faceIndex: number) => void);
  109302. /**
  109303. * An event triggered after the texture clear
  109304. */
  109305. onClearObservable: Observable<Engine>;
  109306. private _onClearObserver;
  109307. /**
  109308. * Set a clear callback in the texture.
  109309. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109310. */
  109311. set onClear(callback: (Engine: Engine) => void);
  109312. /**
  109313. * An event triggered when the texture is resized.
  109314. */
  109315. onResizeObservable: Observable<RenderTargetTexture>;
  109316. /**
  109317. * Define the clear color of the Render Target if it should be different from the scene.
  109318. */
  109319. clearColor: Color4;
  109320. protected _size: number | {
  109321. width: number;
  109322. height: number;
  109323. layers?: number;
  109324. };
  109325. protected _initialSizeParameter: number | {
  109326. width: number;
  109327. height: number;
  109328. } | {
  109329. ratio: number;
  109330. };
  109331. protected _sizeRatio: Nullable<number>;
  109332. /** @hidden */
  109333. _generateMipMaps: boolean;
  109334. protected _renderingManager: RenderingManager;
  109335. /** @hidden */
  109336. _waitingRenderList?: string[];
  109337. protected _doNotChangeAspectRatio: boolean;
  109338. protected _currentRefreshId: number;
  109339. protected _refreshRate: number;
  109340. protected _textureMatrix: Matrix;
  109341. protected _samples: number;
  109342. protected _renderTargetOptions: RenderTargetCreationOptions;
  109343. /**
  109344. * Gets render target creation options that were used.
  109345. */
  109346. get renderTargetOptions(): RenderTargetCreationOptions;
  109347. protected _onRatioRescale(): void;
  109348. /**
  109349. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109350. * It must define where the camera used to render the texture is set
  109351. */
  109352. boundingBoxPosition: Vector3;
  109353. private _boundingBoxSize;
  109354. /**
  109355. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109356. * When defined, the cubemap will switch to local mode
  109357. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109358. * @example https://www.babylonjs-playground.com/#RNASML
  109359. */
  109360. set boundingBoxSize(value: Vector3);
  109361. get boundingBoxSize(): Vector3;
  109362. /**
  109363. * In case the RTT has been created with a depth texture, get the associated
  109364. * depth texture.
  109365. * Otherwise, return null.
  109366. */
  109367. get depthStencilTexture(): Nullable<InternalTexture>;
  109368. /**
  109369. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109370. * or used a shadow, depth texture...
  109371. * @param name The friendly name of the texture
  109372. * @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)
  109373. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109374. * @param generateMipMaps True if mip maps need to be generated after render.
  109375. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109376. * @param type The type of the buffer in the RTT (int, half float, float...)
  109377. * @param isCube True if a cube texture needs to be created
  109378. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109379. * @param generateDepthBuffer True to generate a depth buffer
  109380. * @param generateStencilBuffer True to generate a stencil buffer
  109381. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109382. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109383. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109384. */
  109385. constructor(name: string, size: number | {
  109386. width: number;
  109387. height: number;
  109388. layers?: number;
  109389. } | {
  109390. ratio: number;
  109391. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109392. /**
  109393. * Creates a depth stencil texture.
  109394. * This is only available in WebGL 2 or with the depth texture extension available.
  109395. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109396. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109397. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109398. */
  109399. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109400. private _processSizeParameter;
  109401. /**
  109402. * Define the number of samples to use in case of MSAA.
  109403. * It defaults to one meaning no MSAA has been enabled.
  109404. */
  109405. get samples(): number;
  109406. set samples(value: number);
  109407. /**
  109408. * Resets the refresh counter of the texture and start bak from scratch.
  109409. * Could be useful to regenerate the texture if it is setup to render only once.
  109410. */
  109411. resetRefreshCounter(): void;
  109412. /**
  109413. * Define the refresh rate of the texture or the rendering frequency.
  109414. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109415. */
  109416. get refreshRate(): number;
  109417. set refreshRate(value: number);
  109418. /**
  109419. * Adds a post process to the render target rendering passes.
  109420. * @param postProcess define the post process to add
  109421. */
  109422. addPostProcess(postProcess: PostProcess): void;
  109423. /**
  109424. * Clear all the post processes attached to the render target
  109425. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109426. */
  109427. clearPostProcesses(dispose?: boolean): void;
  109428. /**
  109429. * Remove one of the post process from the list of attached post processes to the texture
  109430. * @param postProcess define the post process to remove from the list
  109431. */
  109432. removePostProcess(postProcess: PostProcess): void;
  109433. /** @hidden */
  109434. _shouldRender(): boolean;
  109435. /**
  109436. * Gets the actual render size of the texture.
  109437. * @returns the width of the render size
  109438. */
  109439. getRenderSize(): number;
  109440. /**
  109441. * Gets the actual render width of the texture.
  109442. * @returns the width of the render size
  109443. */
  109444. getRenderWidth(): number;
  109445. /**
  109446. * Gets the actual render height of the texture.
  109447. * @returns the height of the render size
  109448. */
  109449. getRenderHeight(): number;
  109450. /**
  109451. * Gets the actual number of layers of the texture.
  109452. * @returns the number of layers
  109453. */
  109454. getRenderLayers(): number;
  109455. /**
  109456. * Get if the texture can be rescaled or not.
  109457. */
  109458. get canRescale(): boolean;
  109459. /**
  109460. * Resize the texture using a ratio.
  109461. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109462. */
  109463. scale(ratio: number): void;
  109464. /**
  109465. * Get the texture reflection matrix used to rotate/transform the reflection.
  109466. * @returns the reflection matrix
  109467. */
  109468. getReflectionTextureMatrix(): Matrix;
  109469. /**
  109470. * Resize the texture to a new desired size.
  109471. * Be carrefull as it will recreate all the data in the new texture.
  109472. * @param size Define the new size. It can be:
  109473. * - a number for squared texture,
  109474. * - an object containing { width: number, height: number }
  109475. * - or an object containing a ratio { ratio: number }
  109476. */
  109477. resize(size: number | {
  109478. width: number;
  109479. height: number;
  109480. } | {
  109481. ratio: number;
  109482. }): void;
  109483. private _defaultRenderListPrepared;
  109484. /**
  109485. * Renders all the objects from the render list into the texture.
  109486. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109487. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109488. */
  109489. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109490. private _bestReflectionRenderTargetDimension;
  109491. private _prepareRenderingManager;
  109492. /**
  109493. * @hidden
  109494. * @param faceIndex face index to bind to if this is a cubetexture
  109495. * @param layer defines the index of the texture to bind in the array
  109496. */
  109497. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109498. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109499. private renderToTarget;
  109500. /**
  109501. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109502. * This allowed control for front to back rendering or reversly depending of the special needs.
  109503. *
  109504. * @param renderingGroupId The rendering group id corresponding to its index
  109505. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109506. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109507. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109508. */
  109509. 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;
  109510. /**
  109511. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109512. *
  109513. * @param renderingGroupId The rendering group id corresponding to its index
  109514. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109515. */
  109516. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109517. /**
  109518. * Clones the texture.
  109519. * @returns the cloned texture
  109520. */
  109521. clone(): RenderTargetTexture;
  109522. /**
  109523. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109524. * @returns The JSON representation of the texture
  109525. */
  109526. serialize(): any;
  109527. /**
  109528. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109529. */
  109530. disposeFramebufferObjects(): void;
  109531. /**
  109532. * Dispose the texture and release its associated resources.
  109533. */
  109534. dispose(): void;
  109535. /** @hidden */
  109536. _rebuild(): void;
  109537. /**
  109538. * Clear the info related to rendering groups preventing retention point in material dispose.
  109539. */
  109540. freeRenderingGroups(): void;
  109541. /**
  109542. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109543. * @returns the view count
  109544. */
  109545. getViewCount(): number;
  109546. }
  109547. }
  109548. declare module BABYLON {
  109549. /**
  109550. * Class used to manipulate GUIDs
  109551. */
  109552. export class GUID {
  109553. /**
  109554. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109555. * Be aware Math.random() could cause collisions, but:
  109556. * "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"
  109557. * @returns a pseudo random id
  109558. */
  109559. static RandomId(): string;
  109560. }
  109561. }
  109562. declare module BABYLON {
  109563. /**
  109564. * Options to be used when creating a shadow depth material
  109565. */
  109566. export interface IIOptionShadowDepthMaterial {
  109567. /** Variables in the vertex shader code that need to have their names remapped.
  109568. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109569. * "var_name" should be either: worldPos or vNormalW
  109570. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109571. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109572. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109573. */
  109574. remappedVariables?: string[];
  109575. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109576. standalone?: boolean;
  109577. }
  109578. /**
  109579. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109580. */
  109581. export class ShadowDepthWrapper {
  109582. private _scene;
  109583. private _options?;
  109584. private _baseMaterial;
  109585. private _onEffectCreatedObserver;
  109586. private _subMeshToEffect;
  109587. private _subMeshToDepthEffect;
  109588. private _meshes;
  109589. /** @hidden */
  109590. _matriceNames: any;
  109591. /** Gets the standalone status of the wrapper */
  109592. get standalone(): boolean;
  109593. /** Gets the base material the wrapper is built upon */
  109594. get baseMaterial(): Material;
  109595. /**
  109596. * Instantiate a new shadow depth wrapper.
  109597. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109598. * generate the shadow depth map. For more information, please refer to the documentation:
  109599. * https://doc.babylonjs.com/babylon101/shadows
  109600. * @param baseMaterial Material to wrap
  109601. * @param scene Define the scene the material belongs to
  109602. * @param options Options used to create the wrapper
  109603. */
  109604. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109605. /**
  109606. * Gets the effect to use to generate the depth map
  109607. * @param subMesh subMesh to get the effect for
  109608. * @param shadowGenerator shadow generator to get the effect for
  109609. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109610. */
  109611. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109612. /**
  109613. * Specifies that the submesh is ready to be used for depth rendering
  109614. * @param subMesh submesh to check
  109615. * @param defines the list of defines to take into account when checking the effect
  109616. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109617. * @param useInstances specifies that instances should be used
  109618. * @returns a boolean indicating that the submesh is ready or not
  109619. */
  109620. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109621. /**
  109622. * Disposes the resources
  109623. */
  109624. dispose(): void;
  109625. private _makeEffect;
  109626. }
  109627. }
  109628. declare module BABYLON {
  109629. /**
  109630. * Options for compiling materials.
  109631. */
  109632. export interface IMaterialCompilationOptions {
  109633. /**
  109634. * Defines whether clip planes are enabled.
  109635. */
  109636. clipPlane: boolean;
  109637. /**
  109638. * Defines whether instances are enabled.
  109639. */
  109640. useInstances: boolean;
  109641. }
  109642. /**
  109643. * Options passed when calling customShaderNameResolve
  109644. */
  109645. export interface ICustomShaderNameResolveOptions {
  109646. /**
  109647. * 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
  109648. */
  109649. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109650. }
  109651. /**
  109652. * Base class for the main features of a material in Babylon.js
  109653. */
  109654. export class Material implements IAnimatable {
  109655. /**
  109656. * Returns the triangle fill mode
  109657. */
  109658. static readonly TriangleFillMode: number;
  109659. /**
  109660. * Returns the wireframe mode
  109661. */
  109662. static readonly WireFrameFillMode: number;
  109663. /**
  109664. * Returns the point fill mode
  109665. */
  109666. static readonly PointFillMode: number;
  109667. /**
  109668. * Returns the point list draw mode
  109669. */
  109670. static readonly PointListDrawMode: number;
  109671. /**
  109672. * Returns the line list draw mode
  109673. */
  109674. static readonly LineListDrawMode: number;
  109675. /**
  109676. * Returns the line loop draw mode
  109677. */
  109678. static readonly LineLoopDrawMode: number;
  109679. /**
  109680. * Returns the line strip draw mode
  109681. */
  109682. static readonly LineStripDrawMode: number;
  109683. /**
  109684. * Returns the triangle strip draw mode
  109685. */
  109686. static readonly TriangleStripDrawMode: number;
  109687. /**
  109688. * Returns the triangle fan draw mode
  109689. */
  109690. static readonly TriangleFanDrawMode: number;
  109691. /**
  109692. * Stores the clock-wise side orientation
  109693. */
  109694. static readonly ClockWiseSideOrientation: number;
  109695. /**
  109696. * Stores the counter clock-wise side orientation
  109697. */
  109698. static readonly CounterClockWiseSideOrientation: number;
  109699. /**
  109700. * The dirty texture flag value
  109701. */
  109702. static readonly TextureDirtyFlag: number;
  109703. /**
  109704. * The dirty light flag value
  109705. */
  109706. static readonly LightDirtyFlag: number;
  109707. /**
  109708. * The dirty fresnel flag value
  109709. */
  109710. static readonly FresnelDirtyFlag: number;
  109711. /**
  109712. * The dirty attribute flag value
  109713. */
  109714. static readonly AttributesDirtyFlag: number;
  109715. /**
  109716. * The dirty misc flag value
  109717. */
  109718. static readonly MiscDirtyFlag: number;
  109719. /**
  109720. * The dirty prepass flag value
  109721. */
  109722. static readonly PrePassDirtyFlag: number;
  109723. /**
  109724. * The all dirty flag value
  109725. */
  109726. static readonly AllDirtyFlag: number;
  109727. /**
  109728. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109729. */
  109730. static readonly MATERIAL_OPAQUE: number;
  109731. /**
  109732. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109733. */
  109734. static readonly MATERIAL_ALPHATEST: number;
  109735. /**
  109736. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109737. */
  109738. static readonly MATERIAL_ALPHABLEND: number;
  109739. /**
  109740. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109741. * They are also discarded below the alpha cutoff threshold to improve performances.
  109742. */
  109743. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109744. /**
  109745. * The Whiteout method is used to blend normals.
  109746. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109747. */
  109748. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109749. /**
  109750. * The Reoriented Normal Mapping method is used to blend normals.
  109751. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109752. */
  109753. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109754. /**
  109755. * Custom callback helping to override the default shader used in the material.
  109756. */
  109757. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109758. /**
  109759. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109760. */
  109761. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109762. /**
  109763. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109764. * This means that the material can keep using a previous shader while a new one is being compiled.
  109765. * This is mostly used when shader parallel compilation is supported (true by default)
  109766. */
  109767. allowShaderHotSwapping: boolean;
  109768. /**
  109769. * The ID of the material
  109770. */
  109771. id: string;
  109772. /**
  109773. * Gets or sets the unique id of the material
  109774. */
  109775. uniqueId: number;
  109776. /**
  109777. * The name of the material
  109778. */
  109779. name: string;
  109780. /**
  109781. * Gets or sets user defined metadata
  109782. */
  109783. metadata: any;
  109784. /**
  109785. * For internal use only. Please do not use.
  109786. */
  109787. reservedDataStore: any;
  109788. /**
  109789. * Specifies if the ready state should be checked on each call
  109790. */
  109791. checkReadyOnEveryCall: boolean;
  109792. /**
  109793. * Specifies if the ready state should be checked once
  109794. */
  109795. checkReadyOnlyOnce: boolean;
  109796. /**
  109797. * The state of the material
  109798. */
  109799. state: string;
  109800. /**
  109801. * If the material can be rendered to several textures with MRT extension
  109802. */
  109803. get canRenderToMRT(): boolean;
  109804. /**
  109805. * The alpha value of the material
  109806. */
  109807. protected _alpha: number;
  109808. /**
  109809. * List of inspectable custom properties (used by the Inspector)
  109810. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109811. */
  109812. inspectableCustomProperties: IInspectable[];
  109813. /**
  109814. * Sets the alpha value of the material
  109815. */
  109816. set alpha(value: number);
  109817. /**
  109818. * Gets the alpha value of the material
  109819. */
  109820. get alpha(): number;
  109821. /**
  109822. * Specifies if back face culling is enabled
  109823. */
  109824. protected _backFaceCulling: boolean;
  109825. /**
  109826. * Sets the back-face culling state
  109827. */
  109828. set backFaceCulling(value: boolean);
  109829. /**
  109830. * Gets the back-face culling state
  109831. */
  109832. get backFaceCulling(): boolean;
  109833. /**
  109834. * Stores the value for side orientation
  109835. */
  109836. sideOrientation: number;
  109837. /**
  109838. * Callback triggered when the material is compiled
  109839. */
  109840. onCompiled: Nullable<(effect: Effect) => void>;
  109841. /**
  109842. * Callback triggered when an error occurs
  109843. */
  109844. onError: Nullable<(effect: Effect, errors: string) => void>;
  109845. /**
  109846. * Callback triggered to get the render target textures
  109847. */
  109848. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109849. /**
  109850. * Gets a boolean indicating that current material needs to register RTT
  109851. */
  109852. get hasRenderTargetTextures(): boolean;
  109853. /**
  109854. * Specifies if the material should be serialized
  109855. */
  109856. doNotSerialize: boolean;
  109857. /**
  109858. * @hidden
  109859. */
  109860. _storeEffectOnSubMeshes: boolean;
  109861. /**
  109862. * Stores the animations for the material
  109863. */
  109864. animations: Nullable<Array<Animation>>;
  109865. /**
  109866. * An event triggered when the material is disposed
  109867. */
  109868. onDisposeObservable: Observable<Material>;
  109869. /**
  109870. * An observer which watches for dispose events
  109871. */
  109872. private _onDisposeObserver;
  109873. private _onUnBindObservable;
  109874. /**
  109875. * Called during a dispose event
  109876. */
  109877. set onDispose(callback: () => void);
  109878. private _onBindObservable;
  109879. /**
  109880. * An event triggered when the material is bound
  109881. */
  109882. get onBindObservable(): Observable<AbstractMesh>;
  109883. /**
  109884. * An observer which watches for bind events
  109885. */
  109886. private _onBindObserver;
  109887. /**
  109888. * Called during a bind event
  109889. */
  109890. set onBind(callback: (Mesh: AbstractMesh) => void);
  109891. /**
  109892. * An event triggered when the material is unbound
  109893. */
  109894. get onUnBindObservable(): Observable<Material>;
  109895. protected _onEffectCreatedObservable: Nullable<Observable<{
  109896. effect: Effect;
  109897. subMesh: Nullable<SubMesh>;
  109898. }>>;
  109899. /**
  109900. * An event triggered when the effect is (re)created
  109901. */
  109902. get onEffectCreatedObservable(): Observable<{
  109903. effect: Effect;
  109904. subMesh: Nullable<SubMesh>;
  109905. }>;
  109906. /**
  109907. * Stores the value of the alpha mode
  109908. */
  109909. private _alphaMode;
  109910. /**
  109911. * Sets the value of the alpha mode.
  109912. *
  109913. * | Value | Type | Description |
  109914. * | --- | --- | --- |
  109915. * | 0 | ALPHA_DISABLE | |
  109916. * | 1 | ALPHA_ADD | |
  109917. * | 2 | ALPHA_COMBINE | |
  109918. * | 3 | ALPHA_SUBTRACT | |
  109919. * | 4 | ALPHA_MULTIPLY | |
  109920. * | 5 | ALPHA_MAXIMIZED | |
  109921. * | 6 | ALPHA_ONEONE | |
  109922. * | 7 | ALPHA_PREMULTIPLIED | |
  109923. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109924. * | 9 | ALPHA_INTERPOLATE | |
  109925. * | 10 | ALPHA_SCREENMODE | |
  109926. *
  109927. */
  109928. set alphaMode(value: number);
  109929. /**
  109930. * Gets the value of the alpha mode
  109931. */
  109932. get alphaMode(): number;
  109933. /**
  109934. * Stores the state of the need depth pre-pass value
  109935. */
  109936. private _needDepthPrePass;
  109937. /**
  109938. * Sets the need depth pre-pass value
  109939. */
  109940. set needDepthPrePass(value: boolean);
  109941. /**
  109942. * Gets the depth pre-pass value
  109943. */
  109944. get needDepthPrePass(): boolean;
  109945. /**
  109946. * Specifies if depth writing should be disabled
  109947. */
  109948. disableDepthWrite: boolean;
  109949. /**
  109950. * Specifies if color writing should be disabled
  109951. */
  109952. disableColorWrite: boolean;
  109953. /**
  109954. * Specifies if depth writing should be forced
  109955. */
  109956. forceDepthWrite: boolean;
  109957. /**
  109958. * Specifies the depth function that should be used. 0 means the default engine function
  109959. */
  109960. depthFunction: number;
  109961. /**
  109962. * Specifies if there should be a separate pass for culling
  109963. */
  109964. separateCullingPass: boolean;
  109965. /**
  109966. * Stores the state specifing if fog should be enabled
  109967. */
  109968. private _fogEnabled;
  109969. /**
  109970. * Sets the state for enabling fog
  109971. */
  109972. set fogEnabled(value: boolean);
  109973. /**
  109974. * Gets the value of the fog enabled state
  109975. */
  109976. get fogEnabled(): boolean;
  109977. /**
  109978. * Stores the size of points
  109979. */
  109980. pointSize: number;
  109981. /**
  109982. * Stores the z offset value
  109983. */
  109984. zOffset: number;
  109985. get wireframe(): boolean;
  109986. /**
  109987. * Sets the state of wireframe mode
  109988. */
  109989. set wireframe(value: boolean);
  109990. /**
  109991. * Gets the value specifying if point clouds are enabled
  109992. */
  109993. get pointsCloud(): boolean;
  109994. /**
  109995. * Sets the state of point cloud mode
  109996. */
  109997. set pointsCloud(value: boolean);
  109998. /**
  109999. * Gets the material fill mode
  110000. */
  110001. get fillMode(): number;
  110002. /**
  110003. * Sets the material fill mode
  110004. */
  110005. set fillMode(value: number);
  110006. /**
  110007. * @hidden
  110008. * Stores the effects for the material
  110009. */
  110010. _effect: Nullable<Effect>;
  110011. /**
  110012. * Specifies if uniform buffers should be used
  110013. */
  110014. private _useUBO;
  110015. /**
  110016. * Stores a reference to the scene
  110017. */
  110018. private _scene;
  110019. /**
  110020. * Stores the fill mode state
  110021. */
  110022. private _fillMode;
  110023. /**
  110024. * Specifies if the depth write state should be cached
  110025. */
  110026. private _cachedDepthWriteState;
  110027. /**
  110028. * Specifies if the color write state should be cached
  110029. */
  110030. private _cachedColorWriteState;
  110031. /**
  110032. * Specifies if the depth function state should be cached
  110033. */
  110034. private _cachedDepthFunctionState;
  110035. /**
  110036. * Stores the uniform buffer
  110037. */
  110038. protected _uniformBuffer: UniformBuffer;
  110039. /** @hidden */
  110040. _indexInSceneMaterialArray: number;
  110041. /** @hidden */
  110042. meshMap: Nullable<{
  110043. [id: string]: AbstractMesh | undefined;
  110044. }>;
  110045. /**
  110046. * Creates a material instance
  110047. * @param name defines the name of the material
  110048. * @param scene defines the scene to reference
  110049. * @param doNotAdd specifies if the material should be added to the scene
  110050. */
  110051. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110052. /**
  110053. * Returns a string representation of the current material
  110054. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110055. * @returns a string with material information
  110056. */
  110057. toString(fullDetails?: boolean): string;
  110058. /**
  110059. * Gets the class name of the material
  110060. * @returns a string with the class name of the material
  110061. */
  110062. getClassName(): string;
  110063. /**
  110064. * Specifies if updates for the material been locked
  110065. */
  110066. get isFrozen(): boolean;
  110067. /**
  110068. * Locks updates for the material
  110069. */
  110070. freeze(): void;
  110071. /**
  110072. * Unlocks updates for the material
  110073. */
  110074. unfreeze(): void;
  110075. /**
  110076. * Specifies if the material is ready to be used
  110077. * @param mesh defines the mesh to check
  110078. * @param useInstances specifies if instances should be used
  110079. * @returns a boolean indicating if the material is ready to be used
  110080. */
  110081. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110082. /**
  110083. * Specifies that the submesh is ready to be used
  110084. * @param mesh defines the mesh to check
  110085. * @param subMesh defines which submesh to check
  110086. * @param useInstances specifies that instances should be used
  110087. * @returns a boolean indicating that the submesh is ready or not
  110088. */
  110089. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110090. /**
  110091. * Returns the material effect
  110092. * @returns the effect associated with the material
  110093. */
  110094. getEffect(): Nullable<Effect>;
  110095. /**
  110096. * Returns the current scene
  110097. * @returns a Scene
  110098. */
  110099. getScene(): Scene;
  110100. /**
  110101. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110102. */
  110103. protected _forceAlphaTest: boolean;
  110104. /**
  110105. * The transparency mode of the material.
  110106. */
  110107. protected _transparencyMode: Nullable<number>;
  110108. /**
  110109. * Gets the current transparency mode.
  110110. */
  110111. get transparencyMode(): Nullable<number>;
  110112. /**
  110113. * Sets the transparency mode of the material.
  110114. *
  110115. * | Value | Type | Description |
  110116. * | ----- | ----------------------------------- | ----------- |
  110117. * | 0 | OPAQUE | |
  110118. * | 1 | ALPHATEST | |
  110119. * | 2 | ALPHABLEND | |
  110120. * | 3 | ALPHATESTANDBLEND | |
  110121. *
  110122. */
  110123. set transparencyMode(value: Nullable<number>);
  110124. /**
  110125. * Returns true if alpha blending should be disabled.
  110126. */
  110127. protected get _disableAlphaBlending(): boolean;
  110128. /**
  110129. * Specifies whether or not this material should be rendered in alpha blend mode.
  110130. * @returns a boolean specifying if alpha blending is needed
  110131. */
  110132. needAlphaBlending(): boolean;
  110133. /**
  110134. * Specifies if the mesh will require alpha blending
  110135. * @param mesh defines the mesh to check
  110136. * @returns a boolean specifying if alpha blending is needed for the mesh
  110137. */
  110138. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110139. /**
  110140. * Specifies whether or not this material should be rendered in alpha test mode.
  110141. * @returns a boolean specifying if an alpha test is needed.
  110142. */
  110143. needAlphaTesting(): boolean;
  110144. /**
  110145. * Specifies if material alpha testing should be turned on for the mesh
  110146. * @param mesh defines the mesh to check
  110147. */
  110148. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110149. /**
  110150. * Gets the texture used for the alpha test
  110151. * @returns the texture to use for alpha testing
  110152. */
  110153. getAlphaTestTexture(): Nullable<BaseTexture>;
  110154. /**
  110155. * Marks the material to indicate that it needs to be re-calculated
  110156. */
  110157. markDirty(): void;
  110158. /** @hidden */
  110159. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110160. /**
  110161. * Binds the material to the mesh
  110162. * @param world defines the world transformation matrix
  110163. * @param mesh defines the mesh to bind the material to
  110164. */
  110165. bind(world: Matrix, mesh?: Mesh): void;
  110166. /**
  110167. * Binds the submesh to the material
  110168. * @param world defines the world transformation matrix
  110169. * @param mesh defines the mesh containing the submesh
  110170. * @param subMesh defines the submesh to bind the material to
  110171. */
  110172. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110173. /**
  110174. * Binds the world matrix to the material
  110175. * @param world defines the world transformation matrix
  110176. */
  110177. bindOnlyWorldMatrix(world: Matrix): void;
  110178. /**
  110179. * Binds the scene's uniform buffer to the effect.
  110180. * @param effect defines the effect to bind to the scene uniform buffer
  110181. * @param sceneUbo defines the uniform buffer storing scene data
  110182. */
  110183. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110184. /**
  110185. * Binds the view matrix to the effect
  110186. * @param effect defines the effect to bind the view matrix to
  110187. */
  110188. bindView(effect: Effect): void;
  110189. /**
  110190. * Binds the view projection matrix to the effect
  110191. * @param effect defines the effect to bind the view projection matrix to
  110192. */
  110193. bindViewProjection(effect: Effect): void;
  110194. /**
  110195. * Processes to execute after binding the material to a mesh
  110196. * @param mesh defines the rendered mesh
  110197. */
  110198. protected _afterBind(mesh?: Mesh): void;
  110199. /**
  110200. * Unbinds the material from the mesh
  110201. */
  110202. unbind(): void;
  110203. /**
  110204. * Gets the active textures from the material
  110205. * @returns an array of textures
  110206. */
  110207. getActiveTextures(): BaseTexture[];
  110208. /**
  110209. * Specifies if the material uses a texture
  110210. * @param texture defines the texture to check against the material
  110211. * @returns a boolean specifying if the material uses the texture
  110212. */
  110213. hasTexture(texture: BaseTexture): boolean;
  110214. /**
  110215. * Makes a duplicate of the material, and gives it a new name
  110216. * @param name defines the new name for the duplicated material
  110217. * @returns the cloned material
  110218. */
  110219. clone(name: string): Nullable<Material>;
  110220. /**
  110221. * Gets the meshes bound to the material
  110222. * @returns an array of meshes bound to the material
  110223. */
  110224. getBindedMeshes(): AbstractMesh[];
  110225. /**
  110226. * Force shader compilation
  110227. * @param mesh defines the mesh associated with this material
  110228. * @param onCompiled defines a function to execute once the material is compiled
  110229. * @param options defines the options to configure the compilation
  110230. * @param onError defines a function to execute if the material fails compiling
  110231. */
  110232. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110233. /**
  110234. * Force shader compilation
  110235. * @param mesh defines the mesh that will use this material
  110236. * @param options defines additional options for compiling the shaders
  110237. * @returns a promise that resolves when the compilation completes
  110238. */
  110239. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110240. private static readonly _AllDirtyCallBack;
  110241. private static readonly _ImageProcessingDirtyCallBack;
  110242. private static readonly _TextureDirtyCallBack;
  110243. private static readonly _FresnelDirtyCallBack;
  110244. private static readonly _MiscDirtyCallBack;
  110245. private static readonly _PrePassDirtyCallBack;
  110246. private static readonly _LightsDirtyCallBack;
  110247. private static readonly _AttributeDirtyCallBack;
  110248. private static _FresnelAndMiscDirtyCallBack;
  110249. private static _TextureAndMiscDirtyCallBack;
  110250. private static readonly _DirtyCallbackArray;
  110251. private static readonly _RunDirtyCallBacks;
  110252. /**
  110253. * Marks a define in the material to indicate that it needs to be re-computed
  110254. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110255. */
  110256. markAsDirty(flag: number): void;
  110257. /**
  110258. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110259. * @param func defines a function which checks material defines against the submeshes
  110260. */
  110261. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110262. /**
  110263. * Indicates that the scene should check if the rendering now needs a prepass
  110264. */
  110265. protected _markScenePrePassDirty(): void;
  110266. /**
  110267. * Indicates that we need to re-calculated for all submeshes
  110268. */
  110269. protected _markAllSubMeshesAsAllDirty(): void;
  110270. /**
  110271. * Indicates that image processing needs to be re-calculated for all submeshes
  110272. */
  110273. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110274. /**
  110275. * Indicates that textures need to be re-calculated for all submeshes
  110276. */
  110277. protected _markAllSubMeshesAsTexturesDirty(): void;
  110278. /**
  110279. * Indicates that fresnel needs to be re-calculated for all submeshes
  110280. */
  110281. protected _markAllSubMeshesAsFresnelDirty(): void;
  110282. /**
  110283. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110284. */
  110285. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110286. /**
  110287. * Indicates that lights need to be re-calculated for all submeshes
  110288. */
  110289. protected _markAllSubMeshesAsLightsDirty(): void;
  110290. /**
  110291. * Indicates that attributes need to be re-calculated for all submeshes
  110292. */
  110293. protected _markAllSubMeshesAsAttributesDirty(): void;
  110294. /**
  110295. * Indicates that misc needs to be re-calculated for all submeshes
  110296. */
  110297. protected _markAllSubMeshesAsMiscDirty(): void;
  110298. /**
  110299. * Indicates that prepass needs to be re-calculated for all submeshes
  110300. */
  110301. protected _markAllSubMeshesAsPrePassDirty(): void;
  110302. /**
  110303. * Indicates that textures and misc need to be re-calculated for all submeshes
  110304. */
  110305. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110306. /**
  110307. * Sets the required values to the prepass renderer.
  110308. * @param prePassRenderer defines the prepass renderer to setup.
  110309. * @returns true if the pre pass is needed.
  110310. */
  110311. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110312. /**
  110313. * Disposes the material
  110314. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110315. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110316. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110317. */
  110318. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110319. /** @hidden */
  110320. private releaseVertexArrayObject;
  110321. /**
  110322. * Serializes this material
  110323. * @returns the serialized material object
  110324. */
  110325. serialize(): any;
  110326. /**
  110327. * Creates a material from parsed material data
  110328. * @param parsedMaterial defines parsed material data
  110329. * @param scene defines the hosting scene
  110330. * @param rootUrl defines the root URL to use to load textures
  110331. * @returns a new material
  110332. */
  110333. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110334. }
  110335. }
  110336. declare module BABYLON {
  110337. /**
  110338. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110339. * separate meshes. This can be use to improve performances.
  110340. * @see https://doc.babylonjs.com/how_to/multi_materials
  110341. */
  110342. export class MultiMaterial extends Material {
  110343. private _subMaterials;
  110344. /**
  110345. * Gets or Sets the list of Materials used within the multi material.
  110346. * They need to be ordered according to the submeshes order in the associated mesh
  110347. */
  110348. get subMaterials(): Nullable<Material>[];
  110349. set subMaterials(value: Nullable<Material>[]);
  110350. /**
  110351. * Function used to align with Node.getChildren()
  110352. * @returns the list of Materials used within the multi material
  110353. */
  110354. getChildren(): Nullable<Material>[];
  110355. /**
  110356. * Instantiates a new Multi Material
  110357. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110358. * separate meshes. This can be use to improve performances.
  110359. * @see https://doc.babylonjs.com/how_to/multi_materials
  110360. * @param name Define the name in the scene
  110361. * @param scene Define the scene the material belongs to
  110362. */
  110363. constructor(name: string, scene: Scene);
  110364. private _hookArray;
  110365. /**
  110366. * Get one of the submaterial by its index in the submaterials array
  110367. * @param index The index to look the sub material at
  110368. * @returns The Material if the index has been defined
  110369. */
  110370. getSubMaterial(index: number): Nullable<Material>;
  110371. /**
  110372. * Get the list of active textures for the whole sub materials list.
  110373. * @returns All the textures that will be used during the rendering
  110374. */
  110375. getActiveTextures(): BaseTexture[];
  110376. /**
  110377. * Gets the current class name of the material e.g. "MultiMaterial"
  110378. * Mainly use in serialization.
  110379. * @returns the class name
  110380. */
  110381. getClassName(): string;
  110382. /**
  110383. * Checks if the material is ready to render the requested sub mesh
  110384. * @param mesh Define the mesh the submesh belongs to
  110385. * @param subMesh Define the sub mesh to look readyness for
  110386. * @param useInstances Define whether or not the material is used with instances
  110387. * @returns true if ready, otherwise false
  110388. */
  110389. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110390. /**
  110391. * Clones the current material and its related sub materials
  110392. * @param name Define the name of the newly cloned material
  110393. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110394. * @returns the cloned material
  110395. */
  110396. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110397. /**
  110398. * Serializes the materials into a JSON representation.
  110399. * @returns the JSON representation
  110400. */
  110401. serialize(): any;
  110402. /**
  110403. * Dispose the material and release its associated resources
  110404. * @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)
  110405. * @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)
  110406. * @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)
  110407. */
  110408. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110409. /**
  110410. * Creates a MultiMaterial from parsed MultiMaterial data.
  110411. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110412. * @param scene defines the hosting scene
  110413. * @returns a new MultiMaterial
  110414. */
  110415. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110416. }
  110417. }
  110418. declare module BABYLON {
  110419. /**
  110420. * Defines a subdivision inside a mesh
  110421. */
  110422. export class SubMesh implements ICullable {
  110423. /** the material index to use */
  110424. materialIndex: number;
  110425. /** vertex index start */
  110426. verticesStart: number;
  110427. /** vertices count */
  110428. verticesCount: number;
  110429. /** index start */
  110430. indexStart: number;
  110431. /** indices count */
  110432. indexCount: number;
  110433. /** @hidden */
  110434. _materialDefines: Nullable<MaterialDefines>;
  110435. /** @hidden */
  110436. _materialEffect: Nullable<Effect>;
  110437. /** @hidden */
  110438. _effectOverride: Nullable<Effect>;
  110439. /**
  110440. * Gets material defines used by the effect associated to the sub mesh
  110441. */
  110442. get materialDefines(): Nullable<MaterialDefines>;
  110443. /**
  110444. * Sets material defines used by the effect associated to the sub mesh
  110445. */
  110446. set materialDefines(defines: Nullable<MaterialDefines>);
  110447. /**
  110448. * Gets associated effect
  110449. */
  110450. get effect(): Nullable<Effect>;
  110451. /**
  110452. * Sets associated effect (effect used to render this submesh)
  110453. * @param effect defines the effect to associate with
  110454. * @param defines defines the set of defines used to compile this effect
  110455. */
  110456. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110457. /** @hidden */
  110458. _linesIndexCount: number;
  110459. private _mesh;
  110460. private _renderingMesh;
  110461. private _boundingInfo;
  110462. private _linesIndexBuffer;
  110463. /** @hidden */
  110464. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110465. /** @hidden */
  110466. _trianglePlanes: Plane[];
  110467. /** @hidden */
  110468. _lastColliderTransformMatrix: Nullable<Matrix>;
  110469. /** @hidden */
  110470. _renderId: number;
  110471. /** @hidden */
  110472. _alphaIndex: number;
  110473. /** @hidden */
  110474. _distanceToCamera: number;
  110475. /** @hidden */
  110476. _id: number;
  110477. private _currentMaterial;
  110478. /**
  110479. * Add a new submesh to a mesh
  110480. * @param materialIndex defines the material index to use
  110481. * @param verticesStart defines vertex index start
  110482. * @param verticesCount defines vertices count
  110483. * @param indexStart defines index start
  110484. * @param indexCount defines indices count
  110485. * @param mesh defines the parent mesh
  110486. * @param renderingMesh defines an optional rendering mesh
  110487. * @param createBoundingBox defines if bounding box should be created for this submesh
  110488. * @returns the new submesh
  110489. */
  110490. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110491. /**
  110492. * Creates a new submesh
  110493. * @param materialIndex defines the material index to use
  110494. * @param verticesStart defines vertex index start
  110495. * @param verticesCount defines vertices count
  110496. * @param indexStart defines index start
  110497. * @param indexCount defines indices count
  110498. * @param mesh defines the parent mesh
  110499. * @param renderingMesh defines an optional rendering mesh
  110500. * @param createBoundingBox defines if bounding box should be created for this submesh
  110501. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110502. */
  110503. constructor(
  110504. /** the material index to use */
  110505. materialIndex: number,
  110506. /** vertex index start */
  110507. verticesStart: number,
  110508. /** vertices count */
  110509. verticesCount: number,
  110510. /** index start */
  110511. indexStart: number,
  110512. /** indices count */
  110513. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110514. /**
  110515. * Returns true if this submesh covers the entire parent mesh
  110516. * @ignorenaming
  110517. */
  110518. get IsGlobal(): boolean;
  110519. /**
  110520. * Returns the submesh BoudingInfo object
  110521. * @returns current bounding info (or mesh's one if the submesh is global)
  110522. */
  110523. getBoundingInfo(): BoundingInfo;
  110524. /**
  110525. * Sets the submesh BoundingInfo
  110526. * @param boundingInfo defines the new bounding info to use
  110527. * @returns the SubMesh
  110528. */
  110529. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110530. /**
  110531. * Returns the mesh of the current submesh
  110532. * @return the parent mesh
  110533. */
  110534. getMesh(): AbstractMesh;
  110535. /**
  110536. * Returns the rendering mesh of the submesh
  110537. * @returns the rendering mesh (could be different from parent mesh)
  110538. */
  110539. getRenderingMesh(): Mesh;
  110540. /**
  110541. * Returns the replacement mesh of the submesh
  110542. * @returns the replacement mesh (could be different from parent mesh)
  110543. */
  110544. getReplacementMesh(): Nullable<AbstractMesh>;
  110545. /**
  110546. * Returns the effective mesh of the submesh
  110547. * @returns the effective mesh (could be different from parent mesh)
  110548. */
  110549. getEffectiveMesh(): AbstractMesh;
  110550. /**
  110551. * Returns the submesh material
  110552. * @returns null or the current material
  110553. */
  110554. getMaterial(): Nullable<Material>;
  110555. private _IsMultiMaterial;
  110556. /**
  110557. * Sets a new updated BoundingInfo object to the submesh
  110558. * @param data defines an optional position array to use to determine the bounding info
  110559. * @returns the SubMesh
  110560. */
  110561. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110562. /** @hidden */
  110563. _checkCollision(collider: Collider): boolean;
  110564. /**
  110565. * Updates the submesh BoundingInfo
  110566. * @param world defines the world matrix to use to update the bounding info
  110567. * @returns the submesh
  110568. */
  110569. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110570. /**
  110571. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110572. * @param frustumPlanes defines the frustum planes
  110573. * @returns true if the submesh is intersecting with the frustum
  110574. */
  110575. isInFrustum(frustumPlanes: Plane[]): boolean;
  110576. /**
  110577. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110578. * @param frustumPlanes defines the frustum planes
  110579. * @returns true if the submesh is inside the frustum
  110580. */
  110581. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110582. /**
  110583. * Renders the submesh
  110584. * @param enableAlphaMode defines if alpha needs to be used
  110585. * @returns the submesh
  110586. */
  110587. render(enableAlphaMode: boolean): SubMesh;
  110588. /**
  110589. * @hidden
  110590. */
  110591. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110592. /**
  110593. * Checks if the submesh intersects with a ray
  110594. * @param ray defines the ray to test
  110595. * @returns true is the passed ray intersects the submesh bounding box
  110596. */
  110597. canIntersects(ray: Ray): boolean;
  110598. /**
  110599. * Intersects current submesh with a ray
  110600. * @param ray defines the ray to test
  110601. * @param positions defines mesh's positions array
  110602. * @param indices defines mesh's indices array
  110603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110605. * @returns intersection info or null if no intersection
  110606. */
  110607. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110608. /** @hidden */
  110609. private _intersectLines;
  110610. /** @hidden */
  110611. private _intersectUnIndexedLines;
  110612. /** @hidden */
  110613. private _intersectTriangles;
  110614. /** @hidden */
  110615. private _intersectUnIndexedTriangles;
  110616. /** @hidden */
  110617. _rebuild(): void;
  110618. /**
  110619. * Creates a new submesh from the passed mesh
  110620. * @param newMesh defines the new hosting mesh
  110621. * @param newRenderingMesh defines an optional rendering mesh
  110622. * @returns the new submesh
  110623. */
  110624. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110625. /**
  110626. * Release associated resources
  110627. */
  110628. dispose(): void;
  110629. /**
  110630. * Gets the class name
  110631. * @returns the string "SubMesh".
  110632. */
  110633. getClassName(): string;
  110634. /**
  110635. * Creates a new submesh from indices data
  110636. * @param materialIndex the index of the main mesh material
  110637. * @param startIndex the index where to start the copy in the mesh indices array
  110638. * @param indexCount the number of indices to copy then from the startIndex
  110639. * @param mesh the main mesh to create the submesh from
  110640. * @param renderingMesh the optional rendering mesh
  110641. * @returns a new submesh
  110642. */
  110643. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110644. }
  110645. }
  110646. declare module BABYLON {
  110647. /**
  110648. * Class used to represent data loading progression
  110649. */
  110650. export class SceneLoaderFlags {
  110651. private static _ForceFullSceneLoadingForIncremental;
  110652. private static _ShowLoadingScreen;
  110653. private static _CleanBoneMatrixWeights;
  110654. private static _loggingLevel;
  110655. /**
  110656. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110657. */
  110658. static get ForceFullSceneLoadingForIncremental(): boolean;
  110659. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110660. /**
  110661. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110662. */
  110663. static get ShowLoadingScreen(): boolean;
  110664. static set ShowLoadingScreen(value: boolean);
  110665. /**
  110666. * Defines the current logging level (while loading the scene)
  110667. * @ignorenaming
  110668. */
  110669. static get loggingLevel(): number;
  110670. static set loggingLevel(value: number);
  110671. /**
  110672. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110673. */
  110674. static get CleanBoneMatrixWeights(): boolean;
  110675. static set CleanBoneMatrixWeights(value: boolean);
  110676. }
  110677. }
  110678. declare module BABYLON {
  110679. /**
  110680. * Class used to store geometry data (vertex buffers + index buffer)
  110681. */
  110682. export class Geometry implements IGetSetVerticesData {
  110683. /**
  110684. * Gets or sets the ID of the geometry
  110685. */
  110686. id: string;
  110687. /**
  110688. * Gets or sets the unique ID of the geometry
  110689. */
  110690. uniqueId: number;
  110691. /**
  110692. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110693. */
  110694. delayLoadState: number;
  110695. /**
  110696. * Gets the file containing the data to load when running in delay load state
  110697. */
  110698. delayLoadingFile: Nullable<string>;
  110699. /**
  110700. * Callback called when the geometry is updated
  110701. */
  110702. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110703. private _scene;
  110704. private _engine;
  110705. private _meshes;
  110706. private _totalVertices;
  110707. /** @hidden */
  110708. _indices: IndicesArray;
  110709. /** @hidden */
  110710. _vertexBuffers: {
  110711. [key: string]: VertexBuffer;
  110712. };
  110713. private _isDisposed;
  110714. private _extend;
  110715. private _boundingBias;
  110716. /** @hidden */
  110717. _delayInfo: Array<string>;
  110718. private _indexBuffer;
  110719. private _indexBufferIsUpdatable;
  110720. /** @hidden */
  110721. _boundingInfo: Nullable<BoundingInfo>;
  110722. /** @hidden */
  110723. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110724. /** @hidden */
  110725. _softwareSkinningFrameId: number;
  110726. private _vertexArrayObjects;
  110727. private _updatable;
  110728. /** @hidden */
  110729. _positions: Nullable<Vector3[]>;
  110730. /**
  110731. * 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
  110732. */
  110733. get boundingBias(): Vector2;
  110734. /**
  110735. * 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
  110736. */
  110737. set boundingBias(value: Vector2);
  110738. /**
  110739. * Static function used to attach a new empty geometry to a mesh
  110740. * @param mesh defines the mesh to attach the geometry to
  110741. * @returns the new Geometry
  110742. */
  110743. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110744. /** Get the list of meshes using this geometry */
  110745. get meshes(): Mesh[];
  110746. /**
  110747. * 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
  110748. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110749. */
  110750. useBoundingInfoFromGeometry: boolean;
  110751. /**
  110752. * Creates a new geometry
  110753. * @param id defines the unique ID
  110754. * @param scene defines the hosting scene
  110755. * @param vertexData defines the VertexData used to get geometry data
  110756. * @param updatable defines if geometry must be updatable (false by default)
  110757. * @param mesh defines the mesh that will be associated with the geometry
  110758. */
  110759. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110760. /**
  110761. * Gets the current extend of the geometry
  110762. */
  110763. get extend(): {
  110764. minimum: Vector3;
  110765. maximum: Vector3;
  110766. };
  110767. /**
  110768. * Gets the hosting scene
  110769. * @returns the hosting Scene
  110770. */
  110771. getScene(): Scene;
  110772. /**
  110773. * Gets the hosting engine
  110774. * @returns the hosting Engine
  110775. */
  110776. getEngine(): Engine;
  110777. /**
  110778. * Defines if the geometry is ready to use
  110779. * @returns true if the geometry is ready to be used
  110780. */
  110781. isReady(): boolean;
  110782. /**
  110783. * Gets a value indicating that the geometry should not be serialized
  110784. */
  110785. get doNotSerialize(): boolean;
  110786. /** @hidden */
  110787. _rebuild(): void;
  110788. /**
  110789. * Affects all geometry data in one call
  110790. * @param vertexData defines the geometry data
  110791. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110792. */
  110793. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110794. /**
  110795. * Set specific vertex data
  110796. * @param kind defines the data kind (Position, normal, etc...)
  110797. * @param data defines the vertex data to use
  110798. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110799. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110800. */
  110801. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110802. /**
  110803. * Removes a specific vertex data
  110804. * @param kind defines the data kind (Position, normal, etc...)
  110805. */
  110806. removeVerticesData(kind: string): void;
  110807. /**
  110808. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110809. * @param buffer defines the vertex buffer to use
  110810. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110811. */
  110812. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110813. /**
  110814. * Update a specific vertex buffer
  110815. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110816. * It will do nothing if the buffer is not updatable
  110817. * @param kind defines the data kind (Position, normal, etc...)
  110818. * @param data defines the data to use
  110819. * @param offset defines the offset in the target buffer where to store the data
  110820. * @param useBytes set to true if the offset is in bytes
  110821. */
  110822. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110823. /**
  110824. * Update a specific vertex buffer
  110825. * This function will create a new buffer if the current one is not updatable
  110826. * @param kind defines the data kind (Position, normal, etc...)
  110827. * @param data defines the data to use
  110828. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110829. */
  110830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110831. private _updateBoundingInfo;
  110832. /** @hidden */
  110833. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110834. /**
  110835. * Gets total number of vertices
  110836. * @returns the total number of vertices
  110837. */
  110838. getTotalVertices(): number;
  110839. /**
  110840. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110841. * @param kind defines the data kind (Position, normal, etc...)
  110842. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110844. * @returns a float array containing vertex data
  110845. */
  110846. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110847. /**
  110848. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110849. * @param kind defines the data kind (Position, normal, etc...)
  110850. * @returns true if the vertex buffer with the specified kind is updatable
  110851. */
  110852. isVertexBufferUpdatable(kind: string): boolean;
  110853. /**
  110854. * Gets a specific vertex buffer
  110855. * @param kind defines the data kind (Position, normal, etc...)
  110856. * @returns a VertexBuffer
  110857. */
  110858. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110859. /**
  110860. * Returns all vertex buffers
  110861. * @return an object holding all vertex buffers indexed by kind
  110862. */
  110863. getVertexBuffers(): Nullable<{
  110864. [key: string]: VertexBuffer;
  110865. }>;
  110866. /**
  110867. * Gets a boolean indicating if specific vertex buffer is present
  110868. * @param kind defines the data kind (Position, normal, etc...)
  110869. * @returns true if data is present
  110870. */
  110871. isVerticesDataPresent(kind: string): boolean;
  110872. /**
  110873. * Gets a list of all attached data kinds (Position, normal, etc...)
  110874. * @returns a list of string containing all kinds
  110875. */
  110876. getVerticesDataKinds(): string[];
  110877. /**
  110878. * Update index buffer
  110879. * @param indices defines the indices to store in the index buffer
  110880. * @param offset defines the offset in the target buffer where to store the data
  110881. * @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)
  110882. */
  110883. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110884. /**
  110885. * Creates a new index buffer
  110886. * @param indices defines the indices to store in the index buffer
  110887. * @param totalVertices defines the total number of vertices (could be null)
  110888. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110889. */
  110890. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110891. /**
  110892. * Return the total number of indices
  110893. * @returns the total number of indices
  110894. */
  110895. getTotalIndices(): number;
  110896. /**
  110897. * Gets the index buffer array
  110898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110899. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110900. * @returns the index buffer array
  110901. */
  110902. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110903. /**
  110904. * Gets the index buffer
  110905. * @return the index buffer
  110906. */
  110907. getIndexBuffer(): Nullable<DataBuffer>;
  110908. /** @hidden */
  110909. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110910. /**
  110911. * Release the associated resources for a specific mesh
  110912. * @param mesh defines the source mesh
  110913. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110914. */
  110915. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110916. /**
  110917. * Apply current geometry to a given mesh
  110918. * @param mesh defines the mesh to apply geometry to
  110919. */
  110920. applyToMesh(mesh: Mesh): void;
  110921. private _updateExtend;
  110922. private _applyToMesh;
  110923. private notifyUpdate;
  110924. /**
  110925. * Load the geometry if it was flagged as delay loaded
  110926. * @param scene defines the hosting scene
  110927. * @param onLoaded defines a callback called when the geometry is loaded
  110928. */
  110929. load(scene: Scene, onLoaded?: () => void): void;
  110930. private _queueLoad;
  110931. /**
  110932. * Invert the geometry to move from a right handed system to a left handed one.
  110933. */
  110934. toLeftHanded(): void;
  110935. /** @hidden */
  110936. _resetPointsArrayCache(): void;
  110937. /** @hidden */
  110938. _generatePointsArray(): boolean;
  110939. /**
  110940. * Gets a value indicating if the geometry is disposed
  110941. * @returns true if the geometry was disposed
  110942. */
  110943. isDisposed(): boolean;
  110944. private _disposeVertexArrayObjects;
  110945. /**
  110946. * Free all associated resources
  110947. */
  110948. dispose(): void;
  110949. /**
  110950. * Clone the current geometry into a new geometry
  110951. * @param id defines the unique ID of the new geometry
  110952. * @returns a new geometry object
  110953. */
  110954. copy(id: string): Geometry;
  110955. /**
  110956. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110957. * @return a JSON representation of the current geometry data (without the vertices data)
  110958. */
  110959. serialize(): any;
  110960. private toNumberArray;
  110961. /**
  110962. * Serialize all vertices data into a JSON oject
  110963. * @returns a JSON representation of the current geometry data
  110964. */
  110965. serializeVerticeData(): any;
  110966. /**
  110967. * Extracts a clone of a mesh geometry
  110968. * @param mesh defines the source mesh
  110969. * @param id defines the unique ID of the new geometry object
  110970. * @returns the new geometry object
  110971. */
  110972. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110973. /**
  110974. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110975. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110976. * Be aware Math.random() could cause collisions, but:
  110977. * "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"
  110978. * @returns a string containing a new GUID
  110979. */
  110980. static RandomId(): string;
  110981. /** @hidden */
  110982. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110983. private static _CleanMatricesWeights;
  110984. /**
  110985. * Create a new geometry from persisted data (Using .babylon file format)
  110986. * @param parsedVertexData defines the persisted data
  110987. * @param scene defines the hosting scene
  110988. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110989. * @returns the new geometry object
  110990. */
  110991. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110992. }
  110993. }
  110994. declare module BABYLON {
  110995. /**
  110996. * Define an interface for all classes that will get and set the data on vertices
  110997. */
  110998. export interface IGetSetVerticesData {
  110999. /**
  111000. * Gets a boolean indicating if specific vertex data is present
  111001. * @param kind defines the vertex data kind to use
  111002. * @returns true is data kind is present
  111003. */
  111004. isVerticesDataPresent(kind: string): boolean;
  111005. /**
  111006. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111007. * @param kind defines the data kind (Position, normal, etc...)
  111008. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111010. * @returns a float array containing vertex data
  111011. */
  111012. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111013. /**
  111014. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  111015. * @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.
  111016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111017. * @returns the indices array or an empty array if the mesh has no geometry
  111018. */
  111019. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111020. /**
  111021. * Set specific vertex data
  111022. * @param kind defines the data kind (Position, normal, etc...)
  111023. * @param data defines the vertex data to use
  111024. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111025. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111026. */
  111027. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  111028. /**
  111029. * Update a specific associated vertex buffer
  111030. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  111031. * - VertexBuffer.PositionKind
  111032. * - VertexBuffer.UVKind
  111033. * - VertexBuffer.UV2Kind
  111034. * - VertexBuffer.UV3Kind
  111035. * - VertexBuffer.UV4Kind
  111036. * - VertexBuffer.UV5Kind
  111037. * - VertexBuffer.UV6Kind
  111038. * - VertexBuffer.ColorKind
  111039. * - VertexBuffer.MatricesIndicesKind
  111040. * - VertexBuffer.MatricesIndicesExtraKind
  111041. * - VertexBuffer.MatricesWeightsKind
  111042. * - VertexBuffer.MatricesWeightsExtraKind
  111043. * @param data defines the data source
  111044. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  111045. * @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)
  111046. */
  111047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111048. /**
  111049. * Creates a new index buffer
  111050. * @param indices defines the indices to store in the index buffer
  111051. * @param totalVertices defines the total number of vertices (could be null)
  111052. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111053. */
  111054. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111055. }
  111056. /**
  111057. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111058. */
  111059. export class VertexData {
  111060. /**
  111061. * Mesh side orientation : usually the external or front surface
  111062. */
  111063. static readonly FRONTSIDE: number;
  111064. /**
  111065. * Mesh side orientation : usually the internal or back surface
  111066. */
  111067. static readonly BACKSIDE: number;
  111068. /**
  111069. * Mesh side orientation : both internal and external or front and back surfaces
  111070. */
  111071. static readonly DOUBLESIDE: number;
  111072. /**
  111073. * Mesh side orientation : by default, `FRONTSIDE`
  111074. */
  111075. static readonly DEFAULTSIDE: number;
  111076. /**
  111077. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111078. */
  111079. positions: Nullable<FloatArray>;
  111080. /**
  111081. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111082. */
  111083. normals: Nullable<FloatArray>;
  111084. /**
  111085. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111086. */
  111087. tangents: Nullable<FloatArray>;
  111088. /**
  111089. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111090. */
  111091. uvs: Nullable<FloatArray>;
  111092. /**
  111093. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111094. */
  111095. uvs2: Nullable<FloatArray>;
  111096. /**
  111097. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111098. */
  111099. uvs3: Nullable<FloatArray>;
  111100. /**
  111101. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111102. */
  111103. uvs4: Nullable<FloatArray>;
  111104. /**
  111105. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111106. */
  111107. uvs5: Nullable<FloatArray>;
  111108. /**
  111109. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111110. */
  111111. uvs6: Nullable<FloatArray>;
  111112. /**
  111113. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111114. */
  111115. colors: Nullable<FloatArray>;
  111116. /**
  111117. * 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).
  111118. */
  111119. matricesIndices: Nullable<FloatArray>;
  111120. /**
  111121. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111122. */
  111123. matricesWeights: Nullable<FloatArray>;
  111124. /**
  111125. * An array extending the number of possible indices
  111126. */
  111127. matricesIndicesExtra: Nullable<FloatArray>;
  111128. /**
  111129. * An array extending the number of possible weights when the number of indices is extended
  111130. */
  111131. matricesWeightsExtra: Nullable<FloatArray>;
  111132. /**
  111133. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111134. */
  111135. indices: Nullable<IndicesArray>;
  111136. /**
  111137. * Uses the passed data array to set the set the values for the specified kind of data
  111138. * @param data a linear array of floating numbers
  111139. * @param kind the type of data that is being set, eg positions, colors etc
  111140. */
  111141. set(data: FloatArray, kind: string): void;
  111142. /**
  111143. * Associates the vertexData to the passed Mesh.
  111144. * Sets it as updatable or not (default `false`)
  111145. * @param mesh the mesh the vertexData is applied to
  111146. * @param updatable when used and having the value true allows new data to update the vertexData
  111147. * @returns the VertexData
  111148. */
  111149. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111150. /**
  111151. * Associates the vertexData to the passed Geometry.
  111152. * Sets it as updatable or not (default `false`)
  111153. * @param geometry the geometry the vertexData is applied to
  111154. * @param updatable when used and having the value true allows new data to update the vertexData
  111155. * @returns VertexData
  111156. */
  111157. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111158. /**
  111159. * Updates the associated mesh
  111160. * @param mesh the mesh to be updated
  111161. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111162. * @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
  111163. * @returns VertexData
  111164. */
  111165. updateMesh(mesh: Mesh): VertexData;
  111166. /**
  111167. * Updates the associated geometry
  111168. * @param geometry the geometry to be updated
  111169. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111170. * @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
  111171. * @returns VertexData.
  111172. */
  111173. updateGeometry(geometry: Geometry): VertexData;
  111174. private _applyTo;
  111175. private _update;
  111176. /**
  111177. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111178. * @param matrix the transforming matrix
  111179. * @returns the VertexData
  111180. */
  111181. transform(matrix: Matrix): VertexData;
  111182. /**
  111183. * Merges the passed VertexData into the current one
  111184. * @param other the VertexData to be merged into the current one
  111185. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111186. * @returns the modified VertexData
  111187. */
  111188. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111189. private _mergeElement;
  111190. private _validate;
  111191. /**
  111192. * Serializes the VertexData
  111193. * @returns a serialized object
  111194. */
  111195. serialize(): any;
  111196. /**
  111197. * Extracts the vertexData from a mesh
  111198. * @param mesh the mesh from which to extract the VertexData
  111199. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111200. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111201. * @returns the object VertexData associated to the passed mesh
  111202. */
  111203. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111204. /**
  111205. * Extracts the vertexData from the geometry
  111206. * @param geometry the geometry from which to extract the VertexData
  111207. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111208. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111209. * @returns the object VertexData associated to the passed mesh
  111210. */
  111211. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111212. private static _ExtractFrom;
  111213. /**
  111214. * Creates the VertexData for a Ribbon
  111215. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111216. * * pathArray array of paths, each of which an array of successive Vector3
  111217. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111218. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111219. * * 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
  111220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111221. * * 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)
  111222. * * 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)
  111223. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111224. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111225. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111226. * @returns the VertexData of the ribbon
  111227. */
  111228. static CreateRibbon(options: {
  111229. pathArray: Vector3[][];
  111230. closeArray?: boolean;
  111231. closePath?: boolean;
  111232. offset?: number;
  111233. sideOrientation?: number;
  111234. frontUVs?: Vector4;
  111235. backUVs?: Vector4;
  111236. invertUV?: boolean;
  111237. uvs?: Vector2[];
  111238. colors?: Color4[];
  111239. }): VertexData;
  111240. /**
  111241. * Creates the VertexData for a box
  111242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111243. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111244. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111245. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111246. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111247. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111248. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111250. * * 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)
  111251. * * 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)
  111252. * @returns the VertexData of the box
  111253. */
  111254. static CreateBox(options: {
  111255. size?: number;
  111256. width?: number;
  111257. height?: number;
  111258. depth?: number;
  111259. faceUV?: Vector4[];
  111260. faceColors?: Color4[];
  111261. sideOrientation?: number;
  111262. frontUVs?: Vector4;
  111263. backUVs?: Vector4;
  111264. }): VertexData;
  111265. /**
  111266. * Creates the VertexData for a tiled box
  111267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111268. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111269. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111270. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111272. * @returns the VertexData of the box
  111273. */
  111274. static CreateTiledBox(options: {
  111275. pattern?: number;
  111276. width?: number;
  111277. height?: number;
  111278. depth?: number;
  111279. tileSize?: number;
  111280. tileWidth?: number;
  111281. tileHeight?: number;
  111282. alignHorizontal?: number;
  111283. alignVertical?: number;
  111284. faceUV?: Vector4[];
  111285. faceColors?: Color4[];
  111286. sideOrientation?: number;
  111287. }): VertexData;
  111288. /**
  111289. * Creates the VertexData for a tiled plane
  111290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111291. * * pattern a limited pattern arrangement depending on the number
  111292. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111293. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111294. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111296. * * 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)
  111297. * * 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)
  111298. * @returns the VertexData of the tiled plane
  111299. */
  111300. static CreateTiledPlane(options: {
  111301. pattern?: number;
  111302. tileSize?: number;
  111303. tileWidth?: number;
  111304. tileHeight?: number;
  111305. size?: number;
  111306. width?: number;
  111307. height?: number;
  111308. alignHorizontal?: number;
  111309. alignVertical?: number;
  111310. sideOrientation?: number;
  111311. frontUVs?: Vector4;
  111312. backUVs?: Vector4;
  111313. }): VertexData;
  111314. /**
  111315. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111317. * * segments sets the number of horizontal strips optional, default 32
  111318. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111319. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111320. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111321. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111322. * * 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
  111323. * * 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
  111324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111325. * * 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)
  111326. * * 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)
  111327. * @returns the VertexData of the ellipsoid
  111328. */
  111329. static CreateSphere(options: {
  111330. segments?: number;
  111331. diameter?: number;
  111332. diameterX?: number;
  111333. diameterY?: number;
  111334. diameterZ?: number;
  111335. arc?: number;
  111336. slice?: number;
  111337. sideOrientation?: number;
  111338. frontUVs?: Vector4;
  111339. backUVs?: Vector4;
  111340. }): VertexData;
  111341. /**
  111342. * Creates the VertexData for a cylinder, cone or prism
  111343. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111344. * * height sets the height (y direction) of the cylinder, optional, default 2
  111345. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111346. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111347. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111348. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111349. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111350. * * 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
  111351. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111352. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111353. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111354. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111356. * * 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)
  111357. * * 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)
  111358. * @returns the VertexData of the cylinder, cone or prism
  111359. */
  111360. static CreateCylinder(options: {
  111361. height?: number;
  111362. diameterTop?: number;
  111363. diameterBottom?: number;
  111364. diameter?: number;
  111365. tessellation?: number;
  111366. subdivisions?: number;
  111367. arc?: number;
  111368. faceColors?: Color4[];
  111369. faceUV?: Vector4[];
  111370. hasRings?: boolean;
  111371. enclose?: boolean;
  111372. sideOrientation?: number;
  111373. frontUVs?: Vector4;
  111374. backUVs?: Vector4;
  111375. }): VertexData;
  111376. /**
  111377. * Creates the VertexData for a torus
  111378. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111379. * * diameter the diameter of the torus, optional default 1
  111380. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111381. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111383. * * 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)
  111384. * * 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)
  111385. * @returns the VertexData of the torus
  111386. */
  111387. static CreateTorus(options: {
  111388. diameter?: number;
  111389. thickness?: number;
  111390. tessellation?: number;
  111391. sideOrientation?: number;
  111392. frontUVs?: Vector4;
  111393. backUVs?: Vector4;
  111394. }): VertexData;
  111395. /**
  111396. * Creates the VertexData of the LineSystem
  111397. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111398. * - lines an array of lines, each line being an array of successive Vector3
  111399. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111400. * @returns the VertexData of the LineSystem
  111401. */
  111402. static CreateLineSystem(options: {
  111403. lines: Vector3[][];
  111404. colors?: Nullable<Color4[][]>;
  111405. }): VertexData;
  111406. /**
  111407. * Create the VertexData for a DashedLines
  111408. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111409. * - points an array successive Vector3
  111410. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111411. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111412. * - dashNb the intended total number of dashes, optional, default 200
  111413. * @returns the VertexData for the DashedLines
  111414. */
  111415. static CreateDashedLines(options: {
  111416. points: Vector3[];
  111417. dashSize?: number;
  111418. gapSize?: number;
  111419. dashNb?: number;
  111420. }): VertexData;
  111421. /**
  111422. * Creates the VertexData for a Ground
  111423. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111424. * - width the width (x direction) of the ground, optional, default 1
  111425. * - height the height (z direction) of the ground, optional, default 1
  111426. * - subdivisions the number of subdivisions per side, optional, default 1
  111427. * @returns the VertexData of the Ground
  111428. */
  111429. static CreateGround(options: {
  111430. width?: number;
  111431. height?: number;
  111432. subdivisions?: number;
  111433. subdivisionsX?: number;
  111434. subdivisionsY?: number;
  111435. }): VertexData;
  111436. /**
  111437. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111438. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111439. * * xmin the ground minimum X coordinate, optional, default -1
  111440. * * zmin the ground minimum Z coordinate, optional, default -1
  111441. * * xmax the ground maximum X coordinate, optional, default 1
  111442. * * zmax the ground maximum Z coordinate, optional, default 1
  111443. * * 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}
  111444. * * 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}
  111445. * @returns the VertexData of the TiledGround
  111446. */
  111447. static CreateTiledGround(options: {
  111448. xmin: number;
  111449. zmin: number;
  111450. xmax: number;
  111451. zmax: number;
  111452. subdivisions?: {
  111453. w: number;
  111454. h: number;
  111455. };
  111456. precision?: {
  111457. w: number;
  111458. h: number;
  111459. };
  111460. }): VertexData;
  111461. /**
  111462. * Creates the VertexData of the Ground designed from a heightmap
  111463. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111464. * * width the width (x direction) of the ground
  111465. * * height the height (z direction) of the ground
  111466. * * subdivisions the number of subdivisions per side
  111467. * * minHeight the minimum altitude on the ground, optional, default 0
  111468. * * maxHeight the maximum altitude on the ground, optional default 1
  111469. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111470. * * buffer the array holding the image color data
  111471. * * bufferWidth the width of image
  111472. * * bufferHeight the height of image
  111473. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111474. * @returns the VertexData of the Ground designed from a heightmap
  111475. */
  111476. static CreateGroundFromHeightMap(options: {
  111477. width: number;
  111478. height: number;
  111479. subdivisions: number;
  111480. minHeight: number;
  111481. maxHeight: number;
  111482. colorFilter: Color3;
  111483. buffer: Uint8Array;
  111484. bufferWidth: number;
  111485. bufferHeight: number;
  111486. alphaFilter: number;
  111487. }): VertexData;
  111488. /**
  111489. * Creates the VertexData for a Plane
  111490. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111491. * * size sets the width and height of the plane to the value of size, optional default 1
  111492. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111493. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111495. * * 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)
  111496. * * 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)
  111497. * @returns the VertexData of the box
  111498. */
  111499. static CreatePlane(options: {
  111500. size?: number;
  111501. width?: number;
  111502. height?: number;
  111503. sideOrientation?: number;
  111504. frontUVs?: Vector4;
  111505. backUVs?: Vector4;
  111506. }): VertexData;
  111507. /**
  111508. * Creates the VertexData of the Disc or regular Polygon
  111509. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111510. * * radius the radius of the disc, optional default 0.5
  111511. * * tessellation the number of polygon sides, optional, default 64
  111512. * * 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
  111513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111514. * * 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)
  111515. * * 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)
  111516. * @returns the VertexData of the box
  111517. */
  111518. static CreateDisc(options: {
  111519. radius?: number;
  111520. tessellation?: number;
  111521. arc?: number;
  111522. sideOrientation?: number;
  111523. frontUVs?: Vector4;
  111524. backUVs?: Vector4;
  111525. }): VertexData;
  111526. /**
  111527. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111528. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111529. * @param polygon a mesh built from polygonTriangulation.build()
  111530. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111531. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111532. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111533. * @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)
  111534. * @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)
  111535. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111536. * @returns the VertexData of the Polygon
  111537. */
  111538. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111539. /**
  111540. * Creates the VertexData of the IcoSphere
  111541. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111542. * * radius the radius of the IcoSphere, optional default 1
  111543. * * radiusX allows stretching in the x direction, optional, default radius
  111544. * * radiusY allows stretching in the y direction, optional, default radius
  111545. * * radiusZ allows stretching in the z direction, optional, default radius
  111546. * * flat when true creates a flat shaded mesh, optional, default true
  111547. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111548. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111549. * * 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)
  111550. * * 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)
  111551. * @returns the VertexData of the IcoSphere
  111552. */
  111553. static CreateIcoSphere(options: {
  111554. radius?: number;
  111555. radiusX?: number;
  111556. radiusY?: number;
  111557. radiusZ?: number;
  111558. flat?: boolean;
  111559. subdivisions?: number;
  111560. sideOrientation?: number;
  111561. frontUVs?: Vector4;
  111562. backUVs?: Vector4;
  111563. }): VertexData;
  111564. /**
  111565. * Creates the VertexData for a Polyhedron
  111566. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111567. * * type provided types are:
  111568. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111569. * * 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)
  111570. * * size the size of the IcoSphere, optional default 1
  111571. * * sizeX allows stretching in the x direction, optional, default size
  111572. * * sizeY allows stretching in the y direction, optional, default size
  111573. * * sizeZ allows stretching in the z direction, optional, default size
  111574. * * 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
  111575. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111576. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111577. * * flat when true creates a flat shaded mesh, optional, default true
  111578. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111580. * * 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)
  111581. * * 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)
  111582. * @returns the VertexData of the Polyhedron
  111583. */
  111584. static CreatePolyhedron(options: {
  111585. type?: number;
  111586. size?: number;
  111587. sizeX?: number;
  111588. sizeY?: number;
  111589. sizeZ?: number;
  111590. custom?: any;
  111591. faceUV?: Vector4[];
  111592. faceColors?: Color4[];
  111593. flat?: boolean;
  111594. sideOrientation?: number;
  111595. frontUVs?: Vector4;
  111596. backUVs?: Vector4;
  111597. }): VertexData;
  111598. /**
  111599. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111600. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111601. * @returns the VertexData of the Capsule
  111602. */
  111603. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111604. /**
  111605. * Creates the VertexData for a TorusKnot
  111606. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111607. * * radius the radius of the torus knot, optional, default 2
  111608. * * tube the thickness of the tube, optional, default 0.5
  111609. * * radialSegments the number of sides on each tube segments, optional, default 32
  111610. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111611. * * p the number of windings around the z axis, optional, default 2
  111612. * * q the number of windings around the x axis, optional, default 3
  111613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111614. * * 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)
  111615. * * 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)
  111616. * @returns the VertexData of the Torus Knot
  111617. */
  111618. static CreateTorusKnot(options: {
  111619. radius?: number;
  111620. tube?: number;
  111621. radialSegments?: number;
  111622. tubularSegments?: number;
  111623. p?: number;
  111624. q?: number;
  111625. sideOrientation?: number;
  111626. frontUVs?: Vector4;
  111627. backUVs?: Vector4;
  111628. }): VertexData;
  111629. /**
  111630. * Compute normals for given positions and indices
  111631. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111632. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111633. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111634. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111635. * * facetNormals : optional array of facet normals (vector3)
  111636. * * facetPositions : optional array of facet positions (vector3)
  111637. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111638. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111639. * * bInfo : optional bounding info, required for facetPartitioning computation
  111640. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111641. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111642. * * useRightHandedSystem: optional boolean to for right handed system computation
  111643. * * depthSort : optional boolean to enable the facet depth sort computation
  111644. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111645. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111646. */
  111647. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111648. facetNormals?: any;
  111649. facetPositions?: any;
  111650. facetPartitioning?: any;
  111651. ratio?: number;
  111652. bInfo?: any;
  111653. bbSize?: Vector3;
  111654. subDiv?: any;
  111655. useRightHandedSystem?: boolean;
  111656. depthSort?: boolean;
  111657. distanceTo?: Vector3;
  111658. depthSortedFacets?: any;
  111659. }): void;
  111660. /** @hidden */
  111661. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111662. /**
  111663. * Applies VertexData created from the imported parameters to the geometry
  111664. * @param parsedVertexData the parsed data from an imported file
  111665. * @param geometry the geometry to apply the VertexData to
  111666. */
  111667. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111668. }
  111669. }
  111670. declare module BABYLON {
  111671. /**
  111672. * Defines a target to use with MorphTargetManager
  111673. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111674. */
  111675. export class MorphTarget implements IAnimatable {
  111676. /** defines the name of the target */
  111677. name: string;
  111678. /**
  111679. * Gets or sets the list of animations
  111680. */
  111681. animations: Animation[];
  111682. private _scene;
  111683. private _positions;
  111684. private _normals;
  111685. private _tangents;
  111686. private _uvs;
  111687. private _influence;
  111688. private _uniqueId;
  111689. /**
  111690. * Observable raised when the influence changes
  111691. */
  111692. onInfluenceChanged: Observable<boolean>;
  111693. /** @hidden */
  111694. _onDataLayoutChanged: Observable<void>;
  111695. /**
  111696. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111697. */
  111698. get influence(): number;
  111699. set influence(influence: number);
  111700. /**
  111701. * Gets or sets the id of the morph Target
  111702. */
  111703. id: string;
  111704. private _animationPropertiesOverride;
  111705. /**
  111706. * Gets or sets the animation properties override
  111707. */
  111708. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111709. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111710. /**
  111711. * Creates a new MorphTarget
  111712. * @param name defines the name of the target
  111713. * @param influence defines the influence to use
  111714. * @param scene defines the scene the morphtarget belongs to
  111715. */
  111716. constructor(
  111717. /** defines the name of the target */
  111718. name: string, influence?: number, scene?: Nullable<Scene>);
  111719. /**
  111720. * Gets the unique ID of this manager
  111721. */
  111722. get uniqueId(): number;
  111723. /**
  111724. * Gets a boolean defining if the target contains position data
  111725. */
  111726. get hasPositions(): boolean;
  111727. /**
  111728. * Gets a boolean defining if the target contains normal data
  111729. */
  111730. get hasNormals(): boolean;
  111731. /**
  111732. * Gets a boolean defining if the target contains tangent data
  111733. */
  111734. get hasTangents(): boolean;
  111735. /**
  111736. * Gets a boolean defining if the target contains texture coordinates data
  111737. */
  111738. get hasUVs(): boolean;
  111739. /**
  111740. * Affects position data to this target
  111741. * @param data defines the position data to use
  111742. */
  111743. setPositions(data: Nullable<FloatArray>): void;
  111744. /**
  111745. * Gets the position data stored in this target
  111746. * @returns a FloatArray containing the position data (or null if not present)
  111747. */
  111748. getPositions(): Nullable<FloatArray>;
  111749. /**
  111750. * Affects normal data to this target
  111751. * @param data defines the normal data to use
  111752. */
  111753. setNormals(data: Nullable<FloatArray>): void;
  111754. /**
  111755. * Gets the normal data stored in this target
  111756. * @returns a FloatArray containing the normal data (or null if not present)
  111757. */
  111758. getNormals(): Nullable<FloatArray>;
  111759. /**
  111760. * Affects tangent data to this target
  111761. * @param data defines the tangent data to use
  111762. */
  111763. setTangents(data: Nullable<FloatArray>): void;
  111764. /**
  111765. * Gets the tangent data stored in this target
  111766. * @returns a FloatArray containing the tangent data (or null if not present)
  111767. */
  111768. getTangents(): Nullable<FloatArray>;
  111769. /**
  111770. * Affects texture coordinates data to this target
  111771. * @param data defines the texture coordinates data to use
  111772. */
  111773. setUVs(data: Nullable<FloatArray>): void;
  111774. /**
  111775. * Gets the texture coordinates data stored in this target
  111776. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111777. */
  111778. getUVs(): Nullable<FloatArray>;
  111779. /**
  111780. * Clone the current target
  111781. * @returns a new MorphTarget
  111782. */
  111783. clone(): MorphTarget;
  111784. /**
  111785. * Serializes the current target into a Serialization object
  111786. * @returns the serialized object
  111787. */
  111788. serialize(): any;
  111789. /**
  111790. * Returns the string "MorphTarget"
  111791. * @returns "MorphTarget"
  111792. */
  111793. getClassName(): string;
  111794. /**
  111795. * Creates a new target from serialized data
  111796. * @param serializationObject defines the serialized data to use
  111797. * @returns a new MorphTarget
  111798. */
  111799. static Parse(serializationObject: any): MorphTarget;
  111800. /**
  111801. * Creates a MorphTarget from mesh data
  111802. * @param mesh defines the source mesh
  111803. * @param name defines the name to use for the new target
  111804. * @param influence defines the influence to attach to the target
  111805. * @returns a new MorphTarget
  111806. */
  111807. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111808. }
  111809. }
  111810. declare module BABYLON {
  111811. /**
  111812. * This class is used to deform meshes using morphing between different targets
  111813. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111814. */
  111815. export class MorphTargetManager {
  111816. private _targets;
  111817. private _targetInfluenceChangedObservers;
  111818. private _targetDataLayoutChangedObservers;
  111819. private _activeTargets;
  111820. private _scene;
  111821. private _influences;
  111822. private _supportsNormals;
  111823. private _supportsTangents;
  111824. private _supportsUVs;
  111825. private _vertexCount;
  111826. private _uniqueId;
  111827. private _tempInfluences;
  111828. /**
  111829. * Gets or sets a boolean indicating if normals must be morphed
  111830. */
  111831. enableNormalMorphing: boolean;
  111832. /**
  111833. * Gets or sets a boolean indicating if tangents must be morphed
  111834. */
  111835. enableTangentMorphing: boolean;
  111836. /**
  111837. * Gets or sets a boolean indicating if UV must be morphed
  111838. */
  111839. enableUVMorphing: boolean;
  111840. /**
  111841. * Creates a new MorphTargetManager
  111842. * @param scene defines the current scene
  111843. */
  111844. constructor(scene?: Nullable<Scene>);
  111845. /**
  111846. * Gets the unique ID of this manager
  111847. */
  111848. get uniqueId(): number;
  111849. /**
  111850. * Gets the number of vertices handled by this manager
  111851. */
  111852. get vertexCount(): number;
  111853. /**
  111854. * Gets a boolean indicating if this manager supports morphing of normals
  111855. */
  111856. get supportsNormals(): boolean;
  111857. /**
  111858. * Gets a boolean indicating if this manager supports morphing of tangents
  111859. */
  111860. get supportsTangents(): boolean;
  111861. /**
  111862. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111863. */
  111864. get supportsUVs(): boolean;
  111865. /**
  111866. * Gets the number of targets stored in this manager
  111867. */
  111868. get numTargets(): number;
  111869. /**
  111870. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111871. */
  111872. get numInfluencers(): number;
  111873. /**
  111874. * Gets the list of influences (one per target)
  111875. */
  111876. get influences(): Float32Array;
  111877. /**
  111878. * Gets the active target at specified index. An active target is a target with an influence > 0
  111879. * @param index defines the index to check
  111880. * @returns the requested target
  111881. */
  111882. getActiveTarget(index: number): MorphTarget;
  111883. /**
  111884. * Gets the target at specified index
  111885. * @param index defines the index to check
  111886. * @returns the requested target
  111887. */
  111888. getTarget(index: number): MorphTarget;
  111889. /**
  111890. * Add a new target to this manager
  111891. * @param target defines the target to add
  111892. */
  111893. addTarget(target: MorphTarget): void;
  111894. /**
  111895. * Removes a target from the manager
  111896. * @param target defines the target to remove
  111897. */
  111898. removeTarget(target: MorphTarget): void;
  111899. /**
  111900. * Clone the current manager
  111901. * @returns a new MorphTargetManager
  111902. */
  111903. clone(): MorphTargetManager;
  111904. /**
  111905. * Serializes the current manager into a Serialization object
  111906. * @returns the serialized object
  111907. */
  111908. serialize(): any;
  111909. private _syncActiveTargets;
  111910. /**
  111911. * Syncrhonize the targets with all the meshes using this morph target manager
  111912. */
  111913. synchronize(): void;
  111914. /**
  111915. * Creates a new MorphTargetManager from serialized data
  111916. * @param serializationObject defines the serialized data
  111917. * @param scene defines the hosting scene
  111918. * @returns the new MorphTargetManager
  111919. */
  111920. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111921. }
  111922. }
  111923. declare module BABYLON {
  111924. /**
  111925. * Class used to represent a specific level of detail of a mesh
  111926. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111927. */
  111928. export class MeshLODLevel {
  111929. /** Defines the distance where this level should start being displayed */
  111930. distance: number;
  111931. /** Defines the mesh to use to render this level */
  111932. mesh: Nullable<Mesh>;
  111933. /**
  111934. * Creates a new LOD level
  111935. * @param distance defines the distance where this level should star being displayed
  111936. * @param mesh defines the mesh to use to render this level
  111937. */
  111938. constructor(
  111939. /** Defines the distance where this level should start being displayed */
  111940. distance: number,
  111941. /** Defines the mesh to use to render this level */
  111942. mesh: Nullable<Mesh>);
  111943. }
  111944. }
  111945. declare module BABYLON {
  111946. /**
  111947. * Helper class used to generate a canvas to manipulate images
  111948. */
  111949. export class CanvasGenerator {
  111950. /**
  111951. * Create a new canvas (or offscreen canvas depending on the context)
  111952. * @param width defines the expected width
  111953. * @param height defines the expected height
  111954. * @return a new canvas or offscreen canvas
  111955. */
  111956. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111957. }
  111958. }
  111959. declare module BABYLON {
  111960. /**
  111961. * Mesh representing the gorund
  111962. */
  111963. export class GroundMesh extends Mesh {
  111964. /** If octree should be generated */
  111965. generateOctree: boolean;
  111966. private _heightQuads;
  111967. /** @hidden */
  111968. _subdivisionsX: number;
  111969. /** @hidden */
  111970. _subdivisionsY: number;
  111971. /** @hidden */
  111972. _width: number;
  111973. /** @hidden */
  111974. _height: number;
  111975. /** @hidden */
  111976. _minX: number;
  111977. /** @hidden */
  111978. _maxX: number;
  111979. /** @hidden */
  111980. _minZ: number;
  111981. /** @hidden */
  111982. _maxZ: number;
  111983. constructor(name: string, scene: Scene);
  111984. /**
  111985. * "GroundMesh"
  111986. * @returns "GroundMesh"
  111987. */
  111988. getClassName(): string;
  111989. /**
  111990. * The minimum of x and y subdivisions
  111991. */
  111992. get subdivisions(): number;
  111993. /**
  111994. * X subdivisions
  111995. */
  111996. get subdivisionsX(): number;
  111997. /**
  111998. * Y subdivisions
  111999. */
  112000. get subdivisionsY(): number;
  112001. /**
  112002. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112003. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112004. * @param chunksCount the number of subdivisions for x and y
  112005. * @param octreeBlocksSize (Default: 32)
  112006. */
  112007. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112008. /**
  112009. * Returns a height (y) value in the Worl system :
  112010. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112011. * @param x x coordinate
  112012. * @param z z coordinate
  112013. * @returns the ground y position if (x, z) are outside the ground surface.
  112014. */
  112015. getHeightAtCoordinates(x: number, z: number): number;
  112016. /**
  112017. * Returns a normalized vector (Vector3) orthogonal to the ground
  112018. * at the ground coordinates (x, z) expressed in the World system.
  112019. * @param x x coordinate
  112020. * @param z z coordinate
  112021. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112022. */
  112023. getNormalAtCoordinates(x: number, z: number): Vector3;
  112024. /**
  112025. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112026. * at the ground coordinates (x, z) expressed in the World system.
  112027. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112028. * @param x x coordinate
  112029. * @param z z coordinate
  112030. * @param ref vector to store the result
  112031. * @returns the GroundMesh.
  112032. */
  112033. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112034. /**
  112035. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112036. * if the ground has been updated.
  112037. * This can be used in the render loop.
  112038. * @returns the GroundMesh.
  112039. */
  112040. updateCoordinateHeights(): GroundMesh;
  112041. private _getFacetAt;
  112042. private _initHeightQuads;
  112043. private _computeHeightQuads;
  112044. /**
  112045. * Serializes this ground mesh
  112046. * @param serializationObject object to write serialization to
  112047. */
  112048. serialize(serializationObject: any): void;
  112049. /**
  112050. * Parses a serialized ground mesh
  112051. * @param parsedMesh the serialized mesh
  112052. * @param scene the scene to create the ground mesh in
  112053. * @returns the created ground mesh
  112054. */
  112055. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112056. }
  112057. }
  112058. declare module BABYLON {
  112059. /**
  112060. * Interface for Physics-Joint data
  112061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112062. */
  112063. export interface PhysicsJointData {
  112064. /**
  112065. * The main pivot of the joint
  112066. */
  112067. mainPivot?: Vector3;
  112068. /**
  112069. * The connected pivot of the joint
  112070. */
  112071. connectedPivot?: Vector3;
  112072. /**
  112073. * The main axis of the joint
  112074. */
  112075. mainAxis?: Vector3;
  112076. /**
  112077. * The connected axis of the joint
  112078. */
  112079. connectedAxis?: Vector3;
  112080. /**
  112081. * The collision of the joint
  112082. */
  112083. collision?: boolean;
  112084. /**
  112085. * Native Oimo/Cannon/Energy data
  112086. */
  112087. nativeParams?: any;
  112088. }
  112089. /**
  112090. * This is a holder class for the physics joint created by the physics plugin
  112091. * It holds a set of functions to control the underlying joint
  112092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112093. */
  112094. export class PhysicsJoint {
  112095. /**
  112096. * The type of the physics joint
  112097. */
  112098. type: number;
  112099. /**
  112100. * The data for the physics joint
  112101. */
  112102. jointData: PhysicsJointData;
  112103. private _physicsJoint;
  112104. protected _physicsPlugin: IPhysicsEnginePlugin;
  112105. /**
  112106. * Initializes the physics joint
  112107. * @param type The type of the physics joint
  112108. * @param jointData The data for the physics joint
  112109. */
  112110. constructor(
  112111. /**
  112112. * The type of the physics joint
  112113. */
  112114. type: number,
  112115. /**
  112116. * The data for the physics joint
  112117. */
  112118. jointData: PhysicsJointData);
  112119. /**
  112120. * Gets the physics joint
  112121. */
  112122. get physicsJoint(): any;
  112123. /**
  112124. * Sets the physics joint
  112125. */
  112126. set physicsJoint(newJoint: any);
  112127. /**
  112128. * Sets the physics plugin
  112129. */
  112130. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112131. /**
  112132. * Execute a function that is physics-plugin specific.
  112133. * @param {Function} func the function that will be executed.
  112134. * It accepts two parameters: the physics world and the physics joint
  112135. */
  112136. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112137. /**
  112138. * Distance-Joint type
  112139. */
  112140. static DistanceJoint: number;
  112141. /**
  112142. * Hinge-Joint type
  112143. */
  112144. static HingeJoint: number;
  112145. /**
  112146. * Ball-and-Socket joint type
  112147. */
  112148. static BallAndSocketJoint: number;
  112149. /**
  112150. * Wheel-Joint type
  112151. */
  112152. static WheelJoint: number;
  112153. /**
  112154. * Slider-Joint type
  112155. */
  112156. static SliderJoint: number;
  112157. /**
  112158. * Prismatic-Joint type
  112159. */
  112160. static PrismaticJoint: number;
  112161. /**
  112162. * Universal-Joint type
  112163. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112164. */
  112165. static UniversalJoint: number;
  112166. /**
  112167. * Hinge-Joint 2 type
  112168. */
  112169. static Hinge2Joint: number;
  112170. /**
  112171. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112172. */
  112173. static PointToPointJoint: number;
  112174. /**
  112175. * Spring-Joint type
  112176. */
  112177. static SpringJoint: number;
  112178. /**
  112179. * Lock-Joint type
  112180. */
  112181. static LockJoint: number;
  112182. }
  112183. /**
  112184. * A class representing a physics distance joint
  112185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112186. */
  112187. export class DistanceJoint extends PhysicsJoint {
  112188. /**
  112189. *
  112190. * @param jointData The data for the Distance-Joint
  112191. */
  112192. constructor(jointData: DistanceJointData);
  112193. /**
  112194. * Update the predefined distance.
  112195. * @param maxDistance The maximum preferred distance
  112196. * @param minDistance The minimum preferred distance
  112197. */
  112198. updateDistance(maxDistance: number, minDistance?: number): void;
  112199. }
  112200. /**
  112201. * Represents a Motor-Enabled Joint
  112202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112203. */
  112204. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112205. /**
  112206. * Initializes the Motor-Enabled Joint
  112207. * @param type The type of the joint
  112208. * @param jointData The physica joint data for the joint
  112209. */
  112210. constructor(type: number, jointData: PhysicsJointData);
  112211. /**
  112212. * Set the motor values.
  112213. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112214. * @param force the force to apply
  112215. * @param maxForce max force for this motor.
  112216. */
  112217. setMotor(force?: number, maxForce?: number): void;
  112218. /**
  112219. * Set the motor's limits.
  112220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112221. * @param upperLimit The upper limit of the motor
  112222. * @param lowerLimit The lower limit of the motor
  112223. */
  112224. setLimit(upperLimit: number, lowerLimit?: number): void;
  112225. }
  112226. /**
  112227. * This class represents a single physics Hinge-Joint
  112228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112229. */
  112230. export class HingeJoint extends MotorEnabledJoint {
  112231. /**
  112232. * Initializes the Hinge-Joint
  112233. * @param jointData The joint data for the Hinge-Joint
  112234. */
  112235. constructor(jointData: PhysicsJointData);
  112236. /**
  112237. * Set the motor values.
  112238. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112239. * @param {number} force the force to apply
  112240. * @param {number} maxForce max force for this motor.
  112241. */
  112242. setMotor(force?: number, maxForce?: number): void;
  112243. /**
  112244. * Set the motor's limits.
  112245. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112246. * @param upperLimit The upper limit of the motor
  112247. * @param lowerLimit The lower limit of the motor
  112248. */
  112249. setLimit(upperLimit: number, lowerLimit?: number): void;
  112250. }
  112251. /**
  112252. * This class represents a dual hinge physics joint (same as wheel joint)
  112253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112254. */
  112255. export class Hinge2Joint extends MotorEnabledJoint {
  112256. /**
  112257. * Initializes the Hinge2-Joint
  112258. * @param jointData The joint data for the Hinge2-Joint
  112259. */
  112260. constructor(jointData: PhysicsJointData);
  112261. /**
  112262. * Set the motor values.
  112263. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112264. * @param {number} targetSpeed the speed the motor is to reach
  112265. * @param {number} maxForce max force for this motor.
  112266. * @param {motorIndex} the motor's index, 0 or 1.
  112267. */
  112268. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112269. /**
  112270. * Set the motor limits.
  112271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112272. * @param {number} upperLimit the upper limit
  112273. * @param {number} lowerLimit lower limit
  112274. * @param {motorIndex} the motor's index, 0 or 1.
  112275. */
  112276. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112277. }
  112278. /**
  112279. * Interface for a motor enabled joint
  112280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112281. */
  112282. export interface IMotorEnabledJoint {
  112283. /**
  112284. * Physics joint
  112285. */
  112286. physicsJoint: any;
  112287. /**
  112288. * Sets the motor of the motor-enabled joint
  112289. * @param force The force of the motor
  112290. * @param maxForce The maximum force of the motor
  112291. * @param motorIndex The index of the motor
  112292. */
  112293. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112294. /**
  112295. * Sets the limit of the motor
  112296. * @param upperLimit The upper limit of the motor
  112297. * @param lowerLimit The lower limit of the motor
  112298. * @param motorIndex The index of the motor
  112299. */
  112300. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112301. }
  112302. /**
  112303. * Joint data for a Distance-Joint
  112304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112305. */
  112306. export interface DistanceJointData extends PhysicsJointData {
  112307. /**
  112308. * Max distance the 2 joint objects can be apart
  112309. */
  112310. maxDistance: number;
  112311. }
  112312. /**
  112313. * Joint data from a spring joint
  112314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112315. */
  112316. export interface SpringJointData extends PhysicsJointData {
  112317. /**
  112318. * Length of the spring
  112319. */
  112320. length: number;
  112321. /**
  112322. * Stiffness of the spring
  112323. */
  112324. stiffness: number;
  112325. /**
  112326. * Damping of the spring
  112327. */
  112328. damping: number;
  112329. /** this callback will be called when applying the force to the impostors. */
  112330. forceApplicationCallback: () => void;
  112331. }
  112332. }
  112333. declare module BABYLON {
  112334. /**
  112335. * Holds the data for the raycast result
  112336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112337. */
  112338. export class PhysicsRaycastResult {
  112339. private _hasHit;
  112340. private _hitDistance;
  112341. private _hitNormalWorld;
  112342. private _hitPointWorld;
  112343. private _rayFromWorld;
  112344. private _rayToWorld;
  112345. /**
  112346. * Gets if there was a hit
  112347. */
  112348. get hasHit(): boolean;
  112349. /**
  112350. * Gets the distance from the hit
  112351. */
  112352. get hitDistance(): number;
  112353. /**
  112354. * Gets the hit normal/direction in the world
  112355. */
  112356. get hitNormalWorld(): Vector3;
  112357. /**
  112358. * Gets the hit point in the world
  112359. */
  112360. get hitPointWorld(): Vector3;
  112361. /**
  112362. * Gets the ray "start point" of the ray in the world
  112363. */
  112364. get rayFromWorld(): Vector3;
  112365. /**
  112366. * Gets the ray "end point" of the ray in the world
  112367. */
  112368. get rayToWorld(): Vector3;
  112369. /**
  112370. * Sets the hit data (normal & point in world space)
  112371. * @param hitNormalWorld defines the normal in world space
  112372. * @param hitPointWorld defines the point in world space
  112373. */
  112374. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112375. /**
  112376. * Sets the distance from the start point to the hit point
  112377. * @param distance
  112378. */
  112379. setHitDistance(distance: number): void;
  112380. /**
  112381. * Calculates the distance manually
  112382. */
  112383. calculateHitDistance(): void;
  112384. /**
  112385. * Resets all the values to default
  112386. * @param from The from point on world space
  112387. * @param to The to point on world space
  112388. */
  112389. reset(from?: Vector3, to?: Vector3): void;
  112390. }
  112391. /**
  112392. * Interface for the size containing width and height
  112393. */
  112394. interface IXYZ {
  112395. /**
  112396. * X
  112397. */
  112398. x: number;
  112399. /**
  112400. * Y
  112401. */
  112402. y: number;
  112403. /**
  112404. * Z
  112405. */
  112406. z: number;
  112407. }
  112408. }
  112409. declare module BABYLON {
  112410. /**
  112411. * Interface used to describe a physics joint
  112412. */
  112413. export interface PhysicsImpostorJoint {
  112414. /** Defines the main impostor to which the joint is linked */
  112415. mainImpostor: PhysicsImpostor;
  112416. /** Defines the impostor that is connected to the main impostor using this joint */
  112417. connectedImpostor: PhysicsImpostor;
  112418. /** Defines the joint itself */
  112419. joint: PhysicsJoint;
  112420. }
  112421. /** @hidden */
  112422. export interface IPhysicsEnginePlugin {
  112423. world: any;
  112424. name: string;
  112425. setGravity(gravity: Vector3): void;
  112426. setTimeStep(timeStep: number): void;
  112427. getTimeStep(): number;
  112428. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112429. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112430. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112432. removePhysicsBody(impostor: PhysicsImpostor): void;
  112433. generateJoint(joint: PhysicsImpostorJoint): void;
  112434. removeJoint(joint: PhysicsImpostorJoint): void;
  112435. isSupported(): boolean;
  112436. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112437. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112438. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112439. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112440. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112441. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112442. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112443. getBodyMass(impostor: PhysicsImpostor): number;
  112444. getBodyFriction(impostor: PhysicsImpostor): number;
  112445. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112446. getBodyRestitution(impostor: PhysicsImpostor): number;
  112447. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112448. getBodyPressure?(impostor: PhysicsImpostor): number;
  112449. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112450. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112451. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112452. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112453. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112454. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112455. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112456. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112457. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112458. sleepBody(impostor: PhysicsImpostor): void;
  112459. wakeUpBody(impostor: PhysicsImpostor): void;
  112460. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112461. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112462. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112463. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112464. getRadius(impostor: PhysicsImpostor): number;
  112465. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112466. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112467. dispose(): void;
  112468. }
  112469. /**
  112470. * Interface used to define a physics engine
  112471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112472. */
  112473. export interface IPhysicsEngine {
  112474. /**
  112475. * Gets the gravity vector used by the simulation
  112476. */
  112477. gravity: Vector3;
  112478. /**
  112479. * Sets the gravity vector used by the simulation
  112480. * @param gravity defines the gravity vector to use
  112481. */
  112482. setGravity(gravity: Vector3): void;
  112483. /**
  112484. * Set the time step of the physics engine.
  112485. * Default is 1/60.
  112486. * To slow it down, enter 1/600 for example.
  112487. * To speed it up, 1/30
  112488. * @param newTimeStep the new timestep to apply to this world.
  112489. */
  112490. setTimeStep(newTimeStep: number): void;
  112491. /**
  112492. * Get the time step of the physics engine.
  112493. * @returns the current time step
  112494. */
  112495. getTimeStep(): number;
  112496. /**
  112497. * Set the sub time step of the physics engine.
  112498. * Default is 0 meaning there is no sub steps
  112499. * To increase physics resolution precision, set a small value (like 1 ms)
  112500. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112501. */
  112502. setSubTimeStep(subTimeStep: number): void;
  112503. /**
  112504. * Get the sub time step of the physics engine.
  112505. * @returns the current sub time step
  112506. */
  112507. getSubTimeStep(): number;
  112508. /**
  112509. * Release all resources
  112510. */
  112511. dispose(): void;
  112512. /**
  112513. * Gets the name of the current physics plugin
  112514. * @returns the name of the plugin
  112515. */
  112516. getPhysicsPluginName(): string;
  112517. /**
  112518. * Adding a new impostor for the impostor tracking.
  112519. * This will be done by the impostor itself.
  112520. * @param impostor the impostor to add
  112521. */
  112522. addImpostor(impostor: PhysicsImpostor): void;
  112523. /**
  112524. * Remove an impostor from the engine.
  112525. * This impostor and its mesh will not longer be updated by the physics engine.
  112526. * @param impostor the impostor to remove
  112527. */
  112528. removeImpostor(impostor: PhysicsImpostor): void;
  112529. /**
  112530. * Add a joint to the physics engine
  112531. * @param mainImpostor defines the main impostor to which the joint is added.
  112532. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112533. * @param joint defines the joint that will connect both impostors.
  112534. */
  112535. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112536. /**
  112537. * Removes a joint from the simulation
  112538. * @param mainImpostor defines the impostor used with the joint
  112539. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112540. * @param joint defines the joint to remove
  112541. */
  112542. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112543. /**
  112544. * Gets the current plugin used to run the simulation
  112545. * @returns current plugin
  112546. */
  112547. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112548. /**
  112549. * Gets the list of physic impostors
  112550. * @returns an array of PhysicsImpostor
  112551. */
  112552. getImpostors(): Array<PhysicsImpostor>;
  112553. /**
  112554. * Gets the impostor for a physics enabled object
  112555. * @param object defines the object impersonated by the impostor
  112556. * @returns the PhysicsImpostor or null if not found
  112557. */
  112558. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112559. /**
  112560. * Gets the impostor for a physics body object
  112561. * @param body defines physics body used by the impostor
  112562. * @returns the PhysicsImpostor or null if not found
  112563. */
  112564. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112565. /**
  112566. * Does a raycast in the physics world
  112567. * @param from when should the ray start?
  112568. * @param to when should the ray end?
  112569. * @returns PhysicsRaycastResult
  112570. */
  112571. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112572. /**
  112573. * Called by the scene. No need to call it.
  112574. * @param delta defines the timespam between frames
  112575. */
  112576. _step(delta: number): void;
  112577. }
  112578. }
  112579. declare module BABYLON {
  112580. /**
  112581. * The interface for the physics imposter parameters
  112582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112583. */
  112584. export interface PhysicsImpostorParameters {
  112585. /**
  112586. * The mass of the physics imposter
  112587. */
  112588. mass: number;
  112589. /**
  112590. * The friction of the physics imposter
  112591. */
  112592. friction?: number;
  112593. /**
  112594. * The coefficient of restitution of the physics imposter
  112595. */
  112596. restitution?: number;
  112597. /**
  112598. * The native options of the physics imposter
  112599. */
  112600. nativeOptions?: any;
  112601. /**
  112602. * Specifies if the parent should be ignored
  112603. */
  112604. ignoreParent?: boolean;
  112605. /**
  112606. * Specifies if bi-directional transformations should be disabled
  112607. */
  112608. disableBidirectionalTransformation?: boolean;
  112609. /**
  112610. * The pressure inside the physics imposter, soft object only
  112611. */
  112612. pressure?: number;
  112613. /**
  112614. * The stiffness the physics imposter, soft object only
  112615. */
  112616. stiffness?: number;
  112617. /**
  112618. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112619. */
  112620. velocityIterations?: number;
  112621. /**
  112622. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112623. */
  112624. positionIterations?: number;
  112625. /**
  112626. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112627. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112628. * Add to fix multiple points
  112629. */
  112630. fixedPoints?: number;
  112631. /**
  112632. * The collision margin around a soft object
  112633. */
  112634. margin?: number;
  112635. /**
  112636. * The collision margin around a soft object
  112637. */
  112638. damping?: number;
  112639. /**
  112640. * The path for a rope based on an extrusion
  112641. */
  112642. path?: any;
  112643. /**
  112644. * The shape of an extrusion used for a rope based on an extrusion
  112645. */
  112646. shape?: any;
  112647. }
  112648. /**
  112649. * Interface for a physics-enabled object
  112650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112651. */
  112652. export interface IPhysicsEnabledObject {
  112653. /**
  112654. * The position of the physics-enabled object
  112655. */
  112656. position: Vector3;
  112657. /**
  112658. * The rotation of the physics-enabled object
  112659. */
  112660. rotationQuaternion: Nullable<Quaternion>;
  112661. /**
  112662. * The scale of the physics-enabled object
  112663. */
  112664. scaling: Vector3;
  112665. /**
  112666. * The rotation of the physics-enabled object
  112667. */
  112668. rotation?: Vector3;
  112669. /**
  112670. * The parent of the physics-enabled object
  112671. */
  112672. parent?: any;
  112673. /**
  112674. * The bounding info of the physics-enabled object
  112675. * @returns The bounding info of the physics-enabled object
  112676. */
  112677. getBoundingInfo(): BoundingInfo;
  112678. /**
  112679. * Computes the world matrix
  112680. * @param force Specifies if the world matrix should be computed by force
  112681. * @returns A world matrix
  112682. */
  112683. computeWorldMatrix(force: boolean): Matrix;
  112684. /**
  112685. * Gets the world matrix
  112686. * @returns A world matrix
  112687. */
  112688. getWorldMatrix?(): Matrix;
  112689. /**
  112690. * Gets the child meshes
  112691. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112692. * @returns An array of abstract meshes
  112693. */
  112694. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112695. /**
  112696. * Gets the vertex data
  112697. * @param kind The type of vertex data
  112698. * @returns A nullable array of numbers, or a float32 array
  112699. */
  112700. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112701. /**
  112702. * Gets the indices from the mesh
  112703. * @returns A nullable array of index arrays
  112704. */
  112705. getIndices?(): Nullable<IndicesArray>;
  112706. /**
  112707. * Gets the scene from the mesh
  112708. * @returns the indices array or null
  112709. */
  112710. getScene?(): Scene;
  112711. /**
  112712. * Gets the absolute position from the mesh
  112713. * @returns the absolute position
  112714. */
  112715. getAbsolutePosition(): Vector3;
  112716. /**
  112717. * Gets the absolute pivot point from the mesh
  112718. * @returns the absolute pivot point
  112719. */
  112720. getAbsolutePivotPoint(): Vector3;
  112721. /**
  112722. * Rotates the mesh
  112723. * @param axis The axis of rotation
  112724. * @param amount The amount of rotation
  112725. * @param space The space of the rotation
  112726. * @returns The rotation transform node
  112727. */
  112728. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112729. /**
  112730. * Translates the mesh
  112731. * @param axis The axis of translation
  112732. * @param distance The distance of translation
  112733. * @param space The space of the translation
  112734. * @returns The transform node
  112735. */
  112736. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112737. /**
  112738. * Sets the absolute position of the mesh
  112739. * @param absolutePosition The absolute position of the mesh
  112740. * @returns The transform node
  112741. */
  112742. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112743. /**
  112744. * Gets the class name of the mesh
  112745. * @returns The class name
  112746. */
  112747. getClassName(): string;
  112748. }
  112749. /**
  112750. * Represents a physics imposter
  112751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112752. */
  112753. export class PhysicsImpostor {
  112754. /**
  112755. * The physics-enabled object used as the physics imposter
  112756. */
  112757. object: IPhysicsEnabledObject;
  112758. /**
  112759. * The type of the physics imposter
  112760. */
  112761. type: number;
  112762. private _options;
  112763. private _scene?;
  112764. /**
  112765. * The default object size of the imposter
  112766. */
  112767. static DEFAULT_OBJECT_SIZE: Vector3;
  112768. /**
  112769. * The identity quaternion of the imposter
  112770. */
  112771. static IDENTITY_QUATERNION: Quaternion;
  112772. /** @hidden */
  112773. _pluginData: any;
  112774. private _physicsEngine;
  112775. private _physicsBody;
  112776. private _bodyUpdateRequired;
  112777. private _onBeforePhysicsStepCallbacks;
  112778. private _onAfterPhysicsStepCallbacks;
  112779. /** @hidden */
  112780. _onPhysicsCollideCallbacks: Array<{
  112781. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  112782. otherImpostors: Array<PhysicsImpostor>;
  112783. }>;
  112784. private _deltaPosition;
  112785. private _deltaRotation;
  112786. private _deltaRotationConjugated;
  112787. /** @hidden */
  112788. _isFromLine: boolean;
  112789. private _parent;
  112790. private _isDisposed;
  112791. private static _tmpVecs;
  112792. private static _tmpQuat;
  112793. /**
  112794. * Specifies if the physics imposter is disposed
  112795. */
  112796. get isDisposed(): boolean;
  112797. /**
  112798. * Gets the mass of the physics imposter
  112799. */
  112800. get mass(): number;
  112801. set mass(value: number);
  112802. /**
  112803. * Gets the coefficient of friction
  112804. */
  112805. get friction(): number;
  112806. /**
  112807. * Sets the coefficient of friction
  112808. */
  112809. set friction(value: number);
  112810. /**
  112811. * Gets the coefficient of restitution
  112812. */
  112813. get restitution(): number;
  112814. /**
  112815. * Sets the coefficient of restitution
  112816. */
  112817. set restitution(value: number);
  112818. /**
  112819. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112820. */
  112821. get pressure(): number;
  112822. /**
  112823. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112824. */
  112825. set pressure(value: number);
  112826. /**
  112827. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112828. */
  112829. get stiffness(): number;
  112830. /**
  112831. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112832. */
  112833. set stiffness(value: number);
  112834. /**
  112835. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112836. */
  112837. get velocityIterations(): number;
  112838. /**
  112839. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112840. */
  112841. set velocityIterations(value: number);
  112842. /**
  112843. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112844. */
  112845. get positionIterations(): number;
  112846. /**
  112847. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112848. */
  112849. set positionIterations(value: number);
  112850. /**
  112851. * The unique id of the physics imposter
  112852. * set by the physics engine when adding this impostor to the array
  112853. */
  112854. uniqueId: number;
  112855. /**
  112856. * @hidden
  112857. */
  112858. soft: boolean;
  112859. /**
  112860. * @hidden
  112861. */
  112862. segments: number;
  112863. private _joints;
  112864. /**
  112865. * Initializes the physics imposter
  112866. * @param object The physics-enabled object used as the physics imposter
  112867. * @param type The type of the physics imposter
  112868. * @param _options The options for the physics imposter
  112869. * @param _scene The Babylon scene
  112870. */
  112871. constructor(
  112872. /**
  112873. * The physics-enabled object used as the physics imposter
  112874. */
  112875. object: IPhysicsEnabledObject,
  112876. /**
  112877. * The type of the physics imposter
  112878. */
  112879. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112880. /**
  112881. * This function will completly initialize this impostor.
  112882. * It will create a new body - but only if this mesh has no parent.
  112883. * If it has, this impostor will not be used other than to define the impostor
  112884. * of the child mesh.
  112885. * @hidden
  112886. */
  112887. _init(): void;
  112888. private _getPhysicsParent;
  112889. /**
  112890. * Should a new body be generated.
  112891. * @returns boolean specifying if body initialization is required
  112892. */
  112893. isBodyInitRequired(): boolean;
  112894. /**
  112895. * Sets the updated scaling
  112896. * @param updated Specifies if the scaling is updated
  112897. */
  112898. setScalingUpdated(): void;
  112899. /**
  112900. * Force a regeneration of this or the parent's impostor's body.
  112901. * Use under cautious - This will remove all joints already implemented.
  112902. */
  112903. forceUpdate(): void;
  112904. /**
  112905. * Gets the body that holds this impostor. Either its own, or its parent.
  112906. */
  112907. get physicsBody(): any;
  112908. /**
  112909. * Get the parent of the physics imposter
  112910. * @returns Physics imposter or null
  112911. */
  112912. get parent(): Nullable<PhysicsImpostor>;
  112913. /**
  112914. * Sets the parent of the physics imposter
  112915. */
  112916. set parent(value: Nullable<PhysicsImpostor>);
  112917. /**
  112918. * Set the physics body. Used mainly by the physics engine/plugin
  112919. */
  112920. set physicsBody(physicsBody: any);
  112921. /**
  112922. * Resets the update flags
  112923. */
  112924. resetUpdateFlags(): void;
  112925. /**
  112926. * Gets the object extend size
  112927. * @returns the object extend size
  112928. */
  112929. getObjectExtendSize(): Vector3;
  112930. /**
  112931. * Gets the object center
  112932. * @returns The object center
  112933. */
  112934. getObjectCenter(): Vector3;
  112935. /**
  112936. * Get a specific parameter from the options parameters
  112937. * @param paramName The object parameter name
  112938. * @returns The object parameter
  112939. */
  112940. getParam(paramName: string): any;
  112941. /**
  112942. * Sets a specific parameter in the options given to the physics plugin
  112943. * @param paramName The parameter name
  112944. * @param value The value of the parameter
  112945. */
  112946. setParam(paramName: string, value: number): void;
  112947. /**
  112948. * Specifically change the body's mass option. Won't recreate the physics body object
  112949. * @param mass The mass of the physics imposter
  112950. */
  112951. setMass(mass: number): void;
  112952. /**
  112953. * Gets the linear velocity
  112954. * @returns linear velocity or null
  112955. */
  112956. getLinearVelocity(): Nullable<Vector3>;
  112957. /**
  112958. * Sets the linear velocity
  112959. * @param velocity linear velocity or null
  112960. */
  112961. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112962. /**
  112963. * Gets the angular velocity
  112964. * @returns angular velocity or null
  112965. */
  112966. getAngularVelocity(): Nullable<Vector3>;
  112967. /**
  112968. * Sets the angular velocity
  112969. * @param velocity The velocity or null
  112970. */
  112971. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112972. /**
  112973. * Execute a function with the physics plugin native code
  112974. * Provide a function the will have two variables - the world object and the physics body object
  112975. * @param func The function to execute with the physics plugin native code
  112976. */
  112977. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112978. /**
  112979. * Register a function that will be executed before the physics world is stepping forward
  112980. * @param func The function to execute before the physics world is stepped forward
  112981. */
  112982. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112983. /**
  112984. * Unregister a function that will be executed before the physics world is stepping forward
  112985. * @param func The function to execute before the physics world is stepped forward
  112986. */
  112987. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112988. /**
  112989. * Register a function that will be executed after the physics step
  112990. * @param func The function to execute after physics step
  112991. */
  112992. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112993. /**
  112994. * Unregisters a function that will be executed after the physics step
  112995. * @param func The function to execute after physics step
  112996. */
  112997. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112998. /**
  112999. * register a function that will be executed when this impostor collides against a different body
  113000. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113001. * @param func Callback that is executed on collision
  113002. */
  113003. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113004. /**
  113005. * Unregisters the physics imposter on contact
  113006. * @param collideAgainst The physics object to collide against
  113007. * @param func Callback to execute on collision
  113008. */
  113009. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113010. private _tmpQuat;
  113011. private _tmpQuat2;
  113012. /**
  113013. * Get the parent rotation
  113014. * @returns The parent rotation
  113015. */
  113016. getParentsRotation(): Quaternion;
  113017. /**
  113018. * this function is executed by the physics engine.
  113019. */
  113020. beforeStep: () => void;
  113021. /**
  113022. * this function is executed by the physics engine
  113023. */
  113024. afterStep: () => void;
  113025. /**
  113026. * Legacy collision detection event support
  113027. */
  113028. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113029. /**
  113030. * event and body object due to cannon's event-based architecture.
  113031. */
  113032. onCollide: (e: {
  113033. body: any;
  113034. point: Nullable<Vector3>;
  113035. }) => void;
  113036. /**
  113037. * Apply a force
  113038. * @param force The force to apply
  113039. * @param contactPoint The contact point for the force
  113040. * @returns The physics imposter
  113041. */
  113042. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113043. /**
  113044. * Apply an impulse
  113045. * @param force The impulse force
  113046. * @param contactPoint The contact point for the impulse force
  113047. * @returns The physics imposter
  113048. */
  113049. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113050. /**
  113051. * A help function to create a joint
  113052. * @param otherImpostor A physics imposter used to create a joint
  113053. * @param jointType The type of joint
  113054. * @param jointData The data for the joint
  113055. * @returns The physics imposter
  113056. */
  113057. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113058. /**
  113059. * Add a joint to this impostor with a different impostor
  113060. * @param otherImpostor A physics imposter used to add a joint
  113061. * @param joint The joint to add
  113062. * @returns The physics imposter
  113063. */
  113064. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113065. /**
  113066. * Add an anchor to a cloth impostor
  113067. * @param otherImpostor rigid impostor to anchor to
  113068. * @param width ratio across width from 0 to 1
  113069. * @param height ratio up height from 0 to 1
  113070. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113071. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113072. * @returns impostor the soft imposter
  113073. */
  113074. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113075. /**
  113076. * Add a hook to a rope impostor
  113077. * @param otherImpostor rigid impostor to anchor to
  113078. * @param length ratio across rope from 0 to 1
  113079. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113080. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113081. * @returns impostor the rope imposter
  113082. */
  113083. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113084. /**
  113085. * Will keep this body still, in a sleep mode.
  113086. * @returns the physics imposter
  113087. */
  113088. sleep(): PhysicsImpostor;
  113089. /**
  113090. * Wake the body up.
  113091. * @returns The physics imposter
  113092. */
  113093. wakeUp(): PhysicsImpostor;
  113094. /**
  113095. * Clones the physics imposter
  113096. * @param newObject The physics imposter clones to this physics-enabled object
  113097. * @returns A nullable physics imposter
  113098. */
  113099. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113100. /**
  113101. * Disposes the physics imposter
  113102. */
  113103. dispose(): void;
  113104. /**
  113105. * Sets the delta position
  113106. * @param position The delta position amount
  113107. */
  113108. setDeltaPosition(position: Vector3): void;
  113109. /**
  113110. * Sets the delta rotation
  113111. * @param rotation The delta rotation amount
  113112. */
  113113. setDeltaRotation(rotation: Quaternion): void;
  113114. /**
  113115. * Gets the box size of the physics imposter and stores the result in the input parameter
  113116. * @param result Stores the box size
  113117. * @returns The physics imposter
  113118. */
  113119. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113120. /**
  113121. * Gets the radius of the physics imposter
  113122. * @returns Radius of the physics imposter
  113123. */
  113124. getRadius(): number;
  113125. /**
  113126. * Sync a bone with this impostor
  113127. * @param bone The bone to sync to the impostor.
  113128. * @param boneMesh The mesh that the bone is influencing.
  113129. * @param jointPivot The pivot of the joint / bone in local space.
  113130. * @param distToJoint Optional distance from the impostor to the joint.
  113131. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113132. */
  113133. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113134. /**
  113135. * Sync impostor to a bone
  113136. * @param bone The bone that the impostor will be synced to.
  113137. * @param boneMesh The mesh that the bone is influencing.
  113138. * @param jointPivot The pivot of the joint / bone in local space.
  113139. * @param distToJoint Optional distance from the impostor to the joint.
  113140. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113141. * @param boneAxis Optional vector3 axis the bone is aligned with
  113142. */
  113143. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113144. /**
  113145. * No-Imposter type
  113146. */
  113147. static NoImpostor: number;
  113148. /**
  113149. * Sphere-Imposter type
  113150. */
  113151. static SphereImpostor: number;
  113152. /**
  113153. * Box-Imposter type
  113154. */
  113155. static BoxImpostor: number;
  113156. /**
  113157. * Plane-Imposter type
  113158. */
  113159. static PlaneImpostor: number;
  113160. /**
  113161. * Mesh-imposter type
  113162. */
  113163. static MeshImpostor: number;
  113164. /**
  113165. * Capsule-Impostor type (Ammo.js plugin only)
  113166. */
  113167. static CapsuleImpostor: number;
  113168. /**
  113169. * Cylinder-Imposter type
  113170. */
  113171. static CylinderImpostor: number;
  113172. /**
  113173. * Particle-Imposter type
  113174. */
  113175. static ParticleImpostor: number;
  113176. /**
  113177. * Heightmap-Imposter type
  113178. */
  113179. static HeightmapImpostor: number;
  113180. /**
  113181. * ConvexHull-Impostor type (Ammo.js plugin only)
  113182. */
  113183. static ConvexHullImpostor: number;
  113184. /**
  113185. * Custom-Imposter type (Ammo.js plugin only)
  113186. */
  113187. static CustomImpostor: number;
  113188. /**
  113189. * Rope-Imposter type
  113190. */
  113191. static RopeImpostor: number;
  113192. /**
  113193. * Cloth-Imposter type
  113194. */
  113195. static ClothImpostor: number;
  113196. /**
  113197. * Softbody-Imposter type
  113198. */
  113199. static SoftbodyImpostor: number;
  113200. }
  113201. }
  113202. declare module BABYLON {
  113203. /**
  113204. * @hidden
  113205. **/
  113206. export class _CreationDataStorage {
  113207. closePath?: boolean;
  113208. closeArray?: boolean;
  113209. idx: number[];
  113210. dashSize: number;
  113211. gapSize: number;
  113212. path3D: Path3D;
  113213. pathArray: Vector3[][];
  113214. arc: number;
  113215. radius: number;
  113216. cap: number;
  113217. tessellation: number;
  113218. }
  113219. /**
  113220. * @hidden
  113221. **/
  113222. class _InstanceDataStorage {
  113223. visibleInstances: any;
  113224. batchCache: _InstancesBatch;
  113225. instancesBufferSize: number;
  113226. instancesBuffer: Nullable<Buffer>;
  113227. instancesData: Float32Array;
  113228. overridenInstanceCount: number;
  113229. isFrozen: boolean;
  113230. previousBatch: Nullable<_InstancesBatch>;
  113231. hardwareInstancedRendering: boolean;
  113232. sideOrientation: number;
  113233. manualUpdate: boolean;
  113234. previousRenderId: number;
  113235. }
  113236. /**
  113237. * @hidden
  113238. **/
  113239. export class _InstancesBatch {
  113240. mustReturn: boolean;
  113241. visibleInstances: Nullable<InstancedMesh[]>[];
  113242. renderSelf: boolean[];
  113243. hardwareInstancedRendering: boolean[];
  113244. }
  113245. /**
  113246. * @hidden
  113247. **/
  113248. class _ThinInstanceDataStorage {
  113249. instancesCount: number;
  113250. matrixBuffer: Nullable<Buffer>;
  113251. matrixBufferSize: number;
  113252. matrixData: Nullable<Float32Array>;
  113253. boundingVectors: Array<Vector3>;
  113254. worldMatrices: Nullable<Matrix[]>;
  113255. }
  113256. /**
  113257. * Class used to represent renderable models
  113258. */
  113259. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113260. /**
  113261. * Mesh side orientation : usually the external or front surface
  113262. */
  113263. static readonly FRONTSIDE: number;
  113264. /**
  113265. * Mesh side orientation : usually the internal or back surface
  113266. */
  113267. static readonly BACKSIDE: number;
  113268. /**
  113269. * Mesh side orientation : both internal and external or front and back surfaces
  113270. */
  113271. static readonly DOUBLESIDE: number;
  113272. /**
  113273. * Mesh side orientation : by default, `FRONTSIDE`
  113274. */
  113275. static readonly DEFAULTSIDE: number;
  113276. /**
  113277. * Mesh cap setting : no cap
  113278. */
  113279. static readonly NO_CAP: number;
  113280. /**
  113281. * Mesh cap setting : one cap at the beginning of the mesh
  113282. */
  113283. static readonly CAP_START: number;
  113284. /**
  113285. * Mesh cap setting : one cap at the end of the mesh
  113286. */
  113287. static readonly CAP_END: number;
  113288. /**
  113289. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113290. */
  113291. static readonly CAP_ALL: number;
  113292. /**
  113293. * Mesh pattern setting : no flip or rotate
  113294. */
  113295. static readonly NO_FLIP: number;
  113296. /**
  113297. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113298. */
  113299. static readonly FLIP_TILE: number;
  113300. /**
  113301. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113302. */
  113303. static readonly ROTATE_TILE: number;
  113304. /**
  113305. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113306. */
  113307. static readonly FLIP_ROW: number;
  113308. /**
  113309. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113310. */
  113311. static readonly ROTATE_ROW: number;
  113312. /**
  113313. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113314. */
  113315. static readonly FLIP_N_ROTATE_TILE: number;
  113316. /**
  113317. * Mesh pattern setting : rotate pattern and rotate
  113318. */
  113319. static readonly FLIP_N_ROTATE_ROW: number;
  113320. /**
  113321. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113322. */
  113323. static readonly CENTER: number;
  113324. /**
  113325. * Mesh tile positioning : part tiles on left
  113326. */
  113327. static readonly LEFT: number;
  113328. /**
  113329. * Mesh tile positioning : part tiles on right
  113330. */
  113331. static readonly RIGHT: number;
  113332. /**
  113333. * Mesh tile positioning : part tiles on top
  113334. */
  113335. static readonly TOP: number;
  113336. /**
  113337. * Mesh tile positioning : part tiles on bottom
  113338. */
  113339. static readonly BOTTOM: number;
  113340. /**
  113341. * Gets the default side orientation.
  113342. * @param orientation the orientation to value to attempt to get
  113343. * @returns the default orientation
  113344. * @hidden
  113345. */
  113346. static _GetDefaultSideOrientation(orientation?: number): number;
  113347. private _internalMeshDataInfo;
  113348. get computeBonesUsingShaders(): boolean;
  113349. set computeBonesUsingShaders(value: boolean);
  113350. /**
  113351. * An event triggered before rendering the mesh
  113352. */
  113353. get onBeforeRenderObservable(): Observable<Mesh>;
  113354. /**
  113355. * An event triggered before binding the mesh
  113356. */
  113357. get onBeforeBindObservable(): Observable<Mesh>;
  113358. /**
  113359. * An event triggered after rendering the mesh
  113360. */
  113361. get onAfterRenderObservable(): Observable<Mesh>;
  113362. /**
  113363. * An event triggered before drawing the mesh
  113364. */
  113365. get onBeforeDrawObservable(): Observable<Mesh>;
  113366. private _onBeforeDrawObserver;
  113367. /**
  113368. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113369. */
  113370. set onBeforeDraw(callback: () => void);
  113371. get hasInstances(): boolean;
  113372. get hasThinInstances(): boolean;
  113373. /**
  113374. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113375. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113376. */
  113377. delayLoadState: number;
  113378. /**
  113379. * Gets the list of instances created from this mesh
  113380. * it is not supposed to be modified manually.
  113381. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113382. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113383. */
  113384. instances: InstancedMesh[];
  113385. /**
  113386. * Gets the file containing delay loading data for this mesh
  113387. */
  113388. delayLoadingFile: string;
  113389. /** @hidden */
  113390. _binaryInfo: any;
  113391. /**
  113392. * User defined function used to change how LOD level selection is done
  113393. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113394. */
  113395. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113396. /**
  113397. * Gets or sets the morph target manager
  113398. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113399. */
  113400. get morphTargetManager(): Nullable<MorphTargetManager>;
  113401. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113402. /** @hidden */
  113403. _creationDataStorage: Nullable<_CreationDataStorage>;
  113404. /** @hidden */
  113405. _geometry: Nullable<Geometry>;
  113406. /** @hidden */
  113407. _delayInfo: Array<string>;
  113408. /** @hidden */
  113409. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113410. /** @hidden */
  113411. _instanceDataStorage: _InstanceDataStorage;
  113412. /** @hidden */
  113413. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113414. private _effectiveMaterial;
  113415. /** @hidden */
  113416. _shouldGenerateFlatShading: boolean;
  113417. /** @hidden */
  113418. _originalBuilderSideOrientation: number;
  113419. /**
  113420. * Use this property to change the original side orientation defined at construction time
  113421. */
  113422. overrideMaterialSideOrientation: Nullable<number>;
  113423. /**
  113424. * Gets the source mesh (the one used to clone this one from)
  113425. */
  113426. get source(): Nullable<Mesh>;
  113427. /**
  113428. * Gets the list of clones of this mesh
  113429. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113430. * Note that useClonedMeshMap=true is the default setting
  113431. */
  113432. get cloneMeshMap(): Nullable<{
  113433. [id: string]: Mesh | undefined;
  113434. }>;
  113435. /**
  113436. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113437. */
  113438. get isUnIndexed(): boolean;
  113439. set isUnIndexed(value: boolean);
  113440. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113441. get worldMatrixInstancedBuffer(): Float32Array;
  113442. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113443. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113444. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113445. /**
  113446. * @constructor
  113447. * @param name The value used by scene.getMeshByName() to do a lookup.
  113448. * @param scene The scene to add this mesh to.
  113449. * @param parent The parent of this mesh, if it has one
  113450. * @param source An optional Mesh from which geometry is shared, cloned.
  113451. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113452. * When false, achieved by calling a clone(), also passing False.
  113453. * This will make creation of children, recursive.
  113454. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113455. */
  113456. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113457. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113458. doNotInstantiate: boolean;
  113459. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113460. /**
  113461. * Gets the class name
  113462. * @returns the string "Mesh".
  113463. */
  113464. getClassName(): string;
  113465. /** @hidden */
  113466. get _isMesh(): boolean;
  113467. /**
  113468. * Returns a description of this mesh
  113469. * @param fullDetails define if full details about this mesh must be used
  113470. * @returns a descriptive string representing this mesh
  113471. */
  113472. toString(fullDetails?: boolean): string;
  113473. /** @hidden */
  113474. _unBindEffect(): void;
  113475. /**
  113476. * Gets a boolean indicating if this mesh has LOD
  113477. */
  113478. get hasLODLevels(): boolean;
  113479. /**
  113480. * Gets the list of MeshLODLevel associated with the current mesh
  113481. * @returns an array of MeshLODLevel
  113482. */
  113483. getLODLevels(): MeshLODLevel[];
  113484. private _sortLODLevels;
  113485. /**
  113486. * Add a mesh as LOD level triggered at the given distance.
  113487. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113488. * @param distance The distance from the center of the object to show this level
  113489. * @param mesh The mesh to be added as LOD level (can be null)
  113490. * @return This mesh (for chaining)
  113491. */
  113492. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113493. /**
  113494. * Returns the LOD level mesh at the passed distance or null if not found.
  113495. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113496. * @param distance The distance from the center of the object to show this level
  113497. * @returns a Mesh or `null`
  113498. */
  113499. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113500. /**
  113501. * Remove a mesh from the LOD array
  113502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113503. * @param mesh defines the mesh to be removed
  113504. * @return This mesh (for chaining)
  113505. */
  113506. removeLODLevel(mesh: Mesh): Mesh;
  113507. /**
  113508. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113509. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113510. * @param camera defines the camera to use to compute distance
  113511. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113512. * @return This mesh (for chaining)
  113513. */
  113514. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113515. /**
  113516. * Gets the mesh internal Geometry object
  113517. */
  113518. get geometry(): Nullable<Geometry>;
  113519. /**
  113520. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113521. * @returns the total number of vertices
  113522. */
  113523. getTotalVertices(): number;
  113524. /**
  113525. * Returns the content of an associated vertex buffer
  113526. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113527. * - VertexBuffer.PositionKind
  113528. * - VertexBuffer.UVKind
  113529. * - VertexBuffer.UV2Kind
  113530. * - VertexBuffer.UV3Kind
  113531. * - VertexBuffer.UV4Kind
  113532. * - VertexBuffer.UV5Kind
  113533. * - VertexBuffer.UV6Kind
  113534. * - VertexBuffer.ColorKind
  113535. * - VertexBuffer.MatricesIndicesKind
  113536. * - VertexBuffer.MatricesIndicesExtraKind
  113537. * - VertexBuffer.MatricesWeightsKind
  113538. * - VertexBuffer.MatricesWeightsExtraKind
  113539. * @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
  113540. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113541. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113542. */
  113543. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113544. /**
  113545. * Returns the mesh VertexBuffer object from the requested `kind`
  113546. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113547. * - VertexBuffer.PositionKind
  113548. * - VertexBuffer.NormalKind
  113549. * - VertexBuffer.UVKind
  113550. * - VertexBuffer.UV2Kind
  113551. * - VertexBuffer.UV3Kind
  113552. * - VertexBuffer.UV4Kind
  113553. * - VertexBuffer.UV5Kind
  113554. * - VertexBuffer.UV6Kind
  113555. * - VertexBuffer.ColorKind
  113556. * - VertexBuffer.MatricesIndicesKind
  113557. * - VertexBuffer.MatricesIndicesExtraKind
  113558. * - VertexBuffer.MatricesWeightsKind
  113559. * - VertexBuffer.MatricesWeightsExtraKind
  113560. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113561. */
  113562. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113563. /**
  113564. * Tests if a specific vertex buffer is associated with this mesh
  113565. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113566. * - VertexBuffer.PositionKind
  113567. * - VertexBuffer.NormalKind
  113568. * - VertexBuffer.UVKind
  113569. * - VertexBuffer.UV2Kind
  113570. * - VertexBuffer.UV3Kind
  113571. * - VertexBuffer.UV4Kind
  113572. * - VertexBuffer.UV5Kind
  113573. * - VertexBuffer.UV6Kind
  113574. * - VertexBuffer.ColorKind
  113575. * - VertexBuffer.MatricesIndicesKind
  113576. * - VertexBuffer.MatricesIndicesExtraKind
  113577. * - VertexBuffer.MatricesWeightsKind
  113578. * - VertexBuffer.MatricesWeightsExtraKind
  113579. * @returns a boolean
  113580. */
  113581. isVerticesDataPresent(kind: string): boolean;
  113582. /**
  113583. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113584. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113585. * - VertexBuffer.PositionKind
  113586. * - VertexBuffer.UVKind
  113587. * - VertexBuffer.UV2Kind
  113588. * - VertexBuffer.UV3Kind
  113589. * - VertexBuffer.UV4Kind
  113590. * - VertexBuffer.UV5Kind
  113591. * - VertexBuffer.UV6Kind
  113592. * - VertexBuffer.ColorKind
  113593. * - VertexBuffer.MatricesIndicesKind
  113594. * - VertexBuffer.MatricesIndicesExtraKind
  113595. * - VertexBuffer.MatricesWeightsKind
  113596. * - VertexBuffer.MatricesWeightsExtraKind
  113597. * @returns a boolean
  113598. */
  113599. isVertexBufferUpdatable(kind: string): boolean;
  113600. /**
  113601. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113602. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113603. * - VertexBuffer.PositionKind
  113604. * - VertexBuffer.NormalKind
  113605. * - VertexBuffer.UVKind
  113606. * - VertexBuffer.UV2Kind
  113607. * - VertexBuffer.UV3Kind
  113608. * - VertexBuffer.UV4Kind
  113609. * - VertexBuffer.UV5Kind
  113610. * - VertexBuffer.UV6Kind
  113611. * - VertexBuffer.ColorKind
  113612. * - VertexBuffer.MatricesIndicesKind
  113613. * - VertexBuffer.MatricesIndicesExtraKind
  113614. * - VertexBuffer.MatricesWeightsKind
  113615. * - VertexBuffer.MatricesWeightsExtraKind
  113616. * @returns an array of strings
  113617. */
  113618. getVerticesDataKinds(): string[];
  113619. /**
  113620. * Returns a positive integer : the total number of indices in this mesh geometry.
  113621. * @returns the numner of indices or zero if the mesh has no geometry.
  113622. */
  113623. getTotalIndices(): number;
  113624. /**
  113625. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113626. * @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.
  113627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113628. * @returns the indices array or an empty array if the mesh has no geometry
  113629. */
  113630. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113631. get isBlocked(): boolean;
  113632. /**
  113633. * Determine if the current mesh is ready to be rendered
  113634. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113635. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113636. * @returns true if all associated assets are ready (material, textures, shaders)
  113637. */
  113638. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113639. /**
  113640. * 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.
  113641. */
  113642. get areNormalsFrozen(): boolean;
  113643. /**
  113644. * 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.
  113645. * @returns the current mesh
  113646. */
  113647. freezeNormals(): Mesh;
  113648. /**
  113649. * 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
  113650. * @returns the current mesh
  113651. */
  113652. unfreezeNormals(): Mesh;
  113653. /**
  113654. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113655. */
  113656. set overridenInstanceCount(count: number);
  113657. /** @hidden */
  113658. _preActivate(): Mesh;
  113659. /** @hidden */
  113660. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113661. /** @hidden */
  113662. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113663. protected _afterComputeWorldMatrix(): void;
  113664. /** @hidden */
  113665. _postActivate(): void;
  113666. /**
  113667. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113668. * This means the mesh underlying bounding box and sphere are recomputed.
  113669. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113670. * @returns the current mesh
  113671. */
  113672. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113673. /** @hidden */
  113674. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113675. /**
  113676. * This function will subdivide the mesh into multiple submeshes
  113677. * @param count defines the expected number of submeshes
  113678. */
  113679. subdivide(count: number): void;
  113680. /**
  113681. * Copy a FloatArray into a specific associated vertex buffer
  113682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113683. * - VertexBuffer.PositionKind
  113684. * - VertexBuffer.UVKind
  113685. * - VertexBuffer.UV2Kind
  113686. * - VertexBuffer.UV3Kind
  113687. * - VertexBuffer.UV4Kind
  113688. * - VertexBuffer.UV5Kind
  113689. * - VertexBuffer.UV6Kind
  113690. * - VertexBuffer.ColorKind
  113691. * - VertexBuffer.MatricesIndicesKind
  113692. * - VertexBuffer.MatricesIndicesExtraKind
  113693. * - VertexBuffer.MatricesWeightsKind
  113694. * - VertexBuffer.MatricesWeightsExtraKind
  113695. * @param data defines the data source
  113696. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113697. * @param stride defines the data stride size (can be null)
  113698. * @returns the current mesh
  113699. */
  113700. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113701. /**
  113702. * Delete a vertex buffer associated with this mesh
  113703. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113704. * - VertexBuffer.PositionKind
  113705. * - VertexBuffer.UVKind
  113706. * - VertexBuffer.UV2Kind
  113707. * - VertexBuffer.UV3Kind
  113708. * - VertexBuffer.UV4Kind
  113709. * - VertexBuffer.UV5Kind
  113710. * - VertexBuffer.UV6Kind
  113711. * - VertexBuffer.ColorKind
  113712. * - VertexBuffer.MatricesIndicesKind
  113713. * - VertexBuffer.MatricesIndicesExtraKind
  113714. * - VertexBuffer.MatricesWeightsKind
  113715. * - VertexBuffer.MatricesWeightsExtraKind
  113716. */
  113717. removeVerticesData(kind: string): void;
  113718. /**
  113719. * Flags an associated vertex buffer as updatable
  113720. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113721. * - VertexBuffer.PositionKind
  113722. * - VertexBuffer.UVKind
  113723. * - VertexBuffer.UV2Kind
  113724. * - VertexBuffer.UV3Kind
  113725. * - VertexBuffer.UV4Kind
  113726. * - VertexBuffer.UV5Kind
  113727. * - VertexBuffer.UV6Kind
  113728. * - VertexBuffer.ColorKind
  113729. * - VertexBuffer.MatricesIndicesKind
  113730. * - VertexBuffer.MatricesIndicesExtraKind
  113731. * - VertexBuffer.MatricesWeightsKind
  113732. * - VertexBuffer.MatricesWeightsExtraKind
  113733. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113734. */
  113735. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113736. /**
  113737. * Sets the mesh global Vertex Buffer
  113738. * @param buffer defines the buffer to use
  113739. * @returns the current mesh
  113740. */
  113741. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113742. /**
  113743. * Update a specific associated vertex buffer
  113744. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113745. * - VertexBuffer.PositionKind
  113746. * - VertexBuffer.UVKind
  113747. * - VertexBuffer.UV2Kind
  113748. * - VertexBuffer.UV3Kind
  113749. * - VertexBuffer.UV4Kind
  113750. * - VertexBuffer.UV5Kind
  113751. * - VertexBuffer.UV6Kind
  113752. * - VertexBuffer.ColorKind
  113753. * - VertexBuffer.MatricesIndicesKind
  113754. * - VertexBuffer.MatricesIndicesExtraKind
  113755. * - VertexBuffer.MatricesWeightsKind
  113756. * - VertexBuffer.MatricesWeightsExtraKind
  113757. * @param data defines the data source
  113758. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113759. * @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)
  113760. * @returns the current mesh
  113761. */
  113762. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113763. /**
  113764. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113765. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113766. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113767. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113768. * @returns the current mesh
  113769. */
  113770. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113771. /**
  113772. * Creates a un-shared specific occurence of the geometry for the mesh.
  113773. * @returns the current mesh
  113774. */
  113775. makeGeometryUnique(): Mesh;
  113776. /**
  113777. * Set the index buffer of this mesh
  113778. * @param indices defines the source data
  113779. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113780. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113781. * @returns the current mesh
  113782. */
  113783. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113784. /**
  113785. * Update the current index buffer
  113786. * @param indices defines the source data
  113787. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113788. * @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)
  113789. * @returns the current mesh
  113790. */
  113791. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113792. /**
  113793. * Invert the geometry to move from a right handed system to a left handed one.
  113794. * @returns the current mesh
  113795. */
  113796. toLeftHanded(): Mesh;
  113797. /** @hidden */
  113798. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113799. /** @hidden */
  113800. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113801. /**
  113802. * Registers for this mesh a javascript function called just before the rendering process
  113803. * @param func defines the function to call before rendering this mesh
  113804. * @returns the current mesh
  113805. */
  113806. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113807. /**
  113808. * Disposes a previously registered javascript function called before the rendering
  113809. * @param func defines the function to remove
  113810. * @returns the current mesh
  113811. */
  113812. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113813. /**
  113814. * Registers for this mesh a javascript function called just after the rendering is complete
  113815. * @param func defines the function to call after rendering this mesh
  113816. * @returns the current mesh
  113817. */
  113818. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113819. /**
  113820. * Disposes a previously registered javascript function called after the rendering.
  113821. * @param func defines the function to remove
  113822. * @returns the current mesh
  113823. */
  113824. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113825. /** @hidden */
  113826. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113827. /** @hidden */
  113828. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113829. /** @hidden */
  113830. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113831. /** @hidden */
  113832. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113833. /** @hidden */
  113834. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113835. /** @hidden */
  113836. _rebuild(): void;
  113837. /** @hidden */
  113838. _freeze(): void;
  113839. /** @hidden */
  113840. _unFreeze(): void;
  113841. /**
  113842. * 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
  113843. * @param subMesh defines the subMesh to render
  113844. * @param enableAlphaMode defines if alpha mode can be changed
  113845. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113846. * @returns the current mesh
  113847. */
  113848. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113849. private _onBeforeDraw;
  113850. /**
  113851. * Renormalize the mesh and patch it up if there are no weights
  113852. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113853. * However in the case of zero weights then we set just a single influence to 1.
  113854. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113855. */
  113856. cleanMatrixWeights(): void;
  113857. private normalizeSkinFourWeights;
  113858. private normalizeSkinWeightsAndExtra;
  113859. /**
  113860. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113861. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113862. * the user know there was an issue with importing the mesh
  113863. * @returns a validation object with skinned, valid and report string
  113864. */
  113865. validateSkinning(): {
  113866. skinned: boolean;
  113867. valid: boolean;
  113868. report: string;
  113869. };
  113870. /** @hidden */
  113871. _checkDelayState(): Mesh;
  113872. private _queueLoad;
  113873. /**
  113874. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113875. * A mesh is in the frustum if its bounding box intersects the frustum
  113876. * @param frustumPlanes defines the frustum to test
  113877. * @returns true if the mesh is in the frustum planes
  113878. */
  113879. isInFrustum(frustumPlanes: Plane[]): boolean;
  113880. /**
  113881. * Sets the mesh material by the material or multiMaterial `id` property
  113882. * @param id is a string identifying the material or the multiMaterial
  113883. * @returns the current mesh
  113884. */
  113885. setMaterialByID(id: string): Mesh;
  113886. /**
  113887. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113888. * @returns an array of IAnimatable
  113889. */
  113890. getAnimatables(): IAnimatable[];
  113891. /**
  113892. * Modifies the mesh geometry according to the passed transformation matrix.
  113893. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113894. * The mesh normals are modified using the same transformation.
  113895. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113896. * @param transform defines the transform matrix to use
  113897. * @see https://doc.babylonjs.com/resources/baking_transformations
  113898. * @returns the current mesh
  113899. */
  113900. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113901. /**
  113902. * Modifies the mesh geometry according to its own current World Matrix.
  113903. * The mesh World Matrix is then reset.
  113904. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113905. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113906. * @see https://doc.babylonjs.com/resources/baking_transformations
  113907. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113908. * @returns the current mesh
  113909. */
  113910. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113911. /** @hidden */
  113912. get _positions(): Nullable<Vector3[]>;
  113913. /** @hidden */
  113914. _resetPointsArrayCache(): Mesh;
  113915. /** @hidden */
  113916. _generatePointsArray(): boolean;
  113917. /**
  113918. * Returns a new Mesh object generated from the current mesh properties.
  113919. * This method must not get confused with createInstance()
  113920. * @param name is a string, the name given to the new mesh
  113921. * @param newParent can be any Node object (default `null`)
  113922. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113923. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113924. * @returns a new mesh
  113925. */
  113926. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113927. /**
  113928. * Releases resources associated with this mesh.
  113929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113931. */
  113932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113933. /** @hidden */
  113934. _disposeInstanceSpecificData(): void;
  113935. /** @hidden */
  113936. _disposeThinInstanceSpecificData(): void;
  113937. /**
  113938. * Modifies the mesh geometry according to a displacement map.
  113939. * 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.
  113940. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113941. * @param url is a string, the URL from the image file is to be downloaded.
  113942. * @param minHeight is the lower limit of the displacement.
  113943. * @param maxHeight is the upper limit of the displacement.
  113944. * @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.
  113945. * @param uvOffset is an optional vector2 used to offset UV.
  113946. * @param uvScale is an optional vector2 used to scale UV.
  113947. * @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.
  113948. * @returns the Mesh.
  113949. */
  113950. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113951. /**
  113952. * Modifies the mesh geometry according to a displacementMap buffer.
  113953. * 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.
  113954. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113955. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113956. * @param heightMapWidth is the width of the buffer image.
  113957. * @param heightMapHeight is the height of the buffer image.
  113958. * @param minHeight is the lower limit of the displacement.
  113959. * @param maxHeight is the upper limit of the displacement.
  113960. * @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.
  113961. * @param uvOffset is an optional vector2 used to offset UV.
  113962. * @param uvScale is an optional vector2 used to scale UV.
  113963. * @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.
  113964. * @returns the Mesh.
  113965. */
  113966. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113967. /**
  113968. * Modify the mesh to get a flat shading rendering.
  113969. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113970. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113971. * @returns current mesh
  113972. */
  113973. convertToFlatShadedMesh(): Mesh;
  113974. /**
  113975. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113976. * In other words, more vertices, no more indices and a single bigger VBO.
  113977. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113978. * @returns current mesh
  113979. */
  113980. convertToUnIndexedMesh(): Mesh;
  113981. /**
  113982. * Inverses facet orientations.
  113983. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113984. * @param flipNormals will also inverts the normals
  113985. * @returns current mesh
  113986. */
  113987. flipFaces(flipNormals?: boolean): Mesh;
  113988. /**
  113989. * Increase the number of facets and hence vertices in a mesh
  113990. * Vertex normals are interpolated from existing vertex normals
  113991. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113992. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113993. */
  113994. increaseVertices(numberPerEdge: number): void;
  113995. /**
  113996. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113997. * This will undo any application of covertToFlatShadedMesh
  113998. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113999. */
  114000. forceSharedVertices(): void;
  114001. /** @hidden */
  114002. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114003. /** @hidden */
  114004. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114005. /**
  114006. * Creates a new InstancedMesh object from the mesh model.
  114007. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114008. * @param name defines the name of the new instance
  114009. * @returns a new InstancedMesh
  114010. */
  114011. createInstance(name: string): InstancedMesh;
  114012. /**
  114013. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114014. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114015. * @returns the current mesh
  114016. */
  114017. synchronizeInstances(): Mesh;
  114018. /**
  114019. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114020. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114021. * This should be used together with the simplification to avoid disappearing triangles.
  114022. * @param successCallback an optional success callback to be called after the optimization finished.
  114023. * @returns the current mesh
  114024. */
  114025. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114026. /**
  114027. * Serialize current mesh
  114028. * @param serializationObject defines the object which will receive the serialization data
  114029. */
  114030. serialize(serializationObject: any): void;
  114031. /** @hidden */
  114032. _syncGeometryWithMorphTargetManager(): void;
  114033. /** @hidden */
  114034. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114035. /**
  114036. * Returns a new Mesh object parsed from the source provided.
  114037. * @param parsedMesh is the source
  114038. * @param scene defines the hosting scene
  114039. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114040. * @returns a new Mesh
  114041. */
  114042. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114043. /**
  114044. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114045. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114046. * @param name defines the name of the mesh to create
  114047. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114048. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114049. * @param closePath creates a seam between the first and the last points of each path of the path array
  114050. * @param offset is taken in account only if the `pathArray` is containing a single path
  114051. * @param scene defines the hosting scene
  114052. * @param updatable defines if the mesh must be flagged as updatable
  114053. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114054. * @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)
  114055. * @returns a new Mesh
  114056. */
  114057. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114058. /**
  114059. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114060. * @param name defines the name of the mesh to create
  114061. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114062. * @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
  114063. * @param scene defines the hosting scene
  114064. * @param updatable defines if the mesh must be flagged as updatable
  114065. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114066. * @returns a new Mesh
  114067. */
  114068. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114069. /**
  114070. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114071. * @param name defines the name of the mesh to create
  114072. * @param size sets the size (float) of each box side (default 1)
  114073. * @param scene defines the hosting scene
  114074. * @param updatable defines if the mesh must be flagged as updatable
  114075. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114076. * @returns a new Mesh
  114077. */
  114078. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114079. /**
  114080. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114081. * @param name defines the name of the mesh to create
  114082. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114083. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114084. * @param scene defines the hosting scene
  114085. * @param updatable defines if the mesh must be flagged as updatable
  114086. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114087. * @returns a new Mesh
  114088. */
  114089. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114090. /**
  114091. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114092. * @param name defines the name of the mesh to create
  114093. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114094. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114095. * @param scene defines the hosting scene
  114096. * @returns a new Mesh
  114097. */
  114098. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114099. /**
  114100. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114101. * @param name defines the name of the mesh to create
  114102. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114103. * @param diameterTop set the top cap diameter (floats, default 1)
  114104. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114105. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114106. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114107. * @param scene defines the hosting scene
  114108. * @param updatable defines if the mesh must be flagged as updatable
  114109. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114110. * @returns a new Mesh
  114111. */
  114112. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114113. /**
  114114. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114115. * @param name defines the name of the mesh to create
  114116. * @param diameter sets the diameter size (float) of the torus (default 1)
  114117. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114118. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114119. * @param scene defines the hosting scene
  114120. * @param updatable defines if the mesh must be flagged as updatable
  114121. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114122. * @returns a new Mesh
  114123. */
  114124. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114125. /**
  114126. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114127. * @param name defines the name of the mesh to create
  114128. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114129. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114130. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114131. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114132. * @param p the number of windings on X axis (positive integers, default 2)
  114133. * @param q the number of windings on Y axis (positive integers, default 3)
  114134. * @param scene defines the hosting scene
  114135. * @param updatable defines if the mesh must be flagged as updatable
  114136. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114137. * @returns a new Mesh
  114138. */
  114139. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114140. /**
  114141. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114142. * @param name defines the name of the mesh to create
  114143. * @param points is an array successive Vector3
  114144. * @param scene defines the hosting scene
  114145. * @param updatable defines if the mesh must be flagged as updatable
  114146. * @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).
  114147. * @returns a new Mesh
  114148. */
  114149. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114150. /**
  114151. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114152. * @param name defines the name of the mesh to create
  114153. * @param points is an array successive Vector3
  114154. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114155. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114156. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114157. * @param scene defines the hosting scene
  114158. * @param updatable defines if the mesh must be flagged as updatable
  114159. * @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)
  114160. * @returns a new Mesh
  114161. */
  114162. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114163. /**
  114164. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114165. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114166. * 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.
  114167. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114168. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114169. * Remember you can only change the shape positions, not their number when updating a polygon.
  114170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114171. * @param name defines the name of the mesh to create
  114172. * @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
  114173. * @param scene defines the hosting scene
  114174. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114175. * @param updatable defines if the mesh must be flagged as updatable
  114176. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114177. * @param earcutInjection can be used to inject your own earcut reference
  114178. * @returns a new Mesh
  114179. */
  114180. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114181. /**
  114182. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114184. * @param name defines the name of the mesh to create
  114185. * @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
  114186. * @param depth defines the height of extrusion
  114187. * @param scene defines the hosting scene
  114188. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114189. * @param updatable defines if the mesh must be flagged as updatable
  114190. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114191. * @param earcutInjection can be used to inject your own earcut reference
  114192. * @returns a new Mesh
  114193. */
  114194. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114195. /**
  114196. * Creates an extruded shape mesh.
  114197. * 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
  114198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114200. * @param name defines the name of the mesh to create
  114201. * @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
  114202. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114203. * @param scale is the value to scale the shape
  114204. * @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
  114205. * @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
  114206. * @param scene defines the hosting scene
  114207. * @param updatable defines if the mesh must be flagged as updatable
  114208. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114209. * @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)
  114210. * @returns a new Mesh
  114211. */
  114212. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114213. /**
  114214. * Creates an custom extruded shape mesh.
  114215. * The custom extrusion is a parametric shape.
  114216. * It has no predefined shape. Its final shape will depend on the input parameters.
  114217. * Please consider using the same method from the MeshBuilder class instead
  114218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114219. * @param name defines the name of the mesh to create
  114220. * @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
  114221. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114222. * @param scaleFunction is a custom Javascript function called on each path point
  114223. * @param rotationFunction is a custom Javascript function called on each path point
  114224. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114225. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114226. * @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
  114227. * @param scene defines the hosting scene
  114228. * @param updatable defines if the mesh must be flagged as updatable
  114229. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114230. * @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)
  114231. * @returns a new Mesh
  114232. */
  114233. 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;
  114234. /**
  114235. * Creates lathe mesh.
  114236. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114237. * Please consider using the same method from the MeshBuilder class instead
  114238. * @param name defines the name of the mesh to create
  114239. * @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
  114240. * @param radius is the radius value of the lathe
  114241. * @param tessellation is the side number of the lathe.
  114242. * @param scene defines the hosting scene
  114243. * @param updatable defines if the mesh must be flagged as updatable
  114244. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114245. * @returns a new Mesh
  114246. */
  114247. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114248. /**
  114249. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114250. * @param name defines the name of the mesh to create
  114251. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114252. * @param scene defines the hosting scene
  114253. * @param updatable defines if the mesh must be flagged as updatable
  114254. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114255. * @returns a new Mesh
  114256. */
  114257. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114258. /**
  114259. * Creates a ground mesh.
  114260. * Please consider using the same method from the MeshBuilder class instead
  114261. * @param name defines the name of the mesh to create
  114262. * @param width set the width of the ground
  114263. * @param height set the height of the ground
  114264. * @param subdivisions sets the number of subdivisions per side
  114265. * @param scene defines the hosting scene
  114266. * @param updatable defines if the mesh must be flagged as updatable
  114267. * @returns a new Mesh
  114268. */
  114269. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114270. /**
  114271. * Creates a tiled ground mesh.
  114272. * Please consider using the same method from the MeshBuilder class instead
  114273. * @param name defines the name of the mesh to create
  114274. * @param xmin set the ground minimum X coordinate
  114275. * @param zmin set the ground minimum Y coordinate
  114276. * @param xmax set the ground maximum X coordinate
  114277. * @param zmax set the ground maximum Z coordinate
  114278. * @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
  114279. * @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
  114280. * @param scene defines the hosting scene
  114281. * @param updatable defines if the mesh must be flagged as updatable
  114282. * @returns a new Mesh
  114283. */
  114284. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114285. w: number;
  114286. h: number;
  114287. }, precision: {
  114288. w: number;
  114289. h: number;
  114290. }, scene: Scene, updatable?: boolean): Mesh;
  114291. /**
  114292. * Creates a ground mesh from a height map.
  114293. * Please consider using the same method from the MeshBuilder class instead
  114294. * @see https://doc.babylonjs.com/babylon101/height_map
  114295. * @param name defines the name of the mesh to create
  114296. * @param url sets the URL of the height map image resource
  114297. * @param width set the ground width size
  114298. * @param height set the ground height size
  114299. * @param subdivisions sets the number of subdivision per side
  114300. * @param minHeight is the minimum altitude on the ground
  114301. * @param maxHeight is the maximum altitude on the ground
  114302. * @param scene defines the hosting scene
  114303. * @param updatable defines if the mesh must be flagged as updatable
  114304. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114305. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114306. * @returns a new Mesh
  114307. */
  114308. 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;
  114309. /**
  114310. * Creates a tube mesh.
  114311. * The tube is a parametric shape.
  114312. * It has no predefined shape. Its final shape will depend on the input parameters.
  114313. * Please consider using the same method from the MeshBuilder class instead
  114314. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114315. * @param name defines the name of the mesh to create
  114316. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114317. * @param radius sets the tube radius size
  114318. * @param tessellation is the number of sides on the tubular surface
  114319. * @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
  114320. * @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
  114321. * @param scene defines the hosting scene
  114322. * @param updatable defines if the mesh must be flagged as updatable
  114323. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114324. * @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)
  114325. * @returns a new Mesh
  114326. */
  114327. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114328. (i: number, distance: number): number;
  114329. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114330. /**
  114331. * Creates a polyhedron mesh.
  114332. * Please consider using the same method from the MeshBuilder class instead.
  114333. * * 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
  114334. * * The parameter `size` (positive float, default 1) sets the polygon size
  114335. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114336. * * 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`
  114337. * * 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
  114338. * * 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)`)
  114339. * * 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
  114340. * * 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
  114341. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114344. * @param name defines the name of the mesh to create
  114345. * @param options defines the options used to create the mesh
  114346. * @param scene defines the hosting scene
  114347. * @returns a new Mesh
  114348. */
  114349. static CreatePolyhedron(name: string, options: {
  114350. type?: number;
  114351. size?: number;
  114352. sizeX?: number;
  114353. sizeY?: number;
  114354. sizeZ?: number;
  114355. custom?: any;
  114356. faceUV?: Vector4[];
  114357. faceColors?: Color4[];
  114358. updatable?: boolean;
  114359. sideOrientation?: number;
  114360. }, scene: Scene): Mesh;
  114361. /**
  114362. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114363. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114364. * * 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`)
  114365. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114366. * * 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
  114367. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114370. * @param name defines the name of the mesh
  114371. * @param options defines the options used to create the mesh
  114372. * @param scene defines the hosting scene
  114373. * @returns a new Mesh
  114374. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114375. */
  114376. static CreateIcoSphere(name: string, options: {
  114377. radius?: number;
  114378. flat?: boolean;
  114379. subdivisions?: number;
  114380. sideOrientation?: number;
  114381. updatable?: boolean;
  114382. }, scene: Scene): Mesh;
  114383. /**
  114384. * Creates a decal mesh.
  114385. * Please consider using the same method from the MeshBuilder class instead.
  114386. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114387. * @param name defines the name of the mesh
  114388. * @param sourceMesh defines the mesh receiving the decal
  114389. * @param position sets the position of the decal in world coordinates
  114390. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114391. * @param size sets the decal scaling
  114392. * @param angle sets the angle to rotate the decal
  114393. * @returns a new Mesh
  114394. */
  114395. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114396. /** Creates a Capsule Mesh
  114397. * @param name defines the name of the mesh.
  114398. * @param options the constructors options used to shape the mesh.
  114399. * @param scene defines the scene the mesh is scoped to.
  114400. * @returns the capsule mesh
  114401. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114402. */
  114403. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114404. /**
  114405. * Prepare internal position array for software CPU skinning
  114406. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114407. */
  114408. setPositionsForCPUSkinning(): Float32Array;
  114409. /**
  114410. * Prepare internal normal array for software CPU skinning
  114411. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114412. */
  114413. setNormalsForCPUSkinning(): Float32Array;
  114414. /**
  114415. * Updates the vertex buffer by applying transformation from the bones
  114416. * @param skeleton defines the skeleton to apply to current mesh
  114417. * @returns the current mesh
  114418. */
  114419. applySkeleton(skeleton: Skeleton): Mesh;
  114420. /**
  114421. * 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
  114422. * @param meshes defines the list of meshes to scan
  114423. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114424. */
  114425. static MinMax(meshes: AbstractMesh[]): {
  114426. min: Vector3;
  114427. max: Vector3;
  114428. };
  114429. /**
  114430. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114431. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114432. * @returns a vector3
  114433. */
  114434. static Center(meshesOrMinMaxVector: {
  114435. min: Vector3;
  114436. max: Vector3;
  114437. } | AbstractMesh[]): Vector3;
  114438. /**
  114439. * Merge the array of meshes into a single mesh for performance reasons.
  114440. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114441. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114442. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114443. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114444. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114445. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114446. * @returns a new mesh
  114447. */
  114448. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114449. /** @hidden */
  114450. addInstance(instance: InstancedMesh): void;
  114451. /** @hidden */
  114452. removeInstance(instance: InstancedMesh): void;
  114453. }
  114454. }
  114455. declare module BABYLON {
  114456. /**
  114457. * This is the base class of all the camera used in the application.
  114458. * @see https://doc.babylonjs.com/features/cameras
  114459. */
  114460. export class Camera extends Node {
  114461. /** @hidden */
  114462. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114463. /**
  114464. * This is the default projection mode used by the cameras.
  114465. * It helps recreating a feeling of perspective and better appreciate depth.
  114466. * This is the best way to simulate real life cameras.
  114467. */
  114468. static readonly PERSPECTIVE_CAMERA: number;
  114469. /**
  114470. * This helps creating camera with an orthographic mode.
  114471. * 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.
  114472. */
  114473. static readonly ORTHOGRAPHIC_CAMERA: number;
  114474. /**
  114475. * This is the default FOV mode for perspective cameras.
  114476. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114477. */
  114478. static readonly FOVMODE_VERTICAL_FIXED: number;
  114479. /**
  114480. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114481. */
  114482. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114483. /**
  114484. * This specifies ther is no need for a camera rig.
  114485. * Basically only one eye is rendered corresponding to the camera.
  114486. */
  114487. static readonly RIG_MODE_NONE: number;
  114488. /**
  114489. * Simulates a camera Rig with one blue eye and one red eye.
  114490. * This can be use with 3d blue and red glasses.
  114491. */
  114492. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114493. /**
  114494. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114495. */
  114496. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114497. /**
  114498. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114499. */
  114500. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114501. /**
  114502. * Defines that both eyes of the camera will be rendered over under each other.
  114503. */
  114504. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114505. /**
  114506. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114507. */
  114508. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114509. /**
  114510. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114511. */
  114512. static readonly RIG_MODE_VR: number;
  114513. /**
  114514. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114515. */
  114516. static readonly RIG_MODE_WEBVR: number;
  114517. /**
  114518. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114519. */
  114520. static readonly RIG_MODE_CUSTOM: number;
  114521. /**
  114522. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114523. */
  114524. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114525. /**
  114526. * Define the input manager associated with the camera.
  114527. */
  114528. inputs: CameraInputsManager<Camera>;
  114529. /** @hidden */
  114530. _position: Vector3;
  114531. /**
  114532. * Define the current local position of the camera in the scene
  114533. */
  114534. get position(): Vector3;
  114535. set position(newPosition: Vector3);
  114536. protected _upVector: Vector3;
  114537. /**
  114538. * The vector the camera should consider as up.
  114539. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114540. */
  114541. set upVector(vec: Vector3);
  114542. get upVector(): Vector3;
  114543. /**
  114544. * Define the current limit on the left side for an orthographic camera
  114545. * In scene unit
  114546. */
  114547. orthoLeft: Nullable<number>;
  114548. /**
  114549. * Define the current limit on the right side for an orthographic camera
  114550. * In scene unit
  114551. */
  114552. orthoRight: Nullable<number>;
  114553. /**
  114554. * Define the current limit on the bottom side for an orthographic camera
  114555. * In scene unit
  114556. */
  114557. orthoBottom: Nullable<number>;
  114558. /**
  114559. * Define the current limit on the top side for an orthographic camera
  114560. * In scene unit
  114561. */
  114562. orthoTop: Nullable<number>;
  114563. /**
  114564. * Field Of View is set in Radians. (default is 0.8)
  114565. */
  114566. fov: number;
  114567. /**
  114568. * Define the minimum distance the camera can see from.
  114569. * This is important to note that the depth buffer are not infinite and the closer it starts
  114570. * the more your scene might encounter depth fighting issue.
  114571. */
  114572. minZ: number;
  114573. /**
  114574. * Define the maximum distance the camera can see to.
  114575. * This is important to note that the depth buffer are not infinite and the further it end
  114576. * the more your scene might encounter depth fighting issue.
  114577. */
  114578. maxZ: number;
  114579. /**
  114580. * Define the default inertia of the camera.
  114581. * This helps giving a smooth feeling to the camera movement.
  114582. */
  114583. inertia: number;
  114584. /**
  114585. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114586. */
  114587. mode: number;
  114588. /**
  114589. * Define whether the camera is intermediate.
  114590. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114591. */
  114592. isIntermediate: boolean;
  114593. /**
  114594. * Define the viewport of the camera.
  114595. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114596. */
  114597. viewport: Viewport;
  114598. /**
  114599. * Restricts the camera to viewing objects with the same layerMask.
  114600. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114601. */
  114602. layerMask: number;
  114603. /**
  114604. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114605. */
  114606. fovMode: number;
  114607. /**
  114608. * Rig mode of the camera.
  114609. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114610. * This is normally controlled byt the camera themselves as internal use.
  114611. */
  114612. cameraRigMode: number;
  114613. /**
  114614. * Defines the distance between both "eyes" in case of a RIG
  114615. */
  114616. interaxialDistance: number;
  114617. /**
  114618. * Defines if stereoscopic rendering is done side by side or over under.
  114619. */
  114620. isStereoscopicSideBySide: boolean;
  114621. /**
  114622. * 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
  114623. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114624. * else in the scene. (Eg. security camera)
  114625. *
  114626. * 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)
  114627. */
  114628. customRenderTargets: RenderTargetTexture[];
  114629. /**
  114630. * When set, the camera will render to this render target instead of the default canvas
  114631. *
  114632. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114633. */
  114634. outputRenderTarget: Nullable<RenderTargetTexture>;
  114635. /**
  114636. * Observable triggered when the camera view matrix has changed.
  114637. */
  114638. onViewMatrixChangedObservable: Observable<Camera>;
  114639. /**
  114640. * Observable triggered when the camera Projection matrix has changed.
  114641. */
  114642. onProjectionMatrixChangedObservable: Observable<Camera>;
  114643. /**
  114644. * Observable triggered when the inputs have been processed.
  114645. */
  114646. onAfterCheckInputsObservable: Observable<Camera>;
  114647. /**
  114648. * Observable triggered when reset has been called and applied to the camera.
  114649. */
  114650. onRestoreStateObservable: Observable<Camera>;
  114651. /**
  114652. * Is this camera a part of a rig system?
  114653. */
  114654. isRigCamera: boolean;
  114655. /**
  114656. * If isRigCamera set to true this will be set with the parent camera.
  114657. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114658. */
  114659. rigParent?: Camera;
  114660. /** @hidden */
  114661. _cameraRigParams: any;
  114662. /** @hidden */
  114663. _rigCameras: Camera[];
  114664. /** @hidden */
  114665. _rigPostProcess: Nullable<PostProcess>;
  114666. protected _webvrViewMatrix: Matrix;
  114667. /** @hidden */
  114668. _skipRendering: boolean;
  114669. /** @hidden */
  114670. _projectionMatrix: Matrix;
  114671. /** @hidden */
  114672. _postProcesses: Nullable<PostProcess>[];
  114673. /** @hidden */
  114674. _activeMeshes: SmartArray<AbstractMesh>;
  114675. protected _globalPosition: Vector3;
  114676. /** @hidden */
  114677. _computedViewMatrix: Matrix;
  114678. private _doNotComputeProjectionMatrix;
  114679. private _transformMatrix;
  114680. private _frustumPlanes;
  114681. private _refreshFrustumPlanes;
  114682. private _storedFov;
  114683. private _stateStored;
  114684. /**
  114685. * Instantiates a new camera object.
  114686. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114687. * @see https://doc.babylonjs.com/features/cameras
  114688. * @param name Defines the name of the camera in the scene
  114689. * @param position Defines the position of the camera
  114690. * @param scene Defines the scene the camera belongs too
  114691. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114692. */
  114693. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114694. /**
  114695. * Store current camera state (fov, position, etc..)
  114696. * @returns the camera
  114697. */
  114698. storeState(): Camera;
  114699. /**
  114700. * Restores the camera state values if it has been stored. You must call storeState() first
  114701. */
  114702. protected _restoreStateValues(): boolean;
  114703. /**
  114704. * Restored camera state. You must call storeState() first.
  114705. * @returns true if restored and false otherwise
  114706. */
  114707. restoreState(): boolean;
  114708. /**
  114709. * Gets the class name of the camera.
  114710. * @returns the class name
  114711. */
  114712. getClassName(): string;
  114713. /** @hidden */
  114714. readonly _isCamera: boolean;
  114715. /**
  114716. * Gets a string representation of the camera useful for debug purpose.
  114717. * @param fullDetails Defines that a more verboe level of logging is required
  114718. * @returns the string representation
  114719. */
  114720. toString(fullDetails?: boolean): string;
  114721. /**
  114722. * Gets the current world space position of the camera.
  114723. */
  114724. get globalPosition(): Vector3;
  114725. /**
  114726. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114727. * @returns the active meshe list
  114728. */
  114729. getActiveMeshes(): SmartArray<AbstractMesh>;
  114730. /**
  114731. * Check whether a mesh is part of the current active mesh list of the camera
  114732. * @param mesh Defines the mesh to check
  114733. * @returns true if active, false otherwise
  114734. */
  114735. isActiveMesh(mesh: Mesh): boolean;
  114736. /**
  114737. * Is this camera ready to be used/rendered
  114738. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114739. * @return true if the camera is ready
  114740. */
  114741. isReady(completeCheck?: boolean): boolean;
  114742. /** @hidden */
  114743. _initCache(): void;
  114744. /** @hidden */
  114745. _updateCache(ignoreParentClass?: boolean): void;
  114746. /** @hidden */
  114747. _isSynchronized(): boolean;
  114748. /** @hidden */
  114749. _isSynchronizedViewMatrix(): boolean;
  114750. /** @hidden */
  114751. _isSynchronizedProjectionMatrix(): boolean;
  114752. /**
  114753. * Attach the input controls to a specific dom element to get the input from.
  114754. * @param element Defines the element the controls should be listened from
  114755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114756. */
  114757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114758. /**
  114759. * Detach the current controls from the specified dom element.
  114760. * @param element Defines the element to stop listening the inputs from
  114761. */
  114762. detachControl(element: HTMLElement): void;
  114763. /**
  114764. * Update the camera state according to the different inputs gathered during the frame.
  114765. */
  114766. update(): void;
  114767. /** @hidden */
  114768. _checkInputs(): void;
  114769. /** @hidden */
  114770. get rigCameras(): Camera[];
  114771. /**
  114772. * Gets the post process used by the rig cameras
  114773. */
  114774. get rigPostProcess(): Nullable<PostProcess>;
  114775. /**
  114776. * Internal, gets the first post proces.
  114777. * @returns the first post process to be run on this camera.
  114778. */
  114779. _getFirstPostProcess(): Nullable<PostProcess>;
  114780. private _cascadePostProcessesToRigCams;
  114781. /**
  114782. * Attach a post process to the camera.
  114783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114784. * @param postProcess The post process to attach to the camera
  114785. * @param insertAt The position of the post process in case several of them are in use in the scene
  114786. * @returns the position the post process has been inserted at
  114787. */
  114788. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114789. /**
  114790. * Detach a post process to the camera.
  114791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114792. * @param postProcess The post process to detach from the camera
  114793. */
  114794. detachPostProcess(postProcess: PostProcess): void;
  114795. /**
  114796. * Gets the current world matrix of the camera
  114797. */
  114798. getWorldMatrix(): Matrix;
  114799. /** @hidden */
  114800. _getViewMatrix(): Matrix;
  114801. /**
  114802. * Gets the current view matrix of the camera.
  114803. * @param force forces the camera to recompute the matrix without looking at the cached state
  114804. * @returns the view matrix
  114805. */
  114806. getViewMatrix(force?: boolean): Matrix;
  114807. /**
  114808. * Freeze the projection matrix.
  114809. * It will prevent the cache check of the camera projection compute and can speed up perf
  114810. * if no parameter of the camera are meant to change
  114811. * @param projection Defines manually a projection if necessary
  114812. */
  114813. freezeProjectionMatrix(projection?: Matrix): void;
  114814. /**
  114815. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114816. */
  114817. unfreezeProjectionMatrix(): void;
  114818. /**
  114819. * Gets the current projection matrix of the camera.
  114820. * @param force forces the camera to recompute the matrix without looking at the cached state
  114821. * @returns the projection matrix
  114822. */
  114823. getProjectionMatrix(force?: boolean): Matrix;
  114824. /**
  114825. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114826. * @returns a Matrix
  114827. */
  114828. getTransformationMatrix(): Matrix;
  114829. private _updateFrustumPlanes;
  114830. /**
  114831. * Checks if a cullable object (mesh...) is in the camera frustum
  114832. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114833. * @param target The object to check
  114834. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114835. * @returns true if the object is in frustum otherwise false
  114836. */
  114837. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114838. /**
  114839. * Checks if a cullable object (mesh...) is in the camera frustum
  114840. * Unlike isInFrustum this cheks the full bounding box
  114841. * @param target The object to check
  114842. * @returns true if the object is in frustum otherwise false
  114843. */
  114844. isCompletelyInFrustum(target: ICullable): boolean;
  114845. /**
  114846. * Gets a ray in the forward direction from the camera.
  114847. * @param length Defines the length of the ray to create
  114848. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114849. * @param origin Defines the start point of the ray which defaults to the camera position
  114850. * @returns the forward ray
  114851. */
  114852. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114853. /**
  114854. * Gets a ray in the forward direction from the camera.
  114855. * @param refRay the ray to (re)use when setting the values
  114856. * @param length Defines the length of the ray to create
  114857. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114858. * @param origin Defines the start point of the ray which defaults to the camera position
  114859. * @returns the forward ray
  114860. */
  114861. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114862. /**
  114863. * Releases resources associated with this node.
  114864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114866. */
  114867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114868. /** @hidden */
  114869. _isLeftCamera: boolean;
  114870. /**
  114871. * Gets the left camera of a rig setup in case of Rigged Camera
  114872. */
  114873. get isLeftCamera(): boolean;
  114874. /** @hidden */
  114875. _isRightCamera: boolean;
  114876. /**
  114877. * Gets the right camera of a rig setup in case of Rigged Camera
  114878. */
  114879. get isRightCamera(): boolean;
  114880. /**
  114881. * Gets the left camera of a rig setup in case of Rigged Camera
  114882. */
  114883. get leftCamera(): Nullable<FreeCamera>;
  114884. /**
  114885. * Gets the right camera of a rig setup in case of Rigged Camera
  114886. */
  114887. get rightCamera(): Nullable<FreeCamera>;
  114888. /**
  114889. * Gets the left camera target of a rig setup in case of Rigged Camera
  114890. * @returns the target position
  114891. */
  114892. getLeftTarget(): Nullable<Vector3>;
  114893. /**
  114894. * Gets the right camera target of a rig setup in case of Rigged Camera
  114895. * @returns the target position
  114896. */
  114897. getRightTarget(): Nullable<Vector3>;
  114898. /**
  114899. * @hidden
  114900. */
  114901. setCameraRigMode(mode: number, rigParams: any): void;
  114902. /** @hidden */
  114903. static _setStereoscopicRigMode(camera: Camera): void;
  114904. /** @hidden */
  114905. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114906. /** @hidden */
  114907. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114908. /** @hidden */
  114909. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114910. /** @hidden */
  114911. _getVRProjectionMatrix(): Matrix;
  114912. protected _updateCameraRotationMatrix(): void;
  114913. protected _updateWebVRCameraRotationMatrix(): void;
  114914. /**
  114915. * This function MUST be overwritten by the different WebVR cameras available.
  114916. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114917. * @hidden
  114918. */
  114919. _getWebVRProjectionMatrix(): Matrix;
  114920. /**
  114921. * This function MUST be overwritten by the different WebVR cameras available.
  114922. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114923. * @hidden
  114924. */
  114925. _getWebVRViewMatrix(): Matrix;
  114926. /** @hidden */
  114927. setCameraRigParameter(name: string, value: any): void;
  114928. /**
  114929. * needs to be overridden by children so sub has required properties to be copied
  114930. * @hidden
  114931. */
  114932. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114933. /**
  114934. * May need to be overridden by children
  114935. * @hidden
  114936. */
  114937. _updateRigCameras(): void;
  114938. /** @hidden */
  114939. _setupInputs(): void;
  114940. /**
  114941. * Serialiaze the camera setup to a json represention
  114942. * @returns the JSON representation
  114943. */
  114944. serialize(): any;
  114945. /**
  114946. * Clones the current camera.
  114947. * @param name The cloned camera name
  114948. * @returns the cloned camera
  114949. */
  114950. clone(name: string): Camera;
  114951. /**
  114952. * Gets the direction of the camera relative to a given local axis.
  114953. * @param localAxis Defines the reference axis to provide a relative direction.
  114954. * @return the direction
  114955. */
  114956. getDirection(localAxis: Vector3): Vector3;
  114957. /**
  114958. * Returns the current camera absolute rotation
  114959. */
  114960. get absoluteRotation(): Quaternion;
  114961. /**
  114962. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114963. * @param localAxis Defines the reference axis to provide a relative direction.
  114964. * @param result Defines the vector to store the result in
  114965. */
  114966. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114967. /**
  114968. * Gets a camera constructor for a given camera type
  114969. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114970. * @param name The name of the camera the result will be able to instantiate
  114971. * @param scene The scene the result will construct the camera in
  114972. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114973. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114974. * @returns a factory method to construc the camera
  114975. */
  114976. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114977. /**
  114978. * Compute the world matrix of the camera.
  114979. * @returns the camera world matrix
  114980. */
  114981. computeWorldMatrix(): Matrix;
  114982. /**
  114983. * Parse a JSON and creates the camera from the parsed information
  114984. * @param parsedCamera The JSON to parse
  114985. * @param scene The scene to instantiate the camera in
  114986. * @returns the newly constructed camera
  114987. */
  114988. static Parse(parsedCamera: any, scene: Scene): Camera;
  114989. }
  114990. }
  114991. declare module BABYLON {
  114992. /**
  114993. * Class containing static functions to help procedurally build meshes
  114994. */
  114995. export class DiscBuilder {
  114996. /**
  114997. * Creates a plane polygonal mesh. By default, this is a disc
  114998. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114999. * * 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
  115000. * * 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
  115001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115004. * @param name defines the name of the mesh
  115005. * @param options defines the options used to create the mesh
  115006. * @param scene defines the hosting scene
  115007. * @returns the plane polygonal mesh
  115008. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115009. */
  115010. static CreateDisc(name: string, options: {
  115011. radius?: number;
  115012. tessellation?: number;
  115013. arc?: number;
  115014. updatable?: boolean;
  115015. sideOrientation?: number;
  115016. frontUVs?: Vector4;
  115017. backUVs?: Vector4;
  115018. }, scene?: Nullable<Scene>): Mesh;
  115019. }
  115020. }
  115021. declare module BABYLON {
  115022. /**
  115023. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115024. *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.
  115025. * The SPS is also a particle system. It provides some methods to manage the particles.
  115026. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115027. *
  115028. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115029. */
  115030. export class SolidParticleSystem implements IDisposable {
  115031. /**
  115032. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115033. * Example : var p = SPS.particles[i];
  115034. */
  115035. particles: SolidParticle[];
  115036. /**
  115037. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115038. */
  115039. nbParticles: number;
  115040. /**
  115041. * If the particles must ever face the camera (default false). Useful for planar particles.
  115042. */
  115043. billboard: boolean;
  115044. /**
  115045. * Recompute normals when adding a shape
  115046. */
  115047. recomputeNormals: boolean;
  115048. /**
  115049. * This a counter ofr your own usage. It's not set by any SPS functions.
  115050. */
  115051. counter: number;
  115052. /**
  115053. * The SPS name. This name is also given to the underlying mesh.
  115054. */
  115055. name: string;
  115056. /**
  115057. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115058. */
  115059. mesh: Mesh;
  115060. /**
  115061. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115062. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115063. */
  115064. vars: any;
  115065. /**
  115066. * This array is populated when the SPS is set as 'pickable'.
  115067. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115068. * Each element of this array is an object `{idx: int, faceId: int}`.
  115069. * `idx` is the picked particle index in the `SPS.particles` array
  115070. * `faceId` is the picked face index counted within this particle.
  115071. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115072. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115073. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115074. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115075. */
  115076. pickedParticles: {
  115077. idx: number;
  115078. faceId: number;
  115079. }[];
  115080. /**
  115081. * This array is populated when the SPS is set as 'pickable'
  115082. * Each key of this array is a submesh index.
  115083. * Each element of this array is a second array defined like this :
  115084. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115085. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115086. * `idx` is the picked particle index in the `SPS.particles` array
  115087. * `faceId` is the picked face index counted within this particle.
  115088. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115089. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115090. */
  115091. pickedBySubMesh: {
  115092. idx: number;
  115093. faceId: number;
  115094. }[][];
  115095. /**
  115096. * This array is populated when `enableDepthSort` is set to true.
  115097. * Each element of this array is an instance of the class DepthSortedParticle.
  115098. */
  115099. depthSortedParticles: DepthSortedParticle[];
  115100. /**
  115101. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115102. * @hidden
  115103. */
  115104. _bSphereOnly: boolean;
  115105. /**
  115106. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115107. * @hidden
  115108. */
  115109. _bSphereRadiusFactor: number;
  115110. private _scene;
  115111. private _positions;
  115112. private _indices;
  115113. private _normals;
  115114. private _colors;
  115115. private _uvs;
  115116. private _indices32;
  115117. private _positions32;
  115118. private _normals32;
  115119. private _fixedNormal32;
  115120. private _colors32;
  115121. private _uvs32;
  115122. private _index;
  115123. private _updatable;
  115124. private _pickable;
  115125. private _isVisibilityBoxLocked;
  115126. private _alwaysVisible;
  115127. private _depthSort;
  115128. private _expandable;
  115129. private _shapeCounter;
  115130. private _copy;
  115131. private _color;
  115132. private _computeParticleColor;
  115133. private _computeParticleTexture;
  115134. private _computeParticleRotation;
  115135. private _computeParticleVertex;
  115136. private _computeBoundingBox;
  115137. private _depthSortParticles;
  115138. private _camera;
  115139. private _mustUnrotateFixedNormals;
  115140. private _particlesIntersect;
  115141. private _needs32Bits;
  115142. private _isNotBuilt;
  115143. private _lastParticleId;
  115144. private _idxOfId;
  115145. private _multimaterialEnabled;
  115146. private _useModelMaterial;
  115147. private _indicesByMaterial;
  115148. private _materialIndexes;
  115149. private _depthSortFunction;
  115150. private _materialSortFunction;
  115151. private _materials;
  115152. private _multimaterial;
  115153. private _materialIndexesById;
  115154. private _defaultMaterial;
  115155. private _autoUpdateSubMeshes;
  115156. private _tmpVertex;
  115157. /**
  115158. * Creates a SPS (Solid Particle System) object.
  115159. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115160. * @param scene (Scene) is the scene in which the SPS is added.
  115161. * @param options defines the options of the sps e.g.
  115162. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115163. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115164. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115165. * * 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.
  115166. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115167. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115168. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115169. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115170. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115171. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115172. */
  115173. constructor(name: string, scene: Scene, options?: {
  115174. updatable?: boolean;
  115175. isPickable?: boolean;
  115176. enableDepthSort?: boolean;
  115177. particleIntersection?: boolean;
  115178. boundingSphereOnly?: boolean;
  115179. bSphereRadiusFactor?: number;
  115180. expandable?: boolean;
  115181. useModelMaterial?: boolean;
  115182. enableMultiMaterial?: boolean;
  115183. });
  115184. /**
  115185. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115186. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115187. * @returns the created mesh
  115188. */
  115189. buildMesh(): Mesh;
  115190. /**
  115191. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115192. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115193. * Thus the particles generated from `digest()` have their property `position` set yet.
  115194. * @param mesh ( Mesh ) is the mesh to be digested
  115195. * @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
  115196. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115197. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115198. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115199. * @returns the current SPS
  115200. */
  115201. digest(mesh: Mesh, options?: {
  115202. facetNb?: number;
  115203. number?: number;
  115204. delta?: number;
  115205. storage?: [];
  115206. }): SolidParticleSystem;
  115207. /**
  115208. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115209. * @hidden
  115210. */
  115211. private _unrotateFixedNormals;
  115212. /**
  115213. * Resets the temporary working copy particle
  115214. * @hidden
  115215. */
  115216. private _resetCopy;
  115217. /**
  115218. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115219. * @param p the current index in the positions array to be updated
  115220. * @param ind the current index in the indices array
  115221. * @param shape a Vector3 array, the shape geometry
  115222. * @param positions the positions array to be updated
  115223. * @param meshInd the shape indices array
  115224. * @param indices the indices array to be updated
  115225. * @param meshUV the shape uv array
  115226. * @param uvs the uv array to be updated
  115227. * @param meshCol the shape color array
  115228. * @param colors the color array to be updated
  115229. * @param meshNor the shape normals array
  115230. * @param normals the normals array to be updated
  115231. * @param idx the particle index
  115232. * @param idxInShape the particle index in its shape
  115233. * @param options the addShape() method passed options
  115234. * @model the particle model
  115235. * @hidden
  115236. */
  115237. private _meshBuilder;
  115238. /**
  115239. * Returns a shape Vector3 array from positions float array
  115240. * @param positions float array
  115241. * @returns a vector3 array
  115242. * @hidden
  115243. */
  115244. private _posToShape;
  115245. /**
  115246. * Returns a shapeUV array from a float uvs (array deep copy)
  115247. * @param uvs as a float array
  115248. * @returns a shapeUV array
  115249. * @hidden
  115250. */
  115251. private _uvsToShapeUV;
  115252. /**
  115253. * Adds a new particle object in the particles array
  115254. * @param idx particle index in particles array
  115255. * @param id particle id
  115256. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115257. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115258. * @param model particle ModelShape object
  115259. * @param shapeId model shape identifier
  115260. * @param idxInShape index of the particle in the current model
  115261. * @param bInfo model bounding info object
  115262. * @param storage target storage array, if any
  115263. * @hidden
  115264. */
  115265. private _addParticle;
  115266. /**
  115267. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115268. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115269. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115270. * @param nb (positive integer) the number of particles to be created from this model
  115271. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115272. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115273. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115274. * @returns the number of shapes in the system
  115275. */
  115276. addShape(mesh: Mesh, nb: number, options?: {
  115277. positionFunction?: any;
  115278. vertexFunction?: any;
  115279. storage?: [];
  115280. }): number;
  115281. /**
  115282. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115283. * @hidden
  115284. */
  115285. private _rebuildParticle;
  115286. /**
  115287. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115288. * @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.
  115289. * @returns the SPS.
  115290. */
  115291. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115292. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115293. * Returns an array with the removed particles.
  115294. * 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.
  115295. * The SPS can't be empty so at least one particle needs to remain in place.
  115296. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115297. * @param start index of the first particle to remove
  115298. * @param end index of the last particle to remove (included)
  115299. * @returns an array populated with the removed particles
  115300. */
  115301. removeParticles(start: number, end: number): SolidParticle[];
  115302. /**
  115303. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115304. * @param solidParticleArray an array populated with Solid Particles objects
  115305. * @returns the SPS
  115306. */
  115307. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115308. /**
  115309. * Creates a new particle and modifies the SPS mesh geometry :
  115310. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115311. * - calls _addParticle() to populate the particle array
  115312. * factorized code from addShape() and insertParticlesFromArray()
  115313. * @param idx particle index in the particles array
  115314. * @param i particle index in its shape
  115315. * @param modelShape particle ModelShape object
  115316. * @param shape shape vertex array
  115317. * @param meshInd shape indices array
  115318. * @param meshUV shape uv array
  115319. * @param meshCol shape color array
  115320. * @param meshNor shape normals array
  115321. * @param bbInfo shape bounding info
  115322. * @param storage target particle storage
  115323. * @options addShape() passed options
  115324. * @hidden
  115325. */
  115326. private _insertNewParticle;
  115327. /**
  115328. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115329. * This method calls `updateParticle()` for each particle of the SPS.
  115330. * For an animated SPS, it is usually called within the render loop.
  115331. * 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.
  115332. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115333. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115334. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115335. * @returns the SPS.
  115336. */
  115337. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115338. /**
  115339. * Disposes the SPS.
  115340. */
  115341. dispose(): void;
  115342. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115343. * idx is the particle index in the SPS
  115344. * faceId is the picked face index counted within this particle.
  115345. * Returns null if the pickInfo can't identify a picked particle.
  115346. * @param pickingInfo (PickingInfo object)
  115347. * @returns {idx: number, faceId: number} or null
  115348. */
  115349. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115350. idx: number;
  115351. faceId: number;
  115352. }>;
  115353. /**
  115354. * Returns a SolidParticle object from its identifier : particle.id
  115355. * @param id (integer) the particle Id
  115356. * @returns the searched particle or null if not found in the SPS.
  115357. */
  115358. getParticleById(id: number): Nullable<SolidParticle>;
  115359. /**
  115360. * Returns a new array populated with the particles having the passed shapeId.
  115361. * @param shapeId (integer) the shape identifier
  115362. * @returns a new solid particle array
  115363. */
  115364. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115365. /**
  115366. * Populates the passed array "ref" with the particles having the passed shapeId.
  115367. * @param shapeId the shape identifier
  115368. * @returns the SPS
  115369. * @param ref
  115370. */
  115371. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115372. /**
  115373. * Computes the required SubMeshes according the materials assigned to the particles.
  115374. * @returns the solid particle system.
  115375. * Does nothing if called before the SPS mesh is built.
  115376. */
  115377. computeSubMeshes(): SolidParticleSystem;
  115378. /**
  115379. * Sorts the solid particles by material when MultiMaterial is enabled.
  115380. * Updates the indices32 array.
  115381. * Updates the indicesByMaterial array.
  115382. * Updates the mesh indices array.
  115383. * @returns the SPS
  115384. * @hidden
  115385. */
  115386. private _sortParticlesByMaterial;
  115387. /**
  115388. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115389. * @hidden
  115390. */
  115391. private _setMaterialIndexesById;
  115392. /**
  115393. * Returns an array with unique values of Materials from the passed array
  115394. * @param array the material array to be checked and filtered
  115395. * @hidden
  115396. */
  115397. private _filterUniqueMaterialId;
  115398. /**
  115399. * Sets a new Standard Material as _defaultMaterial if not already set.
  115400. * @hidden
  115401. */
  115402. private _setDefaultMaterial;
  115403. /**
  115404. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115405. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115406. * @returns the SPS.
  115407. */
  115408. refreshVisibleSize(): SolidParticleSystem;
  115409. /**
  115410. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115411. * @param size the size (float) of the visibility box
  115412. * note : this doesn't lock the SPS mesh bounding box.
  115413. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115414. */
  115415. setVisibilityBox(size: number): void;
  115416. /**
  115417. * Gets whether the SPS as always visible or not
  115418. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115419. */
  115420. get isAlwaysVisible(): boolean;
  115421. /**
  115422. * Sets the SPS as always visible or not
  115423. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115424. */
  115425. set isAlwaysVisible(val: boolean);
  115426. /**
  115427. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115428. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115429. */
  115430. set isVisibilityBoxLocked(val: boolean);
  115431. /**
  115432. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115433. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115434. */
  115435. get isVisibilityBoxLocked(): boolean;
  115436. /**
  115437. * Tells to `setParticles()` to compute the particle rotations or not.
  115438. * Default value : true. The SPS is faster when it's set to false.
  115439. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115440. */
  115441. set computeParticleRotation(val: boolean);
  115442. /**
  115443. * Tells to `setParticles()` to compute the particle colors or not.
  115444. * Default value : true. The SPS is faster when it's set to false.
  115445. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115446. */
  115447. set computeParticleColor(val: boolean);
  115448. set computeParticleTexture(val: boolean);
  115449. /**
  115450. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115451. * Default value : false. The SPS is faster when it's set to false.
  115452. * Note : the particle custom vertex positions aren't stored values.
  115453. */
  115454. set computeParticleVertex(val: boolean);
  115455. /**
  115456. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115457. */
  115458. set computeBoundingBox(val: boolean);
  115459. /**
  115460. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115461. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115462. * Default : `true`
  115463. */
  115464. set depthSortParticles(val: boolean);
  115465. /**
  115466. * Gets if `setParticles()` computes the particle rotations or not.
  115467. * Default value : true. The SPS is faster when it's set to false.
  115468. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115469. */
  115470. get computeParticleRotation(): boolean;
  115471. /**
  115472. * Gets if `setParticles()` computes the particle colors or not.
  115473. * Default value : true. The SPS is faster when it's set to false.
  115474. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115475. */
  115476. get computeParticleColor(): boolean;
  115477. /**
  115478. * Gets if `setParticles()` computes the particle textures or not.
  115479. * Default value : true. The SPS is faster when it's set to false.
  115480. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115481. */
  115482. get computeParticleTexture(): boolean;
  115483. /**
  115484. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115485. * Default value : false. The SPS is faster when it's set to false.
  115486. * Note : the particle custom vertex positions aren't stored values.
  115487. */
  115488. get computeParticleVertex(): boolean;
  115489. /**
  115490. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115491. */
  115492. get computeBoundingBox(): boolean;
  115493. /**
  115494. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115495. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115496. * Default : `true`
  115497. */
  115498. get depthSortParticles(): boolean;
  115499. /**
  115500. * Gets if the SPS is created as expandable at construction time.
  115501. * Default : `false`
  115502. */
  115503. get expandable(): boolean;
  115504. /**
  115505. * Gets if the SPS supports the Multi Materials
  115506. */
  115507. get multimaterialEnabled(): boolean;
  115508. /**
  115509. * Gets if the SPS uses the model materials for its own multimaterial.
  115510. */
  115511. get useModelMaterial(): boolean;
  115512. /**
  115513. * The SPS used material array.
  115514. */
  115515. get materials(): Material[];
  115516. /**
  115517. * Sets the SPS MultiMaterial from the passed materials.
  115518. * Note : the passed array is internally copied and not used then by reference.
  115519. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115520. */
  115521. setMultiMaterial(materials: Material[]): void;
  115522. /**
  115523. * The SPS computed multimaterial object
  115524. */
  115525. get multimaterial(): MultiMaterial;
  115526. set multimaterial(mm: MultiMaterial);
  115527. /**
  115528. * If the subMeshes must be updated on the next call to setParticles()
  115529. */
  115530. get autoUpdateSubMeshes(): boolean;
  115531. set autoUpdateSubMeshes(val: boolean);
  115532. /**
  115533. * This function does nothing. It may be overwritten to set all the particle first values.
  115534. * The SPS doesn't call this function, you may have to call it by your own.
  115535. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115536. */
  115537. initParticles(): void;
  115538. /**
  115539. * This function does nothing. It may be overwritten to recycle a particle.
  115540. * The SPS doesn't call this function, you may have to call it by your own.
  115541. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115542. * @param particle The particle to recycle
  115543. * @returns the recycled particle
  115544. */
  115545. recycleParticle(particle: SolidParticle): SolidParticle;
  115546. /**
  115547. * Updates a particle : this function should be overwritten by the user.
  115548. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115549. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115550. * @example : just set a particle position or velocity and recycle conditions
  115551. * @param particle The particle to update
  115552. * @returns the updated particle
  115553. */
  115554. updateParticle(particle: SolidParticle): SolidParticle;
  115555. /**
  115556. * Updates a vertex of a particle : it can be overwritten by the user.
  115557. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115558. * @param particle the current particle
  115559. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115560. * @param pt the index of the current vertex in the particle shape
  115561. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115562. * @example : just set a vertex particle position or color
  115563. * @returns the sps
  115564. */
  115565. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115566. /**
  115567. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115568. * This does nothing and may be overwritten by the user.
  115569. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115570. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115571. * @param update the boolean update value actually passed to setParticles()
  115572. */
  115573. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115574. /**
  115575. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115576. * This will be passed three parameters.
  115577. * This does nothing and may be overwritten by the user.
  115578. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115579. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115580. * @param update the boolean update value actually passed to setParticles()
  115581. */
  115582. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115583. }
  115584. }
  115585. declare module BABYLON {
  115586. /**
  115587. * Represents one particle of a solid particle system.
  115588. */
  115589. export class SolidParticle {
  115590. /**
  115591. * particle global index
  115592. */
  115593. idx: number;
  115594. /**
  115595. * particle identifier
  115596. */
  115597. id: number;
  115598. /**
  115599. * The color of the particle
  115600. */
  115601. color: Nullable<Color4>;
  115602. /**
  115603. * The world space position of the particle.
  115604. */
  115605. position: Vector3;
  115606. /**
  115607. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115608. */
  115609. rotation: Vector3;
  115610. /**
  115611. * The world space rotation quaternion of the particle.
  115612. */
  115613. rotationQuaternion: Nullable<Quaternion>;
  115614. /**
  115615. * The scaling of the particle.
  115616. */
  115617. scaling: Vector3;
  115618. /**
  115619. * The uvs of the particle.
  115620. */
  115621. uvs: Vector4;
  115622. /**
  115623. * The current speed of the particle.
  115624. */
  115625. velocity: Vector3;
  115626. /**
  115627. * The pivot point in the particle local space.
  115628. */
  115629. pivot: Vector3;
  115630. /**
  115631. * Must the particle be translated from its pivot point in its local space ?
  115632. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115633. * Default : false
  115634. */
  115635. translateFromPivot: boolean;
  115636. /**
  115637. * Is the particle active or not ?
  115638. */
  115639. alive: boolean;
  115640. /**
  115641. * Is the particle visible or not ?
  115642. */
  115643. isVisible: boolean;
  115644. /**
  115645. * Index of this particle in the global "positions" array (Internal use)
  115646. * @hidden
  115647. */
  115648. _pos: number;
  115649. /**
  115650. * @hidden Index of this particle in the global "indices" array (Internal use)
  115651. */
  115652. _ind: number;
  115653. /**
  115654. * @hidden ModelShape of this particle (Internal use)
  115655. */
  115656. _model: ModelShape;
  115657. /**
  115658. * ModelShape id of this particle
  115659. */
  115660. shapeId: number;
  115661. /**
  115662. * Index of the particle in its shape id
  115663. */
  115664. idxInShape: number;
  115665. /**
  115666. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115667. */
  115668. _modelBoundingInfo: BoundingInfo;
  115669. /**
  115670. * @hidden Particle BoundingInfo object (Internal use)
  115671. */
  115672. _boundingInfo: BoundingInfo;
  115673. /**
  115674. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115675. */
  115676. _sps: SolidParticleSystem;
  115677. /**
  115678. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115679. */
  115680. _stillInvisible: boolean;
  115681. /**
  115682. * @hidden Last computed particle rotation matrix
  115683. */
  115684. _rotationMatrix: number[];
  115685. /**
  115686. * Parent particle Id, if any.
  115687. * Default null.
  115688. */
  115689. parentId: Nullable<number>;
  115690. /**
  115691. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115692. */
  115693. materialIndex: Nullable<number>;
  115694. /**
  115695. * Custom object or properties.
  115696. */
  115697. props: Nullable<any>;
  115698. /**
  115699. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115700. * The possible values are :
  115701. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115702. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115703. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115704. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115705. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115706. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115707. * */
  115708. cullingStrategy: number;
  115709. /**
  115710. * @hidden Internal global position in the SPS.
  115711. */
  115712. _globalPosition: Vector3;
  115713. /**
  115714. * Creates a Solid Particle object.
  115715. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115716. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115717. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115718. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115719. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115720. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115721. * @param shapeId (integer) is the model shape identifier in the SPS.
  115722. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115723. * @param sps defines the sps it is associated to
  115724. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115725. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115726. */
  115727. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115728. /**
  115729. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115730. * @param target the particle target
  115731. * @returns the current particle
  115732. */
  115733. copyToRef(target: SolidParticle): SolidParticle;
  115734. /**
  115735. * Legacy support, changed scale to scaling
  115736. */
  115737. get scale(): Vector3;
  115738. /**
  115739. * Legacy support, changed scale to scaling
  115740. */
  115741. set scale(scale: Vector3);
  115742. /**
  115743. * Legacy support, changed quaternion to rotationQuaternion
  115744. */
  115745. get quaternion(): Nullable<Quaternion>;
  115746. /**
  115747. * Legacy support, changed quaternion to rotationQuaternion
  115748. */
  115749. set quaternion(q: Nullable<Quaternion>);
  115750. /**
  115751. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115752. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115753. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115754. * @returns true if it intersects
  115755. */
  115756. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115757. /**
  115758. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115759. * A particle is in the frustum if its bounding box intersects the frustum
  115760. * @param frustumPlanes defines the frustum to test
  115761. * @returns true if the particle is in the frustum planes
  115762. */
  115763. isInFrustum(frustumPlanes: Plane[]): boolean;
  115764. /**
  115765. * get the rotation matrix of the particle
  115766. * @hidden
  115767. */
  115768. getRotationMatrix(m: Matrix): void;
  115769. }
  115770. /**
  115771. * Represents the shape of the model used by one particle of a solid particle system.
  115772. * SPS internal tool, don't use it manually.
  115773. */
  115774. export class ModelShape {
  115775. /**
  115776. * The shape id
  115777. * @hidden
  115778. */
  115779. shapeID: number;
  115780. /**
  115781. * flat array of model positions (internal use)
  115782. * @hidden
  115783. */
  115784. _shape: Vector3[];
  115785. /**
  115786. * flat array of model UVs (internal use)
  115787. * @hidden
  115788. */
  115789. _shapeUV: number[];
  115790. /**
  115791. * color array of the model
  115792. * @hidden
  115793. */
  115794. _shapeColors: number[];
  115795. /**
  115796. * indices array of the model
  115797. * @hidden
  115798. */
  115799. _indices: number[];
  115800. /**
  115801. * normals array of the model
  115802. * @hidden
  115803. */
  115804. _normals: number[];
  115805. /**
  115806. * length of the shape in the model indices array (internal use)
  115807. * @hidden
  115808. */
  115809. _indicesLength: number;
  115810. /**
  115811. * Custom position function (internal use)
  115812. * @hidden
  115813. */
  115814. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115815. /**
  115816. * Custom vertex function (internal use)
  115817. * @hidden
  115818. */
  115819. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115820. /**
  115821. * Model material (internal use)
  115822. * @hidden
  115823. */
  115824. _material: Nullable<Material>;
  115825. /**
  115826. * 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.
  115827. * SPS internal tool, don't use it manually.
  115828. * @hidden
  115829. */
  115830. 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>);
  115831. }
  115832. /**
  115833. * Represents a Depth Sorted Particle in the solid particle system.
  115834. * @hidden
  115835. */
  115836. export class DepthSortedParticle {
  115837. /**
  115838. * Particle index
  115839. */
  115840. idx: number;
  115841. /**
  115842. * Index of the particle in the "indices" array
  115843. */
  115844. ind: number;
  115845. /**
  115846. * Length of the particle shape in the "indices" array
  115847. */
  115848. indicesLength: number;
  115849. /**
  115850. * Squared distance from the particle to the camera
  115851. */
  115852. sqDistance: number;
  115853. /**
  115854. * Material index when used with MultiMaterials
  115855. */
  115856. materialIndex: number;
  115857. /**
  115858. * Creates a new sorted particle
  115859. * @param materialIndex
  115860. */
  115861. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115862. }
  115863. /**
  115864. * Represents a solid particle vertex
  115865. */
  115866. export class SolidParticleVertex {
  115867. /**
  115868. * Vertex position
  115869. */
  115870. position: Vector3;
  115871. /**
  115872. * Vertex color
  115873. */
  115874. color: Color4;
  115875. /**
  115876. * Vertex UV
  115877. */
  115878. uv: Vector2;
  115879. /**
  115880. * Creates a new solid particle vertex
  115881. */
  115882. constructor();
  115883. /** Vertex x coordinate */
  115884. get x(): number;
  115885. set x(val: number);
  115886. /** Vertex y coordinate */
  115887. get y(): number;
  115888. set y(val: number);
  115889. /** Vertex z coordinate */
  115890. get z(): number;
  115891. set z(val: number);
  115892. }
  115893. }
  115894. declare module BABYLON {
  115895. /**
  115896. * @hidden
  115897. */
  115898. export class _MeshCollisionData {
  115899. _checkCollisions: boolean;
  115900. _collisionMask: number;
  115901. _collisionGroup: number;
  115902. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115903. _collider: Nullable<Collider>;
  115904. _oldPositionForCollisions: Vector3;
  115905. _diffPositionForCollisions: Vector3;
  115906. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115907. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115908. _collisionResponse: boolean;
  115909. }
  115910. }
  115911. declare module BABYLON {
  115912. /** @hidden */
  115913. class _FacetDataStorage {
  115914. facetPositions: Vector3[];
  115915. facetNormals: Vector3[];
  115916. facetPartitioning: number[][];
  115917. facetNb: number;
  115918. partitioningSubdivisions: number;
  115919. partitioningBBoxRatio: number;
  115920. facetDataEnabled: boolean;
  115921. facetParameters: any;
  115922. bbSize: Vector3;
  115923. subDiv: {
  115924. max: number;
  115925. X: number;
  115926. Y: number;
  115927. Z: number;
  115928. };
  115929. facetDepthSort: boolean;
  115930. facetDepthSortEnabled: boolean;
  115931. depthSortedIndices: IndicesArray;
  115932. depthSortedFacets: {
  115933. ind: number;
  115934. sqDistance: number;
  115935. }[];
  115936. facetDepthSortFunction: (f1: {
  115937. ind: number;
  115938. sqDistance: number;
  115939. }, f2: {
  115940. ind: number;
  115941. sqDistance: number;
  115942. }) => number;
  115943. facetDepthSortFrom: Vector3;
  115944. facetDepthSortOrigin: Vector3;
  115945. invertedMatrix: Matrix;
  115946. }
  115947. /**
  115948. * @hidden
  115949. **/
  115950. class _InternalAbstractMeshDataInfo {
  115951. _hasVertexAlpha: boolean;
  115952. _useVertexColors: boolean;
  115953. _numBoneInfluencers: number;
  115954. _applyFog: boolean;
  115955. _receiveShadows: boolean;
  115956. _facetData: _FacetDataStorage;
  115957. _visibility: number;
  115958. _skeleton: Nullable<Skeleton>;
  115959. _layerMask: number;
  115960. _computeBonesUsingShaders: boolean;
  115961. _isActive: boolean;
  115962. _onlyForInstances: boolean;
  115963. _isActiveIntermediate: boolean;
  115964. _onlyForInstancesIntermediate: boolean;
  115965. _actAsRegularMesh: boolean;
  115966. _currentLOD: Nullable<AbstractMesh>;
  115967. }
  115968. /**
  115969. * Class used to store all common mesh properties
  115970. */
  115971. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115972. /** No occlusion */
  115973. static OCCLUSION_TYPE_NONE: number;
  115974. /** Occlusion set to optimisitic */
  115975. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115976. /** Occlusion set to strict */
  115977. static OCCLUSION_TYPE_STRICT: number;
  115978. /** Use an accurante occlusion algorithm */
  115979. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115980. /** Use a conservative occlusion algorithm */
  115981. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115983. * Test order :
  115984. * Is the bounding sphere outside the frustum ?
  115985. * If not, are the bounding box vertices outside the frustum ?
  115986. * It not, then the cullable object is in the frustum.
  115987. */
  115988. static readonly CULLINGSTRATEGY_STANDARD: number;
  115989. /** Culling strategy : Bounding Sphere Only.
  115990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115991. * It's also less accurate than the standard because some not visible objects can still be selected.
  115992. * Test : is the bounding sphere outside the frustum ?
  115993. * If not, then the cullable object is in the frustum.
  115994. */
  115995. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115996. /** Culling strategy : Optimistic Inclusion.
  115997. * This in an inclusion test first, then the standard exclusion test.
  115998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115999. * 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.
  116000. * Anyway, it's as accurate as the standard strategy.
  116001. * Test :
  116002. * Is the cullable object bounding sphere center in the frustum ?
  116003. * If not, apply the default culling strategy.
  116004. */
  116005. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116009. * 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.
  116010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116011. * Test :
  116012. * Is the cullable object bounding sphere center in the frustum ?
  116013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116014. */
  116015. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116016. /**
  116017. * No billboard
  116018. */
  116019. static get BILLBOARDMODE_NONE(): number;
  116020. /** Billboard on X axis */
  116021. static get BILLBOARDMODE_X(): number;
  116022. /** Billboard on Y axis */
  116023. static get BILLBOARDMODE_Y(): number;
  116024. /** Billboard on Z axis */
  116025. static get BILLBOARDMODE_Z(): number;
  116026. /** Billboard on all axes */
  116027. static get BILLBOARDMODE_ALL(): number;
  116028. /** Billboard on using position instead of orientation */
  116029. static get BILLBOARDMODE_USE_POSITION(): number;
  116030. /** @hidden */
  116031. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116032. /**
  116033. * The culling strategy to use to check whether the mesh must be rendered or not.
  116034. * This value can be changed at any time and will be used on the next render mesh selection.
  116035. * The possible values are :
  116036. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116037. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116038. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116039. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116040. * Please read each static variable documentation to get details about the culling process.
  116041. * */
  116042. cullingStrategy: number;
  116043. /**
  116044. * Gets the number of facets in the mesh
  116045. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116046. */
  116047. get facetNb(): number;
  116048. /**
  116049. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116050. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116051. */
  116052. get partitioningSubdivisions(): number;
  116053. set partitioningSubdivisions(nb: number);
  116054. /**
  116055. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116056. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116057. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116058. */
  116059. get partitioningBBoxRatio(): number;
  116060. set partitioningBBoxRatio(ratio: number);
  116061. /**
  116062. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116063. * Works only for updatable meshes.
  116064. * Doesn't work with multi-materials
  116065. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116066. */
  116067. get mustDepthSortFacets(): boolean;
  116068. set mustDepthSortFacets(sort: boolean);
  116069. /**
  116070. * The location (Vector3) where the facet depth sort must be computed from.
  116071. * By default, the active camera position.
  116072. * Used only when facet depth sort is enabled
  116073. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116074. */
  116075. get facetDepthSortFrom(): Vector3;
  116076. set facetDepthSortFrom(location: Vector3);
  116077. /**
  116078. * gets a boolean indicating if facetData is enabled
  116079. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116080. */
  116081. get isFacetDataEnabled(): boolean;
  116082. /** @hidden */
  116083. _updateNonUniformScalingState(value: boolean): boolean;
  116084. /**
  116085. * An event triggered when this mesh collides with another one
  116086. */
  116087. onCollideObservable: Observable<AbstractMesh>;
  116088. /** Set a function to call when this mesh collides with another one */
  116089. set onCollide(callback: () => void);
  116090. /**
  116091. * An event triggered when the collision's position changes
  116092. */
  116093. onCollisionPositionChangeObservable: Observable<Vector3>;
  116094. /** Set a function to call when the collision's position changes */
  116095. set onCollisionPositionChange(callback: () => void);
  116096. /**
  116097. * An event triggered when material is changed
  116098. */
  116099. onMaterialChangedObservable: Observable<AbstractMesh>;
  116100. /**
  116101. * Gets or sets the orientation for POV movement & rotation
  116102. */
  116103. definedFacingForward: boolean;
  116104. /** @hidden */
  116105. _occlusionQuery: Nullable<WebGLQuery>;
  116106. /** @hidden */
  116107. _renderingGroup: Nullable<RenderingGroup>;
  116108. /**
  116109. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116110. */
  116111. get visibility(): number;
  116112. /**
  116113. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116114. */
  116115. set visibility(value: number);
  116116. /** Gets or sets the alpha index used to sort transparent meshes
  116117. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116118. */
  116119. alphaIndex: number;
  116120. /**
  116121. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116122. */
  116123. isVisible: boolean;
  116124. /**
  116125. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116126. */
  116127. isPickable: boolean;
  116128. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116129. showSubMeshesBoundingBox: boolean;
  116130. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116131. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116132. */
  116133. isBlocker: boolean;
  116134. /**
  116135. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116136. */
  116137. enablePointerMoveEvents: boolean;
  116138. private _renderingGroupId;
  116139. /**
  116140. * Specifies the rendering group id for this mesh (0 by default)
  116141. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116142. */
  116143. get renderingGroupId(): number;
  116144. set renderingGroupId(value: number);
  116145. private _material;
  116146. /** Gets or sets current material */
  116147. get material(): Nullable<Material>;
  116148. set material(value: Nullable<Material>);
  116149. /**
  116150. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116151. * @see https://doc.babylonjs.com/babylon101/shadows
  116152. */
  116153. get receiveShadows(): boolean;
  116154. set receiveShadows(value: boolean);
  116155. /** Defines color to use when rendering outline */
  116156. outlineColor: Color3;
  116157. /** Define width to use when rendering outline */
  116158. outlineWidth: number;
  116159. /** Defines color to use when rendering overlay */
  116160. overlayColor: Color3;
  116161. /** Defines alpha to use when rendering overlay */
  116162. overlayAlpha: number;
  116163. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116164. get hasVertexAlpha(): boolean;
  116165. set hasVertexAlpha(value: boolean);
  116166. /** 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) */
  116167. get useVertexColors(): boolean;
  116168. set useVertexColors(value: boolean);
  116169. /**
  116170. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116171. */
  116172. get computeBonesUsingShaders(): boolean;
  116173. set computeBonesUsingShaders(value: boolean);
  116174. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116175. get numBoneInfluencers(): number;
  116176. set numBoneInfluencers(value: number);
  116177. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116178. get applyFog(): boolean;
  116179. set applyFog(value: boolean);
  116180. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116181. useOctreeForRenderingSelection: boolean;
  116182. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116183. useOctreeForPicking: boolean;
  116184. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116185. useOctreeForCollisions: boolean;
  116186. /**
  116187. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116188. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116189. */
  116190. get layerMask(): number;
  116191. set layerMask(value: number);
  116192. /**
  116193. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116194. */
  116195. alwaysSelectAsActiveMesh: boolean;
  116196. /**
  116197. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116198. */
  116199. doNotSyncBoundingInfo: boolean;
  116200. /**
  116201. * Gets or sets the current action manager
  116202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116203. */
  116204. actionManager: Nullable<AbstractActionManager>;
  116205. private _meshCollisionData;
  116206. /**
  116207. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116208. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116209. */
  116210. ellipsoid: Vector3;
  116211. /**
  116212. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116213. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116214. */
  116215. ellipsoidOffset: Vector3;
  116216. /**
  116217. * Gets or sets a collision mask used to mask collisions (default is -1).
  116218. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116219. */
  116220. get collisionMask(): number;
  116221. set collisionMask(mask: number);
  116222. /**
  116223. * Gets or sets a collision response flag (default is true).
  116224. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116225. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116226. * to respond to the collision.
  116227. */
  116228. get collisionResponse(): boolean;
  116229. set collisionResponse(response: boolean);
  116230. /**
  116231. * Gets or sets the current collision group mask (-1 by default).
  116232. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116233. */
  116234. get collisionGroup(): number;
  116235. set collisionGroup(mask: number);
  116236. /**
  116237. * Gets or sets current surrounding meshes (null by default).
  116238. *
  116239. * By default collision detection is tested against every mesh in the scene.
  116240. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116241. * meshes will be tested for the collision.
  116242. *
  116243. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116244. */
  116245. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116246. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116247. /**
  116248. * Defines edge width used when edgesRenderer is enabled
  116249. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116250. */
  116251. edgesWidth: number;
  116252. /**
  116253. * Defines edge color used when edgesRenderer is enabled
  116254. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116255. */
  116256. edgesColor: Color4;
  116257. /** @hidden */
  116258. _edgesRenderer: Nullable<IEdgesRenderer>;
  116259. /** @hidden */
  116260. _masterMesh: Nullable<AbstractMesh>;
  116261. /** @hidden */
  116262. _boundingInfo: Nullable<BoundingInfo>;
  116263. /** @hidden */
  116264. _renderId: number;
  116265. /**
  116266. * Gets or sets the list of subMeshes
  116267. * @see https://doc.babylonjs.com/how_to/multi_materials
  116268. */
  116269. subMeshes: SubMesh[];
  116270. /** @hidden */
  116271. _intersectionsInProgress: AbstractMesh[];
  116272. /** @hidden */
  116273. _unIndexed: boolean;
  116274. /** @hidden */
  116275. _lightSources: Light[];
  116276. /** Gets the list of lights affecting that mesh */
  116277. get lightSources(): Light[];
  116278. /** @hidden */
  116279. get _positions(): Nullable<Vector3[]>;
  116280. /** @hidden */
  116281. _waitingData: {
  116282. lods: Nullable<any>;
  116283. actions: Nullable<any>;
  116284. freezeWorldMatrix: Nullable<boolean>;
  116285. };
  116286. /** @hidden */
  116287. _bonesTransformMatrices: Nullable<Float32Array>;
  116288. /** @hidden */
  116289. _transformMatrixTexture: Nullable<RawTexture>;
  116290. /**
  116291. * Gets or sets a skeleton to apply skining transformations
  116292. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116293. */
  116294. set skeleton(value: Nullable<Skeleton>);
  116295. get skeleton(): Nullable<Skeleton>;
  116296. /**
  116297. * An event triggered when the mesh is rebuilt.
  116298. */
  116299. onRebuildObservable: Observable<AbstractMesh>;
  116300. /**
  116301. * Creates a new AbstractMesh
  116302. * @param name defines the name of the mesh
  116303. * @param scene defines the hosting scene
  116304. */
  116305. constructor(name: string, scene?: Nullable<Scene>);
  116306. /**
  116307. * Returns the string "AbstractMesh"
  116308. * @returns "AbstractMesh"
  116309. */
  116310. getClassName(): string;
  116311. /**
  116312. * Gets a string representation of the current mesh
  116313. * @param fullDetails defines a boolean indicating if full details must be included
  116314. * @returns a string representation of the current mesh
  116315. */
  116316. toString(fullDetails?: boolean): string;
  116317. /**
  116318. * @hidden
  116319. */
  116320. protected _getEffectiveParent(): Nullable<Node>;
  116321. /** @hidden */
  116322. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116323. /** @hidden */
  116324. _rebuild(): void;
  116325. /** @hidden */
  116326. _resyncLightSources(): void;
  116327. /** @hidden */
  116328. _resyncLightSource(light: Light): void;
  116329. /** @hidden */
  116330. _unBindEffect(): void;
  116331. /** @hidden */
  116332. _removeLightSource(light: Light, dispose: boolean): void;
  116333. private _markSubMeshesAsDirty;
  116334. /** @hidden */
  116335. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116336. /** @hidden */
  116337. _markSubMeshesAsAttributesDirty(): void;
  116338. /** @hidden */
  116339. _markSubMeshesAsMiscDirty(): void;
  116340. /**
  116341. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116342. */
  116343. get scaling(): Vector3;
  116344. set scaling(newScaling: Vector3);
  116345. /**
  116346. * Returns true if the mesh is blocked. Implemented by child classes
  116347. */
  116348. get isBlocked(): boolean;
  116349. /**
  116350. * Returns the mesh itself by default. Implemented by child classes
  116351. * @param camera defines the camera to use to pick the right LOD level
  116352. * @returns the currentAbstractMesh
  116353. */
  116354. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116355. /**
  116356. * Returns 0 by default. Implemented by child classes
  116357. * @returns an integer
  116358. */
  116359. getTotalVertices(): number;
  116360. /**
  116361. * Returns a positive integer : the total number of indices in this mesh geometry.
  116362. * @returns the numner of indices or zero if the mesh has no geometry.
  116363. */
  116364. getTotalIndices(): number;
  116365. /**
  116366. * Returns null by default. Implemented by child classes
  116367. * @returns null
  116368. */
  116369. getIndices(): Nullable<IndicesArray>;
  116370. /**
  116371. * Returns the array of the requested vertex data kind. Implemented by child classes
  116372. * @param kind defines the vertex data kind to use
  116373. * @returns null
  116374. */
  116375. getVerticesData(kind: string): Nullable<FloatArray>;
  116376. /**
  116377. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116378. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116379. * Note that a new underlying VertexBuffer object is created each call.
  116380. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116381. * @param kind defines vertex data kind:
  116382. * * VertexBuffer.PositionKind
  116383. * * VertexBuffer.UVKind
  116384. * * VertexBuffer.UV2Kind
  116385. * * VertexBuffer.UV3Kind
  116386. * * VertexBuffer.UV4Kind
  116387. * * VertexBuffer.UV5Kind
  116388. * * VertexBuffer.UV6Kind
  116389. * * VertexBuffer.ColorKind
  116390. * * VertexBuffer.MatricesIndicesKind
  116391. * * VertexBuffer.MatricesIndicesExtraKind
  116392. * * VertexBuffer.MatricesWeightsKind
  116393. * * VertexBuffer.MatricesWeightsExtraKind
  116394. * @param data defines the data source
  116395. * @param updatable defines if the data must be flagged as updatable (or static)
  116396. * @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
  116397. * @returns the current mesh
  116398. */
  116399. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116400. /**
  116401. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116402. * If the mesh has no geometry, it is simply returned as it is.
  116403. * @param kind defines vertex data kind:
  116404. * * VertexBuffer.PositionKind
  116405. * * VertexBuffer.UVKind
  116406. * * VertexBuffer.UV2Kind
  116407. * * VertexBuffer.UV3Kind
  116408. * * VertexBuffer.UV4Kind
  116409. * * VertexBuffer.UV5Kind
  116410. * * VertexBuffer.UV6Kind
  116411. * * VertexBuffer.ColorKind
  116412. * * VertexBuffer.MatricesIndicesKind
  116413. * * VertexBuffer.MatricesIndicesExtraKind
  116414. * * VertexBuffer.MatricesWeightsKind
  116415. * * VertexBuffer.MatricesWeightsExtraKind
  116416. * @param data defines the data source
  116417. * @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
  116418. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116419. * @returns the current mesh
  116420. */
  116421. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116422. /**
  116423. * Sets the mesh indices,
  116424. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116425. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116426. * @param totalVertices Defines the total number of vertices
  116427. * @returns the current mesh
  116428. */
  116429. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116430. /**
  116431. * Gets a boolean indicating if specific vertex data is present
  116432. * @param kind defines the vertex data kind to use
  116433. * @returns true is data kind is present
  116434. */
  116435. isVerticesDataPresent(kind: string): boolean;
  116436. /**
  116437. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116438. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116439. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116440. * @returns a BoundingInfo
  116441. */
  116442. getBoundingInfo(): BoundingInfo;
  116443. /**
  116444. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116445. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116446. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116447. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116448. * @returns the current mesh
  116449. */
  116450. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116451. /**
  116452. * Overwrite the current bounding info
  116453. * @param boundingInfo defines the new bounding info
  116454. * @returns the current mesh
  116455. */
  116456. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116457. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116458. get useBones(): boolean;
  116459. /** @hidden */
  116460. _preActivate(): void;
  116461. /** @hidden */
  116462. _preActivateForIntermediateRendering(renderId: number): void;
  116463. /** @hidden */
  116464. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116465. /** @hidden */
  116466. _postActivate(): void;
  116467. /** @hidden */
  116468. _freeze(): void;
  116469. /** @hidden */
  116470. _unFreeze(): void;
  116471. /**
  116472. * Gets the current world matrix
  116473. * @returns a Matrix
  116474. */
  116475. getWorldMatrix(): Matrix;
  116476. /** @hidden */
  116477. _getWorldMatrixDeterminant(): number;
  116478. /**
  116479. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116480. */
  116481. get isAnInstance(): boolean;
  116482. /**
  116483. * Gets a boolean indicating if this mesh has instances
  116484. */
  116485. get hasInstances(): boolean;
  116486. /**
  116487. * Gets a boolean indicating if this mesh has thin instances
  116488. */
  116489. get hasThinInstances(): boolean;
  116490. /**
  116491. * Perform relative position change from the point of view of behind the front of the mesh.
  116492. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116493. * Supports definition of mesh facing forward or backward
  116494. * @param amountRight defines the distance on the right axis
  116495. * @param amountUp defines the distance on the up axis
  116496. * @param amountForward defines the distance on the forward axis
  116497. * @returns the current mesh
  116498. */
  116499. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116500. /**
  116501. * Calculate relative position change from the point of view of behind the front of the mesh.
  116502. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116503. * Supports definition of mesh facing forward or backward
  116504. * @param amountRight defines the distance on the right axis
  116505. * @param amountUp defines the distance on the up axis
  116506. * @param amountForward defines the distance on the forward axis
  116507. * @returns the new displacement vector
  116508. */
  116509. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116510. /**
  116511. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116512. * Supports definition of mesh facing forward or backward
  116513. * @param flipBack defines the flip
  116514. * @param twirlClockwise defines the twirl
  116515. * @param tiltRight defines the tilt
  116516. * @returns the current mesh
  116517. */
  116518. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116519. /**
  116520. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116521. * Supports definition of mesh facing forward or backward.
  116522. * @param flipBack defines the flip
  116523. * @param twirlClockwise defines the twirl
  116524. * @param tiltRight defines the tilt
  116525. * @returns the new rotation vector
  116526. */
  116527. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116528. /**
  116529. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116530. * This means the mesh underlying bounding box and sphere are recomputed.
  116531. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116532. * @returns the current mesh
  116533. */
  116534. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116535. /** @hidden */
  116536. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116537. /** @hidden */
  116538. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116539. /** @hidden */
  116540. _updateBoundingInfo(): AbstractMesh;
  116541. /** @hidden */
  116542. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116543. /** @hidden */
  116544. protected _afterComputeWorldMatrix(): void;
  116545. /** @hidden */
  116546. get _effectiveMesh(): AbstractMesh;
  116547. /**
  116548. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116549. * A mesh is in the frustum if its bounding box intersects the frustum
  116550. * @param frustumPlanes defines the frustum to test
  116551. * @returns true if the mesh is in the frustum planes
  116552. */
  116553. isInFrustum(frustumPlanes: Plane[]): boolean;
  116554. /**
  116555. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116556. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116557. * @param frustumPlanes defines the frustum to test
  116558. * @returns true if the mesh is completely in the frustum planes
  116559. */
  116560. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116561. /**
  116562. * True if the mesh intersects another mesh or a SolidParticle object
  116563. * @param mesh defines a target mesh or SolidParticle to test
  116564. * @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)
  116565. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116566. * @returns true if there is an intersection
  116567. */
  116568. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116569. /**
  116570. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116571. * @param point defines the point to test
  116572. * @returns true if there is an intersection
  116573. */
  116574. intersectsPoint(point: Vector3): boolean;
  116575. /**
  116576. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116577. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116578. */
  116579. get checkCollisions(): boolean;
  116580. set checkCollisions(collisionEnabled: boolean);
  116581. /**
  116582. * Gets Collider object used to compute collisions (not physics)
  116583. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116584. */
  116585. get collider(): Nullable<Collider>;
  116586. /**
  116587. * Move the mesh using collision engine
  116588. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116589. * @param displacement defines the requested displacement vector
  116590. * @returns the current mesh
  116591. */
  116592. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116593. private _onCollisionPositionChange;
  116594. /** @hidden */
  116595. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116596. /** @hidden */
  116597. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116598. /** @hidden */
  116599. _checkCollision(collider: Collider): AbstractMesh;
  116600. /** @hidden */
  116601. _generatePointsArray(): boolean;
  116602. /**
  116603. * Checks if the passed Ray intersects with the mesh
  116604. * @param ray defines the ray to use
  116605. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116606. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116607. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116608. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116609. * @returns the picking info
  116610. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116611. */
  116612. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116613. /**
  116614. * Clones the current mesh
  116615. * @param name defines the mesh name
  116616. * @param newParent defines the new mesh parent
  116617. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116618. * @returns the new mesh
  116619. */
  116620. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116621. /**
  116622. * Disposes all the submeshes of the current meshnp
  116623. * @returns the current mesh
  116624. */
  116625. releaseSubMeshes(): AbstractMesh;
  116626. /**
  116627. * Releases resources associated with this abstract mesh.
  116628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116630. */
  116631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116632. /**
  116633. * Adds the passed mesh as a child to the current mesh
  116634. * @param mesh defines the child mesh
  116635. * @returns the current mesh
  116636. */
  116637. addChild(mesh: AbstractMesh): AbstractMesh;
  116638. /**
  116639. * Removes the passed mesh from the current mesh children list
  116640. * @param mesh defines the child mesh
  116641. * @returns the current mesh
  116642. */
  116643. removeChild(mesh: AbstractMesh): AbstractMesh;
  116644. /** @hidden */
  116645. private _initFacetData;
  116646. /**
  116647. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116648. * This method can be called within the render loop.
  116649. * 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
  116650. * @returns the current mesh
  116651. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116652. */
  116653. updateFacetData(): AbstractMesh;
  116654. /**
  116655. * Returns the facetLocalNormals array.
  116656. * The normals are expressed in the mesh local spac
  116657. * @returns an array of Vector3
  116658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116659. */
  116660. getFacetLocalNormals(): Vector3[];
  116661. /**
  116662. * Returns the facetLocalPositions array.
  116663. * The facet positions are expressed in the mesh local space
  116664. * @returns an array of Vector3
  116665. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116666. */
  116667. getFacetLocalPositions(): Vector3[];
  116668. /**
  116669. * Returns the facetLocalPartioning array
  116670. * @returns an array of array of numbers
  116671. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116672. */
  116673. getFacetLocalPartitioning(): number[][];
  116674. /**
  116675. * Returns the i-th facet position in the world system.
  116676. * This method allocates a new Vector3 per call
  116677. * @param i defines the facet index
  116678. * @returns a new Vector3
  116679. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116680. */
  116681. getFacetPosition(i: number): Vector3;
  116682. /**
  116683. * Sets the reference Vector3 with the i-th facet position in the world system
  116684. * @param i defines the facet index
  116685. * @param ref defines the target vector
  116686. * @returns the current mesh
  116687. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116688. */
  116689. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116690. /**
  116691. * Returns the i-th facet normal in the world system.
  116692. * This method allocates a new Vector3 per call
  116693. * @param i defines the facet index
  116694. * @returns a new Vector3
  116695. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116696. */
  116697. getFacetNormal(i: number): Vector3;
  116698. /**
  116699. * Sets the reference Vector3 with the i-th facet normal in the world system
  116700. * @param i defines the facet index
  116701. * @param ref defines the target vector
  116702. * @returns the current mesh
  116703. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116704. */
  116705. getFacetNormalToRef(i: number, ref: Vector3): this;
  116706. /**
  116707. * 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)
  116708. * @param x defines x coordinate
  116709. * @param y defines y coordinate
  116710. * @param z defines z coordinate
  116711. * @returns the array of facet indexes
  116712. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116713. */
  116714. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116715. /**
  116716. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116717. * @param projected sets as the (x,y,z) world projection on the facet
  116718. * @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
  116719. * @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
  116720. * @param x defines x coordinate
  116721. * @param y defines y coordinate
  116722. * @param z defines z coordinate
  116723. * @returns the face index if found (or null instead)
  116724. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116725. */
  116726. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116727. /**
  116728. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116729. * @param projected sets as the (x,y,z) local projection on the facet
  116730. * @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
  116731. * @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
  116732. * @param x defines x coordinate
  116733. * @param y defines y coordinate
  116734. * @param z defines z coordinate
  116735. * @returns the face index if found (or null instead)
  116736. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116737. */
  116738. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116739. /**
  116740. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116741. * @returns the parameters
  116742. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116743. */
  116744. getFacetDataParameters(): any;
  116745. /**
  116746. * Disables the feature FacetData and frees the related memory
  116747. * @returns the current mesh
  116748. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116749. */
  116750. disableFacetData(): AbstractMesh;
  116751. /**
  116752. * Updates the AbstractMesh indices array
  116753. * @param indices defines the data source
  116754. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116755. * @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)
  116756. * @returns the current mesh
  116757. */
  116758. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116759. /**
  116760. * Creates new normals data for the mesh
  116761. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116762. * @returns the current mesh
  116763. */
  116764. createNormals(updatable: boolean): AbstractMesh;
  116765. /**
  116766. * Align the mesh with a normal
  116767. * @param normal defines the normal to use
  116768. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116769. * @returns the current mesh
  116770. */
  116771. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116772. /** @hidden */
  116773. _checkOcclusionQuery(): boolean;
  116774. /**
  116775. * Disables the mesh edge rendering mode
  116776. * @returns the currentAbstractMesh
  116777. */
  116778. disableEdgesRendering(): AbstractMesh;
  116779. /**
  116780. * Enables the edge rendering mode on the mesh.
  116781. * This mode makes the mesh edges visible
  116782. * @param epsilon defines the maximal distance between two angles to detect a face
  116783. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116784. * @returns the currentAbstractMesh
  116785. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116786. */
  116787. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116788. /**
  116789. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116790. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116791. */
  116792. getConnectedParticleSystems(): IParticleSystem[];
  116793. }
  116794. }
  116795. declare module BABYLON {
  116796. /**
  116797. * Interface used to define ActionEvent
  116798. */
  116799. export interface IActionEvent {
  116800. /** The mesh or sprite that triggered the action */
  116801. source: any;
  116802. /** The X mouse cursor position at the time of the event */
  116803. pointerX: number;
  116804. /** The Y mouse cursor position at the time of the event */
  116805. pointerY: number;
  116806. /** The mesh that is currently pointed at (can be null) */
  116807. meshUnderPointer: Nullable<AbstractMesh>;
  116808. /** the original (browser) event that triggered the ActionEvent */
  116809. sourceEvent?: any;
  116810. /** additional data for the event */
  116811. additionalData?: any;
  116812. }
  116813. /**
  116814. * ActionEvent is the event being sent when an action is triggered.
  116815. */
  116816. export class ActionEvent implements IActionEvent {
  116817. /** The mesh or sprite that triggered the action */
  116818. source: any;
  116819. /** The X mouse cursor position at the time of the event */
  116820. pointerX: number;
  116821. /** The Y mouse cursor position at the time of the event */
  116822. pointerY: number;
  116823. /** The mesh that is currently pointed at (can be null) */
  116824. meshUnderPointer: Nullable<AbstractMesh>;
  116825. /** the original (browser) event that triggered the ActionEvent */
  116826. sourceEvent?: any;
  116827. /** additional data for the event */
  116828. additionalData?: any;
  116829. /**
  116830. * Creates a new ActionEvent
  116831. * @param source The mesh or sprite that triggered the action
  116832. * @param pointerX The X mouse cursor position at the time of the event
  116833. * @param pointerY The Y mouse cursor position at the time of the event
  116834. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116835. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116836. * @param additionalData additional data for the event
  116837. */
  116838. constructor(
  116839. /** The mesh or sprite that triggered the action */
  116840. source: any,
  116841. /** The X mouse cursor position at the time of the event */
  116842. pointerX: number,
  116843. /** The Y mouse cursor position at the time of the event */
  116844. pointerY: number,
  116845. /** The mesh that is currently pointed at (can be null) */
  116846. meshUnderPointer: Nullable<AbstractMesh>,
  116847. /** the original (browser) event that triggered the ActionEvent */
  116848. sourceEvent?: any,
  116849. /** additional data for the event */
  116850. additionalData?: any);
  116851. /**
  116852. * Helper function to auto-create an ActionEvent from a source mesh.
  116853. * @param source The source mesh that triggered the event
  116854. * @param evt The original (browser) event
  116855. * @param additionalData additional data for the event
  116856. * @returns the new ActionEvent
  116857. */
  116858. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116859. /**
  116860. * Helper function to auto-create an ActionEvent from a source sprite
  116861. * @param source The source sprite that triggered the event
  116862. * @param scene Scene associated with the sprite
  116863. * @param evt The original (browser) event
  116864. * @param additionalData additional data for the event
  116865. * @returns the new ActionEvent
  116866. */
  116867. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116868. /**
  116869. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116870. * @param scene the scene where the event occurred
  116871. * @param evt The original (browser) event
  116872. * @returns the new ActionEvent
  116873. */
  116874. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116875. /**
  116876. * Helper function to auto-create an ActionEvent from a primitive
  116877. * @param prim defines the target primitive
  116878. * @param pointerPos defines the pointer position
  116879. * @param evt The original (browser) event
  116880. * @param additionalData additional data for the event
  116881. * @returns the new ActionEvent
  116882. */
  116883. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116884. }
  116885. }
  116886. declare module BABYLON {
  116887. /**
  116888. * Abstract class used to decouple action Manager from scene and meshes.
  116889. * Do not instantiate.
  116890. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116891. */
  116892. export abstract class AbstractActionManager implements IDisposable {
  116893. /** Gets the list of active triggers */
  116894. static Triggers: {
  116895. [key: string]: number;
  116896. };
  116897. /** Gets the cursor to use when hovering items */
  116898. hoverCursor: string;
  116899. /** Gets the list of actions */
  116900. actions: IAction[];
  116901. /**
  116902. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116903. */
  116904. isRecursive: boolean;
  116905. /**
  116906. * Releases all associated resources
  116907. */
  116908. abstract dispose(): void;
  116909. /**
  116910. * Does this action manager has pointer triggers
  116911. */
  116912. abstract get hasPointerTriggers(): boolean;
  116913. /**
  116914. * Does this action manager has pick triggers
  116915. */
  116916. abstract get hasPickTriggers(): boolean;
  116917. /**
  116918. * Process a specific trigger
  116919. * @param trigger defines the trigger to process
  116920. * @param evt defines the event details to be processed
  116921. */
  116922. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116923. /**
  116924. * Does this action manager handles actions of any of the given triggers
  116925. * @param triggers defines the triggers to be tested
  116926. * @return a boolean indicating whether one (or more) of the triggers is handled
  116927. */
  116928. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116929. /**
  116930. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116931. * speed.
  116932. * @param triggerA defines the trigger to be tested
  116933. * @param triggerB defines the trigger to be tested
  116934. * @return a boolean indicating whether one (or more) of the triggers is handled
  116935. */
  116936. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116937. /**
  116938. * Does this action manager handles actions of a given trigger
  116939. * @param trigger defines the trigger to be tested
  116940. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116941. * @return whether the trigger is handled
  116942. */
  116943. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116944. /**
  116945. * Serialize this manager to a JSON object
  116946. * @param name defines the property name to store this manager
  116947. * @returns a JSON representation of this manager
  116948. */
  116949. abstract serialize(name: string): any;
  116950. /**
  116951. * Registers an action to this action manager
  116952. * @param action defines the action to be registered
  116953. * @return the action amended (prepared) after registration
  116954. */
  116955. abstract registerAction(action: IAction): Nullable<IAction>;
  116956. /**
  116957. * Unregisters an action to this action manager
  116958. * @param action defines the action to be unregistered
  116959. * @return a boolean indicating whether the action has been unregistered
  116960. */
  116961. abstract unregisterAction(action: IAction): Boolean;
  116962. /**
  116963. * Does exist one action manager with at least one trigger
  116964. **/
  116965. static get HasTriggers(): boolean;
  116966. /**
  116967. * Does exist one action manager with at least one pick trigger
  116968. **/
  116969. static get HasPickTriggers(): boolean;
  116970. /**
  116971. * Does exist one action manager that handles actions of a given trigger
  116972. * @param trigger defines the trigger to be tested
  116973. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116974. **/
  116975. static HasSpecificTrigger(trigger: number): boolean;
  116976. }
  116977. }
  116978. declare module BABYLON {
  116979. /**
  116980. * Defines how a node can be built from a string name.
  116981. */
  116982. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116983. /**
  116984. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116985. */
  116986. export class Node implements IBehaviorAware<Node> {
  116987. /** @hidden */
  116988. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116989. private static _NodeConstructors;
  116990. /**
  116991. * Add a new node constructor
  116992. * @param type defines the type name of the node to construct
  116993. * @param constructorFunc defines the constructor function
  116994. */
  116995. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116996. /**
  116997. * Returns a node constructor based on type name
  116998. * @param type defines the type name
  116999. * @param name defines the new node name
  117000. * @param scene defines the hosting scene
  117001. * @param options defines optional options to transmit to constructors
  117002. * @returns the new constructor or null
  117003. */
  117004. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117005. /**
  117006. * Gets or sets the name of the node
  117007. */
  117008. name: string;
  117009. /**
  117010. * Gets or sets the id of the node
  117011. */
  117012. id: string;
  117013. /**
  117014. * Gets or sets the unique id of the node
  117015. */
  117016. uniqueId: number;
  117017. /**
  117018. * Gets or sets a string used to store user defined state for the node
  117019. */
  117020. state: string;
  117021. /**
  117022. * Gets or sets an object used to store user defined information for the node
  117023. */
  117024. metadata: any;
  117025. /**
  117026. * For internal use only. Please do not use.
  117027. */
  117028. reservedDataStore: any;
  117029. /**
  117030. * List of inspectable custom properties (used by the Inspector)
  117031. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117032. */
  117033. inspectableCustomProperties: IInspectable[];
  117034. private _doNotSerialize;
  117035. /**
  117036. * Gets or sets a boolean used to define if the node must be serialized
  117037. */
  117038. get doNotSerialize(): boolean;
  117039. set doNotSerialize(value: boolean);
  117040. /** @hidden */
  117041. _isDisposed: boolean;
  117042. /**
  117043. * Gets a list of Animations associated with the node
  117044. */
  117045. animations: Animation[];
  117046. protected _ranges: {
  117047. [name: string]: Nullable<AnimationRange>;
  117048. };
  117049. /**
  117050. * Callback raised when the node is ready to be used
  117051. */
  117052. onReady: Nullable<(node: Node) => void>;
  117053. private _isEnabled;
  117054. private _isParentEnabled;
  117055. private _isReady;
  117056. /** @hidden */
  117057. _currentRenderId: number;
  117058. private _parentUpdateId;
  117059. /** @hidden */
  117060. _childUpdateId: number;
  117061. /** @hidden */
  117062. _waitingParentId: Nullable<string>;
  117063. /** @hidden */
  117064. _scene: Scene;
  117065. /** @hidden */
  117066. _cache: any;
  117067. private _parentNode;
  117068. private _children;
  117069. /** @hidden */
  117070. _worldMatrix: Matrix;
  117071. /** @hidden */
  117072. _worldMatrixDeterminant: number;
  117073. /** @hidden */
  117074. _worldMatrixDeterminantIsDirty: boolean;
  117075. /** @hidden */
  117076. private _sceneRootNodesIndex;
  117077. /**
  117078. * Gets a boolean indicating if the node has been disposed
  117079. * @returns true if the node was disposed
  117080. */
  117081. isDisposed(): boolean;
  117082. /**
  117083. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117084. * @see https://doc.babylonjs.com/how_to/parenting
  117085. */
  117086. set parent(parent: Nullable<Node>);
  117087. get parent(): Nullable<Node>;
  117088. /** @hidden */
  117089. _addToSceneRootNodes(): void;
  117090. /** @hidden */
  117091. _removeFromSceneRootNodes(): void;
  117092. private _animationPropertiesOverride;
  117093. /**
  117094. * Gets or sets the animation properties override
  117095. */
  117096. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117097. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117098. /**
  117099. * Gets a string identifying the name of the class
  117100. * @returns "Node" string
  117101. */
  117102. getClassName(): string;
  117103. /** @hidden */
  117104. readonly _isNode: boolean;
  117105. /**
  117106. * An event triggered when the mesh is disposed
  117107. */
  117108. onDisposeObservable: Observable<Node>;
  117109. private _onDisposeObserver;
  117110. /**
  117111. * Sets a callback that will be raised when the node will be disposed
  117112. */
  117113. set onDispose(callback: () => void);
  117114. /**
  117115. * Creates a new Node
  117116. * @param name the name and id to be given to this node
  117117. * @param scene the scene this node will be added to
  117118. */
  117119. constructor(name: string, scene?: Nullable<Scene>);
  117120. /**
  117121. * Gets the scene of the node
  117122. * @returns a scene
  117123. */
  117124. getScene(): Scene;
  117125. /**
  117126. * Gets the engine of the node
  117127. * @returns a Engine
  117128. */
  117129. getEngine(): Engine;
  117130. private _behaviors;
  117131. /**
  117132. * Attach a behavior to the node
  117133. * @see https://doc.babylonjs.com/features/behaviour
  117134. * @param behavior defines the behavior to attach
  117135. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117136. * @returns the current Node
  117137. */
  117138. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117139. /**
  117140. * Remove an attached behavior
  117141. * @see https://doc.babylonjs.com/features/behaviour
  117142. * @param behavior defines the behavior to attach
  117143. * @returns the current Node
  117144. */
  117145. removeBehavior(behavior: Behavior<Node>): Node;
  117146. /**
  117147. * Gets the list of attached behaviors
  117148. * @see https://doc.babylonjs.com/features/behaviour
  117149. */
  117150. get behaviors(): Behavior<Node>[];
  117151. /**
  117152. * Gets an attached behavior by name
  117153. * @param name defines the name of the behavior to look for
  117154. * @see https://doc.babylonjs.com/features/behaviour
  117155. * @returns null if behavior was not found else the requested behavior
  117156. */
  117157. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117158. /**
  117159. * Returns the latest update of the World matrix
  117160. * @returns a Matrix
  117161. */
  117162. getWorldMatrix(): Matrix;
  117163. /** @hidden */
  117164. _getWorldMatrixDeterminant(): number;
  117165. /**
  117166. * Returns directly the latest state of the mesh World matrix.
  117167. * A Matrix is returned.
  117168. */
  117169. get worldMatrixFromCache(): Matrix;
  117170. /** @hidden */
  117171. _initCache(): void;
  117172. /** @hidden */
  117173. updateCache(force?: boolean): void;
  117174. /** @hidden */
  117175. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117176. /** @hidden */
  117177. _updateCache(ignoreParentClass?: boolean): void;
  117178. /** @hidden */
  117179. _isSynchronized(): boolean;
  117180. /** @hidden */
  117181. _markSyncedWithParent(): void;
  117182. /** @hidden */
  117183. isSynchronizedWithParent(): boolean;
  117184. /** @hidden */
  117185. isSynchronized(): boolean;
  117186. /**
  117187. * Is this node ready to be used/rendered
  117188. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117189. * @return true if the node is ready
  117190. */
  117191. isReady(completeCheck?: boolean): boolean;
  117192. /**
  117193. * Is this node enabled?
  117194. * 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
  117195. * @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
  117196. * @return whether this node (and its parent) is enabled
  117197. */
  117198. isEnabled(checkAncestors?: boolean): boolean;
  117199. /** @hidden */
  117200. protected _syncParentEnabledState(): void;
  117201. /**
  117202. * Set the enabled state of this node
  117203. * @param value defines the new enabled state
  117204. */
  117205. setEnabled(value: boolean): void;
  117206. /**
  117207. * Is this node a descendant of the given node?
  117208. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117209. * @param ancestor defines the parent node to inspect
  117210. * @returns a boolean indicating if this node is a descendant of the given node
  117211. */
  117212. isDescendantOf(ancestor: Node): boolean;
  117213. /** @hidden */
  117214. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117215. /**
  117216. * Will return all nodes that have this node as ascendant
  117217. * @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
  117218. * @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
  117219. * @return all children nodes of all types
  117220. */
  117221. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117222. /**
  117223. * Get all child-meshes of this node
  117224. * @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)
  117225. * @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
  117226. * @returns an array of AbstractMesh
  117227. */
  117228. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117229. /**
  117230. * Get all direct children of this node
  117231. * @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
  117232. * @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)
  117233. * @returns an array of Node
  117234. */
  117235. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117236. /** @hidden */
  117237. _setReady(state: boolean): void;
  117238. /**
  117239. * Get an animation by name
  117240. * @param name defines the name of the animation to look for
  117241. * @returns null if not found else the requested animation
  117242. */
  117243. getAnimationByName(name: string): Nullable<Animation>;
  117244. /**
  117245. * Creates an animation range for this node
  117246. * @param name defines the name of the range
  117247. * @param from defines the starting key
  117248. * @param to defines the end key
  117249. */
  117250. createAnimationRange(name: string, from: number, to: number): void;
  117251. /**
  117252. * Delete a specific animation range
  117253. * @param name defines the name of the range to delete
  117254. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117255. */
  117256. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117257. /**
  117258. * Get an animation range by name
  117259. * @param name defines the name of the animation range to look for
  117260. * @returns null if not found else the requested animation range
  117261. */
  117262. getAnimationRange(name: string): Nullable<AnimationRange>;
  117263. /**
  117264. * Gets the list of all animation ranges defined on this node
  117265. * @returns an array
  117266. */
  117267. getAnimationRanges(): Nullable<AnimationRange>[];
  117268. /**
  117269. * Will start the animation sequence
  117270. * @param name defines the range frames for animation sequence
  117271. * @param loop defines if the animation should loop (false by default)
  117272. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117273. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117274. * @returns the object created for this animation. If range does not exist, it will return null
  117275. */
  117276. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117277. /**
  117278. * Serialize animation ranges into a JSON compatible object
  117279. * @returns serialization object
  117280. */
  117281. serializeAnimationRanges(): any;
  117282. /**
  117283. * Computes the world matrix of the node
  117284. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117285. * @returns the world matrix
  117286. */
  117287. computeWorldMatrix(force?: boolean): Matrix;
  117288. /**
  117289. * Releases resources associated with this node.
  117290. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117291. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117292. */
  117293. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117294. /**
  117295. * Parse animation range data from a serialization object and store them into a given node
  117296. * @param node defines where to store the animation ranges
  117297. * @param parsedNode defines the serialization object to read data from
  117298. * @param scene defines the hosting scene
  117299. */
  117300. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117301. /**
  117302. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117303. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117304. * @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
  117305. * @returns the new bounding vectors
  117306. */
  117307. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117308. min: Vector3;
  117309. max: Vector3;
  117310. };
  117311. }
  117312. }
  117313. declare module BABYLON {
  117314. /**
  117315. * @hidden
  117316. */
  117317. export class _IAnimationState {
  117318. key: number;
  117319. repeatCount: number;
  117320. workValue?: any;
  117321. loopMode?: number;
  117322. offsetValue?: any;
  117323. highLimitValue?: any;
  117324. }
  117325. /**
  117326. * Class used to store any kind of animation
  117327. */
  117328. export class Animation {
  117329. /**Name of the animation */
  117330. name: string;
  117331. /**Property to animate */
  117332. targetProperty: string;
  117333. /**The frames per second of the animation */
  117334. framePerSecond: number;
  117335. /**The data type of the animation */
  117336. dataType: number;
  117337. /**The loop mode of the animation */
  117338. loopMode?: number | undefined;
  117339. /**Specifies if blending should be enabled */
  117340. enableBlending?: boolean | undefined;
  117341. /**
  117342. * Use matrix interpolation instead of using direct key value when animating matrices
  117343. */
  117344. static AllowMatricesInterpolation: boolean;
  117345. /**
  117346. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117347. */
  117348. static AllowMatrixDecomposeForInterpolation: boolean;
  117349. /** Define the Url to load snippets */
  117350. static SnippetUrl: string;
  117351. /** Snippet ID if the animation was created from the snippet server */
  117352. snippetId: string;
  117353. /**
  117354. * Stores the key frames of the animation
  117355. */
  117356. private _keys;
  117357. /**
  117358. * Stores the easing function of the animation
  117359. */
  117360. private _easingFunction;
  117361. /**
  117362. * @hidden Internal use only
  117363. */
  117364. _runtimeAnimations: RuntimeAnimation[];
  117365. /**
  117366. * The set of event that will be linked to this animation
  117367. */
  117368. private _events;
  117369. /**
  117370. * Stores an array of target property paths
  117371. */
  117372. targetPropertyPath: string[];
  117373. /**
  117374. * Stores the blending speed of the animation
  117375. */
  117376. blendingSpeed: number;
  117377. /**
  117378. * Stores the animation ranges for the animation
  117379. */
  117380. private _ranges;
  117381. /**
  117382. * @hidden Internal use
  117383. */
  117384. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117385. /**
  117386. * Sets up an animation
  117387. * @param property The property to animate
  117388. * @param animationType The animation type to apply
  117389. * @param framePerSecond The frames per second of the animation
  117390. * @param easingFunction The easing function used in the animation
  117391. * @returns The created animation
  117392. */
  117393. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117394. /**
  117395. * Create and start an animation on a node
  117396. * @param name defines the name of the global animation that will be run on all nodes
  117397. * @param node defines the root node where the animation will take place
  117398. * @param targetProperty defines property to animate
  117399. * @param framePerSecond defines the number of frame per second yo use
  117400. * @param totalFrame defines the number of frames in total
  117401. * @param from defines the initial value
  117402. * @param to defines the final value
  117403. * @param loopMode defines which loop mode you want to use (off by default)
  117404. * @param easingFunction defines the easing function to use (linear by default)
  117405. * @param onAnimationEnd defines the callback to call when animation end
  117406. * @returns the animatable created for this animation
  117407. */
  117408. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117409. /**
  117410. * Create and start an animation on a node and its descendants
  117411. * @param name defines the name of the global animation that will be run on all nodes
  117412. * @param node defines the root node where the animation will take place
  117413. * @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
  117414. * @param targetProperty defines property to animate
  117415. * @param framePerSecond defines the number of frame per second to use
  117416. * @param totalFrame defines the number of frames in total
  117417. * @param from defines the initial value
  117418. * @param to defines the final value
  117419. * @param loopMode defines which loop mode you want to use (off by default)
  117420. * @param easingFunction defines the easing function to use (linear by default)
  117421. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117422. * @returns the list of animatables created for all nodes
  117423. * @example https://www.babylonjs-playground.com/#MH0VLI
  117424. */
  117425. 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[]>;
  117426. /**
  117427. * Creates a new animation, merges it with the existing animations and starts it
  117428. * @param name Name of the animation
  117429. * @param node Node which contains the scene that begins the animations
  117430. * @param targetProperty Specifies which property to animate
  117431. * @param framePerSecond The frames per second of the animation
  117432. * @param totalFrame The total number of frames
  117433. * @param from The frame at the beginning of the animation
  117434. * @param to The frame at the end of the animation
  117435. * @param loopMode Specifies the loop mode of the animation
  117436. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117437. * @param onAnimationEnd Callback to run once the animation is complete
  117438. * @returns Nullable animation
  117439. */
  117440. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117441. /**
  117442. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117443. * @param sourceAnimation defines the Animation containing keyframes to convert
  117444. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117445. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117446. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117447. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117448. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117449. */
  117450. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117451. /**
  117452. * Transition property of an host to the target Value
  117453. * @param property The property to transition
  117454. * @param targetValue The target Value of the property
  117455. * @param host The object where the property to animate belongs
  117456. * @param scene Scene used to run the animation
  117457. * @param frameRate Framerate (in frame/s) to use
  117458. * @param transition The transition type we want to use
  117459. * @param duration The duration of the animation, in milliseconds
  117460. * @param onAnimationEnd Callback trigger at the end of the animation
  117461. * @returns Nullable animation
  117462. */
  117463. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117464. /**
  117465. * Return the array of runtime animations currently using this animation
  117466. */
  117467. get runtimeAnimations(): RuntimeAnimation[];
  117468. /**
  117469. * Specifies if any of the runtime animations are currently running
  117470. */
  117471. get hasRunningRuntimeAnimations(): boolean;
  117472. /**
  117473. * Initializes the animation
  117474. * @param name Name of the animation
  117475. * @param targetProperty Property to animate
  117476. * @param framePerSecond The frames per second of the animation
  117477. * @param dataType The data type of the animation
  117478. * @param loopMode The loop mode of the animation
  117479. * @param enableBlending Specifies if blending should be enabled
  117480. */
  117481. constructor(
  117482. /**Name of the animation */
  117483. name: string,
  117484. /**Property to animate */
  117485. targetProperty: string,
  117486. /**The frames per second of the animation */
  117487. framePerSecond: number,
  117488. /**The data type of the animation */
  117489. dataType: number,
  117490. /**The loop mode of the animation */
  117491. loopMode?: number | undefined,
  117492. /**Specifies if blending should be enabled */
  117493. enableBlending?: boolean | undefined);
  117494. /**
  117495. * Converts the animation to a string
  117496. * @param fullDetails support for multiple levels of logging within scene loading
  117497. * @returns String form of the animation
  117498. */
  117499. toString(fullDetails?: boolean): string;
  117500. /**
  117501. * Add an event to this animation
  117502. * @param event Event to add
  117503. */
  117504. addEvent(event: AnimationEvent): void;
  117505. /**
  117506. * Remove all events found at the given frame
  117507. * @param frame The frame to remove events from
  117508. */
  117509. removeEvents(frame: number): void;
  117510. /**
  117511. * Retrieves all the events from the animation
  117512. * @returns Events from the animation
  117513. */
  117514. getEvents(): AnimationEvent[];
  117515. /**
  117516. * Creates an animation range
  117517. * @param name Name of the animation range
  117518. * @param from Starting frame of the animation range
  117519. * @param to Ending frame of the animation
  117520. */
  117521. createRange(name: string, from: number, to: number): void;
  117522. /**
  117523. * Deletes an animation range by name
  117524. * @param name Name of the animation range to delete
  117525. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117526. */
  117527. deleteRange(name: string, deleteFrames?: boolean): void;
  117528. /**
  117529. * Gets the animation range by name, or null if not defined
  117530. * @param name Name of the animation range
  117531. * @returns Nullable animation range
  117532. */
  117533. getRange(name: string): Nullable<AnimationRange>;
  117534. /**
  117535. * Gets the key frames from the animation
  117536. * @returns The key frames of the animation
  117537. */
  117538. getKeys(): Array<IAnimationKey>;
  117539. /**
  117540. * Gets the highest frame rate of the animation
  117541. * @returns Highest frame rate of the animation
  117542. */
  117543. getHighestFrame(): number;
  117544. /**
  117545. * Gets the easing function of the animation
  117546. * @returns Easing function of the animation
  117547. */
  117548. getEasingFunction(): IEasingFunction;
  117549. /**
  117550. * Sets the easing function of the animation
  117551. * @param easingFunction A custom mathematical formula for animation
  117552. */
  117553. setEasingFunction(easingFunction: EasingFunction): void;
  117554. /**
  117555. * Interpolates a scalar linearly
  117556. * @param startValue Start value of the animation curve
  117557. * @param endValue End value of the animation curve
  117558. * @param gradient Scalar amount to interpolate
  117559. * @returns Interpolated scalar value
  117560. */
  117561. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117562. /**
  117563. * Interpolates a scalar cubically
  117564. * @param startValue Start value of the animation curve
  117565. * @param outTangent End tangent of the animation
  117566. * @param endValue End value of the animation curve
  117567. * @param inTangent Start tangent of the animation curve
  117568. * @param gradient Scalar amount to interpolate
  117569. * @returns Interpolated scalar value
  117570. */
  117571. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117572. /**
  117573. * Interpolates a quaternion using a spherical linear interpolation
  117574. * @param startValue Start value of the animation curve
  117575. * @param endValue End value of the animation curve
  117576. * @param gradient Scalar amount to interpolate
  117577. * @returns Interpolated quaternion value
  117578. */
  117579. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117580. /**
  117581. * Interpolates a quaternion cubically
  117582. * @param startValue Start value of the animation curve
  117583. * @param outTangent End tangent of the animation curve
  117584. * @param endValue End value of the animation curve
  117585. * @param inTangent Start tangent of the animation curve
  117586. * @param gradient Scalar amount to interpolate
  117587. * @returns Interpolated quaternion value
  117588. */
  117589. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117590. /**
  117591. * Interpolates a Vector3 linearl
  117592. * @param startValue Start value of the animation curve
  117593. * @param endValue End value of the animation curve
  117594. * @param gradient Scalar amount to interpolate
  117595. * @returns Interpolated scalar value
  117596. */
  117597. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117598. /**
  117599. * Interpolates a Vector3 cubically
  117600. * @param startValue Start value of the animation curve
  117601. * @param outTangent End tangent of the animation
  117602. * @param endValue End value of the animation curve
  117603. * @param inTangent Start tangent of the animation curve
  117604. * @param gradient Scalar amount to interpolate
  117605. * @returns InterpolatedVector3 value
  117606. */
  117607. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117608. /**
  117609. * Interpolates a Vector2 linearly
  117610. * @param startValue Start value of the animation curve
  117611. * @param endValue End value of the animation curve
  117612. * @param gradient Scalar amount to interpolate
  117613. * @returns Interpolated Vector2 value
  117614. */
  117615. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117616. /**
  117617. * Interpolates a Vector2 cubically
  117618. * @param startValue Start value of the animation curve
  117619. * @param outTangent End tangent of the animation
  117620. * @param endValue End value of the animation curve
  117621. * @param inTangent Start tangent of the animation curve
  117622. * @param gradient Scalar amount to interpolate
  117623. * @returns Interpolated Vector2 value
  117624. */
  117625. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117626. /**
  117627. * Interpolates a size linearly
  117628. * @param startValue Start value of the animation curve
  117629. * @param endValue End value of the animation curve
  117630. * @param gradient Scalar amount to interpolate
  117631. * @returns Interpolated Size value
  117632. */
  117633. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117634. /**
  117635. * Interpolates a Color3 linearly
  117636. * @param startValue Start value of the animation curve
  117637. * @param endValue End value of the animation curve
  117638. * @param gradient Scalar amount to interpolate
  117639. * @returns Interpolated Color3 value
  117640. */
  117641. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117642. /**
  117643. * Interpolates a Color4 linearly
  117644. * @param startValue Start value of the animation curve
  117645. * @param endValue End value of the animation curve
  117646. * @param gradient Scalar amount to interpolate
  117647. * @returns Interpolated Color3 value
  117648. */
  117649. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117650. /**
  117651. * @hidden Internal use only
  117652. */
  117653. _getKeyValue(value: any): any;
  117654. /**
  117655. * @hidden Internal use only
  117656. */
  117657. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117658. /**
  117659. * Defines the function to use to interpolate matrices
  117660. * @param startValue defines the start matrix
  117661. * @param endValue defines the end matrix
  117662. * @param gradient defines the gradient between both matrices
  117663. * @param result defines an optional target matrix where to store the interpolation
  117664. * @returns the interpolated matrix
  117665. */
  117666. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117667. /**
  117668. * Makes a copy of the animation
  117669. * @returns Cloned animation
  117670. */
  117671. clone(): Animation;
  117672. /**
  117673. * Sets the key frames of the animation
  117674. * @param values The animation key frames to set
  117675. */
  117676. setKeys(values: Array<IAnimationKey>): void;
  117677. /**
  117678. * Serializes the animation to an object
  117679. * @returns Serialized object
  117680. */
  117681. serialize(): any;
  117682. /**
  117683. * Float animation type
  117684. */
  117685. static readonly ANIMATIONTYPE_FLOAT: number;
  117686. /**
  117687. * Vector3 animation type
  117688. */
  117689. static readonly ANIMATIONTYPE_VECTOR3: number;
  117690. /**
  117691. * Quaternion animation type
  117692. */
  117693. static readonly ANIMATIONTYPE_QUATERNION: number;
  117694. /**
  117695. * Matrix animation type
  117696. */
  117697. static readonly ANIMATIONTYPE_MATRIX: number;
  117698. /**
  117699. * Color3 animation type
  117700. */
  117701. static readonly ANIMATIONTYPE_COLOR3: number;
  117702. /**
  117703. * Color3 animation type
  117704. */
  117705. static readonly ANIMATIONTYPE_COLOR4: number;
  117706. /**
  117707. * Vector2 animation type
  117708. */
  117709. static readonly ANIMATIONTYPE_VECTOR2: number;
  117710. /**
  117711. * Size animation type
  117712. */
  117713. static readonly ANIMATIONTYPE_SIZE: number;
  117714. /**
  117715. * Relative Loop Mode
  117716. */
  117717. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117718. /**
  117719. * Cycle Loop Mode
  117720. */
  117721. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117722. /**
  117723. * Constant Loop Mode
  117724. */
  117725. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117726. /** @hidden */
  117727. static _UniversalLerp(left: any, right: any, amount: number): any;
  117728. /**
  117729. * Parses an animation object and creates an animation
  117730. * @param parsedAnimation Parsed animation object
  117731. * @returns Animation object
  117732. */
  117733. static Parse(parsedAnimation: any): Animation;
  117734. /**
  117735. * Appends the serialized animations from the source animations
  117736. * @param source Source containing the animations
  117737. * @param destination Target to store the animations
  117738. */
  117739. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117740. /**
  117741. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117742. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117743. * @param url defines the url to load from
  117744. * @returns a promise that will resolve to the new animation or an array of animations
  117745. */
  117746. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117747. /**
  117748. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117749. * @param snippetId defines the snippet to load
  117750. * @returns a promise that will resolve to the new animation or a new array of animations
  117751. */
  117752. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117753. }
  117754. }
  117755. declare module BABYLON {
  117756. /**
  117757. * Interface containing an array of animations
  117758. */
  117759. export interface IAnimatable {
  117760. /**
  117761. * Array of animations
  117762. */
  117763. animations: Nullable<Array<Animation>>;
  117764. }
  117765. }
  117766. declare module BABYLON {
  117767. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117768. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117769. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117770. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117771. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117772. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117773. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117774. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117775. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117776. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117777. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117778. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117779. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117780. /**
  117781. * Decorator used to define property that can be serialized as reference to a camera
  117782. * @param sourceName defines the name of the property to decorate
  117783. */
  117784. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117785. /**
  117786. * Class used to help serialization objects
  117787. */
  117788. export class SerializationHelper {
  117789. /** @hidden */
  117790. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117791. /** @hidden */
  117792. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117793. /** @hidden */
  117794. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117795. /** @hidden */
  117796. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117797. /**
  117798. * Appends the serialized animations from the source animations
  117799. * @param source Source containing the animations
  117800. * @param destination Target to store the animations
  117801. */
  117802. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117803. /**
  117804. * Static function used to serialized a specific entity
  117805. * @param entity defines the entity to serialize
  117806. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117807. * @returns a JSON compatible object representing the serialization of the entity
  117808. */
  117809. static Serialize<T>(entity: T, serializationObject?: any): any;
  117810. /**
  117811. * Creates a new entity from a serialization data object
  117812. * @param creationFunction defines a function used to instanciated the new entity
  117813. * @param source defines the source serialization data
  117814. * @param scene defines the hosting scene
  117815. * @param rootUrl defines the root url for resources
  117816. * @returns a new entity
  117817. */
  117818. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117819. /**
  117820. * Clones an object
  117821. * @param creationFunction defines the function used to instanciate the new object
  117822. * @param source defines the source object
  117823. * @returns the cloned object
  117824. */
  117825. static Clone<T>(creationFunction: () => T, source: T): T;
  117826. /**
  117827. * Instanciates a new object based on a source one (some data will be shared between both object)
  117828. * @param creationFunction defines the function used to instanciate the new object
  117829. * @param source defines the source object
  117830. * @returns the new object
  117831. */
  117832. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117833. }
  117834. }
  117835. declare module BABYLON {
  117836. /**
  117837. * Base class of all the textures in babylon.
  117838. * It groups all the common properties the materials, post process, lights... might need
  117839. * in order to make a correct use of the texture.
  117840. */
  117841. export class BaseTexture implements IAnimatable {
  117842. /**
  117843. * Default anisotropic filtering level for the application.
  117844. * It is set to 4 as a good tradeoff between perf and quality.
  117845. */
  117846. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117847. /**
  117848. * Gets or sets the unique id of the texture
  117849. */
  117850. uniqueId: number;
  117851. /**
  117852. * Define the name of the texture.
  117853. */
  117854. name: string;
  117855. /**
  117856. * Gets or sets an object used to store user defined information.
  117857. */
  117858. metadata: any;
  117859. /**
  117860. * For internal use only. Please do not use.
  117861. */
  117862. reservedDataStore: any;
  117863. private _hasAlpha;
  117864. /**
  117865. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117866. */
  117867. set hasAlpha(value: boolean);
  117868. get hasAlpha(): boolean;
  117869. /**
  117870. * Defines if the alpha value should be determined via the rgb values.
  117871. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117872. */
  117873. getAlphaFromRGB: boolean;
  117874. /**
  117875. * Intensity or strength of the texture.
  117876. * It is commonly used by materials to fine tune the intensity of the texture
  117877. */
  117878. level: number;
  117879. /**
  117880. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117881. * This is part of the texture as textures usually maps to one uv set.
  117882. */
  117883. coordinatesIndex: number;
  117884. protected _coordinatesMode: number;
  117885. /**
  117886. * How a texture is mapped.
  117887. *
  117888. * | Value | Type | Description |
  117889. * | ----- | ----------------------------------- | ----------- |
  117890. * | 0 | EXPLICIT_MODE | |
  117891. * | 1 | SPHERICAL_MODE | |
  117892. * | 2 | PLANAR_MODE | |
  117893. * | 3 | CUBIC_MODE | |
  117894. * | 4 | PROJECTION_MODE | |
  117895. * | 5 | SKYBOX_MODE | |
  117896. * | 6 | INVCUBIC_MODE | |
  117897. * | 7 | EQUIRECTANGULAR_MODE | |
  117898. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117899. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117900. */
  117901. set coordinatesMode(value: number);
  117902. get coordinatesMode(): number;
  117903. private _wrapU;
  117904. /**
  117905. * | Value | Type | Description |
  117906. * | ----- | ------------------ | ----------- |
  117907. * | 0 | CLAMP_ADDRESSMODE | |
  117908. * | 1 | WRAP_ADDRESSMODE | |
  117909. * | 2 | MIRROR_ADDRESSMODE | |
  117910. */
  117911. get wrapU(): number;
  117912. set wrapU(value: number);
  117913. private _wrapV;
  117914. /**
  117915. * | Value | Type | Description |
  117916. * | ----- | ------------------ | ----------- |
  117917. * | 0 | CLAMP_ADDRESSMODE | |
  117918. * | 1 | WRAP_ADDRESSMODE | |
  117919. * | 2 | MIRROR_ADDRESSMODE | |
  117920. */
  117921. get wrapV(): number;
  117922. set wrapV(value: number);
  117923. /**
  117924. * | Value | Type | Description |
  117925. * | ----- | ------------------ | ----------- |
  117926. * | 0 | CLAMP_ADDRESSMODE | |
  117927. * | 1 | WRAP_ADDRESSMODE | |
  117928. * | 2 | MIRROR_ADDRESSMODE | |
  117929. */
  117930. wrapR: number;
  117931. /**
  117932. * With compliant hardware and browser (supporting anisotropic filtering)
  117933. * this defines the level of anisotropic filtering in the texture.
  117934. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117935. */
  117936. anisotropicFilteringLevel: number;
  117937. /**
  117938. * Define if the texture is a cube texture or if false a 2d texture.
  117939. */
  117940. get isCube(): boolean;
  117941. set isCube(value: boolean);
  117942. /**
  117943. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117944. */
  117945. get is3D(): boolean;
  117946. set is3D(value: boolean);
  117947. /**
  117948. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117949. */
  117950. get is2DArray(): boolean;
  117951. set is2DArray(value: boolean);
  117952. private _gammaSpace;
  117953. /**
  117954. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117955. * HDR texture are usually stored in linear space.
  117956. * This only impacts the PBR and Background materials
  117957. */
  117958. get gammaSpace(): boolean;
  117959. set gammaSpace(gamma: boolean);
  117960. /**
  117961. * Gets or sets whether or not the texture contains RGBD data.
  117962. */
  117963. get isRGBD(): boolean;
  117964. set isRGBD(value: boolean);
  117965. /**
  117966. * Is Z inverted in the texture (useful in a cube texture).
  117967. */
  117968. invertZ: boolean;
  117969. /**
  117970. * Are mip maps generated for this texture or not.
  117971. */
  117972. get noMipmap(): boolean;
  117973. /**
  117974. * @hidden
  117975. */
  117976. lodLevelInAlpha: boolean;
  117977. /**
  117978. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117979. */
  117980. get lodGenerationOffset(): number;
  117981. set lodGenerationOffset(value: number);
  117982. /**
  117983. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117984. */
  117985. get lodGenerationScale(): number;
  117986. set lodGenerationScale(value: number);
  117987. /**
  117988. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117989. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117990. * average roughness values.
  117991. */
  117992. get linearSpecularLOD(): boolean;
  117993. set linearSpecularLOD(value: boolean);
  117994. /**
  117995. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117996. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117997. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117998. */
  117999. get irradianceTexture(): Nullable<BaseTexture>;
  118000. set irradianceTexture(value: Nullable<BaseTexture>);
  118001. /**
  118002. * Define if the texture is a render target.
  118003. */
  118004. isRenderTarget: boolean;
  118005. /**
  118006. * Define the unique id of the texture in the scene.
  118007. */
  118008. get uid(): string;
  118009. /** @hidden */
  118010. _prefiltered: boolean;
  118011. /**
  118012. * Return a string representation of the texture.
  118013. * @returns the texture as a string
  118014. */
  118015. toString(): string;
  118016. /**
  118017. * Get the class name of the texture.
  118018. * @returns "BaseTexture"
  118019. */
  118020. getClassName(): string;
  118021. /**
  118022. * Define the list of animation attached to the texture.
  118023. */
  118024. animations: Animation[];
  118025. /**
  118026. * An event triggered when the texture is disposed.
  118027. */
  118028. onDisposeObservable: Observable<BaseTexture>;
  118029. private _onDisposeObserver;
  118030. /**
  118031. * Callback triggered when the texture has been disposed.
  118032. * Kept for back compatibility, you can use the onDisposeObservable instead.
  118033. */
  118034. set onDispose(callback: () => void);
  118035. /**
  118036. * Define the current state of the loading sequence when in delayed load mode.
  118037. */
  118038. delayLoadState: number;
  118039. protected _scene: Nullable<Scene>;
  118040. protected _engine: Nullable<ThinEngine>;
  118041. /** @hidden */
  118042. _texture: Nullable<InternalTexture>;
  118043. private _uid;
  118044. /**
  118045. * Define if the texture is preventinga material to render or not.
  118046. * If not and the texture is not ready, the engine will use a default black texture instead.
  118047. */
  118048. get isBlocking(): boolean;
  118049. /**
  118050. * Instantiates a new BaseTexture.
  118051. * Base class of all the textures in babylon.
  118052. * It groups all the common properties the materials, post process, lights... might need
  118053. * in order to make a correct use of the texture.
  118054. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118055. */
  118056. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118057. /**
  118058. * Get the scene the texture belongs to.
  118059. * @returns the scene or null if undefined
  118060. */
  118061. getScene(): Nullable<Scene>;
  118062. /** @hidden */
  118063. protected _getEngine(): Nullable<ThinEngine>;
  118064. /**
  118065. * Checks if the texture has the same transform matrix than another texture
  118066. * @param texture texture to check against
  118067. * @returns true if the transforms are the same, else false
  118068. */
  118069. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118070. /**
  118071. * Get the texture transform matrix used to offset tile the texture for istance.
  118072. * @returns the transformation matrix
  118073. */
  118074. getTextureMatrix(): Matrix;
  118075. /**
  118076. * Get the texture reflection matrix used to rotate/transform the reflection.
  118077. * @returns the reflection matrix
  118078. */
  118079. getReflectionTextureMatrix(): Matrix;
  118080. /**
  118081. * Get the underlying lower level texture from Babylon.
  118082. * @returns the insternal texture
  118083. */
  118084. getInternalTexture(): Nullable<InternalTexture>;
  118085. /**
  118086. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118087. * @returns true if ready or not blocking
  118088. */
  118089. isReadyOrNotBlocking(): boolean;
  118090. /**
  118091. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118092. * @returns true if fully ready
  118093. */
  118094. isReady(): boolean;
  118095. private _cachedSize;
  118096. /**
  118097. * Get the size of the texture.
  118098. * @returns the texture size.
  118099. */
  118100. getSize(): ISize;
  118101. /**
  118102. * Get the base size of the texture.
  118103. * It can be different from the size if the texture has been resized for POT for instance
  118104. * @returns the base size
  118105. */
  118106. getBaseSize(): ISize;
  118107. /**
  118108. * Update the sampling mode of the texture.
  118109. * Default is Trilinear mode.
  118110. *
  118111. * | Value | Type | Description |
  118112. * | ----- | ------------------ | ----------- |
  118113. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118114. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118115. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118116. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118117. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118118. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118119. * | 7 | NEAREST_LINEAR | |
  118120. * | 8 | NEAREST_NEAREST | |
  118121. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118122. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118123. * | 11 | LINEAR_LINEAR | |
  118124. * | 12 | LINEAR_NEAREST | |
  118125. *
  118126. * > _mag_: magnification filter (close to the viewer)
  118127. * > _min_: minification filter (far from the viewer)
  118128. * > _mip_: filter used between mip map levels
  118129. *@param samplingMode Define the new sampling mode of the texture
  118130. */
  118131. updateSamplingMode(samplingMode: number): void;
  118132. /**
  118133. * Scales the texture if is `canRescale()`
  118134. * @param ratio the resize factor we want to use to rescale
  118135. */
  118136. scale(ratio: number): void;
  118137. /**
  118138. * Get if the texture can rescale.
  118139. */
  118140. get canRescale(): boolean;
  118141. /** @hidden */
  118142. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118143. /** @hidden */
  118144. _rebuild(): void;
  118145. /**
  118146. * Triggers the load sequence in delayed load mode.
  118147. */
  118148. delayLoad(): void;
  118149. /**
  118150. * Clones the texture.
  118151. * @returns the cloned texture
  118152. */
  118153. clone(): Nullable<BaseTexture>;
  118154. /**
  118155. * Get the texture underlying type (INT, FLOAT...)
  118156. */
  118157. get textureType(): number;
  118158. /**
  118159. * Get the texture underlying format (RGB, RGBA...)
  118160. */
  118161. get textureFormat(): number;
  118162. /**
  118163. * Indicates that textures need to be re-calculated for all materials
  118164. */
  118165. protected _markAllSubMeshesAsTexturesDirty(): void;
  118166. /**
  118167. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118168. * This will returns an RGBA array buffer containing either in values (0-255) or
  118169. * float values (0-1) depending of the underlying buffer type.
  118170. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118171. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118172. * @param buffer defines a user defined buffer to fill with data (can be null)
  118173. * @returns The Array buffer containing the pixels data.
  118174. */
  118175. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118176. /**
  118177. * Release and destroy the underlying lower level texture aka internalTexture.
  118178. */
  118179. releaseInternalTexture(): void;
  118180. /** @hidden */
  118181. get _lodTextureHigh(): Nullable<BaseTexture>;
  118182. /** @hidden */
  118183. get _lodTextureMid(): Nullable<BaseTexture>;
  118184. /** @hidden */
  118185. get _lodTextureLow(): Nullable<BaseTexture>;
  118186. /**
  118187. * Dispose the texture and release its associated resources.
  118188. */
  118189. dispose(): void;
  118190. /**
  118191. * Serialize the texture into a JSON representation that can be parsed later on.
  118192. * @returns the JSON representation of the texture
  118193. */
  118194. serialize(): any;
  118195. /**
  118196. * Helper function to be called back once a list of texture contains only ready textures.
  118197. * @param textures Define the list of textures to wait for
  118198. * @param callback Define the callback triggered once the entire list will be ready
  118199. */
  118200. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118201. private static _isScene;
  118202. }
  118203. }
  118204. declare module BABYLON {
  118205. /**
  118206. * Options to be used when creating an effect.
  118207. */
  118208. export interface IEffectCreationOptions {
  118209. /**
  118210. * Atrributes that will be used in the shader.
  118211. */
  118212. attributes: string[];
  118213. /**
  118214. * Uniform varible names that will be set in the shader.
  118215. */
  118216. uniformsNames: string[];
  118217. /**
  118218. * Uniform buffer variable names that will be set in the shader.
  118219. */
  118220. uniformBuffersNames: string[];
  118221. /**
  118222. * Sampler texture variable names that will be set in the shader.
  118223. */
  118224. samplers: string[];
  118225. /**
  118226. * Define statements that will be set in the shader.
  118227. */
  118228. defines: any;
  118229. /**
  118230. * Possible fallbacks for this effect to improve performance when needed.
  118231. */
  118232. fallbacks: Nullable<IEffectFallbacks>;
  118233. /**
  118234. * Callback that will be called when the shader is compiled.
  118235. */
  118236. onCompiled: Nullable<(effect: Effect) => void>;
  118237. /**
  118238. * Callback that will be called if an error occurs during shader compilation.
  118239. */
  118240. onError: Nullable<(effect: Effect, errors: string) => void>;
  118241. /**
  118242. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118243. */
  118244. indexParameters?: any;
  118245. /**
  118246. * Max number of lights that can be used in the shader.
  118247. */
  118248. maxSimultaneousLights?: number;
  118249. /**
  118250. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118251. */
  118252. transformFeedbackVaryings?: Nullable<string[]>;
  118253. /**
  118254. * 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
  118255. */
  118256. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118257. /**
  118258. * Is this effect rendering to several color attachments ?
  118259. */
  118260. multiTarget?: boolean;
  118261. }
  118262. /**
  118263. * Effect containing vertex and fragment shader that can be executed on an object.
  118264. */
  118265. export class Effect implements IDisposable {
  118266. /**
  118267. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118268. */
  118269. static ShadersRepository: string;
  118270. /**
  118271. * Enable logging of the shader code when a compilation error occurs
  118272. */
  118273. static LogShaderCodeOnCompilationError: boolean;
  118274. /**
  118275. * Name of the effect.
  118276. */
  118277. name: any;
  118278. /**
  118279. * String container all the define statements that should be set on the shader.
  118280. */
  118281. defines: string;
  118282. /**
  118283. * Callback that will be called when the shader is compiled.
  118284. */
  118285. onCompiled: Nullable<(effect: Effect) => void>;
  118286. /**
  118287. * Callback that will be called if an error occurs during shader compilation.
  118288. */
  118289. onError: Nullable<(effect: Effect, errors: string) => void>;
  118290. /**
  118291. * Callback that will be called when effect is bound.
  118292. */
  118293. onBind: Nullable<(effect: Effect) => void>;
  118294. /**
  118295. * Unique ID of the effect.
  118296. */
  118297. uniqueId: number;
  118298. /**
  118299. * Observable that will be called when the shader is compiled.
  118300. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118301. */
  118302. onCompileObservable: Observable<Effect>;
  118303. /**
  118304. * Observable that will be called if an error occurs during shader compilation.
  118305. */
  118306. onErrorObservable: Observable<Effect>;
  118307. /** @hidden */
  118308. _onBindObservable: Nullable<Observable<Effect>>;
  118309. /**
  118310. * @hidden
  118311. * Specifies if the effect was previously ready
  118312. */
  118313. _wasPreviouslyReady: boolean;
  118314. /**
  118315. * Observable that will be called when effect is bound.
  118316. */
  118317. get onBindObservable(): Observable<Effect>;
  118318. /** @hidden */
  118319. _bonesComputationForcedToCPU: boolean;
  118320. /** @hidden */
  118321. _multiTarget: boolean;
  118322. private static _uniqueIdSeed;
  118323. private _engine;
  118324. private _uniformBuffersNames;
  118325. private _uniformBuffersNamesList;
  118326. private _uniformsNames;
  118327. private _samplerList;
  118328. private _samplers;
  118329. private _isReady;
  118330. private _compilationError;
  118331. private _allFallbacksProcessed;
  118332. private _attributesNames;
  118333. private _attributes;
  118334. private _attributeLocationByName;
  118335. private _uniforms;
  118336. /**
  118337. * Key for the effect.
  118338. * @hidden
  118339. */
  118340. _key: string;
  118341. private _indexParameters;
  118342. private _fallbacks;
  118343. private _vertexSourceCode;
  118344. private _fragmentSourceCode;
  118345. private _vertexSourceCodeOverride;
  118346. private _fragmentSourceCodeOverride;
  118347. private _transformFeedbackVaryings;
  118348. /**
  118349. * Compiled shader to webGL program.
  118350. * @hidden
  118351. */
  118352. _pipelineContext: Nullable<IPipelineContext>;
  118353. private _valueCache;
  118354. private static _baseCache;
  118355. /**
  118356. * Instantiates an effect.
  118357. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118358. * @param baseName Name of the effect.
  118359. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118360. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118361. * @param samplers List of sampler variables that will be passed to the shader.
  118362. * @param engine Engine to be used to render the effect
  118363. * @param defines Define statements to be added to the shader.
  118364. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118365. * @param onCompiled Callback that will be called when the shader is compiled.
  118366. * @param onError Callback that will be called if an error occurs during shader compilation.
  118367. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118368. */
  118369. 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);
  118370. private _useFinalCode;
  118371. /**
  118372. * Unique key for this effect
  118373. */
  118374. get key(): string;
  118375. /**
  118376. * If the effect has been compiled and prepared.
  118377. * @returns if the effect is compiled and prepared.
  118378. */
  118379. isReady(): boolean;
  118380. private _isReadyInternal;
  118381. /**
  118382. * The engine the effect was initialized with.
  118383. * @returns the engine.
  118384. */
  118385. getEngine(): Engine;
  118386. /**
  118387. * The pipeline context for this effect
  118388. * @returns the associated pipeline context
  118389. */
  118390. getPipelineContext(): Nullable<IPipelineContext>;
  118391. /**
  118392. * The set of names of attribute variables for the shader.
  118393. * @returns An array of attribute names.
  118394. */
  118395. getAttributesNames(): string[];
  118396. /**
  118397. * Returns the attribute at the given index.
  118398. * @param index The index of the attribute.
  118399. * @returns The location of the attribute.
  118400. */
  118401. getAttributeLocation(index: number): number;
  118402. /**
  118403. * Returns the attribute based on the name of the variable.
  118404. * @param name of the attribute to look up.
  118405. * @returns the attribute location.
  118406. */
  118407. getAttributeLocationByName(name: string): number;
  118408. /**
  118409. * The number of attributes.
  118410. * @returns the numnber of attributes.
  118411. */
  118412. getAttributesCount(): number;
  118413. /**
  118414. * Gets the index of a uniform variable.
  118415. * @param uniformName of the uniform to look up.
  118416. * @returns the index.
  118417. */
  118418. getUniformIndex(uniformName: string): number;
  118419. /**
  118420. * Returns the attribute based on the name of the variable.
  118421. * @param uniformName of the uniform to look up.
  118422. * @returns the location of the uniform.
  118423. */
  118424. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118425. /**
  118426. * Returns an array of sampler variable names
  118427. * @returns The array of sampler variable names.
  118428. */
  118429. getSamplers(): string[];
  118430. /**
  118431. * Returns an array of uniform variable names
  118432. * @returns The array of uniform variable names.
  118433. */
  118434. getUniformNames(): string[];
  118435. /**
  118436. * Returns an array of uniform buffer variable names
  118437. * @returns The array of uniform buffer variable names.
  118438. */
  118439. getUniformBuffersNames(): string[];
  118440. /**
  118441. * Returns the index parameters used to create the effect
  118442. * @returns The index parameters object
  118443. */
  118444. getIndexParameters(): any;
  118445. /**
  118446. * The error from the last compilation.
  118447. * @returns the error string.
  118448. */
  118449. getCompilationError(): string;
  118450. /**
  118451. * Gets a boolean indicating that all fallbacks were used during compilation
  118452. * @returns true if all fallbacks were used
  118453. */
  118454. allFallbacksProcessed(): boolean;
  118455. /**
  118456. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118457. * @param func The callback to be used.
  118458. */
  118459. executeWhenCompiled(func: (effect: Effect) => void): void;
  118460. private _checkIsReady;
  118461. private _loadShader;
  118462. /**
  118463. * Gets the vertex shader source code of this effect
  118464. */
  118465. get vertexSourceCode(): string;
  118466. /**
  118467. * Gets the fragment shader source code of this effect
  118468. */
  118469. get fragmentSourceCode(): string;
  118470. /**
  118471. * Recompiles the webGL program
  118472. * @param vertexSourceCode The source code for the vertex shader.
  118473. * @param fragmentSourceCode The source code for the fragment shader.
  118474. * @param onCompiled Callback called when completed.
  118475. * @param onError Callback called on error.
  118476. * @hidden
  118477. */
  118478. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118479. /**
  118480. * Prepares the effect
  118481. * @hidden
  118482. */
  118483. _prepareEffect(): void;
  118484. private _getShaderCodeAndErrorLine;
  118485. private _processCompilationErrors;
  118486. /**
  118487. * Checks if the effect is supported. (Must be called after compilation)
  118488. */
  118489. get isSupported(): boolean;
  118490. /**
  118491. * Binds a texture to the engine to be used as output of the shader.
  118492. * @param channel Name of the output variable.
  118493. * @param texture Texture to bind.
  118494. * @hidden
  118495. */
  118496. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118497. /**
  118498. * Sets a texture on the engine to be used in the shader.
  118499. * @param channel Name of the sampler variable.
  118500. * @param texture Texture to set.
  118501. */
  118502. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118503. /**
  118504. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118505. * @param channel Name of the sampler variable.
  118506. * @param texture Texture to set.
  118507. */
  118508. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118509. /**
  118510. * Sets an array of textures on the engine to be used in the shader.
  118511. * @param channel Name of the variable.
  118512. * @param textures Textures to set.
  118513. */
  118514. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118515. /**
  118516. * 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)
  118517. * @param channel Name of the sampler variable.
  118518. * @param postProcess Post process to get the input texture from.
  118519. */
  118520. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118521. /**
  118522. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118523. * 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)
  118524. * @param channel Name of the sampler variable.
  118525. * @param postProcess Post process to get the output texture from.
  118526. */
  118527. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118528. /** @hidden */
  118529. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118530. /** @hidden */
  118531. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118532. /** @hidden */
  118533. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118534. /** @hidden */
  118535. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118536. /**
  118537. * Binds a buffer to a uniform.
  118538. * @param buffer Buffer to bind.
  118539. * @param name Name of the uniform variable to bind to.
  118540. */
  118541. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118542. /**
  118543. * Binds block to a uniform.
  118544. * @param blockName Name of the block to bind.
  118545. * @param index Index to bind.
  118546. */
  118547. bindUniformBlock(blockName: string, index: number): void;
  118548. /**
  118549. * Sets an interger value on a uniform variable.
  118550. * @param uniformName Name of the variable.
  118551. * @param value Value to be set.
  118552. * @returns this effect.
  118553. */
  118554. setInt(uniformName: string, value: number): Effect;
  118555. /**
  118556. * Sets an int array on a uniform variable.
  118557. * @param uniformName Name of the variable.
  118558. * @param array array to be set.
  118559. * @returns this effect.
  118560. */
  118561. setIntArray(uniformName: string, array: Int32Array): Effect;
  118562. /**
  118563. * 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)
  118564. * @param uniformName Name of the variable.
  118565. * @param array array to be set.
  118566. * @returns this effect.
  118567. */
  118568. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118569. /**
  118570. * 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)
  118571. * @param uniformName Name of the variable.
  118572. * @param array array to be set.
  118573. * @returns this effect.
  118574. */
  118575. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118576. /**
  118577. * 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)
  118578. * @param uniformName Name of the variable.
  118579. * @param array array to be set.
  118580. * @returns this effect.
  118581. */
  118582. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118583. /**
  118584. * Sets an float array on a uniform variable.
  118585. * @param uniformName Name of the variable.
  118586. * @param array array to be set.
  118587. * @returns this effect.
  118588. */
  118589. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118590. /**
  118591. * 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)
  118592. * @param uniformName Name of the variable.
  118593. * @param array array to be set.
  118594. * @returns this effect.
  118595. */
  118596. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118597. /**
  118598. * 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)
  118599. * @param uniformName Name of the variable.
  118600. * @param array array to be set.
  118601. * @returns this effect.
  118602. */
  118603. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118604. /**
  118605. * 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)
  118606. * @param uniformName Name of the variable.
  118607. * @param array array to be set.
  118608. * @returns this effect.
  118609. */
  118610. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118611. /**
  118612. * Sets an array on a uniform variable.
  118613. * @param uniformName Name of the variable.
  118614. * @param array array to be set.
  118615. * @returns this effect.
  118616. */
  118617. setArray(uniformName: string, array: number[]): Effect;
  118618. /**
  118619. * 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)
  118620. * @param uniformName Name of the variable.
  118621. * @param array array to be set.
  118622. * @returns this effect.
  118623. */
  118624. setArray2(uniformName: string, array: number[]): Effect;
  118625. /**
  118626. * 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)
  118627. * @param uniformName Name of the variable.
  118628. * @param array array to be set.
  118629. * @returns this effect.
  118630. */
  118631. setArray3(uniformName: string, array: number[]): Effect;
  118632. /**
  118633. * 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)
  118634. * @param uniformName Name of the variable.
  118635. * @param array array to be set.
  118636. * @returns this effect.
  118637. */
  118638. setArray4(uniformName: string, array: number[]): Effect;
  118639. /**
  118640. * Sets matrices on a uniform variable.
  118641. * @param uniformName Name of the variable.
  118642. * @param matrices matrices to be set.
  118643. * @returns this effect.
  118644. */
  118645. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118646. /**
  118647. * Sets matrix on a uniform variable.
  118648. * @param uniformName Name of the variable.
  118649. * @param matrix matrix to be set.
  118650. * @returns this effect.
  118651. */
  118652. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118653. /**
  118654. * 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)
  118655. * @param uniformName Name of the variable.
  118656. * @param matrix matrix to be set.
  118657. * @returns this effect.
  118658. */
  118659. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118660. /**
  118661. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118662. * @param uniformName Name of the variable.
  118663. * @param matrix matrix to be set.
  118664. * @returns this effect.
  118665. */
  118666. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118667. /**
  118668. * Sets a float on a uniform variable.
  118669. * @param uniformName Name of the variable.
  118670. * @param value value to be set.
  118671. * @returns this effect.
  118672. */
  118673. setFloat(uniformName: string, value: number): Effect;
  118674. /**
  118675. * Sets a boolean on a uniform variable.
  118676. * @param uniformName Name of the variable.
  118677. * @param bool value to be set.
  118678. * @returns this effect.
  118679. */
  118680. setBool(uniformName: string, bool: boolean): Effect;
  118681. /**
  118682. * Sets a Vector2 on a uniform variable.
  118683. * @param uniformName Name of the variable.
  118684. * @param vector2 vector2 to be set.
  118685. * @returns this effect.
  118686. */
  118687. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118688. /**
  118689. * Sets a float2 on a uniform variable.
  118690. * @param uniformName Name of the variable.
  118691. * @param x First float in float2.
  118692. * @param y Second float in float2.
  118693. * @returns this effect.
  118694. */
  118695. setFloat2(uniformName: string, x: number, y: number): Effect;
  118696. /**
  118697. * Sets a Vector3 on a uniform variable.
  118698. * @param uniformName Name of the variable.
  118699. * @param vector3 Value to be set.
  118700. * @returns this effect.
  118701. */
  118702. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118703. /**
  118704. * Sets a float3 on a uniform variable.
  118705. * @param uniformName Name of the variable.
  118706. * @param x First float in float3.
  118707. * @param y Second float in float3.
  118708. * @param z Third float in float3.
  118709. * @returns this effect.
  118710. */
  118711. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118712. /**
  118713. * Sets a Vector4 on a uniform variable.
  118714. * @param uniformName Name of the variable.
  118715. * @param vector4 Value to be set.
  118716. * @returns this effect.
  118717. */
  118718. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118719. /**
  118720. * Sets a float4 on a uniform variable.
  118721. * @param uniformName Name of the variable.
  118722. * @param x First float in float4.
  118723. * @param y Second float in float4.
  118724. * @param z Third float in float4.
  118725. * @param w Fourth float in float4.
  118726. * @returns this effect.
  118727. */
  118728. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118729. /**
  118730. * Sets a Color3 on a uniform variable.
  118731. * @param uniformName Name of the variable.
  118732. * @param color3 Value to be set.
  118733. * @returns this effect.
  118734. */
  118735. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118736. /**
  118737. * Sets a Color4 on a uniform variable.
  118738. * @param uniformName Name of the variable.
  118739. * @param color3 Value to be set.
  118740. * @param alpha Alpha value to be set.
  118741. * @returns this effect.
  118742. */
  118743. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118744. /**
  118745. * Sets a Color4 on a uniform variable
  118746. * @param uniformName defines the name of the variable
  118747. * @param color4 defines the value to be set
  118748. * @returns this effect.
  118749. */
  118750. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118751. /** Release all associated resources */
  118752. dispose(): void;
  118753. /**
  118754. * This function will add a new shader to the shader store
  118755. * @param name the name of the shader
  118756. * @param pixelShader optional pixel shader content
  118757. * @param vertexShader optional vertex shader content
  118758. */
  118759. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118760. /**
  118761. * Store of each shader (The can be looked up using effect.key)
  118762. */
  118763. static ShadersStore: {
  118764. [key: string]: string;
  118765. };
  118766. /**
  118767. * Store of each included file for a shader (The can be looked up using effect.key)
  118768. */
  118769. static IncludesShadersStore: {
  118770. [key: string]: string;
  118771. };
  118772. /**
  118773. * Resets the cache of effects.
  118774. */
  118775. static ResetCache(): void;
  118776. }
  118777. }
  118778. declare module BABYLON {
  118779. /**
  118780. * Interface used to describe the capabilities of the engine relatively to the current browser
  118781. */
  118782. export interface EngineCapabilities {
  118783. /** Maximum textures units per fragment shader */
  118784. maxTexturesImageUnits: number;
  118785. /** Maximum texture units per vertex shader */
  118786. maxVertexTextureImageUnits: number;
  118787. /** Maximum textures units in the entire pipeline */
  118788. maxCombinedTexturesImageUnits: number;
  118789. /** Maximum texture size */
  118790. maxTextureSize: number;
  118791. /** Maximum texture samples */
  118792. maxSamples?: number;
  118793. /** Maximum cube texture size */
  118794. maxCubemapTextureSize: number;
  118795. /** Maximum render texture size */
  118796. maxRenderTextureSize: number;
  118797. /** Maximum number of vertex attributes */
  118798. maxVertexAttribs: number;
  118799. /** Maximum number of varyings */
  118800. maxVaryingVectors: number;
  118801. /** Maximum number of uniforms per vertex shader */
  118802. maxVertexUniformVectors: number;
  118803. /** Maximum number of uniforms per fragment shader */
  118804. maxFragmentUniformVectors: number;
  118805. /** Defines if standard derivates (dx/dy) are supported */
  118806. standardDerivatives: boolean;
  118807. /** Defines if s3tc texture compression is supported */
  118808. s3tc?: WEBGL_compressed_texture_s3tc;
  118809. /** Defines if pvrtc texture compression is supported */
  118810. pvrtc: any;
  118811. /** Defines if etc1 texture compression is supported */
  118812. etc1: any;
  118813. /** Defines if etc2 texture compression is supported */
  118814. etc2: any;
  118815. /** Defines if astc texture compression is supported */
  118816. astc: any;
  118817. /** Defines if bptc texture compression is supported */
  118818. bptc: any;
  118819. /** Defines if float textures are supported */
  118820. textureFloat: boolean;
  118821. /** Defines if vertex array objects are supported */
  118822. vertexArrayObject: boolean;
  118823. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118824. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118825. /** Gets the maximum level of anisotropy supported */
  118826. maxAnisotropy: number;
  118827. /** Defines if instancing is supported */
  118828. instancedArrays: boolean;
  118829. /** Defines if 32 bits indices are supported */
  118830. uintIndices: boolean;
  118831. /** Defines if high precision shaders are supported */
  118832. highPrecisionShaderSupported: boolean;
  118833. /** Defines if depth reading in the fragment shader is supported */
  118834. fragmentDepthSupported: boolean;
  118835. /** Defines if float texture linear filtering is supported*/
  118836. textureFloatLinearFiltering: boolean;
  118837. /** Defines if rendering to float textures is supported */
  118838. textureFloatRender: boolean;
  118839. /** Defines if half float textures are supported*/
  118840. textureHalfFloat: boolean;
  118841. /** Defines if half float texture linear filtering is supported*/
  118842. textureHalfFloatLinearFiltering: boolean;
  118843. /** Defines if rendering to half float textures is supported */
  118844. textureHalfFloatRender: boolean;
  118845. /** Defines if textureLOD shader command is supported */
  118846. textureLOD: boolean;
  118847. /** Defines if draw buffers extension is supported */
  118848. drawBuffersExtension: boolean;
  118849. /** Defines if depth textures are supported */
  118850. depthTextureExtension: boolean;
  118851. /** Defines if float color buffer are supported */
  118852. colorBufferFloat: boolean;
  118853. /** Gets disjoint timer query extension (null if not supported) */
  118854. timerQuery?: EXT_disjoint_timer_query;
  118855. /** Defines if timestamp can be used with timer query */
  118856. canUseTimestampForTimerQuery: boolean;
  118857. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118858. multiview?: any;
  118859. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118860. oculusMultiview?: any;
  118861. /** Function used to let the system compiles shaders in background */
  118862. parallelShaderCompile?: {
  118863. COMPLETION_STATUS_KHR: number;
  118864. };
  118865. /** Max number of texture samples for MSAA */
  118866. maxMSAASamples: number;
  118867. /** Defines if the blend min max extension is supported */
  118868. blendMinMax: boolean;
  118869. }
  118870. }
  118871. declare module BABYLON {
  118872. /**
  118873. * @hidden
  118874. **/
  118875. export class DepthCullingState {
  118876. private _isDepthTestDirty;
  118877. private _isDepthMaskDirty;
  118878. private _isDepthFuncDirty;
  118879. private _isCullFaceDirty;
  118880. private _isCullDirty;
  118881. private _isZOffsetDirty;
  118882. private _isFrontFaceDirty;
  118883. private _depthTest;
  118884. private _depthMask;
  118885. private _depthFunc;
  118886. private _cull;
  118887. private _cullFace;
  118888. private _zOffset;
  118889. private _frontFace;
  118890. /**
  118891. * Initializes the state.
  118892. */
  118893. constructor();
  118894. get isDirty(): boolean;
  118895. get zOffset(): number;
  118896. set zOffset(value: number);
  118897. get cullFace(): Nullable<number>;
  118898. set cullFace(value: Nullable<number>);
  118899. get cull(): Nullable<boolean>;
  118900. set cull(value: Nullable<boolean>);
  118901. get depthFunc(): Nullable<number>;
  118902. set depthFunc(value: Nullable<number>);
  118903. get depthMask(): boolean;
  118904. set depthMask(value: boolean);
  118905. get depthTest(): boolean;
  118906. set depthTest(value: boolean);
  118907. get frontFace(): Nullable<number>;
  118908. set frontFace(value: Nullable<number>);
  118909. reset(): void;
  118910. apply(gl: WebGLRenderingContext): void;
  118911. }
  118912. }
  118913. declare module BABYLON {
  118914. /**
  118915. * @hidden
  118916. **/
  118917. export class StencilState {
  118918. /** 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 */
  118919. static readonly ALWAYS: number;
  118920. /** Passed to stencilOperation to specify that stencil value must be kept */
  118921. static readonly KEEP: number;
  118922. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118923. static readonly REPLACE: number;
  118924. private _isStencilTestDirty;
  118925. private _isStencilMaskDirty;
  118926. private _isStencilFuncDirty;
  118927. private _isStencilOpDirty;
  118928. private _stencilTest;
  118929. private _stencilMask;
  118930. private _stencilFunc;
  118931. private _stencilFuncRef;
  118932. private _stencilFuncMask;
  118933. private _stencilOpStencilFail;
  118934. private _stencilOpDepthFail;
  118935. private _stencilOpStencilDepthPass;
  118936. get isDirty(): boolean;
  118937. get stencilFunc(): number;
  118938. set stencilFunc(value: number);
  118939. get stencilFuncRef(): number;
  118940. set stencilFuncRef(value: number);
  118941. get stencilFuncMask(): number;
  118942. set stencilFuncMask(value: number);
  118943. get stencilOpStencilFail(): number;
  118944. set stencilOpStencilFail(value: number);
  118945. get stencilOpDepthFail(): number;
  118946. set stencilOpDepthFail(value: number);
  118947. get stencilOpStencilDepthPass(): number;
  118948. set stencilOpStencilDepthPass(value: number);
  118949. get stencilMask(): number;
  118950. set stencilMask(value: number);
  118951. get stencilTest(): boolean;
  118952. set stencilTest(value: boolean);
  118953. constructor();
  118954. reset(): void;
  118955. apply(gl: WebGLRenderingContext): void;
  118956. }
  118957. }
  118958. declare module BABYLON {
  118959. /**
  118960. * @hidden
  118961. **/
  118962. export class AlphaState {
  118963. private _isAlphaBlendDirty;
  118964. private _isBlendFunctionParametersDirty;
  118965. private _isBlendEquationParametersDirty;
  118966. private _isBlendConstantsDirty;
  118967. private _alphaBlend;
  118968. private _blendFunctionParameters;
  118969. private _blendEquationParameters;
  118970. private _blendConstants;
  118971. /**
  118972. * Initializes the state.
  118973. */
  118974. constructor();
  118975. get isDirty(): boolean;
  118976. get alphaBlend(): boolean;
  118977. set alphaBlend(value: boolean);
  118978. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118979. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118980. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118981. reset(): void;
  118982. apply(gl: WebGLRenderingContext): void;
  118983. }
  118984. }
  118985. declare module BABYLON {
  118986. /** @hidden */
  118987. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118988. attributeProcessor(attribute: string): string;
  118989. varyingProcessor(varying: string, isFragment: boolean): string;
  118990. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118991. }
  118992. }
  118993. declare module BABYLON {
  118994. /**
  118995. * Interface for attribute information associated with buffer instanciation
  118996. */
  118997. export interface InstancingAttributeInfo {
  118998. /**
  118999. * Name of the GLSL attribute
  119000. * if attribute index is not specified, this is used to retrieve the index from the effect
  119001. */
  119002. attributeName: string;
  119003. /**
  119004. * Index/offset of the attribute in the vertex shader
  119005. * if not specified, this will be computes from the name.
  119006. */
  119007. index?: number;
  119008. /**
  119009. * size of the attribute, 1, 2, 3 or 4
  119010. */
  119011. attributeSize: number;
  119012. /**
  119013. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  119014. */
  119015. offset: number;
  119016. /**
  119017. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  119018. * default to 1
  119019. */
  119020. divisor?: number;
  119021. /**
  119022. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  119023. * default is FLOAT
  119024. */
  119025. attributeType?: number;
  119026. /**
  119027. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  119028. */
  119029. normalized?: boolean;
  119030. }
  119031. }
  119032. declare module BABYLON {
  119033. interface ThinEngine {
  119034. /**
  119035. * Update a video texture
  119036. * @param texture defines the texture to update
  119037. * @param video defines the video element to use
  119038. * @param invertY defines if data must be stored with Y axis inverted
  119039. */
  119040. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  119041. }
  119042. }
  119043. declare module BABYLON {
  119044. interface ThinEngine {
  119045. /**
  119046. * Creates a dynamic texture
  119047. * @param width defines the width of the texture
  119048. * @param height defines the height of the texture
  119049. * @param generateMipMaps defines if the engine should generate the mip levels
  119050. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119051. * @returns the dynamic texture inside an InternalTexture
  119052. */
  119053. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119054. /**
  119055. * Update the content of a dynamic texture
  119056. * @param texture defines the texture to update
  119057. * @param canvas defines the canvas containing the source
  119058. * @param invertY defines if data must be stored with Y axis inverted
  119059. * @param premulAlpha defines if alpha is stored as premultiplied
  119060. * @param format defines the format of the data
  119061. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119062. */
  119063. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119064. }
  119065. }
  119066. declare module BABYLON {
  119067. /**
  119068. * Settings for finer control over video usage
  119069. */
  119070. export interface VideoTextureSettings {
  119071. /**
  119072. * Applies `autoplay` to video, if specified
  119073. */
  119074. autoPlay?: boolean;
  119075. /**
  119076. * Applies `muted` to video, if specified
  119077. */
  119078. muted?: boolean;
  119079. /**
  119080. * Applies `loop` to video, if specified
  119081. */
  119082. loop?: boolean;
  119083. /**
  119084. * Automatically updates internal texture from video at every frame in the render loop
  119085. */
  119086. autoUpdateTexture: boolean;
  119087. /**
  119088. * Image src displayed during the video loading or until the user interacts with the video.
  119089. */
  119090. poster?: string;
  119091. }
  119092. /**
  119093. * If you want to display a video in your scene, this is the special texture for that.
  119094. * This special texture works similar to other textures, with the exception of a few parameters.
  119095. * @see https://doc.babylonjs.com/how_to/video_texture
  119096. */
  119097. export class VideoTexture extends Texture {
  119098. /**
  119099. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119100. */
  119101. readonly autoUpdateTexture: boolean;
  119102. /**
  119103. * The video instance used by the texture internally
  119104. */
  119105. readonly video: HTMLVideoElement;
  119106. private _onUserActionRequestedObservable;
  119107. /**
  119108. * Event triggerd when a dom action is required by the user to play the video.
  119109. * This happens due to recent changes in browser policies preventing video to auto start.
  119110. */
  119111. get onUserActionRequestedObservable(): Observable<Texture>;
  119112. private _generateMipMaps;
  119113. private _stillImageCaptured;
  119114. private _displayingPosterTexture;
  119115. private _settings;
  119116. private _createInternalTextureOnEvent;
  119117. private _frameId;
  119118. private _currentSrc;
  119119. /**
  119120. * Creates a video texture.
  119121. * If you want to display a video in your scene, this is the special texture for that.
  119122. * This special texture works similar to other textures, with the exception of a few parameters.
  119123. * @see https://doc.babylonjs.com/how_to/video_texture
  119124. * @param name optional name, will detect from video source, if not defined
  119125. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119126. * @param scene is obviously the current scene.
  119127. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119128. * @param invertY is false by default but can be used to invert video on Y axis
  119129. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119130. * @param settings allows finer control over video usage
  119131. */
  119132. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119133. private _getName;
  119134. private _getVideo;
  119135. private _createInternalTexture;
  119136. private reset;
  119137. /**
  119138. * @hidden Internal method to initiate `update`.
  119139. */
  119140. _rebuild(): void;
  119141. /**
  119142. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119143. */
  119144. update(): void;
  119145. /**
  119146. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119147. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119148. */
  119149. updateTexture(isVisible: boolean): void;
  119150. protected _updateInternalTexture: () => void;
  119151. /**
  119152. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119153. * @param url New url.
  119154. */
  119155. updateURL(url: string): void;
  119156. /**
  119157. * Clones the texture.
  119158. * @returns the cloned texture
  119159. */
  119160. clone(): VideoTexture;
  119161. /**
  119162. * Dispose the texture and release its associated resources.
  119163. */
  119164. dispose(): void;
  119165. /**
  119166. * Creates a video texture straight from a stream.
  119167. * @param scene Define the scene the texture should be created in
  119168. * @param stream Define the stream the texture should be created from
  119169. * @returns The created video texture as a promise
  119170. */
  119171. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119172. /**
  119173. * Creates a video texture straight from your WebCam video feed.
  119174. * @param scene Define the scene the texture should be created in
  119175. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119176. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119177. * @returns The created video texture as a promise
  119178. */
  119179. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119180. minWidth: number;
  119181. maxWidth: number;
  119182. minHeight: number;
  119183. maxHeight: number;
  119184. deviceId: string;
  119185. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119186. /**
  119187. * Creates a video texture straight from your WebCam video feed.
  119188. * @param scene Define the scene the texture should be created in
  119189. * @param onReady Define a callback to triggered once the texture will be ready
  119190. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119191. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119192. */
  119193. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119194. minWidth: number;
  119195. maxWidth: number;
  119196. minHeight: number;
  119197. maxHeight: number;
  119198. deviceId: string;
  119199. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119200. }
  119201. }
  119202. declare module BABYLON {
  119203. /**
  119204. * Defines the interface used by objects working like Scene
  119205. * @hidden
  119206. */
  119207. export interface ISceneLike {
  119208. _addPendingData(data: any): void;
  119209. _removePendingData(data: any): void;
  119210. offlineProvider: IOfflineProvider;
  119211. }
  119212. /**
  119213. * Information about the current host
  119214. */
  119215. export interface HostInformation {
  119216. /**
  119217. * Defines if the current host is a mobile
  119218. */
  119219. isMobile: boolean;
  119220. }
  119221. /** Interface defining initialization parameters for Engine class */
  119222. export interface EngineOptions extends WebGLContextAttributes {
  119223. /**
  119224. * Defines if the engine should no exceed a specified device ratio
  119225. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119226. */
  119227. limitDeviceRatio?: number;
  119228. /**
  119229. * Defines if webvr should be enabled automatically
  119230. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119231. */
  119232. autoEnableWebVR?: boolean;
  119233. /**
  119234. * Defines if webgl2 should be turned off even if supported
  119235. * @see https://doc.babylonjs.com/features/webgl2
  119236. */
  119237. disableWebGL2Support?: boolean;
  119238. /**
  119239. * Defines if webaudio should be initialized as well
  119240. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119241. */
  119242. audioEngine?: boolean;
  119243. /**
  119244. * Defines if animations should run using a deterministic lock step
  119245. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119246. */
  119247. deterministicLockstep?: boolean;
  119248. /** Defines the maximum steps to use with deterministic lock step mode */
  119249. lockstepMaxSteps?: number;
  119250. /** Defines the seconds between each deterministic lock step */
  119251. timeStep?: number;
  119252. /**
  119253. * Defines that engine should ignore context lost events
  119254. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119255. */
  119256. doNotHandleContextLost?: boolean;
  119257. /**
  119258. * Defines that engine should ignore modifying touch action attribute and style
  119259. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119260. */
  119261. doNotHandleTouchAction?: boolean;
  119262. /**
  119263. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119264. */
  119265. useHighPrecisionFloats?: boolean;
  119266. /**
  119267. * Make the canvas XR Compatible for XR sessions
  119268. */
  119269. xrCompatible?: boolean;
  119270. /**
  119271. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119272. */
  119273. useHighPrecisionMatrix?: boolean;
  119274. /**
  119275. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119276. */
  119277. failIfMajorPerformanceCaveat?: boolean;
  119278. }
  119279. /**
  119280. * The base engine class (root of all engines)
  119281. */
  119282. export class ThinEngine {
  119283. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119284. static ExceptionList: ({
  119285. key: string;
  119286. capture: string;
  119287. captureConstraint: number;
  119288. targets: string[];
  119289. } | {
  119290. key: string;
  119291. capture: null;
  119292. captureConstraint: null;
  119293. targets: string[];
  119294. })[];
  119295. /** @hidden */
  119296. static _TextureLoaders: IInternalTextureLoader[];
  119297. /**
  119298. * Returns the current npm package of the sdk
  119299. */
  119300. static get NpmPackage(): string;
  119301. /**
  119302. * Returns the current version of the framework
  119303. */
  119304. static get Version(): string;
  119305. /**
  119306. * Returns a string describing the current engine
  119307. */
  119308. get description(): string;
  119309. /**
  119310. * Gets or sets the epsilon value used by collision engine
  119311. */
  119312. static CollisionsEpsilon: number;
  119313. /**
  119314. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119315. */
  119316. static get ShadersRepository(): string;
  119317. static set ShadersRepository(value: string);
  119318. /** @hidden */
  119319. _shaderProcessor: IShaderProcessor;
  119320. /**
  119321. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119322. */
  119323. forcePOTTextures: boolean;
  119324. /**
  119325. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119326. */
  119327. isFullscreen: boolean;
  119328. /**
  119329. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119330. */
  119331. cullBackFaces: boolean;
  119332. /**
  119333. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119334. */
  119335. renderEvenInBackground: boolean;
  119336. /**
  119337. * Gets or sets a boolean indicating that cache can be kept between frames
  119338. */
  119339. preventCacheWipeBetweenFrames: boolean;
  119340. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119341. validateShaderPrograms: boolean;
  119342. /**
  119343. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119344. * This can provide greater z depth for distant objects.
  119345. */
  119346. useReverseDepthBuffer: boolean;
  119347. /**
  119348. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119349. */
  119350. disableUniformBuffers: boolean;
  119351. /** @hidden */
  119352. _uniformBuffers: UniformBuffer[];
  119353. /**
  119354. * Gets a boolean indicating that the engine supports uniform buffers
  119355. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119356. */
  119357. get supportsUniformBuffers(): boolean;
  119358. /** @hidden */
  119359. _gl: WebGLRenderingContext;
  119360. /** @hidden */
  119361. _webGLVersion: number;
  119362. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119363. protected _windowIsBackground: boolean;
  119364. protected _creationOptions: EngineOptions;
  119365. protected _highPrecisionShadersAllowed: boolean;
  119366. /** @hidden */
  119367. get _shouldUseHighPrecisionShader(): boolean;
  119368. /**
  119369. * Gets a boolean indicating that only power of 2 textures are supported
  119370. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119371. */
  119372. get needPOTTextures(): boolean;
  119373. /** @hidden */
  119374. _badOS: boolean;
  119375. /** @hidden */
  119376. _badDesktopOS: boolean;
  119377. private _hardwareScalingLevel;
  119378. /** @hidden */
  119379. _caps: EngineCapabilities;
  119380. private _isStencilEnable;
  119381. private _glVersion;
  119382. private _glRenderer;
  119383. private _glVendor;
  119384. /** @hidden */
  119385. _videoTextureSupported: boolean;
  119386. protected _renderingQueueLaunched: boolean;
  119387. protected _activeRenderLoops: (() => void)[];
  119388. /**
  119389. * Observable signaled when a context lost event is raised
  119390. */
  119391. onContextLostObservable: Observable<ThinEngine>;
  119392. /**
  119393. * Observable signaled when a context restored event is raised
  119394. */
  119395. onContextRestoredObservable: Observable<ThinEngine>;
  119396. private _onContextLost;
  119397. private _onContextRestored;
  119398. protected _contextWasLost: boolean;
  119399. /** @hidden */
  119400. _doNotHandleContextLost: boolean;
  119401. /**
  119402. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119403. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119404. */
  119405. get doNotHandleContextLost(): boolean;
  119406. set doNotHandleContextLost(value: boolean);
  119407. /**
  119408. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119409. */
  119410. disableVertexArrayObjects: boolean;
  119411. /** @hidden */
  119412. protected _colorWrite: boolean;
  119413. /** @hidden */
  119414. protected _colorWriteChanged: boolean;
  119415. /** @hidden */
  119416. protected _depthCullingState: DepthCullingState;
  119417. /** @hidden */
  119418. protected _stencilState: StencilState;
  119419. /** @hidden */
  119420. _alphaState: AlphaState;
  119421. /** @hidden */
  119422. _alphaMode: number;
  119423. /** @hidden */
  119424. _alphaEquation: number;
  119425. /** @hidden */
  119426. _internalTexturesCache: InternalTexture[];
  119427. /** @hidden */
  119428. protected _activeChannel: number;
  119429. private _currentTextureChannel;
  119430. /** @hidden */
  119431. protected _boundTexturesCache: {
  119432. [key: string]: Nullable<InternalTexture>;
  119433. };
  119434. /** @hidden */
  119435. protected _currentEffect: Nullable<Effect>;
  119436. /** @hidden */
  119437. protected _currentProgram: Nullable<WebGLProgram>;
  119438. private _compiledEffects;
  119439. private _vertexAttribArraysEnabled;
  119440. /** @hidden */
  119441. protected _cachedViewport: Nullable<IViewportLike>;
  119442. private _cachedVertexArrayObject;
  119443. /** @hidden */
  119444. protected _cachedVertexBuffers: any;
  119445. /** @hidden */
  119446. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119447. /** @hidden */
  119448. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119449. /** @hidden */
  119450. _currentRenderTarget: Nullable<InternalTexture>;
  119451. private _uintIndicesCurrentlySet;
  119452. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119453. /** @hidden */
  119454. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119455. /** @hidden */
  119456. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119457. private _currentBufferPointers;
  119458. private _currentInstanceLocations;
  119459. private _currentInstanceBuffers;
  119460. private _textureUnits;
  119461. /** @hidden */
  119462. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119463. /** @hidden */
  119464. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119465. /** @hidden */
  119466. _boundRenderFunction: any;
  119467. private _vaoRecordInProgress;
  119468. private _mustWipeVertexAttributes;
  119469. private _emptyTexture;
  119470. private _emptyCubeTexture;
  119471. private _emptyTexture3D;
  119472. private _emptyTexture2DArray;
  119473. /** @hidden */
  119474. _frameHandler: number;
  119475. private _nextFreeTextureSlots;
  119476. private _maxSimultaneousTextures;
  119477. private _activeRequests;
  119478. /** @hidden */
  119479. _transformTextureUrl: Nullable<(url: string) => string>;
  119480. /**
  119481. * Gets information about the current host
  119482. */
  119483. hostInformation: HostInformation;
  119484. protected get _supportsHardwareTextureRescaling(): boolean;
  119485. private _framebufferDimensionsObject;
  119486. /**
  119487. * sets the object from which width and height will be taken from when getting render width and height
  119488. * Will fallback to the gl object
  119489. * @param dimensions the framebuffer width and height that will be used.
  119490. */
  119491. set framebufferDimensionsObject(dimensions: Nullable<{
  119492. framebufferWidth: number;
  119493. framebufferHeight: number;
  119494. }>);
  119495. /**
  119496. * Gets the current viewport
  119497. */
  119498. get currentViewport(): Nullable<IViewportLike>;
  119499. /**
  119500. * Gets the default empty texture
  119501. */
  119502. get emptyTexture(): InternalTexture;
  119503. /**
  119504. * Gets the default empty 3D texture
  119505. */
  119506. get emptyTexture3D(): InternalTexture;
  119507. /**
  119508. * Gets the default empty 2D array texture
  119509. */
  119510. get emptyTexture2DArray(): InternalTexture;
  119511. /**
  119512. * Gets the default empty cube texture
  119513. */
  119514. get emptyCubeTexture(): InternalTexture;
  119515. /**
  119516. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119517. */
  119518. readonly premultipliedAlpha: boolean;
  119519. /**
  119520. * Observable event triggered before each texture is initialized
  119521. */
  119522. onBeforeTextureInitObservable: Observable<Texture>;
  119523. /**
  119524. * Creates a new engine
  119525. * @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
  119526. * @param antialias defines enable antialiasing (default: false)
  119527. * @param options defines further options to be sent to the getContext() function
  119528. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119529. */
  119530. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119531. private _rebuildInternalTextures;
  119532. private _rebuildEffects;
  119533. /**
  119534. * Gets a boolean indicating if all created effects are ready
  119535. * @returns true if all effects are ready
  119536. */
  119537. areAllEffectsReady(): boolean;
  119538. protected _rebuildBuffers(): void;
  119539. protected _initGLContext(): void;
  119540. /**
  119541. * Gets version of the current webGL context
  119542. */
  119543. get webGLVersion(): number;
  119544. /**
  119545. * Gets a string identifying the name of the class
  119546. * @returns "Engine" string
  119547. */
  119548. getClassName(): string;
  119549. /**
  119550. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119551. */
  119552. get isStencilEnable(): boolean;
  119553. /** @hidden */
  119554. _prepareWorkingCanvas(): void;
  119555. /**
  119556. * Reset the texture cache to empty state
  119557. */
  119558. resetTextureCache(): void;
  119559. /**
  119560. * Gets an object containing information about the current webGL context
  119561. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119562. */
  119563. getGlInfo(): {
  119564. vendor: string;
  119565. renderer: string;
  119566. version: string;
  119567. };
  119568. /**
  119569. * Defines the hardware scaling level.
  119570. * By default the hardware scaling level is computed from the window device ratio.
  119571. * 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.
  119572. * @param level defines the level to use
  119573. */
  119574. setHardwareScalingLevel(level: number): void;
  119575. /**
  119576. * Gets the current hardware scaling level.
  119577. * By default the hardware scaling level is computed from the window device ratio.
  119578. * 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.
  119579. * @returns a number indicating the current hardware scaling level
  119580. */
  119581. getHardwareScalingLevel(): number;
  119582. /**
  119583. * Gets the list of loaded textures
  119584. * @returns an array containing all loaded textures
  119585. */
  119586. getLoadedTexturesCache(): InternalTexture[];
  119587. /**
  119588. * Gets the object containing all engine capabilities
  119589. * @returns the EngineCapabilities object
  119590. */
  119591. getCaps(): EngineCapabilities;
  119592. /**
  119593. * stop executing a render loop function and remove it from the execution array
  119594. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119595. */
  119596. stopRenderLoop(renderFunction?: () => void): void;
  119597. /** @hidden */
  119598. _renderLoop(): void;
  119599. /**
  119600. * Gets the HTML canvas attached with the current webGL context
  119601. * @returns a HTML canvas
  119602. */
  119603. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119604. /**
  119605. * Gets host window
  119606. * @returns the host window object
  119607. */
  119608. getHostWindow(): Nullable<Window>;
  119609. /**
  119610. * Gets the current render width
  119611. * @param useScreen defines if screen size must be used (or the current render target if any)
  119612. * @returns a number defining the current render width
  119613. */
  119614. getRenderWidth(useScreen?: boolean): number;
  119615. /**
  119616. * Gets the current render height
  119617. * @param useScreen defines if screen size must be used (or the current render target if any)
  119618. * @returns a number defining the current render height
  119619. */
  119620. getRenderHeight(useScreen?: boolean): number;
  119621. /**
  119622. * Can be used to override the current requestAnimationFrame requester.
  119623. * @hidden
  119624. */
  119625. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119626. /**
  119627. * Register and execute a render loop. The engine can have more than one render function
  119628. * @param renderFunction defines the function to continuously execute
  119629. */
  119630. runRenderLoop(renderFunction: () => void): void;
  119631. /**
  119632. * Clear the current render buffer or the current render target (if any is set up)
  119633. * @param color defines the color to use
  119634. * @param backBuffer defines if the back buffer must be cleared
  119635. * @param depth defines if the depth buffer must be cleared
  119636. * @param stencil defines if the stencil buffer must be cleared
  119637. */
  119638. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119639. private _viewportCached;
  119640. /** @hidden */
  119641. _viewport(x: number, y: number, width: number, height: number): void;
  119642. /**
  119643. * Set the WebGL's viewport
  119644. * @param viewport defines the viewport element to be used
  119645. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119646. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119647. */
  119648. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119649. /**
  119650. * Begin a new frame
  119651. */
  119652. beginFrame(): void;
  119653. /**
  119654. * Enf the current frame
  119655. */
  119656. endFrame(): void;
  119657. /**
  119658. * Resize the view according to the canvas' size
  119659. */
  119660. resize(): void;
  119661. /**
  119662. * Force a specific size of the canvas
  119663. * @param width defines the new canvas' width
  119664. * @param height defines the new canvas' height
  119665. * @returns true if the size was changed
  119666. */
  119667. setSize(width: number, height: number): boolean;
  119668. /**
  119669. * Binds the frame buffer to the specified texture.
  119670. * @param texture The texture to render to or null for the default canvas
  119671. * @param faceIndex The face of the texture to render to in case of cube texture
  119672. * @param requiredWidth The width of the target to render to
  119673. * @param requiredHeight The height of the target to render to
  119674. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119675. * @param lodLevel defines the lod level to bind to the frame buffer
  119676. * @param layer defines the 2d array index to bind to frame buffer to
  119677. */
  119678. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119679. /** @hidden */
  119680. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119681. /**
  119682. * Unbind the current render target texture from the webGL context
  119683. * @param texture defines the render target texture to unbind
  119684. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119685. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119686. */
  119687. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119688. /**
  119689. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119690. */
  119691. flushFramebuffer(): void;
  119692. /**
  119693. * Unbind the current render target and bind the default framebuffer
  119694. */
  119695. restoreDefaultFramebuffer(): void;
  119696. /** @hidden */
  119697. protected _resetVertexBufferBinding(): void;
  119698. /**
  119699. * Creates a vertex buffer
  119700. * @param data the data for the vertex buffer
  119701. * @returns the new WebGL static buffer
  119702. */
  119703. createVertexBuffer(data: DataArray): DataBuffer;
  119704. private _createVertexBuffer;
  119705. /**
  119706. * Creates a dynamic vertex buffer
  119707. * @param data the data for the dynamic vertex buffer
  119708. * @returns the new WebGL dynamic buffer
  119709. */
  119710. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119711. protected _resetIndexBufferBinding(): void;
  119712. /**
  119713. * Creates a new index buffer
  119714. * @param indices defines the content of the index buffer
  119715. * @param updatable defines if the index buffer must be updatable
  119716. * @returns a new webGL buffer
  119717. */
  119718. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119719. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119720. /**
  119721. * Bind a webGL buffer to the webGL context
  119722. * @param buffer defines the buffer to bind
  119723. */
  119724. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119725. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119726. private bindBuffer;
  119727. /**
  119728. * update the bound buffer with the given data
  119729. * @param data defines the data to update
  119730. */
  119731. updateArrayBuffer(data: Float32Array): void;
  119732. private _vertexAttribPointer;
  119733. /** @hidden */
  119734. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119735. private _bindVertexBuffersAttributes;
  119736. /**
  119737. * Records a vertex array object
  119738. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119739. * @param vertexBuffers defines the list of vertex buffers to store
  119740. * @param indexBuffer defines the index buffer to store
  119741. * @param effect defines the effect to store
  119742. * @returns the new vertex array object
  119743. */
  119744. recordVertexArrayObject(vertexBuffers: {
  119745. [key: string]: VertexBuffer;
  119746. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119747. /**
  119748. * Bind a specific vertex array object
  119749. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119750. * @param vertexArrayObject defines the vertex array object to bind
  119751. * @param indexBuffer defines the index buffer to bind
  119752. */
  119753. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119754. /**
  119755. * Bind webGl buffers directly to the webGL context
  119756. * @param vertexBuffer defines the vertex buffer to bind
  119757. * @param indexBuffer defines the index buffer to bind
  119758. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119759. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119760. * @param effect defines the effect associated with the vertex buffer
  119761. */
  119762. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119763. private _unbindVertexArrayObject;
  119764. /**
  119765. * Bind a list of vertex buffers to the webGL context
  119766. * @param vertexBuffers defines the list of vertex buffers to bind
  119767. * @param indexBuffer defines the index buffer to bind
  119768. * @param effect defines the effect associated with the vertex buffers
  119769. */
  119770. bindBuffers(vertexBuffers: {
  119771. [key: string]: Nullable<VertexBuffer>;
  119772. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119773. /**
  119774. * Unbind all instance attributes
  119775. */
  119776. unbindInstanceAttributes(): void;
  119777. /**
  119778. * Release and free the memory of a vertex array object
  119779. * @param vao defines the vertex array object to delete
  119780. */
  119781. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119782. /** @hidden */
  119783. _releaseBuffer(buffer: DataBuffer): boolean;
  119784. protected _deleteBuffer(buffer: DataBuffer): void;
  119785. /**
  119786. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119787. * @param instancesBuffer defines the webGL buffer to update and bind
  119788. * @param data defines the data to store in the buffer
  119789. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119790. */
  119791. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119792. /**
  119793. * Bind the content of a webGL buffer used with instantiation
  119794. * @param instancesBuffer defines the webGL buffer to bind
  119795. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119796. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119797. */
  119798. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119799. /**
  119800. * Disable the instance attribute corresponding to the name in parameter
  119801. * @param name defines the name of the attribute to disable
  119802. */
  119803. disableInstanceAttributeByName(name: string): void;
  119804. /**
  119805. * Disable the instance attribute corresponding to the location in parameter
  119806. * @param attributeLocation defines the attribute location of the attribute to disable
  119807. */
  119808. disableInstanceAttribute(attributeLocation: number): void;
  119809. /**
  119810. * Disable the attribute corresponding to the location in parameter
  119811. * @param attributeLocation defines the attribute location of the attribute to disable
  119812. */
  119813. disableAttributeByIndex(attributeLocation: number): void;
  119814. /**
  119815. * Send a draw order
  119816. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119817. * @param indexStart defines the starting index
  119818. * @param indexCount defines the number of index to draw
  119819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119820. */
  119821. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119822. /**
  119823. * Draw a list of points
  119824. * @param verticesStart defines the index of first vertex to draw
  119825. * @param verticesCount defines the count of vertices to draw
  119826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119827. */
  119828. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119829. /**
  119830. * Draw a list of unindexed primitives
  119831. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119832. * @param verticesStart defines the index of first vertex to draw
  119833. * @param verticesCount defines the count of vertices to draw
  119834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119835. */
  119836. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119837. /**
  119838. * Draw a list of indexed primitives
  119839. * @param fillMode defines the primitive to use
  119840. * @param indexStart defines the starting index
  119841. * @param indexCount defines the number of index to draw
  119842. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119843. */
  119844. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119845. /**
  119846. * Draw a list of unindexed primitives
  119847. * @param fillMode defines the primitive to use
  119848. * @param verticesStart defines the index of first vertex to draw
  119849. * @param verticesCount defines the count of vertices to draw
  119850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119851. */
  119852. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119853. private _drawMode;
  119854. /** @hidden */
  119855. protected _reportDrawCall(): void;
  119856. /** @hidden */
  119857. _releaseEffect(effect: Effect): void;
  119858. /** @hidden */
  119859. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119860. /**
  119861. * Create a new effect (used to store vertex/fragment shaders)
  119862. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119863. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119864. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119865. * @param samplers defines an array of string used to represent textures
  119866. * @param defines defines the string containing the defines to use to compile the shaders
  119867. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119868. * @param onCompiled defines a function to call when the effect creation is successful
  119869. * @param onError defines a function to call when the effect creation has failed
  119870. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119871. * @returns the new Effect
  119872. */
  119873. 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;
  119874. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119875. private _compileShader;
  119876. private _compileRawShader;
  119877. /** @hidden */
  119878. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119879. /**
  119880. * Directly creates a webGL program
  119881. * @param pipelineContext defines the pipeline context to attach to
  119882. * @param vertexCode defines the vertex shader code to use
  119883. * @param fragmentCode defines the fragment shader code to use
  119884. * @param context defines the webGL context to use (if not set, the current one will be used)
  119885. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119886. * @returns the new webGL program
  119887. */
  119888. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119889. /**
  119890. * Creates a webGL program
  119891. * @param pipelineContext defines the pipeline context to attach to
  119892. * @param vertexCode defines the vertex shader code to use
  119893. * @param fragmentCode defines the fragment shader code to use
  119894. * @param defines defines the string containing the defines to use to compile the shaders
  119895. * @param context defines the webGL context to use (if not set, the current one will be used)
  119896. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119897. * @returns the new webGL program
  119898. */
  119899. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119900. /**
  119901. * Creates a new pipeline context
  119902. * @returns the new pipeline
  119903. */
  119904. createPipelineContext(): IPipelineContext;
  119905. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119906. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119907. /** @hidden */
  119908. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119909. /** @hidden */
  119910. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119911. /** @hidden */
  119912. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119913. /**
  119914. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119915. * @param pipelineContext defines the pipeline context to use
  119916. * @param uniformsNames defines the list of uniform names
  119917. * @returns an array of webGL uniform locations
  119918. */
  119919. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119920. /**
  119921. * Gets the lsit of active attributes for a given webGL program
  119922. * @param pipelineContext defines the pipeline context to use
  119923. * @param attributesNames defines the list of attribute names to get
  119924. * @returns an array of indices indicating the offset of each attribute
  119925. */
  119926. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119927. /**
  119928. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119929. * @param effect defines the effect to activate
  119930. */
  119931. enableEffect(effect: Nullable<Effect>): void;
  119932. /**
  119933. * Set the value of an uniform to a number (int)
  119934. * @param uniform defines the webGL uniform location where to store the value
  119935. * @param value defines the int number to store
  119936. * @returns true if the value was set
  119937. */
  119938. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119939. /**
  119940. * Set the value of an uniform to an array of int32
  119941. * @param uniform defines the webGL uniform location where to store the value
  119942. * @param array defines the array of int32 to store
  119943. * @returns true if the value was set
  119944. */
  119945. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119946. /**
  119947. * Set the value of an uniform to an array of int32 (stored as vec2)
  119948. * @param uniform defines the webGL uniform location where to store the value
  119949. * @param array defines the array of int32 to store
  119950. * @returns true if the value was set
  119951. */
  119952. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119953. /**
  119954. * Set the value of an uniform to an array of int32 (stored as vec3)
  119955. * @param uniform defines the webGL uniform location where to store the value
  119956. * @param array defines the array of int32 to store
  119957. * @returns true if the value was set
  119958. */
  119959. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119960. /**
  119961. * Set the value of an uniform to an array of int32 (stored as vec4)
  119962. * @param uniform defines the webGL uniform location where to store the value
  119963. * @param array defines the array of int32 to store
  119964. * @returns true if the value was set
  119965. */
  119966. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119967. /**
  119968. * Set the value of an uniform to an array of number
  119969. * @param uniform defines the webGL uniform location where to store the value
  119970. * @param array defines the array of number to store
  119971. * @returns true if the value was set
  119972. */
  119973. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119974. /**
  119975. * Set the value of an uniform to an array of number (stored as vec2)
  119976. * @param uniform defines the webGL uniform location where to store the value
  119977. * @param array defines the array of number to store
  119978. * @returns true if the value was set
  119979. */
  119980. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119981. /**
  119982. * Set the value of an uniform to an array of number (stored as vec3)
  119983. * @param uniform defines the webGL uniform location where to store the value
  119984. * @param array defines the array of number to store
  119985. * @returns true if the value was set
  119986. */
  119987. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119988. /**
  119989. * Set the value of an uniform to an array of number (stored as vec4)
  119990. * @param uniform defines the webGL uniform location where to store the value
  119991. * @param array defines the array of number to store
  119992. * @returns true if the value was set
  119993. */
  119994. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119995. /**
  119996. * Set the value of an uniform to an array of float32 (stored as matrices)
  119997. * @param uniform defines the webGL uniform location where to store the value
  119998. * @param matrices defines the array of float32 to store
  119999. * @returns true if the value was set
  120000. */
  120001. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  120002. /**
  120003. * Set the value of an uniform to a matrix (3x3)
  120004. * @param uniform defines the webGL uniform location where to store the value
  120005. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120006. * @returns true if the value was set
  120007. */
  120008. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120009. /**
  120010. * Set the value of an uniform to a matrix (2x2)
  120011. * @param uniform defines the webGL uniform location where to store the value
  120012. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120013. * @returns true if the value was set
  120014. */
  120015. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120016. /**
  120017. * Set the value of an uniform to a number (float)
  120018. * @param uniform defines the webGL uniform location where to store the value
  120019. * @param value defines the float number to store
  120020. * @returns true if the value was transfered
  120021. */
  120022. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120023. /**
  120024. * Set the value of an uniform to a vec2
  120025. * @param uniform defines the webGL uniform location where to store the value
  120026. * @param x defines the 1st component of the value
  120027. * @param y defines the 2nd component of the value
  120028. * @returns true if the value was set
  120029. */
  120030. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  120031. /**
  120032. * Set the value of an uniform to a vec3
  120033. * @param uniform defines the webGL uniform location where to store the value
  120034. * @param x defines the 1st component of the value
  120035. * @param y defines the 2nd component of the value
  120036. * @param z defines the 3rd component of the value
  120037. * @returns true if the value was set
  120038. */
  120039. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  120040. /**
  120041. * Set the value of an uniform to a vec4
  120042. * @param uniform defines the webGL uniform location where to store the value
  120043. * @param x defines the 1st component of the value
  120044. * @param y defines the 2nd component of the value
  120045. * @param z defines the 3rd component of the value
  120046. * @param w defines the 4th component of the value
  120047. * @returns true if the value was set
  120048. */
  120049. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120050. /**
  120051. * Apply all cached states (depth, culling, stencil and alpha)
  120052. */
  120053. applyStates(): void;
  120054. /**
  120055. * Enable or disable color writing
  120056. * @param enable defines the state to set
  120057. */
  120058. setColorWrite(enable: boolean): void;
  120059. /**
  120060. * Gets a boolean indicating if color writing is enabled
  120061. * @returns the current color writing state
  120062. */
  120063. getColorWrite(): boolean;
  120064. /**
  120065. * Gets the depth culling state manager
  120066. */
  120067. get depthCullingState(): DepthCullingState;
  120068. /**
  120069. * Gets the alpha state manager
  120070. */
  120071. get alphaState(): AlphaState;
  120072. /**
  120073. * Gets the stencil state manager
  120074. */
  120075. get stencilState(): StencilState;
  120076. /**
  120077. * Clears the list of texture accessible through engine.
  120078. * This can help preventing texture load conflict due to name collision.
  120079. */
  120080. clearInternalTexturesCache(): void;
  120081. /**
  120082. * Force the entire cache to be cleared
  120083. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120084. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120085. */
  120086. wipeCaches(bruteForce?: boolean): void;
  120087. /** @hidden */
  120088. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120089. min: number;
  120090. mag: number;
  120091. };
  120092. /** @hidden */
  120093. _createTexture(): WebGLTexture;
  120094. /**
  120095. * Usually called from Texture.ts.
  120096. * Passed information to create a WebGLTexture
  120097. * @param url defines a value which contains one of the following:
  120098. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120099. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120100. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120101. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120102. * @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)
  120103. * @param scene needed for loading to the correct scene
  120104. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120105. * @param onLoad optional callback to be called upon successful completion
  120106. * @param onError optional callback to be called upon failure
  120107. * @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
  120108. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120109. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120110. * @param forcedExtension defines the extension to use to pick the right loader
  120111. * @param mimeType defines an optional mime type
  120112. * @param loaderOptions options to be passed to the loader
  120113. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120114. */
  120115. 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, loaderOptions?: any): InternalTexture;
  120116. /**
  120117. * Loads an image as an HTMLImageElement.
  120118. * @param input url string, ArrayBuffer, or Blob to load
  120119. * @param onLoad callback called when the image successfully loads
  120120. * @param onError callback called when the image fails to load
  120121. * @param offlineProvider offline provider for caching
  120122. * @param mimeType optional mime type
  120123. * @returns the HTMLImageElement of the loaded image
  120124. * @hidden
  120125. */
  120126. 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>;
  120127. /**
  120128. * @hidden
  120129. */
  120130. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120131. private _unpackFlipYCached;
  120132. /**
  120133. * In case you are sharing the context with other applications, it might
  120134. * be interested to not cache the unpack flip y state to ensure a consistent
  120135. * value would be set.
  120136. */
  120137. enableUnpackFlipYCached: boolean;
  120138. /** @hidden */
  120139. _unpackFlipY(value: boolean): void;
  120140. /** @hidden */
  120141. _getUnpackAlignement(): number;
  120142. private _getTextureTarget;
  120143. /**
  120144. * Update the sampling mode of a given texture
  120145. * @param samplingMode defines the required sampling mode
  120146. * @param texture defines the texture to update
  120147. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120148. */
  120149. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120150. /**
  120151. * Update the sampling mode of a given texture
  120152. * @param texture defines the texture to update
  120153. * @param wrapU defines the texture wrap mode of the u coordinates
  120154. * @param wrapV defines the texture wrap mode of the v coordinates
  120155. * @param wrapR defines the texture wrap mode of the r coordinates
  120156. */
  120157. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120158. /** @hidden */
  120159. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120160. width: number;
  120161. height: number;
  120162. layers?: number;
  120163. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120164. /** @hidden */
  120165. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120166. /** @hidden */
  120167. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120168. /**
  120169. * Update a portion of an internal texture
  120170. * @param texture defines the texture to update
  120171. * @param imageData defines the data to store into the texture
  120172. * @param xOffset defines the x coordinates of the update rectangle
  120173. * @param yOffset defines the y coordinates of the update rectangle
  120174. * @param width defines the width of the update rectangle
  120175. * @param height defines the height of the update rectangle
  120176. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120177. * @param lod defines the lod level to update (0 by default)
  120178. */
  120179. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120180. /** @hidden */
  120181. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120182. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120183. private _prepareWebGLTexture;
  120184. /** @hidden */
  120185. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120186. private _getDepthStencilBuffer;
  120187. /** @hidden */
  120188. _releaseFramebufferObjects(texture: InternalTexture): void;
  120189. /** @hidden */
  120190. _releaseTexture(texture: InternalTexture): void;
  120191. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120192. protected _setProgram(program: WebGLProgram): void;
  120193. protected _boundUniforms: {
  120194. [key: number]: WebGLUniformLocation;
  120195. };
  120196. /**
  120197. * Binds an effect to the webGL context
  120198. * @param effect defines the effect to bind
  120199. */
  120200. bindSamplers(effect: Effect): void;
  120201. private _activateCurrentTexture;
  120202. /** @hidden */
  120203. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120204. /** @hidden */
  120205. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120206. /**
  120207. * Unbind all textures from the webGL context
  120208. */
  120209. unbindAllTextures(): void;
  120210. /**
  120211. * Sets a texture to the according uniform.
  120212. * @param channel The texture channel
  120213. * @param uniform The uniform to set
  120214. * @param texture The texture to apply
  120215. */
  120216. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120217. private _bindSamplerUniformToChannel;
  120218. private _getTextureWrapMode;
  120219. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120220. /**
  120221. * Sets an array of texture to the webGL context
  120222. * @param channel defines the channel where the texture array must be set
  120223. * @param uniform defines the associated uniform location
  120224. * @param textures defines the array of textures to bind
  120225. */
  120226. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120227. /** @hidden */
  120228. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120229. private _setTextureParameterFloat;
  120230. private _setTextureParameterInteger;
  120231. /**
  120232. * Unbind all vertex attributes from the webGL context
  120233. */
  120234. unbindAllAttributes(): void;
  120235. /**
  120236. * 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
  120237. */
  120238. releaseEffects(): void;
  120239. /**
  120240. * Dispose and release all associated resources
  120241. */
  120242. dispose(): void;
  120243. /**
  120244. * Attach a new callback raised when context lost event is fired
  120245. * @param callback defines the callback to call
  120246. */
  120247. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120248. /**
  120249. * Attach a new callback raised when context restored event is fired
  120250. * @param callback defines the callback to call
  120251. */
  120252. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120253. /**
  120254. * Get the current error code of the webGL context
  120255. * @returns the error code
  120256. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120257. */
  120258. getError(): number;
  120259. private _canRenderToFloatFramebuffer;
  120260. private _canRenderToHalfFloatFramebuffer;
  120261. private _canRenderToFramebuffer;
  120262. /** @hidden */
  120263. _getWebGLTextureType(type: number): number;
  120264. /** @hidden */
  120265. _getInternalFormat(format: number): number;
  120266. /** @hidden */
  120267. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120268. /** @hidden */
  120269. _getRGBAMultiSampleBufferFormat(type: number): number;
  120270. /** @hidden */
  120271. _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;
  120272. /**
  120273. * Loads a file from a url
  120274. * @param url url to load
  120275. * @param onSuccess callback called when the file successfully loads
  120276. * @param onProgress callback called while file is loading (if the server supports this mode)
  120277. * @param offlineProvider defines the offline provider for caching
  120278. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120279. * @param onError callback called when the file fails to load
  120280. * @returns a file request object
  120281. * @hidden
  120282. */
  120283. 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;
  120284. /**
  120285. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120286. * @param x defines the x coordinate of the rectangle where pixels must be read
  120287. * @param y defines the y coordinate of the rectangle where pixels must be read
  120288. * @param width defines the width of the rectangle where pixels must be read
  120289. * @param height defines the height of the rectangle where pixels must be read
  120290. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120291. * @returns a Uint8Array containing RGBA colors
  120292. */
  120293. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120294. private static _IsSupported;
  120295. private static _HasMajorPerformanceCaveat;
  120296. /**
  120297. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120298. */
  120299. static get IsSupported(): boolean;
  120300. /**
  120301. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120302. * @returns true if the engine can be created
  120303. * @ignorenaming
  120304. */
  120305. static isSupported(): boolean;
  120306. /**
  120307. * 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)
  120308. */
  120309. static get HasMajorPerformanceCaveat(): boolean;
  120310. /**
  120311. * Find the next highest power of two.
  120312. * @param x Number to start search from.
  120313. * @return Next highest power of two.
  120314. */
  120315. static CeilingPOT(x: number): number;
  120316. /**
  120317. * Find the next lowest power of two.
  120318. * @param x Number to start search from.
  120319. * @return Next lowest power of two.
  120320. */
  120321. static FloorPOT(x: number): number;
  120322. /**
  120323. * Find the nearest power of two.
  120324. * @param x Number to start search from.
  120325. * @return Next nearest power of two.
  120326. */
  120327. static NearestPOT(x: number): number;
  120328. /**
  120329. * Get the closest exponent of two
  120330. * @param value defines the value to approximate
  120331. * @param max defines the maximum value to return
  120332. * @param mode defines how to define the closest value
  120333. * @returns closest exponent of two of the given value
  120334. */
  120335. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120336. /**
  120337. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120338. * @param func - the function to be called
  120339. * @param requester - the object that will request the next frame. Falls back to window.
  120340. * @returns frame number
  120341. */
  120342. static QueueNewFrame(func: () => void, requester?: any): number;
  120343. /**
  120344. * Gets host document
  120345. * @returns the host document object
  120346. */
  120347. getHostDocument(): Nullable<Document>;
  120348. }
  120349. }
  120350. declare module BABYLON {
  120351. /**
  120352. * Defines the source of the internal texture
  120353. */
  120354. export enum InternalTextureSource {
  120355. /**
  120356. * The source of the texture data is unknown
  120357. */
  120358. Unknown = 0,
  120359. /**
  120360. * Texture data comes from an URL
  120361. */
  120362. Url = 1,
  120363. /**
  120364. * Texture data is only used for temporary storage
  120365. */
  120366. Temp = 2,
  120367. /**
  120368. * Texture data comes from raw data (ArrayBuffer)
  120369. */
  120370. Raw = 3,
  120371. /**
  120372. * Texture content is dynamic (video or dynamic texture)
  120373. */
  120374. Dynamic = 4,
  120375. /**
  120376. * Texture content is generated by rendering to it
  120377. */
  120378. RenderTarget = 5,
  120379. /**
  120380. * Texture content is part of a multi render target process
  120381. */
  120382. MultiRenderTarget = 6,
  120383. /**
  120384. * Texture data comes from a cube data file
  120385. */
  120386. Cube = 7,
  120387. /**
  120388. * Texture data comes from a raw cube data
  120389. */
  120390. CubeRaw = 8,
  120391. /**
  120392. * Texture data come from a prefiltered cube data file
  120393. */
  120394. CubePrefiltered = 9,
  120395. /**
  120396. * Texture content is raw 3D data
  120397. */
  120398. Raw3D = 10,
  120399. /**
  120400. * Texture content is raw 2D array data
  120401. */
  120402. Raw2DArray = 11,
  120403. /**
  120404. * Texture content is a depth texture
  120405. */
  120406. Depth = 12,
  120407. /**
  120408. * Texture data comes from a raw cube data encoded with RGBD
  120409. */
  120410. CubeRawRGBD = 13
  120411. }
  120412. /**
  120413. * Class used to store data associated with WebGL texture data for the engine
  120414. * This class should not be used directly
  120415. */
  120416. export class InternalTexture {
  120417. /** @hidden */
  120418. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120419. /**
  120420. * Defines if the texture is ready
  120421. */
  120422. isReady: boolean;
  120423. /**
  120424. * Defines if the texture is a cube texture
  120425. */
  120426. isCube: boolean;
  120427. /**
  120428. * Defines if the texture contains 3D data
  120429. */
  120430. is3D: boolean;
  120431. /**
  120432. * Defines if the texture contains 2D array data
  120433. */
  120434. is2DArray: boolean;
  120435. /**
  120436. * Defines if the texture contains multiview data
  120437. */
  120438. isMultiview: boolean;
  120439. /**
  120440. * Gets the URL used to load this texture
  120441. */
  120442. url: string;
  120443. /**
  120444. * Gets the sampling mode of the texture
  120445. */
  120446. samplingMode: number;
  120447. /**
  120448. * Gets a boolean indicating if the texture needs mipmaps generation
  120449. */
  120450. generateMipMaps: boolean;
  120451. /**
  120452. * Gets the number of samples used by the texture (WebGL2+ only)
  120453. */
  120454. samples: number;
  120455. /**
  120456. * Gets the type of the texture (int, float...)
  120457. */
  120458. type: number;
  120459. /**
  120460. * Gets the format of the texture (RGB, RGBA...)
  120461. */
  120462. format: number;
  120463. /**
  120464. * Observable called when the texture is loaded
  120465. */
  120466. onLoadedObservable: Observable<InternalTexture>;
  120467. /**
  120468. * Gets the width of the texture
  120469. */
  120470. width: number;
  120471. /**
  120472. * Gets the height of the texture
  120473. */
  120474. height: number;
  120475. /**
  120476. * Gets the depth of the texture
  120477. */
  120478. depth: number;
  120479. /**
  120480. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120481. */
  120482. baseWidth: number;
  120483. /**
  120484. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120485. */
  120486. baseHeight: number;
  120487. /**
  120488. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120489. */
  120490. baseDepth: number;
  120491. /**
  120492. * Gets a boolean indicating if the texture is inverted on Y axis
  120493. */
  120494. invertY: boolean;
  120495. /** @hidden */
  120496. _invertVScale: boolean;
  120497. /** @hidden */
  120498. _associatedChannel: number;
  120499. /** @hidden */
  120500. _source: InternalTextureSource;
  120501. /** @hidden */
  120502. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120503. /** @hidden */
  120504. _bufferView: Nullable<ArrayBufferView>;
  120505. /** @hidden */
  120506. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120507. /** @hidden */
  120508. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120509. /** @hidden */
  120510. _size: number;
  120511. /** @hidden */
  120512. _extension: string;
  120513. /** @hidden */
  120514. _files: Nullable<string[]>;
  120515. /** @hidden */
  120516. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120517. /** @hidden */
  120518. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120519. /** @hidden */
  120520. _framebuffer: Nullable<WebGLFramebuffer>;
  120521. /** @hidden */
  120522. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120523. /** @hidden */
  120524. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120525. /** @hidden */
  120526. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120527. /** @hidden */
  120528. _attachments: Nullable<number[]>;
  120529. /** @hidden */
  120530. _textureArray: Nullable<InternalTexture[]>;
  120531. /** @hidden */
  120532. _cachedCoordinatesMode: Nullable<number>;
  120533. /** @hidden */
  120534. _cachedWrapU: Nullable<number>;
  120535. /** @hidden */
  120536. _cachedWrapV: Nullable<number>;
  120537. /** @hidden */
  120538. _cachedWrapR: Nullable<number>;
  120539. /** @hidden */
  120540. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120541. /** @hidden */
  120542. _isDisabled: boolean;
  120543. /** @hidden */
  120544. _compression: Nullable<string>;
  120545. /** @hidden */
  120546. _generateStencilBuffer: boolean;
  120547. /** @hidden */
  120548. _generateDepthBuffer: boolean;
  120549. /** @hidden */
  120550. _comparisonFunction: number;
  120551. /** @hidden */
  120552. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120553. /** @hidden */
  120554. _lodGenerationScale: number;
  120555. /** @hidden */
  120556. _lodGenerationOffset: number;
  120557. /** @hidden */
  120558. _depthStencilTexture: Nullable<InternalTexture>;
  120559. /** @hidden */
  120560. _colorTextureArray: Nullable<WebGLTexture>;
  120561. /** @hidden */
  120562. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120563. /** @hidden */
  120564. _lodTextureHigh: Nullable<BaseTexture>;
  120565. /** @hidden */
  120566. _lodTextureMid: Nullable<BaseTexture>;
  120567. /** @hidden */
  120568. _lodTextureLow: Nullable<BaseTexture>;
  120569. /** @hidden */
  120570. _isRGBD: boolean;
  120571. /** @hidden */
  120572. _linearSpecularLOD: boolean;
  120573. /** @hidden */
  120574. _irradianceTexture: Nullable<BaseTexture>;
  120575. /** @hidden */
  120576. _webGLTexture: Nullable<WebGLTexture>;
  120577. /** @hidden */
  120578. _references: number;
  120579. /** @hidden */
  120580. _gammaSpace: Nullable<boolean>;
  120581. private _engine;
  120582. /**
  120583. * Gets the Engine the texture belongs to.
  120584. * @returns The babylon engine
  120585. */
  120586. getEngine(): ThinEngine;
  120587. /**
  120588. * Gets the data source type of the texture
  120589. */
  120590. get source(): InternalTextureSource;
  120591. /**
  120592. * Creates a new InternalTexture
  120593. * @param engine defines the engine to use
  120594. * @param source defines the type of data that will be used
  120595. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120596. */
  120597. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120598. /**
  120599. * Increments the number of references (ie. the number of Texture that point to it)
  120600. */
  120601. incrementReferences(): void;
  120602. /**
  120603. * Change the size of the texture (not the size of the content)
  120604. * @param width defines the new width
  120605. * @param height defines the new height
  120606. * @param depth defines the new depth (1 by default)
  120607. */
  120608. updateSize(width: int, height: int, depth?: int): void;
  120609. /** @hidden */
  120610. _rebuild(): void;
  120611. /** @hidden */
  120612. _swapAndDie(target: InternalTexture): void;
  120613. /**
  120614. * Dispose the current allocated resources
  120615. */
  120616. dispose(): void;
  120617. }
  120618. }
  120619. declare module BABYLON {
  120620. /**
  120621. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120622. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120623. */
  120624. export class Analyser {
  120625. /**
  120626. * Gets or sets the smoothing
  120627. * @ignorenaming
  120628. */
  120629. SMOOTHING: number;
  120630. /**
  120631. * Gets or sets the FFT table size
  120632. * @ignorenaming
  120633. */
  120634. FFT_SIZE: number;
  120635. /**
  120636. * Gets or sets the bar graph amplitude
  120637. * @ignorenaming
  120638. */
  120639. BARGRAPHAMPLITUDE: number;
  120640. /**
  120641. * Gets or sets the position of the debug canvas
  120642. * @ignorenaming
  120643. */
  120644. DEBUGCANVASPOS: {
  120645. x: number;
  120646. y: number;
  120647. };
  120648. /**
  120649. * Gets or sets the debug canvas size
  120650. * @ignorenaming
  120651. */
  120652. DEBUGCANVASSIZE: {
  120653. width: number;
  120654. height: number;
  120655. };
  120656. private _byteFreqs;
  120657. private _byteTime;
  120658. private _floatFreqs;
  120659. private _webAudioAnalyser;
  120660. private _debugCanvas;
  120661. private _debugCanvasContext;
  120662. private _scene;
  120663. private _registerFunc;
  120664. private _audioEngine;
  120665. /**
  120666. * Creates a new analyser
  120667. * @param scene defines hosting scene
  120668. */
  120669. constructor(scene: Scene);
  120670. /**
  120671. * Get the number of data values you will have to play with for the visualization
  120672. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120673. * @returns a number
  120674. */
  120675. getFrequencyBinCount(): number;
  120676. /**
  120677. * Gets the current frequency data as a byte array
  120678. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120679. * @returns a Uint8Array
  120680. */
  120681. getByteFrequencyData(): Uint8Array;
  120682. /**
  120683. * Gets the current waveform as a byte array
  120684. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120685. * @returns a Uint8Array
  120686. */
  120687. getByteTimeDomainData(): Uint8Array;
  120688. /**
  120689. * Gets the current frequency data as a float array
  120690. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120691. * @returns a Float32Array
  120692. */
  120693. getFloatFrequencyData(): Float32Array;
  120694. /**
  120695. * Renders the debug canvas
  120696. */
  120697. drawDebugCanvas(): void;
  120698. /**
  120699. * Stops rendering the debug canvas and removes it
  120700. */
  120701. stopDebugCanvas(): void;
  120702. /**
  120703. * Connects two audio nodes
  120704. * @param inputAudioNode defines first node to connect
  120705. * @param outputAudioNode defines second node to connect
  120706. */
  120707. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120708. /**
  120709. * Releases all associated resources
  120710. */
  120711. dispose(): void;
  120712. }
  120713. }
  120714. declare module BABYLON {
  120715. /**
  120716. * This represents an audio engine and it is responsible
  120717. * to play, synchronize and analyse sounds throughout the application.
  120718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120719. */
  120720. export interface IAudioEngine extends IDisposable {
  120721. /**
  120722. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120723. */
  120724. readonly canUseWebAudio: boolean;
  120725. /**
  120726. * Gets the current AudioContext if available.
  120727. */
  120728. readonly audioContext: Nullable<AudioContext>;
  120729. /**
  120730. * The master gain node defines the global audio volume of your audio engine.
  120731. */
  120732. readonly masterGain: GainNode;
  120733. /**
  120734. * Gets whether or not mp3 are supported by your browser.
  120735. */
  120736. readonly isMP3supported: boolean;
  120737. /**
  120738. * Gets whether or not ogg are supported by your browser.
  120739. */
  120740. readonly isOGGsupported: boolean;
  120741. /**
  120742. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120743. * @ignoreNaming
  120744. */
  120745. WarnedWebAudioUnsupported: boolean;
  120746. /**
  120747. * Defines if the audio engine relies on a custom unlocked button.
  120748. * In this case, the embedded button will not be displayed.
  120749. */
  120750. useCustomUnlockedButton: boolean;
  120751. /**
  120752. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120753. */
  120754. readonly unlocked: boolean;
  120755. /**
  120756. * Event raised when audio has been unlocked on the browser.
  120757. */
  120758. onAudioUnlockedObservable: Observable<AudioEngine>;
  120759. /**
  120760. * Event raised when audio has been locked on the browser.
  120761. */
  120762. onAudioLockedObservable: Observable<AudioEngine>;
  120763. /**
  120764. * Flags the audio engine in Locked state.
  120765. * This happens due to new browser policies preventing audio to autoplay.
  120766. */
  120767. lock(): void;
  120768. /**
  120769. * Unlocks the audio engine once a user action has been done on the dom.
  120770. * This is helpful to resume play once browser policies have been satisfied.
  120771. */
  120772. unlock(): void;
  120773. /**
  120774. * Gets the global volume sets on the master gain.
  120775. * @returns the global volume if set or -1 otherwise
  120776. */
  120777. getGlobalVolume(): number;
  120778. /**
  120779. * Sets the global volume of your experience (sets on the master gain).
  120780. * @param newVolume Defines the new global volume of the application
  120781. */
  120782. setGlobalVolume(newVolume: number): void;
  120783. /**
  120784. * Connect the audio engine to an audio analyser allowing some amazing
  120785. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120787. * @param analyser The analyser to connect to the engine
  120788. */
  120789. connectToAnalyser(analyser: Analyser): void;
  120790. }
  120791. /**
  120792. * This represents the default audio engine used in babylon.
  120793. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120794. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120795. */
  120796. export class AudioEngine implements IAudioEngine {
  120797. private _audioContext;
  120798. private _audioContextInitialized;
  120799. private _muteButton;
  120800. private _hostElement;
  120801. /**
  120802. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120803. */
  120804. canUseWebAudio: boolean;
  120805. /**
  120806. * The master gain node defines the global audio volume of your audio engine.
  120807. */
  120808. masterGain: GainNode;
  120809. /**
  120810. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120811. * @ignoreNaming
  120812. */
  120813. WarnedWebAudioUnsupported: boolean;
  120814. /**
  120815. * Gets whether or not mp3 are supported by your browser.
  120816. */
  120817. isMP3supported: boolean;
  120818. /**
  120819. * Gets whether or not ogg are supported by your browser.
  120820. */
  120821. isOGGsupported: boolean;
  120822. /**
  120823. * Gets whether audio has been unlocked on the device.
  120824. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120825. * a user interaction has happened.
  120826. */
  120827. unlocked: boolean;
  120828. /**
  120829. * Defines if the audio engine relies on a custom unlocked button.
  120830. * In this case, the embedded button will not be displayed.
  120831. */
  120832. useCustomUnlockedButton: boolean;
  120833. /**
  120834. * Event raised when audio has been unlocked on the browser.
  120835. */
  120836. onAudioUnlockedObservable: Observable<AudioEngine>;
  120837. /**
  120838. * Event raised when audio has been locked on the browser.
  120839. */
  120840. onAudioLockedObservable: Observable<AudioEngine>;
  120841. /**
  120842. * Gets the current AudioContext if available.
  120843. */
  120844. get audioContext(): Nullable<AudioContext>;
  120845. private _connectedAnalyser;
  120846. /**
  120847. * Instantiates a new audio engine.
  120848. *
  120849. * There should be only one per page as some browsers restrict the number
  120850. * of audio contexts you can create.
  120851. * @param hostElement defines the host element where to display the mute icon if necessary
  120852. */
  120853. constructor(hostElement?: Nullable<HTMLElement>);
  120854. /**
  120855. * Flags the audio engine in Locked state.
  120856. * This happens due to new browser policies preventing audio to autoplay.
  120857. */
  120858. lock(): void;
  120859. /**
  120860. * Unlocks the audio engine once a user action has been done on the dom.
  120861. * This is helpful to resume play once browser policies have been satisfied.
  120862. */
  120863. unlock(): void;
  120864. private _resumeAudioContext;
  120865. private _initializeAudioContext;
  120866. private _tryToRun;
  120867. private _triggerRunningState;
  120868. private _triggerSuspendedState;
  120869. private _displayMuteButton;
  120870. private _moveButtonToTopLeft;
  120871. private _onResize;
  120872. private _hideMuteButton;
  120873. /**
  120874. * Destroy and release the resources associated with the audio ccontext.
  120875. */
  120876. dispose(): void;
  120877. /**
  120878. * Gets the global volume sets on the master gain.
  120879. * @returns the global volume if set or -1 otherwise
  120880. */
  120881. getGlobalVolume(): number;
  120882. /**
  120883. * Sets the global volume of your experience (sets on the master gain).
  120884. * @param newVolume Defines the new global volume of the application
  120885. */
  120886. setGlobalVolume(newVolume: number): void;
  120887. /**
  120888. * Connect the audio engine to an audio analyser allowing some amazing
  120889. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120890. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120891. * @param analyser The analyser to connect to the engine
  120892. */
  120893. connectToAnalyser(analyser: Analyser): void;
  120894. }
  120895. }
  120896. declare module BABYLON {
  120897. /**
  120898. * Interface used to present a loading screen while loading a scene
  120899. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120900. */
  120901. export interface ILoadingScreen {
  120902. /**
  120903. * Function called to display the loading screen
  120904. */
  120905. displayLoadingUI: () => void;
  120906. /**
  120907. * Function called to hide the loading screen
  120908. */
  120909. hideLoadingUI: () => void;
  120910. /**
  120911. * Gets or sets the color to use for the background
  120912. */
  120913. loadingUIBackgroundColor: string;
  120914. /**
  120915. * Gets or sets the text to display while loading
  120916. */
  120917. loadingUIText: string;
  120918. }
  120919. /**
  120920. * Class used for the default loading screen
  120921. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120922. */
  120923. export class DefaultLoadingScreen implements ILoadingScreen {
  120924. private _renderingCanvas;
  120925. private _loadingText;
  120926. private _loadingDivBackgroundColor;
  120927. private _loadingDiv;
  120928. private _loadingTextDiv;
  120929. /** Gets or sets the logo url to use for the default loading screen */
  120930. static DefaultLogoUrl: string;
  120931. /** Gets or sets the spinner url to use for the default loading screen */
  120932. static DefaultSpinnerUrl: string;
  120933. /**
  120934. * Creates a new default loading screen
  120935. * @param _renderingCanvas defines the canvas used to render the scene
  120936. * @param _loadingText defines the default text to display
  120937. * @param _loadingDivBackgroundColor defines the default background color
  120938. */
  120939. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120940. /**
  120941. * Function called to display the loading screen
  120942. */
  120943. displayLoadingUI(): void;
  120944. /**
  120945. * Function called to hide the loading screen
  120946. */
  120947. hideLoadingUI(): void;
  120948. /**
  120949. * Gets or sets the text to display while loading
  120950. */
  120951. set loadingUIText(text: string);
  120952. get loadingUIText(): string;
  120953. /**
  120954. * Gets or sets the color to use for the background
  120955. */
  120956. get loadingUIBackgroundColor(): string;
  120957. set loadingUIBackgroundColor(color: string);
  120958. private _resizeLoadingUI;
  120959. }
  120960. }
  120961. declare module BABYLON {
  120962. /**
  120963. * Interface for any object that can request an animation frame
  120964. */
  120965. export interface ICustomAnimationFrameRequester {
  120966. /**
  120967. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120968. */
  120969. renderFunction?: Function;
  120970. /**
  120971. * Called to request the next frame to render to
  120972. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120973. */
  120974. requestAnimationFrame: Function;
  120975. /**
  120976. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120977. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120978. */
  120979. requestID?: number;
  120980. }
  120981. }
  120982. declare module BABYLON {
  120983. /**
  120984. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120985. */
  120986. export class PerformanceMonitor {
  120987. private _enabled;
  120988. private _rollingFrameTime;
  120989. private _lastFrameTimeMs;
  120990. /**
  120991. * constructor
  120992. * @param frameSampleSize The number of samples required to saturate the sliding window
  120993. */
  120994. constructor(frameSampleSize?: number);
  120995. /**
  120996. * Samples current frame
  120997. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120998. */
  120999. sampleFrame(timeMs?: number): void;
  121000. /**
  121001. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121002. */
  121003. get averageFrameTime(): number;
  121004. /**
  121005. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121006. */
  121007. get averageFrameTimeVariance(): number;
  121008. /**
  121009. * Returns the frame time of the most recent frame
  121010. */
  121011. get instantaneousFrameTime(): number;
  121012. /**
  121013. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121014. */
  121015. get averageFPS(): number;
  121016. /**
  121017. * Returns the average framerate in frames per second using the most recent frame time
  121018. */
  121019. get instantaneousFPS(): number;
  121020. /**
  121021. * Returns true if enough samples have been taken to completely fill the sliding window
  121022. */
  121023. get isSaturated(): boolean;
  121024. /**
  121025. * Enables contributions to the sliding window sample set
  121026. */
  121027. enable(): void;
  121028. /**
  121029. * Disables contributions to the sliding window sample set
  121030. * Samples will not be interpolated over the disabled period
  121031. */
  121032. disable(): void;
  121033. /**
  121034. * Returns true if sampling is enabled
  121035. */
  121036. get isEnabled(): boolean;
  121037. /**
  121038. * Resets performance monitor
  121039. */
  121040. reset(): void;
  121041. }
  121042. /**
  121043. * RollingAverage
  121044. *
  121045. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121046. */
  121047. export class RollingAverage {
  121048. /**
  121049. * Current average
  121050. */
  121051. average: number;
  121052. /**
  121053. * Current variance
  121054. */
  121055. variance: number;
  121056. protected _samples: Array<number>;
  121057. protected _sampleCount: number;
  121058. protected _pos: number;
  121059. protected _m2: number;
  121060. /**
  121061. * constructor
  121062. * @param length The number of samples required to saturate the sliding window
  121063. */
  121064. constructor(length: number);
  121065. /**
  121066. * Adds a sample to the sample set
  121067. * @param v The sample value
  121068. */
  121069. add(v: number): void;
  121070. /**
  121071. * Returns previously added values or null if outside of history or outside the sliding window domain
  121072. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121073. * @return Value previously recorded with add() or null if outside of range
  121074. */
  121075. history(i: number): number;
  121076. /**
  121077. * Returns true if enough samples have been taken to completely fill the sliding window
  121078. * @return true if sample-set saturated
  121079. */
  121080. isSaturated(): boolean;
  121081. /**
  121082. * Resets the rolling average (equivalent to 0 samples taken so far)
  121083. */
  121084. reset(): void;
  121085. /**
  121086. * Wraps a value around the sample range boundaries
  121087. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121088. * @return Wrapped position in sample range
  121089. */
  121090. protected _wrapPosition(i: number): number;
  121091. }
  121092. }
  121093. declare module BABYLON {
  121094. /**
  121095. * This class is used to track a performance counter which is number based.
  121096. * The user has access to many properties which give statistics of different nature.
  121097. *
  121098. * The implementer can track two kinds of Performance Counter: time and count.
  121099. * 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.
  121100. * 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.
  121101. */
  121102. export class PerfCounter {
  121103. /**
  121104. * Gets or sets a global boolean to turn on and off all the counters
  121105. */
  121106. static Enabled: boolean;
  121107. /**
  121108. * Returns the smallest value ever
  121109. */
  121110. get min(): number;
  121111. /**
  121112. * Returns the biggest value ever
  121113. */
  121114. get max(): number;
  121115. /**
  121116. * Returns the average value since the performance counter is running
  121117. */
  121118. get average(): number;
  121119. /**
  121120. * Returns the average value of the last second the counter was monitored
  121121. */
  121122. get lastSecAverage(): number;
  121123. /**
  121124. * Returns the current value
  121125. */
  121126. get current(): number;
  121127. /**
  121128. * Gets the accumulated total
  121129. */
  121130. get total(): number;
  121131. /**
  121132. * Gets the total value count
  121133. */
  121134. get count(): number;
  121135. /**
  121136. * Creates a new counter
  121137. */
  121138. constructor();
  121139. /**
  121140. * Call this method to start monitoring a new frame.
  121141. * 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.
  121142. */
  121143. fetchNewFrame(): void;
  121144. /**
  121145. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121146. * @param newCount the count value to add to the monitored count
  121147. * @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.
  121148. */
  121149. addCount(newCount: number, fetchResult: boolean): void;
  121150. /**
  121151. * Start monitoring this performance counter
  121152. */
  121153. beginMonitoring(): void;
  121154. /**
  121155. * Compute the time lapsed since the previous beginMonitoring() call.
  121156. * @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
  121157. */
  121158. endMonitoring(newFrame?: boolean): void;
  121159. private _fetchResult;
  121160. private _startMonitoringTime;
  121161. private _min;
  121162. private _max;
  121163. private _average;
  121164. private _current;
  121165. private _totalValueCount;
  121166. private _totalAccumulated;
  121167. private _lastSecAverage;
  121168. private _lastSecAccumulated;
  121169. private _lastSecTime;
  121170. private _lastSecValueCount;
  121171. }
  121172. }
  121173. declare module BABYLON {
  121174. interface ThinEngine {
  121175. /** @hidden */
  121176. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121177. }
  121178. }
  121179. declare module BABYLON {
  121180. /**
  121181. * Defines the interface used by display changed events
  121182. */
  121183. export interface IDisplayChangedEventArgs {
  121184. /** Gets the vrDisplay object (if any) */
  121185. vrDisplay: Nullable<any>;
  121186. /** Gets a boolean indicating if webVR is supported */
  121187. vrSupported: boolean;
  121188. }
  121189. /**
  121190. * Defines the interface used by objects containing a viewport (like a camera)
  121191. */
  121192. interface IViewportOwnerLike {
  121193. /**
  121194. * Gets or sets the viewport
  121195. */
  121196. viewport: IViewportLike;
  121197. }
  121198. /**
  121199. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121200. */
  121201. export class Engine extends ThinEngine {
  121202. /** Defines that alpha blending is disabled */
  121203. static readonly ALPHA_DISABLE: number;
  121204. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121205. static readonly ALPHA_ADD: number;
  121206. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121207. static readonly ALPHA_COMBINE: number;
  121208. /** Defines that alpha blending to DEST - SRC * DEST */
  121209. static readonly ALPHA_SUBTRACT: number;
  121210. /** Defines that alpha blending to SRC * DEST */
  121211. static readonly ALPHA_MULTIPLY: number;
  121212. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121213. static readonly ALPHA_MAXIMIZED: number;
  121214. /** Defines that alpha blending to SRC + DEST */
  121215. static readonly ALPHA_ONEONE: number;
  121216. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121217. static readonly ALPHA_PREMULTIPLIED: number;
  121218. /**
  121219. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121220. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121221. */
  121222. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121223. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121224. static readonly ALPHA_INTERPOLATE: number;
  121225. /**
  121226. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121227. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121228. */
  121229. static readonly ALPHA_SCREENMODE: number;
  121230. /** Defines that the ressource is not delayed*/
  121231. static readonly DELAYLOADSTATE_NONE: number;
  121232. /** Defines that the ressource was successfully delay loaded */
  121233. static readonly DELAYLOADSTATE_LOADED: number;
  121234. /** Defines that the ressource is currently delay loading */
  121235. static readonly DELAYLOADSTATE_LOADING: number;
  121236. /** Defines that the ressource is delayed and has not started loading */
  121237. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121238. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121239. static readonly NEVER: number;
  121240. /** 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 */
  121241. static readonly ALWAYS: number;
  121242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121243. static readonly LESS: number;
  121244. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121245. static readonly EQUAL: number;
  121246. /** 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 */
  121247. static readonly LEQUAL: number;
  121248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121249. static readonly GREATER: number;
  121250. /** 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 */
  121251. static readonly GEQUAL: number;
  121252. /** 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 */
  121253. static readonly NOTEQUAL: number;
  121254. /** Passed to stencilOperation to specify that stencil value must be kept */
  121255. static readonly KEEP: number;
  121256. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121257. static readonly REPLACE: number;
  121258. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121259. static readonly INCR: number;
  121260. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121261. static readonly DECR: number;
  121262. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121263. static readonly INVERT: number;
  121264. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121265. static readonly INCR_WRAP: number;
  121266. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121267. static readonly DECR_WRAP: number;
  121268. /** Texture is not repeating outside of 0..1 UVs */
  121269. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121270. /** Texture is repeating outside of 0..1 UVs */
  121271. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121272. /** Texture is repeating and mirrored */
  121273. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121274. /** ALPHA */
  121275. static readonly TEXTUREFORMAT_ALPHA: number;
  121276. /** LUMINANCE */
  121277. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121278. /** LUMINANCE_ALPHA */
  121279. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121280. /** RGB */
  121281. static readonly TEXTUREFORMAT_RGB: number;
  121282. /** RGBA */
  121283. static readonly TEXTUREFORMAT_RGBA: number;
  121284. /** RED */
  121285. static readonly TEXTUREFORMAT_RED: number;
  121286. /** RED (2nd reference) */
  121287. static readonly TEXTUREFORMAT_R: number;
  121288. /** RG */
  121289. static readonly TEXTUREFORMAT_RG: number;
  121290. /** RED_INTEGER */
  121291. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121292. /** RED_INTEGER (2nd reference) */
  121293. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121294. /** RG_INTEGER */
  121295. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121296. /** RGB_INTEGER */
  121297. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121298. /** RGBA_INTEGER */
  121299. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121300. /** UNSIGNED_BYTE */
  121301. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121302. /** UNSIGNED_BYTE (2nd reference) */
  121303. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121304. /** FLOAT */
  121305. static readonly TEXTURETYPE_FLOAT: number;
  121306. /** HALF_FLOAT */
  121307. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121308. /** BYTE */
  121309. static readonly TEXTURETYPE_BYTE: number;
  121310. /** SHORT */
  121311. static readonly TEXTURETYPE_SHORT: number;
  121312. /** UNSIGNED_SHORT */
  121313. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121314. /** INT */
  121315. static readonly TEXTURETYPE_INT: number;
  121316. /** UNSIGNED_INT */
  121317. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121318. /** UNSIGNED_SHORT_4_4_4_4 */
  121319. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121320. /** UNSIGNED_SHORT_5_5_5_1 */
  121321. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121322. /** UNSIGNED_SHORT_5_6_5 */
  121323. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121324. /** UNSIGNED_INT_2_10_10_10_REV */
  121325. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121326. /** UNSIGNED_INT_24_8 */
  121327. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121328. /** UNSIGNED_INT_10F_11F_11F_REV */
  121329. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121330. /** UNSIGNED_INT_5_9_9_9_REV */
  121331. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121332. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121333. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121334. /** nearest is mag = nearest and min = nearest and mip = linear */
  121335. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121336. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121337. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121338. /** Trilinear is mag = linear and min = linear and mip = linear */
  121339. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121340. /** nearest is mag = nearest and min = nearest and mip = linear */
  121341. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121343. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121344. /** Trilinear is mag = linear and min = linear and mip = linear */
  121345. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121346. /** mag = nearest and min = nearest and mip = nearest */
  121347. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121348. /** mag = nearest and min = linear and mip = nearest */
  121349. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121350. /** mag = nearest and min = linear and mip = linear */
  121351. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121352. /** mag = nearest and min = linear and mip = none */
  121353. static readonly TEXTURE_NEAREST_LINEAR: number;
  121354. /** mag = nearest and min = nearest and mip = none */
  121355. static readonly TEXTURE_NEAREST_NEAREST: number;
  121356. /** mag = linear and min = nearest and mip = nearest */
  121357. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121358. /** mag = linear and min = nearest and mip = linear */
  121359. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121360. /** mag = linear and min = linear and mip = none */
  121361. static readonly TEXTURE_LINEAR_LINEAR: number;
  121362. /** mag = linear and min = nearest and mip = none */
  121363. static readonly TEXTURE_LINEAR_NEAREST: number;
  121364. /** Explicit coordinates mode */
  121365. static readonly TEXTURE_EXPLICIT_MODE: number;
  121366. /** Spherical coordinates mode */
  121367. static readonly TEXTURE_SPHERICAL_MODE: number;
  121368. /** Planar coordinates mode */
  121369. static readonly TEXTURE_PLANAR_MODE: number;
  121370. /** Cubic coordinates mode */
  121371. static readonly TEXTURE_CUBIC_MODE: number;
  121372. /** Projection coordinates mode */
  121373. static readonly TEXTURE_PROJECTION_MODE: number;
  121374. /** Skybox coordinates mode */
  121375. static readonly TEXTURE_SKYBOX_MODE: number;
  121376. /** Inverse Cubic coordinates mode */
  121377. static readonly TEXTURE_INVCUBIC_MODE: number;
  121378. /** Equirectangular coordinates mode */
  121379. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121380. /** Equirectangular Fixed coordinates mode */
  121381. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121382. /** Equirectangular Fixed Mirrored coordinates mode */
  121383. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121384. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121385. static readonly SCALEMODE_FLOOR: number;
  121386. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121387. static readonly SCALEMODE_NEAREST: number;
  121388. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121389. static readonly SCALEMODE_CEILING: number;
  121390. /**
  121391. * Returns the current npm package of the sdk
  121392. */
  121393. static get NpmPackage(): string;
  121394. /**
  121395. * Returns the current version of the framework
  121396. */
  121397. static get Version(): string;
  121398. /** Gets the list of created engines */
  121399. static get Instances(): Engine[];
  121400. /**
  121401. * Gets the latest created engine
  121402. */
  121403. static get LastCreatedEngine(): Nullable<Engine>;
  121404. /**
  121405. * Gets the latest created scene
  121406. */
  121407. static get LastCreatedScene(): Nullable<Scene>;
  121408. /**
  121409. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121410. * @param flag defines which part of the materials must be marked as dirty
  121411. * @param predicate defines a predicate used to filter which materials should be affected
  121412. */
  121413. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121414. /**
  121415. * Method called to create the default loading screen.
  121416. * This can be overriden in your own app.
  121417. * @param canvas The rendering canvas element
  121418. * @returns The loading screen
  121419. */
  121420. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121421. /**
  121422. * Method called to create the default rescale post process on each engine.
  121423. */
  121424. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121425. /**
  121426. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121427. **/
  121428. enableOfflineSupport: boolean;
  121429. /**
  121430. * 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)
  121431. **/
  121432. disableManifestCheck: boolean;
  121433. /**
  121434. * Gets the list of created scenes
  121435. */
  121436. scenes: Scene[];
  121437. /**
  121438. * Event raised when a new scene is created
  121439. */
  121440. onNewSceneAddedObservable: Observable<Scene>;
  121441. /**
  121442. * Gets the list of created postprocesses
  121443. */
  121444. postProcesses: PostProcess[];
  121445. /**
  121446. * Gets a boolean indicating if the pointer is currently locked
  121447. */
  121448. isPointerLock: boolean;
  121449. /**
  121450. * Observable event triggered each time the rendering canvas is resized
  121451. */
  121452. onResizeObservable: Observable<Engine>;
  121453. /**
  121454. * Observable event triggered each time the canvas loses focus
  121455. */
  121456. onCanvasBlurObservable: Observable<Engine>;
  121457. /**
  121458. * Observable event triggered each time the canvas gains focus
  121459. */
  121460. onCanvasFocusObservable: Observable<Engine>;
  121461. /**
  121462. * Observable event triggered each time the canvas receives pointerout event
  121463. */
  121464. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121465. /**
  121466. * Observable raised when the engine begins a new frame
  121467. */
  121468. onBeginFrameObservable: Observable<Engine>;
  121469. /**
  121470. * If set, will be used to request the next animation frame for the render loop
  121471. */
  121472. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121473. /**
  121474. * Observable raised when the engine ends the current frame
  121475. */
  121476. onEndFrameObservable: Observable<Engine>;
  121477. /**
  121478. * Observable raised when the engine is about to compile a shader
  121479. */
  121480. onBeforeShaderCompilationObservable: Observable<Engine>;
  121481. /**
  121482. * Observable raised when the engine has jsut compiled a shader
  121483. */
  121484. onAfterShaderCompilationObservable: Observable<Engine>;
  121485. /**
  121486. * Gets the audio engine
  121487. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121488. * @ignorenaming
  121489. */
  121490. static audioEngine: IAudioEngine;
  121491. /**
  121492. * Default AudioEngine factory responsible of creating the Audio Engine.
  121493. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121494. */
  121495. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121496. /**
  121497. * Default offline support factory responsible of creating a tool used to store data locally.
  121498. * By default, this will create a Database object if the workload has been embedded.
  121499. */
  121500. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121501. private _loadingScreen;
  121502. private _pointerLockRequested;
  121503. private _rescalePostProcess;
  121504. private _deterministicLockstep;
  121505. private _lockstepMaxSteps;
  121506. private _timeStep;
  121507. protected get _supportsHardwareTextureRescaling(): boolean;
  121508. private _fps;
  121509. private _deltaTime;
  121510. /** @hidden */
  121511. _drawCalls: PerfCounter;
  121512. /** 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 */
  121513. canvasTabIndex: number;
  121514. /**
  121515. * Turn this value on if you want to pause FPS computation when in background
  121516. */
  121517. disablePerformanceMonitorInBackground: boolean;
  121518. private _performanceMonitor;
  121519. /**
  121520. * Gets the performance monitor attached to this engine
  121521. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121522. */
  121523. get performanceMonitor(): PerformanceMonitor;
  121524. private _onFocus;
  121525. private _onBlur;
  121526. private _onCanvasPointerOut;
  121527. private _onCanvasBlur;
  121528. private _onCanvasFocus;
  121529. private _onFullscreenChange;
  121530. private _onPointerLockChange;
  121531. /**
  121532. * Gets the HTML element used to attach event listeners
  121533. * @returns a HTML element
  121534. */
  121535. getInputElement(): Nullable<HTMLElement>;
  121536. /**
  121537. * Creates a new engine
  121538. * @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
  121539. * @param antialias defines enable antialiasing (default: false)
  121540. * @param options defines further options to be sent to the getContext() function
  121541. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121542. */
  121543. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121544. /**
  121545. * Gets current aspect ratio
  121546. * @param viewportOwner defines the camera to use to get the aspect ratio
  121547. * @param useScreen defines if screen size must be used (or the current render target if any)
  121548. * @returns a number defining the aspect ratio
  121549. */
  121550. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121551. /**
  121552. * Gets current screen aspect ratio
  121553. * @returns a number defining the aspect ratio
  121554. */
  121555. getScreenAspectRatio(): number;
  121556. /**
  121557. * Gets the client rect of the HTML canvas attached with the current webGL context
  121558. * @returns a client rectanglee
  121559. */
  121560. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121561. /**
  121562. * Gets the client rect of the HTML element used for events
  121563. * @returns a client rectanglee
  121564. */
  121565. getInputElementClientRect(): Nullable<ClientRect>;
  121566. /**
  121567. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121568. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121569. * @returns true if engine is in deterministic lock step mode
  121570. */
  121571. isDeterministicLockStep(): boolean;
  121572. /**
  121573. * Gets the max steps when engine is running in deterministic lock step
  121574. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121575. * @returns the max steps
  121576. */
  121577. getLockstepMaxSteps(): number;
  121578. /**
  121579. * Returns the time in ms between steps when using deterministic lock step.
  121580. * @returns time step in (ms)
  121581. */
  121582. getTimeStep(): number;
  121583. /**
  121584. * Force the mipmap generation for the given render target texture
  121585. * @param texture defines the render target texture to use
  121586. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121587. */
  121588. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121589. /** States */
  121590. /**
  121591. * Set various states to the webGL context
  121592. * @param culling defines backface culling state
  121593. * @param zOffset defines the value to apply to zOffset (0 by default)
  121594. * @param force defines if states must be applied even if cache is up to date
  121595. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121596. */
  121597. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121598. /**
  121599. * Set the z offset to apply to current rendering
  121600. * @param value defines the offset to apply
  121601. */
  121602. setZOffset(value: number): void;
  121603. /**
  121604. * Gets the current value of the zOffset
  121605. * @returns the current zOffset state
  121606. */
  121607. getZOffset(): number;
  121608. /**
  121609. * Enable or disable depth buffering
  121610. * @param enable defines the state to set
  121611. */
  121612. setDepthBuffer(enable: boolean): void;
  121613. /**
  121614. * Gets a boolean indicating if depth writing is enabled
  121615. * @returns the current depth writing state
  121616. */
  121617. getDepthWrite(): boolean;
  121618. /**
  121619. * Enable or disable depth writing
  121620. * @param enable defines the state to set
  121621. */
  121622. setDepthWrite(enable: boolean): void;
  121623. /**
  121624. * Gets a boolean indicating if stencil buffer is enabled
  121625. * @returns the current stencil buffer state
  121626. */
  121627. getStencilBuffer(): boolean;
  121628. /**
  121629. * Enable or disable the stencil buffer
  121630. * @param enable defines if the stencil buffer must be enabled or disabled
  121631. */
  121632. setStencilBuffer(enable: boolean): void;
  121633. /**
  121634. * Gets the current stencil mask
  121635. * @returns a number defining the new stencil mask to use
  121636. */
  121637. getStencilMask(): number;
  121638. /**
  121639. * Sets the current stencil mask
  121640. * @param mask defines the new stencil mask to use
  121641. */
  121642. setStencilMask(mask: number): void;
  121643. /**
  121644. * Gets the current stencil function
  121645. * @returns a number defining the stencil function to use
  121646. */
  121647. getStencilFunction(): number;
  121648. /**
  121649. * Gets the current stencil reference value
  121650. * @returns a number defining the stencil reference value to use
  121651. */
  121652. getStencilFunctionReference(): number;
  121653. /**
  121654. * Gets the current stencil mask
  121655. * @returns a number defining the stencil mask to use
  121656. */
  121657. getStencilFunctionMask(): number;
  121658. /**
  121659. * Sets the current stencil function
  121660. * @param stencilFunc defines the new stencil function to use
  121661. */
  121662. setStencilFunction(stencilFunc: number): void;
  121663. /**
  121664. * Sets the current stencil reference
  121665. * @param reference defines the new stencil reference to use
  121666. */
  121667. setStencilFunctionReference(reference: number): void;
  121668. /**
  121669. * Sets the current stencil mask
  121670. * @param mask defines the new stencil mask to use
  121671. */
  121672. setStencilFunctionMask(mask: number): void;
  121673. /**
  121674. * Gets the current stencil operation when stencil fails
  121675. * @returns a number defining stencil operation to use when stencil fails
  121676. */
  121677. getStencilOperationFail(): number;
  121678. /**
  121679. * Gets the current stencil operation when depth fails
  121680. * @returns a number defining stencil operation to use when depth fails
  121681. */
  121682. getStencilOperationDepthFail(): number;
  121683. /**
  121684. * Gets the current stencil operation when stencil passes
  121685. * @returns a number defining stencil operation to use when stencil passes
  121686. */
  121687. getStencilOperationPass(): number;
  121688. /**
  121689. * Sets the stencil operation to use when stencil fails
  121690. * @param operation defines the stencil operation to use when stencil fails
  121691. */
  121692. setStencilOperationFail(operation: number): void;
  121693. /**
  121694. * Sets the stencil operation to use when depth fails
  121695. * @param operation defines the stencil operation to use when depth fails
  121696. */
  121697. setStencilOperationDepthFail(operation: number): void;
  121698. /**
  121699. * Sets the stencil operation to use when stencil passes
  121700. * @param operation defines the stencil operation to use when stencil passes
  121701. */
  121702. setStencilOperationPass(operation: number): void;
  121703. /**
  121704. * Sets a boolean indicating if the dithering state is enabled or disabled
  121705. * @param value defines the dithering state
  121706. */
  121707. setDitheringState(value: boolean): void;
  121708. /**
  121709. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121710. * @param value defines the rasterizer state
  121711. */
  121712. setRasterizerState(value: boolean): void;
  121713. /**
  121714. * Gets the current depth function
  121715. * @returns a number defining the depth function
  121716. */
  121717. getDepthFunction(): Nullable<number>;
  121718. /**
  121719. * Sets the current depth function
  121720. * @param depthFunc defines the function to use
  121721. */
  121722. setDepthFunction(depthFunc: number): void;
  121723. /**
  121724. * Sets the current depth function to GREATER
  121725. */
  121726. setDepthFunctionToGreater(): void;
  121727. /**
  121728. * Sets the current depth function to GEQUAL
  121729. */
  121730. setDepthFunctionToGreaterOrEqual(): void;
  121731. /**
  121732. * Sets the current depth function to LESS
  121733. */
  121734. setDepthFunctionToLess(): void;
  121735. /**
  121736. * Sets the current depth function to LEQUAL
  121737. */
  121738. setDepthFunctionToLessOrEqual(): void;
  121739. private _cachedStencilBuffer;
  121740. private _cachedStencilFunction;
  121741. private _cachedStencilMask;
  121742. private _cachedStencilOperationPass;
  121743. private _cachedStencilOperationFail;
  121744. private _cachedStencilOperationDepthFail;
  121745. private _cachedStencilReference;
  121746. /**
  121747. * Caches the the state of the stencil buffer
  121748. */
  121749. cacheStencilState(): void;
  121750. /**
  121751. * Restores the state of the stencil buffer
  121752. */
  121753. restoreStencilState(): void;
  121754. /**
  121755. * Directly set the WebGL Viewport
  121756. * @param x defines the x coordinate of the viewport (in screen space)
  121757. * @param y defines the y coordinate of the viewport (in screen space)
  121758. * @param width defines the width of the viewport (in screen space)
  121759. * @param height defines the height of the viewport (in screen space)
  121760. * @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
  121761. */
  121762. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121763. /**
  121764. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121765. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121766. * @param y defines the y-coordinate of the corner of the clear rectangle
  121767. * @param width defines the width of the clear rectangle
  121768. * @param height defines the height of the clear rectangle
  121769. * @param clearColor defines the clear color
  121770. */
  121771. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121772. /**
  121773. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121774. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121775. * @param y defines the y-coordinate of the corner of the clear rectangle
  121776. * @param width defines the width of the clear rectangle
  121777. * @param height defines the height of the clear rectangle
  121778. */
  121779. enableScissor(x: number, y: number, width: number, height: number): void;
  121780. /**
  121781. * Disable previously set scissor test rectangle
  121782. */
  121783. disableScissor(): void;
  121784. protected _reportDrawCall(): void;
  121785. /**
  121786. * Initializes a webVR display and starts listening to display change events
  121787. * The onVRDisplayChangedObservable will be notified upon these changes
  121788. * @returns The onVRDisplayChangedObservable
  121789. */
  121790. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121791. /** @hidden */
  121792. _prepareVRComponent(): void;
  121793. /** @hidden */
  121794. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121795. /** @hidden */
  121796. _submitVRFrame(): void;
  121797. /**
  121798. * Call this function to leave webVR mode
  121799. * Will do nothing if webVR is not supported or if there is no webVR device
  121800. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121801. */
  121802. disableVR(): void;
  121803. /**
  121804. * Gets a boolean indicating that the system is in VR mode and is presenting
  121805. * @returns true if VR mode is engaged
  121806. */
  121807. isVRPresenting(): boolean;
  121808. /** @hidden */
  121809. _requestVRFrame(): void;
  121810. /** @hidden */
  121811. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121812. /**
  121813. * Gets the source code of the vertex shader associated with a specific webGL program
  121814. * @param program defines the program to use
  121815. * @returns a string containing the source code of the vertex shader associated with the program
  121816. */
  121817. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121818. /**
  121819. * Gets the source code of the fragment shader associated with a specific webGL program
  121820. * @param program defines the program to use
  121821. * @returns a string containing the source code of the fragment shader associated with the program
  121822. */
  121823. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121824. /**
  121825. * Sets a depth stencil texture from a render target to the according uniform.
  121826. * @param channel The texture channel
  121827. * @param uniform The uniform to set
  121828. * @param texture The render target texture containing the depth stencil texture to apply
  121829. */
  121830. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121831. /**
  121832. * Sets a texture to the webGL context from a postprocess
  121833. * @param channel defines the channel to use
  121834. * @param postProcess defines the source postprocess
  121835. */
  121836. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121837. /**
  121838. * Binds the output of the passed in post process to the texture channel specified
  121839. * @param channel The channel the texture should be bound to
  121840. * @param postProcess The post process which's output should be bound
  121841. */
  121842. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121843. protected _rebuildBuffers(): void;
  121844. /** @hidden */
  121845. _renderFrame(): void;
  121846. _renderLoop(): void;
  121847. /** @hidden */
  121848. _renderViews(): boolean;
  121849. /**
  121850. * Toggle full screen mode
  121851. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121852. */
  121853. switchFullscreen(requestPointerLock: boolean): void;
  121854. /**
  121855. * Enters full screen mode
  121856. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121857. */
  121858. enterFullscreen(requestPointerLock: boolean): void;
  121859. /**
  121860. * Exits full screen mode
  121861. */
  121862. exitFullscreen(): void;
  121863. /**
  121864. * Enters Pointerlock mode
  121865. */
  121866. enterPointerlock(): void;
  121867. /**
  121868. * Exits Pointerlock mode
  121869. */
  121870. exitPointerlock(): void;
  121871. /**
  121872. * Begin a new frame
  121873. */
  121874. beginFrame(): void;
  121875. /**
  121876. * Enf the current frame
  121877. */
  121878. endFrame(): void;
  121879. resize(): void;
  121880. /**
  121881. * Force a specific size of the canvas
  121882. * @param width defines the new canvas' width
  121883. * @param height defines the new canvas' height
  121884. * @returns true if the size was changed
  121885. */
  121886. setSize(width: number, height: number): boolean;
  121887. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121888. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121889. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121890. _releaseTexture(texture: InternalTexture): void;
  121891. /**
  121892. * @hidden
  121893. * Rescales a texture
  121894. * @param source input texutre
  121895. * @param destination destination texture
  121896. * @param scene scene to use to render the resize
  121897. * @param internalFormat format to use when resizing
  121898. * @param onComplete callback to be called when resize has completed
  121899. */
  121900. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121901. /**
  121902. * Gets the current framerate
  121903. * @returns a number representing the framerate
  121904. */
  121905. getFps(): number;
  121906. /**
  121907. * Gets the time spent between current and previous frame
  121908. * @returns a number representing the delta time in ms
  121909. */
  121910. getDeltaTime(): number;
  121911. private _measureFps;
  121912. /** @hidden */
  121913. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121914. /**
  121915. * Updates the sample count of a render target texture
  121916. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121917. * @param texture defines the texture to update
  121918. * @param samples defines the sample count to set
  121919. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121920. */
  121921. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121922. /**
  121923. * Updates a depth texture Comparison Mode and Function.
  121924. * If the comparison Function is equal to 0, the mode will be set to none.
  121925. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121926. * @param texture The texture to set the comparison function for
  121927. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121928. */
  121929. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121930. /**
  121931. * Creates a webGL buffer to use with instanciation
  121932. * @param capacity defines the size of the buffer
  121933. * @returns the webGL buffer
  121934. */
  121935. createInstancesBuffer(capacity: number): DataBuffer;
  121936. /**
  121937. * Delete a webGL buffer used with instanciation
  121938. * @param buffer defines the webGL buffer to delete
  121939. */
  121940. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121941. private _clientWaitAsync;
  121942. /** @hidden */
  121943. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121944. dispose(): void;
  121945. private _disableTouchAction;
  121946. /**
  121947. * Display the loading screen
  121948. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121949. */
  121950. displayLoadingUI(): void;
  121951. /**
  121952. * Hide the loading screen
  121953. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121954. */
  121955. hideLoadingUI(): void;
  121956. /**
  121957. * Gets the current loading screen object
  121958. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121959. */
  121960. get loadingScreen(): ILoadingScreen;
  121961. /**
  121962. * Sets the current loading screen object
  121963. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121964. */
  121965. set loadingScreen(loadingScreen: ILoadingScreen);
  121966. /**
  121967. * Sets the current loading screen text
  121968. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121969. */
  121970. set loadingUIText(text: string);
  121971. /**
  121972. * Sets the current loading screen background color
  121973. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121974. */
  121975. set loadingUIBackgroundColor(color: string);
  121976. /** Pointerlock and fullscreen */
  121977. /**
  121978. * Ask the browser to promote the current element to pointerlock mode
  121979. * @param element defines the DOM element to promote
  121980. */
  121981. static _RequestPointerlock(element: HTMLElement): void;
  121982. /**
  121983. * Asks the browser to exit pointerlock mode
  121984. */
  121985. static _ExitPointerlock(): void;
  121986. /**
  121987. * Ask the browser to promote the current element to fullscreen rendering mode
  121988. * @param element defines the DOM element to promote
  121989. */
  121990. static _RequestFullscreen(element: HTMLElement): void;
  121991. /**
  121992. * Asks the browser to exit fullscreen mode
  121993. */
  121994. static _ExitFullscreen(): void;
  121995. }
  121996. }
  121997. declare module BABYLON {
  121998. /**
  121999. * The engine store class is responsible to hold all the instances of Engine and Scene created
  122000. * during the life time of the application.
  122001. */
  122002. export class EngineStore {
  122003. /** Gets the list of created engines */
  122004. static Instances: Engine[];
  122005. /** @hidden */
  122006. static _LastCreatedScene: Nullable<Scene>;
  122007. /**
  122008. * Gets the latest created engine
  122009. */
  122010. static get LastCreatedEngine(): Nullable<Engine>;
  122011. /**
  122012. * Gets the latest created scene
  122013. */
  122014. static get LastCreatedScene(): Nullable<Scene>;
  122015. /**
  122016. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122017. * @ignorenaming
  122018. */
  122019. static UseFallbackTexture: boolean;
  122020. /**
  122021. * Texture content used if a texture cannot loaded
  122022. * @ignorenaming
  122023. */
  122024. static FallbackTexture: string;
  122025. }
  122026. }
  122027. declare module BABYLON {
  122028. /**
  122029. * Helper class that provides a small promise polyfill
  122030. */
  122031. export class PromisePolyfill {
  122032. /**
  122033. * Static function used to check if the polyfill is required
  122034. * If this is the case then the function will inject the polyfill to window.Promise
  122035. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  122036. */
  122037. static Apply(force?: boolean): void;
  122038. }
  122039. }
  122040. declare module BABYLON {
  122041. /**
  122042. * Interface for screenshot methods with describe argument called `size` as object with options
  122043. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  122044. */
  122045. export interface IScreenshotSize {
  122046. /**
  122047. * number in pixels for canvas height
  122048. */
  122049. height?: number;
  122050. /**
  122051. * multiplier allowing render at a higher or lower resolution
  122052. * If value is defined then height and width will be ignored and taken from camera
  122053. */
  122054. precision?: number;
  122055. /**
  122056. * number in pixels for canvas width
  122057. */
  122058. width?: number;
  122059. }
  122060. }
  122061. declare module BABYLON {
  122062. interface IColor4Like {
  122063. r: float;
  122064. g: float;
  122065. b: float;
  122066. a: float;
  122067. }
  122068. /**
  122069. * Class containing a set of static utilities functions
  122070. */
  122071. export class Tools {
  122072. /**
  122073. * Gets or sets the base URL to use to load assets
  122074. */
  122075. static get BaseUrl(): string;
  122076. static set BaseUrl(value: string);
  122077. /**
  122078. * Enable/Disable Custom HTTP Request Headers globally.
  122079. * default = false
  122080. * @see CustomRequestHeaders
  122081. */
  122082. static UseCustomRequestHeaders: boolean;
  122083. /**
  122084. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122085. * i.e. when loading files, where the server/service expects an Authorization header
  122086. */
  122087. static CustomRequestHeaders: {
  122088. [key: string]: string;
  122089. };
  122090. /**
  122091. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122092. */
  122093. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122094. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122095. /**
  122096. * Default behaviour for cors in the application.
  122097. * It can be a string if the expected behavior is identical in the entire app.
  122098. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122099. */
  122100. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122101. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122102. /**
  122103. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122104. * @ignorenaming
  122105. */
  122106. static get UseFallbackTexture(): boolean;
  122107. static set UseFallbackTexture(value: boolean);
  122108. /**
  122109. * Use this object to register external classes like custom textures or material
  122110. * to allow the laoders to instantiate them
  122111. */
  122112. static get RegisteredExternalClasses(): {
  122113. [key: string]: Object;
  122114. };
  122115. static set RegisteredExternalClasses(classes: {
  122116. [key: string]: Object;
  122117. });
  122118. /**
  122119. * Texture content used if a texture cannot loaded
  122120. * @ignorenaming
  122121. */
  122122. static get fallbackTexture(): string;
  122123. static set fallbackTexture(value: string);
  122124. /**
  122125. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122126. * @param u defines the coordinate on X axis
  122127. * @param v defines the coordinate on Y axis
  122128. * @param width defines the width of the source data
  122129. * @param height defines the height of the source data
  122130. * @param pixels defines the source byte array
  122131. * @param color defines the output color
  122132. */
  122133. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122134. /**
  122135. * Interpolates between a and b via alpha
  122136. * @param a The lower value (returned when alpha = 0)
  122137. * @param b The upper value (returned when alpha = 1)
  122138. * @param alpha The interpolation-factor
  122139. * @return The mixed value
  122140. */
  122141. static Mix(a: number, b: number, alpha: number): number;
  122142. /**
  122143. * Tries to instantiate a new object from a given class name
  122144. * @param className defines the class name to instantiate
  122145. * @returns the new object or null if the system was not able to do the instantiation
  122146. */
  122147. static Instantiate(className: string): any;
  122148. /**
  122149. * Provides a slice function that will work even on IE
  122150. * @param data defines the array to slice
  122151. * @param start defines the start of the data (optional)
  122152. * @param end defines the end of the data (optional)
  122153. * @returns the new sliced array
  122154. */
  122155. static Slice<T>(data: T, start?: number, end?: number): T;
  122156. /**
  122157. * Polyfill for setImmediate
  122158. * @param action defines the action to execute after the current execution block
  122159. */
  122160. static SetImmediate(action: () => void): void;
  122161. /**
  122162. * Function indicating if a number is an exponent of 2
  122163. * @param value defines the value to test
  122164. * @returns true if the value is an exponent of 2
  122165. */
  122166. static IsExponentOfTwo(value: number): boolean;
  122167. private static _tmpFloatArray;
  122168. /**
  122169. * Returns the nearest 32-bit single precision float representation of a Number
  122170. * @param value A Number. If the parameter is of a different type, it will get converted
  122171. * to a number or to NaN if it cannot be converted
  122172. * @returns number
  122173. */
  122174. static FloatRound(value: number): number;
  122175. /**
  122176. * Extracts the filename from a path
  122177. * @param path defines the path to use
  122178. * @returns the filename
  122179. */
  122180. static GetFilename(path: string): string;
  122181. /**
  122182. * Extracts the "folder" part of a path (everything before the filename).
  122183. * @param uri The URI to extract the info from
  122184. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122185. * @returns The "folder" part of the path
  122186. */
  122187. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122188. /**
  122189. * Extracts text content from a DOM element hierarchy
  122190. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122191. */
  122192. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122193. /**
  122194. * Convert an angle in radians to degrees
  122195. * @param angle defines the angle to convert
  122196. * @returns the angle in degrees
  122197. */
  122198. static ToDegrees(angle: number): number;
  122199. /**
  122200. * Convert an angle in degrees to radians
  122201. * @param angle defines the angle to convert
  122202. * @returns the angle in radians
  122203. */
  122204. static ToRadians(angle: number): number;
  122205. /**
  122206. * Returns an array if obj is not an array
  122207. * @param obj defines the object to evaluate as an array
  122208. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122209. * @returns either obj directly if obj is an array or a new array containing obj
  122210. */
  122211. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122212. /**
  122213. * Gets the pointer prefix to use
  122214. * @param engine defines the engine we are finding the prefix for
  122215. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122216. */
  122217. static GetPointerPrefix(engine: Engine): string;
  122218. /**
  122219. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122220. * @param url define the url we are trying
  122221. * @param element define the dom element where to configure the cors policy
  122222. */
  122223. static SetCorsBehavior(url: string | string[], element: {
  122224. crossOrigin: string | null;
  122225. }): void;
  122226. /**
  122227. * Removes unwanted characters from an url
  122228. * @param url defines the url to clean
  122229. * @returns the cleaned url
  122230. */
  122231. static CleanUrl(url: string): string;
  122232. /**
  122233. * Gets or sets a function used to pre-process url before using them to load assets
  122234. */
  122235. static get PreprocessUrl(): (url: string) => string;
  122236. static set PreprocessUrl(processor: (url: string) => string);
  122237. /**
  122238. * Loads an image as an HTMLImageElement.
  122239. * @param input url string, ArrayBuffer, or Blob to load
  122240. * @param onLoad callback called when the image successfully loads
  122241. * @param onError callback called when the image fails to load
  122242. * @param offlineProvider offline provider for caching
  122243. * @param mimeType optional mime type
  122244. * @returns the HTMLImageElement of the loaded image
  122245. */
  122246. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122247. /**
  122248. * Loads a file from a url
  122249. * @param url url string, ArrayBuffer, or Blob to load
  122250. * @param onSuccess callback called when the file successfully loads
  122251. * @param onProgress callback called while file is loading (if the server supports this mode)
  122252. * @param offlineProvider defines the offline provider for caching
  122253. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122254. * @param onError callback called when the file fails to load
  122255. * @returns a file request object
  122256. */
  122257. 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;
  122258. /**
  122259. * Loads a file from a url
  122260. * @param url the file url to load
  122261. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122262. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122263. */
  122264. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122265. /**
  122266. * Load a script (identified by an url). When the url returns, the
  122267. * content of this file is added into a new script element, attached to the DOM (body element)
  122268. * @param scriptUrl defines the url of the script to laod
  122269. * @param onSuccess defines the callback called when the script is loaded
  122270. * @param onError defines the callback to call if an error occurs
  122271. * @param scriptId defines the id of the script element
  122272. */
  122273. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122274. /**
  122275. * Load an asynchronous script (identified by an url). When the url returns, the
  122276. * content of this file is added into a new script element, attached to the DOM (body element)
  122277. * @param scriptUrl defines the url of the script to laod
  122278. * @param scriptId defines the id of the script element
  122279. * @returns a promise request object
  122280. */
  122281. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122282. /**
  122283. * Loads a file from a blob
  122284. * @param fileToLoad defines the blob to use
  122285. * @param callback defines the callback to call when data is loaded
  122286. * @param progressCallback defines the callback to call during loading process
  122287. * @returns a file request object
  122288. */
  122289. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122290. /**
  122291. * Reads a file from a File object
  122292. * @param file defines the file to load
  122293. * @param onSuccess defines the callback to call when data is loaded
  122294. * @param onProgress defines the callback to call during loading process
  122295. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122296. * @param onError defines the callback to call when an error occurs
  122297. * @returns a file request object
  122298. */
  122299. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122300. /**
  122301. * Creates a data url from a given string content
  122302. * @param content defines the content to convert
  122303. * @returns the new data url link
  122304. */
  122305. static FileAsURL(content: string): string;
  122306. /**
  122307. * Format the given number to a specific decimal format
  122308. * @param value defines the number to format
  122309. * @param decimals defines the number of decimals to use
  122310. * @returns the formatted string
  122311. */
  122312. static Format(value: number, decimals?: number): string;
  122313. /**
  122314. * Tries to copy an object by duplicating every property
  122315. * @param source defines the source object
  122316. * @param destination defines the target object
  122317. * @param doNotCopyList defines a list of properties to avoid
  122318. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122319. */
  122320. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122321. /**
  122322. * Gets a boolean indicating if the given object has no own property
  122323. * @param obj defines the object to test
  122324. * @returns true if object has no own property
  122325. */
  122326. static IsEmpty(obj: any): boolean;
  122327. /**
  122328. * Function used to register events at window level
  122329. * @param windowElement defines the Window object to use
  122330. * @param events defines the events to register
  122331. */
  122332. static RegisterTopRootEvents(windowElement: Window, events: {
  122333. name: string;
  122334. handler: Nullable<(e: FocusEvent) => any>;
  122335. }[]): void;
  122336. /**
  122337. * Function used to unregister events from window level
  122338. * @param windowElement defines the Window object to use
  122339. * @param events defines the events to unregister
  122340. */
  122341. static UnregisterTopRootEvents(windowElement: Window, events: {
  122342. name: string;
  122343. handler: Nullable<(e: FocusEvent) => any>;
  122344. }[]): void;
  122345. /**
  122346. * @ignore
  122347. */
  122348. static _ScreenshotCanvas: HTMLCanvasElement;
  122349. /**
  122350. * Dumps the current bound framebuffer
  122351. * @param width defines the rendering width
  122352. * @param height defines the rendering height
  122353. * @param engine defines the hosting engine
  122354. * @param successCallback defines the callback triggered once the data are available
  122355. * @param mimeType defines the mime type of the result
  122356. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122357. */
  122358. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122359. /**
  122360. * Converts the canvas data to blob.
  122361. * This acts as a polyfill for browsers not supporting the to blob function.
  122362. * @param canvas Defines the canvas to extract the data from
  122363. * @param successCallback Defines the callback triggered once the data are available
  122364. * @param mimeType Defines the mime type of the result
  122365. */
  122366. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122367. /**
  122368. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122369. * @param successCallback defines the callback triggered once the data are available
  122370. * @param mimeType defines the mime type of the result
  122371. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122372. */
  122373. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122374. /**
  122375. * Downloads a blob in the browser
  122376. * @param blob defines the blob to download
  122377. * @param fileName defines the name of the downloaded file
  122378. */
  122379. static Download(blob: Blob, fileName: string): void;
  122380. /**
  122381. * Captures a screenshot of the current rendering
  122382. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122383. * @param engine defines the rendering engine
  122384. * @param camera defines the source camera
  122385. * @param size This parameter can be set to a single number or to an object with the
  122386. * following (optional) properties: precision, width, height. If a single number is passed,
  122387. * it will be used for both width and height. If an object is passed, the screenshot size
  122388. * will be derived from the parameters. The precision property is a multiplier allowing
  122389. * rendering at a higher or lower resolution
  122390. * @param successCallback defines the callback receives a single parameter which contains the
  122391. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122392. * src parameter of an <img> to display it
  122393. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122394. * Check your browser for supported MIME types
  122395. */
  122396. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122397. /**
  122398. * Captures a screenshot of the current rendering
  122399. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122400. * @param engine defines the rendering engine
  122401. * @param camera defines the source camera
  122402. * @param size This parameter can be set to a single number or to an object with the
  122403. * following (optional) properties: precision, width, height. If a single number is passed,
  122404. * it will be used for both width and height. If an object is passed, the screenshot size
  122405. * will be derived from the parameters. The precision property is a multiplier allowing
  122406. * rendering at a higher or lower resolution
  122407. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122408. * Check your browser for supported MIME types
  122409. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122410. * to the src parameter of an <img> to display it
  122411. */
  122412. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122413. /**
  122414. * Generates an image screenshot from the specified camera.
  122415. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122416. * @param engine The engine to use for rendering
  122417. * @param camera The camera to use for rendering
  122418. * @param size This parameter can be set to a single number or to an object with the
  122419. * following (optional) properties: precision, width, height. If a single number is passed,
  122420. * it will be used for both width and height. If an object is passed, the screenshot size
  122421. * will be derived from the parameters. The precision property is a multiplier allowing
  122422. * rendering at a higher or lower resolution
  122423. * @param successCallback The callback receives a single parameter which contains the
  122424. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122425. * src parameter of an <img> to display it
  122426. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122427. * Check your browser for supported MIME types
  122428. * @param samples Texture samples (default: 1)
  122429. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122430. * @param fileName A name for for the downloaded file.
  122431. */
  122432. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122433. /**
  122434. * Generates an image screenshot from the specified camera.
  122435. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122436. * @param engine The engine to use for rendering
  122437. * @param camera The camera to use for rendering
  122438. * @param size This parameter can be set to a single number or to an object with the
  122439. * following (optional) properties: precision, width, height. If a single number is passed,
  122440. * it will be used for both width and height. If an object is passed, the screenshot size
  122441. * will be derived from the parameters. The precision property is a multiplier allowing
  122442. * rendering at a higher or lower resolution
  122443. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122444. * Check your browser for supported MIME types
  122445. * @param samples Texture samples (default: 1)
  122446. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122447. * @param fileName A name for for the downloaded file.
  122448. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122449. * to the src parameter of an <img> to display it
  122450. */
  122451. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122452. /**
  122453. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122454. * Be aware Math.random() could cause collisions, but:
  122455. * "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"
  122456. * @returns a pseudo random id
  122457. */
  122458. static RandomId(): string;
  122459. /**
  122460. * Test if the given uri is a base64 string
  122461. * @param uri The uri to test
  122462. * @return True if the uri is a base64 string or false otherwise
  122463. */
  122464. static IsBase64(uri: string): boolean;
  122465. /**
  122466. * Decode the given base64 uri.
  122467. * @param uri The uri to decode
  122468. * @return The decoded base64 data.
  122469. */
  122470. static DecodeBase64(uri: string): ArrayBuffer;
  122471. /**
  122472. * Gets the absolute url.
  122473. * @param url the input url
  122474. * @return the absolute url
  122475. */
  122476. static GetAbsoluteUrl(url: string): string;
  122477. /**
  122478. * No log
  122479. */
  122480. static readonly NoneLogLevel: number;
  122481. /**
  122482. * Only message logs
  122483. */
  122484. static readonly MessageLogLevel: number;
  122485. /**
  122486. * Only warning logs
  122487. */
  122488. static readonly WarningLogLevel: number;
  122489. /**
  122490. * Only error logs
  122491. */
  122492. static readonly ErrorLogLevel: number;
  122493. /**
  122494. * All logs
  122495. */
  122496. static readonly AllLogLevel: number;
  122497. /**
  122498. * Gets a value indicating the number of loading errors
  122499. * @ignorenaming
  122500. */
  122501. static get errorsCount(): number;
  122502. /**
  122503. * Callback called when a new log is added
  122504. */
  122505. static OnNewCacheEntry: (entry: string) => void;
  122506. /**
  122507. * Log a message to the console
  122508. * @param message defines the message to log
  122509. */
  122510. static Log(message: string): void;
  122511. /**
  122512. * Write a warning message to the console
  122513. * @param message defines the message to log
  122514. */
  122515. static Warn(message: string): void;
  122516. /**
  122517. * Write an error message to the console
  122518. * @param message defines the message to log
  122519. */
  122520. static Error(message: string): void;
  122521. /**
  122522. * Gets current log cache (list of logs)
  122523. */
  122524. static get LogCache(): string;
  122525. /**
  122526. * Clears the log cache
  122527. */
  122528. static ClearLogCache(): void;
  122529. /**
  122530. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122531. */
  122532. static set LogLevels(level: number);
  122533. /**
  122534. * Checks if the window object exists
  122535. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122536. */
  122537. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122538. /**
  122539. * No performance log
  122540. */
  122541. static readonly PerformanceNoneLogLevel: number;
  122542. /**
  122543. * Use user marks to log performance
  122544. */
  122545. static readonly PerformanceUserMarkLogLevel: number;
  122546. /**
  122547. * Log performance to the console
  122548. */
  122549. static readonly PerformanceConsoleLogLevel: number;
  122550. private static _performance;
  122551. /**
  122552. * Sets the current performance log level
  122553. */
  122554. static set PerformanceLogLevel(level: number);
  122555. private static _StartPerformanceCounterDisabled;
  122556. private static _EndPerformanceCounterDisabled;
  122557. private static _StartUserMark;
  122558. private static _EndUserMark;
  122559. private static _StartPerformanceConsole;
  122560. private static _EndPerformanceConsole;
  122561. /**
  122562. * Starts a performance counter
  122563. */
  122564. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122565. /**
  122566. * Ends a specific performance coutner
  122567. */
  122568. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122569. /**
  122570. * Gets either window.performance.now() if supported or Date.now() else
  122571. */
  122572. static get Now(): number;
  122573. /**
  122574. * This method will return the name of the class used to create the instance of the given object.
  122575. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122576. * @param object the object to get the class name from
  122577. * @param isType defines if the object is actually a type
  122578. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122579. */
  122580. static GetClassName(object: any, isType?: boolean): string;
  122581. /**
  122582. * Gets the first element of an array satisfying a given predicate
  122583. * @param array defines the array to browse
  122584. * @param predicate defines the predicate to use
  122585. * @returns null if not found or the element
  122586. */
  122587. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122588. /**
  122589. * This method will return the name of the full name of the class, including its owning module (if any).
  122590. * 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).
  122591. * @param object the object to get the class name from
  122592. * @param isType defines if the object is actually a type
  122593. * @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.
  122594. * @ignorenaming
  122595. */
  122596. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122597. /**
  122598. * Returns a promise that resolves after the given amount of time.
  122599. * @param delay Number of milliseconds to delay
  122600. * @returns Promise that resolves after the given amount of time
  122601. */
  122602. static DelayAsync(delay: number): Promise<void>;
  122603. /**
  122604. * Utility function to detect if the current user agent is Safari
  122605. * @returns whether or not the current user agent is safari
  122606. */
  122607. static IsSafari(): boolean;
  122608. }
  122609. /**
  122610. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122611. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122612. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122613. * @param name The name of the class, case should be preserved
  122614. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122615. */
  122616. export function className(name: string, module?: string): (target: Object) => void;
  122617. /**
  122618. * An implementation of a loop for asynchronous functions.
  122619. */
  122620. export class AsyncLoop {
  122621. /**
  122622. * Defines the number of iterations for the loop
  122623. */
  122624. iterations: number;
  122625. /**
  122626. * Defines the current index of the loop.
  122627. */
  122628. index: number;
  122629. private _done;
  122630. private _fn;
  122631. private _successCallback;
  122632. /**
  122633. * Constructor.
  122634. * @param iterations the number of iterations.
  122635. * @param func the function to run each iteration
  122636. * @param successCallback the callback that will be called upon succesful execution
  122637. * @param offset starting offset.
  122638. */
  122639. constructor(
  122640. /**
  122641. * Defines the number of iterations for the loop
  122642. */
  122643. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122644. /**
  122645. * Execute the next iteration. Must be called after the last iteration was finished.
  122646. */
  122647. executeNext(): void;
  122648. /**
  122649. * Break the loop and run the success callback.
  122650. */
  122651. breakLoop(): void;
  122652. /**
  122653. * Create and run an async loop.
  122654. * @param iterations the number of iterations.
  122655. * @param fn the function to run each iteration
  122656. * @param successCallback the callback that will be called upon succesful execution
  122657. * @param offset starting offset.
  122658. * @returns the created async loop object
  122659. */
  122660. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122661. /**
  122662. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122663. * @param iterations total number of iterations
  122664. * @param syncedIterations number of synchronous iterations in each async iteration.
  122665. * @param fn the function to call each iteration.
  122666. * @param callback a success call back that will be called when iterating stops.
  122667. * @param breakFunction a break condition (optional)
  122668. * @param timeout timeout settings for the setTimeout function. default - 0.
  122669. * @returns the created async loop object
  122670. */
  122671. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122672. }
  122673. }
  122674. declare module BABYLON {
  122675. /**
  122676. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122677. * The underlying implementation relies on an associative array to ensure the best performances.
  122678. * The value can be anything including 'null' but except 'undefined'
  122679. */
  122680. export class StringDictionary<T> {
  122681. /**
  122682. * This will clear this dictionary and copy the content from the 'source' one.
  122683. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122684. * @param source the dictionary to take the content from and copy to this dictionary
  122685. */
  122686. copyFrom(source: StringDictionary<T>): void;
  122687. /**
  122688. * Get a value based from its key
  122689. * @param key the given key to get the matching value from
  122690. * @return the value if found, otherwise undefined is returned
  122691. */
  122692. get(key: string): T | undefined;
  122693. /**
  122694. * Get a value from its key or add it if it doesn't exist.
  122695. * This method will ensure you that a given key/data will be present in the dictionary.
  122696. * @param key the given key to get the matching value from
  122697. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122698. * The factory will only be invoked if there's no data for the given key.
  122699. * @return the value corresponding to the key.
  122700. */
  122701. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122702. /**
  122703. * Get a value from its key if present in the dictionary otherwise add it
  122704. * @param key the key to get the value from
  122705. * @param val if there's no such key/value pair in the dictionary add it with this value
  122706. * @return the value corresponding to the key
  122707. */
  122708. getOrAdd(key: string, val: T): T;
  122709. /**
  122710. * Check if there's a given key in the dictionary
  122711. * @param key the key to check for
  122712. * @return true if the key is present, false otherwise
  122713. */
  122714. contains(key: string): boolean;
  122715. /**
  122716. * Add a new key and its corresponding value
  122717. * @param key the key to add
  122718. * @param value the value corresponding to the key
  122719. * @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
  122720. */
  122721. add(key: string, value: T): boolean;
  122722. /**
  122723. * Update a specific value associated to a key
  122724. * @param key defines the key to use
  122725. * @param value defines the value to store
  122726. * @returns true if the value was updated (or false if the key was not found)
  122727. */
  122728. set(key: string, value: T): boolean;
  122729. /**
  122730. * Get the element of the given key and remove it from the dictionary
  122731. * @param key defines the key to search
  122732. * @returns the value associated with the key or null if not found
  122733. */
  122734. getAndRemove(key: string): Nullable<T>;
  122735. /**
  122736. * Remove a key/value from the dictionary.
  122737. * @param key the key to remove
  122738. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122739. */
  122740. remove(key: string): boolean;
  122741. /**
  122742. * Clear the whole content of the dictionary
  122743. */
  122744. clear(): void;
  122745. /**
  122746. * Gets the current count
  122747. */
  122748. get count(): number;
  122749. /**
  122750. * Execute a callback on each key/val of the dictionary.
  122751. * Note that you can remove any element in this dictionary in the callback implementation
  122752. * @param callback the callback to execute on a given key/value pair
  122753. */
  122754. forEach(callback: (key: string, val: T) => void): void;
  122755. /**
  122756. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122757. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122758. * Note that you can remove any element in this dictionary in the callback implementation
  122759. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122760. * @returns the first item
  122761. */
  122762. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122763. private _count;
  122764. private _data;
  122765. }
  122766. }
  122767. declare module BABYLON {
  122768. /** @hidden */
  122769. export interface ICollisionCoordinator {
  122770. createCollider(): Collider;
  122771. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122772. init(scene: Scene): void;
  122773. }
  122774. /** @hidden */
  122775. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122776. private _scene;
  122777. private _scaledPosition;
  122778. private _scaledVelocity;
  122779. private _finalPosition;
  122780. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122781. createCollider(): Collider;
  122782. init(scene: Scene): void;
  122783. private _collideWithWorld;
  122784. }
  122785. }
  122786. declare module BABYLON {
  122787. /**
  122788. * Class used to manage all inputs for the scene.
  122789. */
  122790. export class InputManager {
  122791. /** The distance in pixel that you have to move to prevent some events */
  122792. static DragMovementThreshold: number;
  122793. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122794. static LongPressDelay: number;
  122795. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122796. static DoubleClickDelay: number;
  122797. /** If you need to check double click without raising a single click at first click, enable this flag */
  122798. static ExclusiveDoubleClickMode: boolean;
  122799. /** 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. */
  122800. private _alreadyAttached;
  122801. private _alreadyAttachedTo;
  122802. private _wheelEventName;
  122803. private _onPointerMove;
  122804. private _onPointerDown;
  122805. private _onPointerUp;
  122806. private _initClickEvent;
  122807. private _initActionManager;
  122808. private _delayedSimpleClick;
  122809. private _delayedSimpleClickTimeout;
  122810. private _previousDelayedSimpleClickTimeout;
  122811. private _meshPickProceed;
  122812. private _previousButtonPressed;
  122813. private _currentPickResult;
  122814. private _previousPickResult;
  122815. private _totalPointersPressed;
  122816. private _doubleClickOccured;
  122817. private _pointerOverMesh;
  122818. private _pickedDownMesh;
  122819. private _pickedUpMesh;
  122820. private _pointerX;
  122821. private _pointerY;
  122822. private _unTranslatedPointerX;
  122823. private _unTranslatedPointerY;
  122824. private _startingPointerPosition;
  122825. private _previousStartingPointerPosition;
  122826. private _startingPointerTime;
  122827. private _previousStartingPointerTime;
  122828. private _pointerCaptures;
  122829. private _meshUnderPointerId;
  122830. private _onKeyDown;
  122831. private _onKeyUp;
  122832. private _keyboardIsAttached;
  122833. private _onCanvasFocusObserver;
  122834. private _onCanvasBlurObserver;
  122835. private _scene;
  122836. /**
  122837. * Creates a new InputManager
  122838. * @param scene defines the hosting scene
  122839. */
  122840. constructor(scene: Scene);
  122841. /**
  122842. * Gets the mesh that is currently under the pointer
  122843. */
  122844. get meshUnderPointer(): Nullable<AbstractMesh>;
  122845. /**
  122846. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122847. * @param pointerId the pointer id to use
  122848. * @returns The mesh under this pointer id or null if not found
  122849. */
  122850. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122851. /**
  122852. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122853. */
  122854. get unTranslatedPointer(): Vector2;
  122855. /**
  122856. * Gets or sets the current on-screen X position of the pointer
  122857. */
  122858. get pointerX(): number;
  122859. set pointerX(value: number);
  122860. /**
  122861. * Gets or sets the current on-screen Y position of the pointer
  122862. */
  122863. get pointerY(): number;
  122864. set pointerY(value: number);
  122865. private _updatePointerPosition;
  122866. private _processPointerMove;
  122867. private _setRayOnPointerInfo;
  122868. private _checkPrePointerObservable;
  122869. /**
  122870. * Use this method to simulate a pointer move on a mesh
  122871. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122872. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122873. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122874. */
  122875. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122876. /**
  122877. * Use this method to simulate a pointer down on a mesh
  122878. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122879. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122880. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122881. */
  122882. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122883. private _processPointerDown;
  122884. /** @hidden */
  122885. _isPointerSwiping(): boolean;
  122886. /**
  122887. * Use this method to simulate a pointer up on a mesh
  122888. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122889. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122890. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122891. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122892. */
  122893. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122894. private _processPointerUp;
  122895. /**
  122896. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122897. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122898. * @returns true if the pointer was captured
  122899. */
  122900. isPointerCaptured(pointerId?: number): boolean;
  122901. /**
  122902. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122903. * @param attachUp defines if you want to attach events to pointerup
  122904. * @param attachDown defines if you want to attach events to pointerdown
  122905. * @param attachMove defines if you want to attach events to pointermove
  122906. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122907. */
  122908. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122909. /**
  122910. * Detaches all event handlers
  122911. */
  122912. detachControl(): void;
  122913. /**
  122914. * Force the value of meshUnderPointer
  122915. * @param mesh defines the mesh to use
  122916. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122917. */
  122918. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122919. /**
  122920. * Gets the mesh under the pointer
  122921. * @returns a Mesh or null if no mesh is under the pointer
  122922. */
  122923. getPointerOverMesh(): Nullable<AbstractMesh>;
  122924. }
  122925. }
  122926. declare module BABYLON {
  122927. /**
  122928. * This class defines the direct association between an animation and a target
  122929. */
  122930. export class TargetedAnimation {
  122931. /**
  122932. * Animation to perform
  122933. */
  122934. animation: Animation;
  122935. /**
  122936. * Target to animate
  122937. */
  122938. target: any;
  122939. /**
  122940. * Returns the string "TargetedAnimation"
  122941. * @returns "TargetedAnimation"
  122942. */
  122943. getClassName(): string;
  122944. /**
  122945. * Serialize the object
  122946. * @returns the JSON object representing the current entity
  122947. */
  122948. serialize(): any;
  122949. }
  122950. /**
  122951. * Use this class to create coordinated animations on multiple targets
  122952. */
  122953. export class AnimationGroup implements IDisposable {
  122954. /** The name of the animation group */
  122955. name: string;
  122956. private _scene;
  122957. private _targetedAnimations;
  122958. private _animatables;
  122959. private _from;
  122960. private _to;
  122961. private _isStarted;
  122962. private _isPaused;
  122963. private _speedRatio;
  122964. private _loopAnimation;
  122965. private _isAdditive;
  122966. /**
  122967. * Gets or sets the unique id of the node
  122968. */
  122969. uniqueId: number;
  122970. /**
  122971. * This observable will notify when one animation have ended
  122972. */
  122973. onAnimationEndObservable: Observable<TargetedAnimation>;
  122974. /**
  122975. * Observer raised when one animation loops
  122976. */
  122977. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122978. /**
  122979. * Observer raised when all animations have looped
  122980. */
  122981. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122982. /**
  122983. * This observable will notify when all animations have ended.
  122984. */
  122985. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122986. /**
  122987. * This observable will notify when all animations have paused.
  122988. */
  122989. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122990. /**
  122991. * This observable will notify when all animations are playing.
  122992. */
  122993. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122994. /**
  122995. * Gets the first frame
  122996. */
  122997. get from(): number;
  122998. /**
  122999. * Gets the last frame
  123000. */
  123001. get to(): number;
  123002. /**
  123003. * Define if the animations are started
  123004. */
  123005. get isStarted(): boolean;
  123006. /**
  123007. * Gets a value indicating that the current group is playing
  123008. */
  123009. get isPlaying(): boolean;
  123010. /**
  123011. * Gets or sets the speed ratio to use for all animations
  123012. */
  123013. get speedRatio(): number;
  123014. /**
  123015. * Gets or sets the speed ratio to use for all animations
  123016. */
  123017. set speedRatio(value: number);
  123018. /**
  123019. * Gets or sets if all animations should loop or not
  123020. */
  123021. get loopAnimation(): boolean;
  123022. set loopAnimation(value: boolean);
  123023. /**
  123024. * Gets or sets if all animations should be evaluated additively
  123025. */
  123026. get isAdditive(): boolean;
  123027. set isAdditive(value: boolean);
  123028. /**
  123029. * Gets the targeted animations for this animation group
  123030. */
  123031. get targetedAnimations(): Array<TargetedAnimation>;
  123032. /**
  123033. * returning the list of animatables controlled by this animation group.
  123034. */
  123035. get animatables(): Array<Animatable>;
  123036. /**
  123037. * Gets the list of target animations
  123038. */
  123039. get children(): TargetedAnimation[];
  123040. /**
  123041. * Instantiates a new Animation Group.
  123042. * This helps managing several animations at once.
  123043. * @see https://doc.babylonjs.com/how_to/group
  123044. * @param name Defines the name of the group
  123045. * @param scene Defines the scene the group belongs to
  123046. */
  123047. constructor(
  123048. /** The name of the animation group */
  123049. name: string, scene?: Nullable<Scene>);
  123050. /**
  123051. * Add an animation (with its target) in the group
  123052. * @param animation defines the animation we want to add
  123053. * @param target defines the target of the animation
  123054. * @returns the TargetedAnimation object
  123055. */
  123056. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123057. /**
  123058. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123059. * It can add constant keys at begin or end
  123060. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123061. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123062. * @returns the animation group
  123063. */
  123064. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123065. private _animationLoopCount;
  123066. private _animationLoopFlags;
  123067. private _processLoop;
  123068. /**
  123069. * Start all animations on given targets
  123070. * @param loop defines if animations must loop
  123071. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123072. * @param from defines the from key (optional)
  123073. * @param to defines the to key (optional)
  123074. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123075. * @returns the current animation group
  123076. */
  123077. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123078. /**
  123079. * Pause all animations
  123080. * @returns the animation group
  123081. */
  123082. pause(): AnimationGroup;
  123083. /**
  123084. * Play all animations to initial state
  123085. * This function will start() the animations if they were not started or will restart() them if they were paused
  123086. * @param loop defines if animations must loop
  123087. * @returns the animation group
  123088. */
  123089. play(loop?: boolean): AnimationGroup;
  123090. /**
  123091. * Reset all animations to initial state
  123092. * @returns the animation group
  123093. */
  123094. reset(): AnimationGroup;
  123095. /**
  123096. * Restart animations from key 0
  123097. * @returns the animation group
  123098. */
  123099. restart(): AnimationGroup;
  123100. /**
  123101. * Stop all animations
  123102. * @returns the animation group
  123103. */
  123104. stop(): AnimationGroup;
  123105. /**
  123106. * Set animation weight for all animatables
  123107. * @param weight defines the weight to use
  123108. * @return the animationGroup
  123109. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123110. */
  123111. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123112. /**
  123113. * Synchronize and normalize all animatables with a source animatable
  123114. * @param root defines the root animatable to synchronize with
  123115. * @return the animationGroup
  123116. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123117. */
  123118. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123119. /**
  123120. * Goes to a specific frame in this animation group
  123121. * @param frame the frame number to go to
  123122. * @return the animationGroup
  123123. */
  123124. goToFrame(frame: number): AnimationGroup;
  123125. /**
  123126. * Dispose all associated resources
  123127. */
  123128. dispose(): void;
  123129. private _checkAnimationGroupEnded;
  123130. /**
  123131. * Clone the current animation group and returns a copy
  123132. * @param newName defines the name of the new group
  123133. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123134. * @returns the new aniamtion group
  123135. */
  123136. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123137. /**
  123138. * Serializes the animationGroup to an object
  123139. * @returns Serialized object
  123140. */
  123141. serialize(): any;
  123142. /**
  123143. * Returns a new AnimationGroup object parsed from the source provided.
  123144. * @param parsedAnimationGroup defines the source
  123145. * @param scene defines the scene that will receive the animationGroup
  123146. * @returns a new AnimationGroup
  123147. */
  123148. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123149. /**
  123150. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123151. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123152. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123153. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123154. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123155. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123156. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123157. */
  123158. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123159. /**
  123160. * Returns the string "AnimationGroup"
  123161. * @returns "AnimationGroup"
  123162. */
  123163. getClassName(): string;
  123164. /**
  123165. * Creates a detailled string about the object
  123166. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123167. * @returns a string representing the object
  123168. */
  123169. toString(fullDetails?: boolean): string;
  123170. }
  123171. }
  123172. declare module BABYLON {
  123173. /**
  123174. * Define an interface for all classes that will hold resources
  123175. */
  123176. export interface IDisposable {
  123177. /**
  123178. * Releases all held resources
  123179. */
  123180. dispose(): void;
  123181. }
  123182. /** Interface defining initialization parameters for Scene class */
  123183. export interface SceneOptions {
  123184. /**
  123185. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123186. * It will improve performance when the number of geometries becomes important.
  123187. */
  123188. useGeometryUniqueIdsMap?: boolean;
  123189. /**
  123190. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123191. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123192. */
  123193. useMaterialMeshMap?: boolean;
  123194. /**
  123195. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123196. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123197. */
  123198. useClonedMeshMap?: boolean;
  123199. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123200. virtual?: boolean;
  123201. }
  123202. /**
  123203. * Represents a scene to be rendered by the engine.
  123204. * @see https://doc.babylonjs.com/features/scene
  123205. */
  123206. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123207. /** The fog is deactivated */
  123208. static readonly FOGMODE_NONE: number;
  123209. /** The fog density is following an exponential function */
  123210. static readonly FOGMODE_EXP: number;
  123211. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123212. static readonly FOGMODE_EXP2: number;
  123213. /** The fog density is following a linear function. */
  123214. static readonly FOGMODE_LINEAR: number;
  123215. /**
  123216. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123217. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123218. */
  123219. static MinDeltaTime: number;
  123220. /**
  123221. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123222. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123223. */
  123224. static MaxDeltaTime: number;
  123225. /**
  123226. * Factory used to create the default material.
  123227. * @param name The name of the material to create
  123228. * @param scene The scene to create the material for
  123229. * @returns The default material
  123230. */
  123231. static DefaultMaterialFactory(scene: Scene): Material;
  123232. /**
  123233. * Factory used to create the a collision coordinator.
  123234. * @returns The collision coordinator
  123235. */
  123236. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123237. /** @hidden */
  123238. _inputManager: InputManager;
  123239. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123240. cameraToUseForPointers: Nullable<Camera>;
  123241. /** @hidden */
  123242. readonly _isScene: boolean;
  123243. /** @hidden */
  123244. _blockEntityCollection: boolean;
  123245. /**
  123246. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123247. */
  123248. autoClear: boolean;
  123249. /**
  123250. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123251. */
  123252. autoClearDepthAndStencil: boolean;
  123253. /**
  123254. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123255. */
  123256. clearColor: Color4;
  123257. /**
  123258. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123259. */
  123260. ambientColor: Color3;
  123261. /**
  123262. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123263. * It should only be one of the following (if not the default embedded one):
  123264. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123265. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123266. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123267. * The material properties need to be setup according to the type of texture in use.
  123268. */
  123269. environmentBRDFTexture: BaseTexture;
  123270. /**
  123271. * Texture used in all pbr material as the reflection texture.
  123272. * As in the majority of the scene they are the same (exception for multi room and so on),
  123273. * this is easier to reference from here than from all the materials.
  123274. */
  123275. get environmentTexture(): Nullable<BaseTexture>;
  123276. /**
  123277. * Texture used in all pbr material as the reflection texture.
  123278. * As in the majority of the scene they are the same (exception for multi room and so on),
  123279. * this is easier to set here than in all the materials.
  123280. */
  123281. set environmentTexture(value: Nullable<BaseTexture>);
  123282. /** @hidden */
  123283. protected _environmentIntensity: number;
  123284. /**
  123285. * Intensity of the environment in all pbr material.
  123286. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123287. * As in the majority of the scene they are the same (exception for multi room and so on),
  123288. * this is easier to reference from here than from all the materials.
  123289. */
  123290. get environmentIntensity(): number;
  123291. /**
  123292. * Intensity of the environment in all pbr material.
  123293. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123294. * As in the majority of the scene they are the same (exception for multi room and so on),
  123295. * this is easier to set here than in all the materials.
  123296. */
  123297. set environmentIntensity(value: number);
  123298. /** @hidden */
  123299. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123300. /**
  123301. * Default image processing configuration used either in the rendering
  123302. * Forward main pass or through the imageProcessingPostProcess if present.
  123303. * As in the majority of the scene they are the same (exception for multi camera),
  123304. * this is easier to reference from here than from all the materials and post process.
  123305. *
  123306. * No setter as we it is a shared configuration, you can set the values instead.
  123307. */
  123308. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123309. private _forceWireframe;
  123310. /**
  123311. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123312. */
  123313. set forceWireframe(value: boolean);
  123314. get forceWireframe(): boolean;
  123315. private _skipFrustumClipping;
  123316. /**
  123317. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123318. */
  123319. set skipFrustumClipping(value: boolean);
  123320. get skipFrustumClipping(): boolean;
  123321. private _forcePointsCloud;
  123322. /**
  123323. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123324. */
  123325. set forcePointsCloud(value: boolean);
  123326. get forcePointsCloud(): boolean;
  123327. /**
  123328. * Gets or sets the active clipplane 1
  123329. */
  123330. clipPlane: Nullable<Plane>;
  123331. /**
  123332. * Gets or sets the active clipplane 2
  123333. */
  123334. clipPlane2: Nullable<Plane>;
  123335. /**
  123336. * Gets or sets the active clipplane 3
  123337. */
  123338. clipPlane3: Nullable<Plane>;
  123339. /**
  123340. * Gets or sets the active clipplane 4
  123341. */
  123342. clipPlane4: Nullable<Plane>;
  123343. /**
  123344. * Gets or sets the active clipplane 5
  123345. */
  123346. clipPlane5: Nullable<Plane>;
  123347. /**
  123348. * Gets or sets the active clipplane 6
  123349. */
  123350. clipPlane6: Nullable<Plane>;
  123351. /**
  123352. * Gets or sets a boolean indicating if animations are enabled
  123353. */
  123354. animationsEnabled: boolean;
  123355. private _animationPropertiesOverride;
  123356. /**
  123357. * Gets or sets the animation properties override
  123358. */
  123359. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123360. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123361. /**
  123362. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123363. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123364. */
  123365. useConstantAnimationDeltaTime: boolean;
  123366. /**
  123367. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123368. * Please note that it requires to run a ray cast through the scene on every frame
  123369. */
  123370. constantlyUpdateMeshUnderPointer: boolean;
  123371. /**
  123372. * Defines the HTML cursor to use when hovering over interactive elements
  123373. */
  123374. hoverCursor: string;
  123375. /**
  123376. * Defines the HTML default cursor to use (empty by default)
  123377. */
  123378. defaultCursor: string;
  123379. /**
  123380. * Defines whether cursors are handled by the scene.
  123381. */
  123382. doNotHandleCursors: boolean;
  123383. /**
  123384. * This is used to call preventDefault() on pointer down
  123385. * in order to block unwanted artifacts like system double clicks
  123386. */
  123387. preventDefaultOnPointerDown: boolean;
  123388. /**
  123389. * This is used to call preventDefault() on pointer up
  123390. * in order to block unwanted artifacts like system double clicks
  123391. */
  123392. preventDefaultOnPointerUp: boolean;
  123393. /**
  123394. * Gets or sets user defined metadata
  123395. */
  123396. metadata: any;
  123397. /**
  123398. * For internal use only. Please do not use.
  123399. */
  123400. reservedDataStore: any;
  123401. /**
  123402. * Gets the name of the plugin used to load this scene (null by default)
  123403. */
  123404. loadingPluginName: string;
  123405. /**
  123406. * Use this array to add regular expressions used to disable offline support for specific urls
  123407. */
  123408. disableOfflineSupportExceptionRules: RegExp[];
  123409. /**
  123410. * An event triggered when the scene is disposed.
  123411. */
  123412. onDisposeObservable: Observable<Scene>;
  123413. private _onDisposeObserver;
  123414. /** Sets a function to be executed when this scene is disposed. */
  123415. set onDispose(callback: () => void);
  123416. /**
  123417. * An event triggered before rendering the scene (right after animations and physics)
  123418. */
  123419. onBeforeRenderObservable: Observable<Scene>;
  123420. private _onBeforeRenderObserver;
  123421. /** Sets a function to be executed before rendering this scene */
  123422. set beforeRender(callback: Nullable<() => void>);
  123423. /**
  123424. * An event triggered after rendering the scene
  123425. */
  123426. onAfterRenderObservable: Observable<Scene>;
  123427. /**
  123428. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123429. */
  123430. onAfterRenderCameraObservable: Observable<Camera>;
  123431. private _onAfterRenderObserver;
  123432. /** Sets a function to be executed after rendering this scene */
  123433. set afterRender(callback: Nullable<() => void>);
  123434. /**
  123435. * An event triggered before animating the scene
  123436. */
  123437. onBeforeAnimationsObservable: Observable<Scene>;
  123438. /**
  123439. * An event triggered after animations processing
  123440. */
  123441. onAfterAnimationsObservable: Observable<Scene>;
  123442. /**
  123443. * An event triggered before draw calls are ready to be sent
  123444. */
  123445. onBeforeDrawPhaseObservable: Observable<Scene>;
  123446. /**
  123447. * An event triggered after draw calls have been sent
  123448. */
  123449. onAfterDrawPhaseObservable: Observable<Scene>;
  123450. /**
  123451. * An event triggered when the scene is ready
  123452. */
  123453. onReadyObservable: Observable<Scene>;
  123454. /**
  123455. * An event triggered before rendering a camera
  123456. */
  123457. onBeforeCameraRenderObservable: Observable<Camera>;
  123458. private _onBeforeCameraRenderObserver;
  123459. /** Sets a function to be executed before rendering a camera*/
  123460. set beforeCameraRender(callback: () => void);
  123461. /**
  123462. * An event triggered after rendering a camera
  123463. */
  123464. onAfterCameraRenderObservable: Observable<Camera>;
  123465. private _onAfterCameraRenderObserver;
  123466. /** Sets a function to be executed after rendering a camera*/
  123467. set afterCameraRender(callback: () => void);
  123468. /**
  123469. * An event triggered when active meshes evaluation is about to start
  123470. */
  123471. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123472. /**
  123473. * An event triggered when active meshes evaluation is done
  123474. */
  123475. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123476. /**
  123477. * An event triggered when particles rendering is about to start
  123478. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123479. */
  123480. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123481. /**
  123482. * An event triggered when particles rendering is done
  123483. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123484. */
  123485. onAfterParticlesRenderingObservable: Observable<Scene>;
  123486. /**
  123487. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123488. */
  123489. onDataLoadedObservable: Observable<Scene>;
  123490. /**
  123491. * An event triggered when a camera is created
  123492. */
  123493. onNewCameraAddedObservable: Observable<Camera>;
  123494. /**
  123495. * An event triggered when a camera is removed
  123496. */
  123497. onCameraRemovedObservable: Observable<Camera>;
  123498. /**
  123499. * An event triggered when a light is created
  123500. */
  123501. onNewLightAddedObservable: Observable<Light>;
  123502. /**
  123503. * An event triggered when a light is removed
  123504. */
  123505. onLightRemovedObservable: Observable<Light>;
  123506. /**
  123507. * An event triggered when a geometry is created
  123508. */
  123509. onNewGeometryAddedObservable: Observable<Geometry>;
  123510. /**
  123511. * An event triggered when a geometry is removed
  123512. */
  123513. onGeometryRemovedObservable: Observable<Geometry>;
  123514. /**
  123515. * An event triggered when a transform node is created
  123516. */
  123517. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123518. /**
  123519. * An event triggered when a transform node is removed
  123520. */
  123521. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123522. /**
  123523. * An event triggered when a mesh is created
  123524. */
  123525. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123526. /**
  123527. * An event triggered when a mesh is removed
  123528. */
  123529. onMeshRemovedObservable: Observable<AbstractMesh>;
  123530. /**
  123531. * An event triggered when a skeleton is created
  123532. */
  123533. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123534. /**
  123535. * An event triggered when a skeleton is removed
  123536. */
  123537. onSkeletonRemovedObservable: Observable<Skeleton>;
  123538. /**
  123539. * An event triggered when a material is created
  123540. */
  123541. onNewMaterialAddedObservable: Observable<Material>;
  123542. /**
  123543. * An event triggered when a material is removed
  123544. */
  123545. onMaterialRemovedObservable: Observable<Material>;
  123546. /**
  123547. * An event triggered when a texture is created
  123548. */
  123549. onNewTextureAddedObservable: Observable<BaseTexture>;
  123550. /**
  123551. * An event triggered when a texture is removed
  123552. */
  123553. onTextureRemovedObservable: Observable<BaseTexture>;
  123554. /**
  123555. * An event triggered when render targets are about to be rendered
  123556. * Can happen multiple times per frame.
  123557. */
  123558. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123559. /**
  123560. * An event triggered when render targets were rendered.
  123561. * Can happen multiple times per frame.
  123562. */
  123563. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123564. /**
  123565. * An event triggered before calculating deterministic simulation step
  123566. */
  123567. onBeforeStepObservable: Observable<Scene>;
  123568. /**
  123569. * An event triggered after calculating deterministic simulation step
  123570. */
  123571. onAfterStepObservable: Observable<Scene>;
  123572. /**
  123573. * An event triggered when the activeCamera property is updated
  123574. */
  123575. onActiveCameraChanged: Observable<Scene>;
  123576. /**
  123577. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123578. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123579. * 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)
  123580. */
  123581. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123582. /**
  123583. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123584. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123585. * 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)
  123586. */
  123587. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123588. /**
  123589. * This Observable will when a mesh has been imported into the scene.
  123590. */
  123591. onMeshImportedObservable: Observable<AbstractMesh>;
  123592. /**
  123593. * This Observable will when an animation file has been imported into the scene.
  123594. */
  123595. onAnimationFileImportedObservable: Observable<Scene>;
  123596. /**
  123597. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123598. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123599. */
  123600. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123601. /** @hidden */
  123602. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123603. /**
  123604. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123605. */
  123606. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123607. /**
  123608. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123609. */
  123610. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123611. /**
  123612. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123613. */
  123614. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123615. /** Callback called when a pointer move is detected */
  123616. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123617. /** Callback called when a pointer down is detected */
  123618. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123619. /** Callback called when a pointer up is detected */
  123620. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123621. /** Callback called when a pointer pick is detected */
  123622. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123623. /**
  123624. * 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).
  123625. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123626. */
  123627. onPrePointerObservable: Observable<PointerInfoPre>;
  123628. /**
  123629. * Observable event triggered each time an input event is received from the rendering canvas
  123630. */
  123631. onPointerObservable: Observable<PointerInfo>;
  123632. /**
  123633. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123634. */
  123635. get unTranslatedPointer(): Vector2;
  123636. /**
  123637. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123638. */
  123639. static get DragMovementThreshold(): number;
  123640. static set DragMovementThreshold(value: number);
  123641. /**
  123642. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123643. */
  123644. static get LongPressDelay(): number;
  123645. static set LongPressDelay(value: number);
  123646. /**
  123647. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123648. */
  123649. static get DoubleClickDelay(): number;
  123650. static set DoubleClickDelay(value: number);
  123651. /** If you need to check double click without raising a single click at first click, enable this flag */
  123652. static get ExclusiveDoubleClickMode(): boolean;
  123653. static set ExclusiveDoubleClickMode(value: boolean);
  123654. /** @hidden */
  123655. _mirroredCameraPosition: Nullable<Vector3>;
  123656. /**
  123657. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123658. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123659. */
  123660. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123661. /**
  123662. * Observable event triggered each time an keyboard event is received from the hosting window
  123663. */
  123664. onKeyboardObservable: Observable<KeyboardInfo>;
  123665. private _useRightHandedSystem;
  123666. /**
  123667. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123668. */
  123669. set useRightHandedSystem(value: boolean);
  123670. get useRightHandedSystem(): boolean;
  123671. private _timeAccumulator;
  123672. private _currentStepId;
  123673. private _currentInternalStep;
  123674. /**
  123675. * Sets the step Id used by deterministic lock step
  123676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123677. * @param newStepId defines the step Id
  123678. */
  123679. setStepId(newStepId: number): void;
  123680. /**
  123681. * Gets the step Id used by deterministic lock step
  123682. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123683. * @returns the step Id
  123684. */
  123685. getStepId(): number;
  123686. /**
  123687. * Gets the internal step used by deterministic lock step
  123688. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123689. * @returns the internal step
  123690. */
  123691. getInternalStep(): number;
  123692. private _fogEnabled;
  123693. /**
  123694. * Gets or sets a boolean indicating if fog is enabled on this scene
  123695. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123696. * (Default is true)
  123697. */
  123698. set fogEnabled(value: boolean);
  123699. get fogEnabled(): boolean;
  123700. private _fogMode;
  123701. /**
  123702. * Gets or sets the fog mode to use
  123703. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123704. * | mode | value |
  123705. * | --- | --- |
  123706. * | FOGMODE_NONE | 0 |
  123707. * | FOGMODE_EXP | 1 |
  123708. * | FOGMODE_EXP2 | 2 |
  123709. * | FOGMODE_LINEAR | 3 |
  123710. */
  123711. set fogMode(value: number);
  123712. get fogMode(): number;
  123713. /**
  123714. * Gets or sets the fog color to use
  123715. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123716. * (Default is Color3(0.2, 0.2, 0.3))
  123717. */
  123718. fogColor: Color3;
  123719. /**
  123720. * Gets or sets the fog density to use
  123721. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123722. * (Default is 0.1)
  123723. */
  123724. fogDensity: number;
  123725. /**
  123726. * Gets or sets the fog start distance to use
  123727. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123728. * (Default is 0)
  123729. */
  123730. fogStart: number;
  123731. /**
  123732. * Gets or sets the fog end distance to use
  123733. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123734. * (Default is 1000)
  123735. */
  123736. fogEnd: number;
  123737. /**
  123738. * Flag indicating that the frame buffer binding is handled by another component
  123739. */
  123740. prePass: boolean;
  123741. private _shadowsEnabled;
  123742. /**
  123743. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123744. */
  123745. set shadowsEnabled(value: boolean);
  123746. get shadowsEnabled(): boolean;
  123747. private _lightsEnabled;
  123748. /**
  123749. * Gets or sets a boolean indicating if lights are enabled on this scene
  123750. */
  123751. set lightsEnabled(value: boolean);
  123752. get lightsEnabled(): boolean;
  123753. /** All of the active cameras added to this scene. */
  123754. activeCameras: Camera[];
  123755. /** @hidden */
  123756. _activeCamera: Nullable<Camera>;
  123757. /** Gets or sets the current active camera */
  123758. get activeCamera(): Nullable<Camera>;
  123759. set activeCamera(value: Nullable<Camera>);
  123760. private _defaultMaterial;
  123761. /** The default material used on meshes when no material is affected */
  123762. get defaultMaterial(): Material;
  123763. /** The default material used on meshes when no material is affected */
  123764. set defaultMaterial(value: Material);
  123765. private _texturesEnabled;
  123766. /**
  123767. * Gets or sets a boolean indicating if textures are enabled on this scene
  123768. */
  123769. set texturesEnabled(value: boolean);
  123770. get texturesEnabled(): boolean;
  123771. /**
  123772. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123773. */
  123774. physicsEnabled: boolean;
  123775. /**
  123776. * Gets or sets a boolean indicating if particles are enabled on this scene
  123777. */
  123778. particlesEnabled: boolean;
  123779. /**
  123780. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123781. */
  123782. spritesEnabled: boolean;
  123783. private _skeletonsEnabled;
  123784. /**
  123785. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123786. */
  123787. set skeletonsEnabled(value: boolean);
  123788. get skeletonsEnabled(): boolean;
  123789. /**
  123790. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123791. */
  123792. lensFlaresEnabled: boolean;
  123793. /**
  123794. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123795. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123796. */
  123797. collisionsEnabled: boolean;
  123798. private _collisionCoordinator;
  123799. /** @hidden */
  123800. get collisionCoordinator(): ICollisionCoordinator;
  123801. /**
  123802. * Defines the gravity applied to this scene (used only for collisions)
  123803. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123804. */
  123805. gravity: Vector3;
  123806. /**
  123807. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123808. */
  123809. postProcessesEnabled: boolean;
  123810. /**
  123811. * Gets the current postprocess manager
  123812. */
  123813. postProcessManager: PostProcessManager;
  123814. /**
  123815. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123816. */
  123817. renderTargetsEnabled: boolean;
  123818. /**
  123819. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123820. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123821. */
  123822. dumpNextRenderTargets: boolean;
  123823. /**
  123824. * The list of user defined render targets added to the scene
  123825. */
  123826. customRenderTargets: RenderTargetTexture[];
  123827. /**
  123828. * Defines if texture loading must be delayed
  123829. * If true, textures will only be loaded when they need to be rendered
  123830. */
  123831. useDelayedTextureLoading: boolean;
  123832. /**
  123833. * Gets the list of meshes imported to the scene through SceneLoader
  123834. */
  123835. importedMeshesFiles: String[];
  123836. /**
  123837. * Gets or sets a boolean indicating if probes are enabled on this scene
  123838. */
  123839. probesEnabled: boolean;
  123840. /**
  123841. * Gets or sets the current offline provider to use to store scene data
  123842. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123843. */
  123844. offlineProvider: IOfflineProvider;
  123845. /**
  123846. * Gets or sets the action manager associated with the scene
  123847. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123848. */
  123849. actionManager: AbstractActionManager;
  123850. private _meshesForIntersections;
  123851. /**
  123852. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123853. */
  123854. proceduralTexturesEnabled: boolean;
  123855. private _engine;
  123856. private _totalVertices;
  123857. /** @hidden */
  123858. _activeIndices: PerfCounter;
  123859. /** @hidden */
  123860. _activeParticles: PerfCounter;
  123861. /** @hidden */
  123862. _activeBones: PerfCounter;
  123863. private _animationRatio;
  123864. /** @hidden */
  123865. _animationTimeLast: number;
  123866. /** @hidden */
  123867. _animationTime: number;
  123868. /**
  123869. * Gets or sets a general scale for animation speed
  123870. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123871. */
  123872. animationTimeScale: number;
  123873. /** @hidden */
  123874. _cachedMaterial: Nullable<Material>;
  123875. /** @hidden */
  123876. _cachedEffect: Nullable<Effect>;
  123877. /** @hidden */
  123878. _cachedVisibility: Nullable<number>;
  123879. private _renderId;
  123880. private _frameId;
  123881. private _executeWhenReadyTimeoutId;
  123882. private _intermediateRendering;
  123883. private _viewUpdateFlag;
  123884. private _projectionUpdateFlag;
  123885. /** @hidden */
  123886. _toBeDisposed: Nullable<IDisposable>[];
  123887. private _activeRequests;
  123888. /** @hidden */
  123889. _pendingData: any[];
  123890. private _isDisposed;
  123891. /**
  123892. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123893. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123894. */
  123895. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123896. private _activeMeshes;
  123897. private _processedMaterials;
  123898. private _renderTargets;
  123899. /** @hidden */
  123900. _activeParticleSystems: SmartArray<IParticleSystem>;
  123901. private _activeSkeletons;
  123902. private _softwareSkinnedMeshes;
  123903. private _renderingManager;
  123904. /** @hidden */
  123905. _activeAnimatables: Animatable[];
  123906. private _transformMatrix;
  123907. private _sceneUbo;
  123908. /** @hidden */
  123909. _viewMatrix: Matrix;
  123910. private _projectionMatrix;
  123911. /** @hidden */
  123912. _forcedViewPosition: Nullable<Vector3>;
  123913. /** @hidden */
  123914. _frustumPlanes: Plane[];
  123915. /**
  123916. * Gets the list of frustum planes (built from the active camera)
  123917. */
  123918. get frustumPlanes(): Plane[];
  123919. /**
  123920. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123921. * This is useful if there are more lights that the maximum simulteanous authorized
  123922. */
  123923. requireLightSorting: boolean;
  123924. /** @hidden */
  123925. readonly useMaterialMeshMap: boolean;
  123926. /** @hidden */
  123927. readonly useClonedMeshMap: boolean;
  123928. private _externalData;
  123929. private _uid;
  123930. /**
  123931. * @hidden
  123932. * Backing store of defined scene components.
  123933. */
  123934. _components: ISceneComponent[];
  123935. /**
  123936. * @hidden
  123937. * Backing store of defined scene components.
  123938. */
  123939. _serializableComponents: ISceneSerializableComponent[];
  123940. /**
  123941. * List of components to register on the next registration step.
  123942. */
  123943. private _transientComponents;
  123944. /**
  123945. * Registers the transient components if needed.
  123946. */
  123947. private _registerTransientComponents;
  123948. /**
  123949. * @hidden
  123950. * Add a component to the scene.
  123951. * Note that the ccomponent could be registered on th next frame if this is called after
  123952. * the register component stage.
  123953. * @param component Defines the component to add to the scene
  123954. */
  123955. _addComponent(component: ISceneComponent): void;
  123956. /**
  123957. * @hidden
  123958. * Gets a component from the scene.
  123959. * @param name defines the name of the component to retrieve
  123960. * @returns the component or null if not present
  123961. */
  123962. _getComponent(name: string): Nullable<ISceneComponent>;
  123963. /**
  123964. * @hidden
  123965. * Defines the actions happening before camera updates.
  123966. */
  123967. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123968. /**
  123969. * @hidden
  123970. * Defines the actions happening before clear the canvas.
  123971. */
  123972. _beforeClearStage: Stage<SimpleStageAction>;
  123973. /**
  123974. * @hidden
  123975. * Defines the actions when collecting render targets for the frame.
  123976. */
  123977. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123978. /**
  123979. * @hidden
  123980. * Defines the actions happening for one camera in the frame.
  123981. */
  123982. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123983. /**
  123984. * @hidden
  123985. * Defines the actions happening during the per mesh ready checks.
  123986. */
  123987. _isReadyForMeshStage: Stage<MeshStageAction>;
  123988. /**
  123989. * @hidden
  123990. * Defines the actions happening before evaluate active mesh checks.
  123991. */
  123992. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123993. /**
  123994. * @hidden
  123995. * Defines the actions happening during the evaluate sub mesh checks.
  123996. */
  123997. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123998. /**
  123999. * @hidden
  124000. * Defines the actions happening during the active mesh stage.
  124001. */
  124002. _activeMeshStage: Stage<ActiveMeshStageAction>;
  124003. /**
  124004. * @hidden
  124005. * Defines the actions happening during the per camera render target step.
  124006. */
  124007. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  124008. /**
  124009. * @hidden
  124010. * Defines the actions happening just before the active camera is drawing.
  124011. */
  124012. _beforeCameraDrawStage: Stage<CameraStageAction>;
  124013. /**
  124014. * @hidden
  124015. * Defines the actions happening just before a render target is drawing.
  124016. */
  124017. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124018. /**
  124019. * @hidden
  124020. * Defines the actions happening just before a rendering group is drawing.
  124021. */
  124022. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124023. /**
  124024. * @hidden
  124025. * Defines the actions happening just before a mesh is drawing.
  124026. */
  124027. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124028. /**
  124029. * @hidden
  124030. * Defines the actions happening just after a mesh has been drawn.
  124031. */
  124032. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124033. /**
  124034. * @hidden
  124035. * Defines the actions happening just after a rendering group has been drawn.
  124036. */
  124037. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124038. /**
  124039. * @hidden
  124040. * Defines the actions happening just after the active camera has been drawn.
  124041. */
  124042. _afterCameraDrawStage: Stage<CameraStageAction>;
  124043. /**
  124044. * @hidden
  124045. * Defines the actions happening just after a render target has been drawn.
  124046. */
  124047. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124048. /**
  124049. * @hidden
  124050. * Defines the actions happening just after rendering all cameras and computing intersections.
  124051. */
  124052. _afterRenderStage: Stage<SimpleStageAction>;
  124053. /**
  124054. * @hidden
  124055. * Defines the actions happening when a pointer move event happens.
  124056. */
  124057. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124058. /**
  124059. * @hidden
  124060. * Defines the actions happening when a pointer down event happens.
  124061. */
  124062. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124063. /**
  124064. * @hidden
  124065. * Defines the actions happening when a pointer up event happens.
  124066. */
  124067. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124068. /**
  124069. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124070. */
  124071. private geometriesByUniqueId;
  124072. /**
  124073. * Creates a new Scene
  124074. * @param engine defines the engine to use to render this scene
  124075. * @param options defines the scene options
  124076. */
  124077. constructor(engine: Engine, options?: SceneOptions);
  124078. /**
  124079. * Gets a string identifying the name of the class
  124080. * @returns "Scene" string
  124081. */
  124082. getClassName(): string;
  124083. private _defaultMeshCandidates;
  124084. /**
  124085. * @hidden
  124086. */
  124087. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124088. private _defaultSubMeshCandidates;
  124089. /**
  124090. * @hidden
  124091. */
  124092. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124093. /**
  124094. * Sets the default candidate providers for the scene.
  124095. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124096. * and getCollidingSubMeshCandidates to their default function
  124097. */
  124098. setDefaultCandidateProviders(): void;
  124099. /**
  124100. * Gets the mesh that is currently under the pointer
  124101. */
  124102. get meshUnderPointer(): Nullable<AbstractMesh>;
  124103. /**
  124104. * Gets or sets the current on-screen X position of the pointer
  124105. */
  124106. get pointerX(): number;
  124107. set pointerX(value: number);
  124108. /**
  124109. * Gets or sets the current on-screen Y position of the pointer
  124110. */
  124111. get pointerY(): number;
  124112. set pointerY(value: number);
  124113. /**
  124114. * Gets the cached material (ie. the latest rendered one)
  124115. * @returns the cached material
  124116. */
  124117. getCachedMaterial(): Nullable<Material>;
  124118. /**
  124119. * Gets the cached effect (ie. the latest rendered one)
  124120. * @returns the cached effect
  124121. */
  124122. getCachedEffect(): Nullable<Effect>;
  124123. /**
  124124. * Gets the cached visibility state (ie. the latest rendered one)
  124125. * @returns the cached visibility state
  124126. */
  124127. getCachedVisibility(): Nullable<number>;
  124128. /**
  124129. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124130. * @param material defines the current material
  124131. * @param effect defines the current effect
  124132. * @param visibility defines the current visibility state
  124133. * @returns true if one parameter is not cached
  124134. */
  124135. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124136. /**
  124137. * Gets the engine associated with the scene
  124138. * @returns an Engine
  124139. */
  124140. getEngine(): Engine;
  124141. /**
  124142. * Gets the total number of vertices rendered per frame
  124143. * @returns the total number of vertices rendered per frame
  124144. */
  124145. getTotalVertices(): number;
  124146. /**
  124147. * Gets the performance counter for total vertices
  124148. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124149. */
  124150. get totalVerticesPerfCounter(): PerfCounter;
  124151. /**
  124152. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124153. * @returns the total number of active indices rendered per frame
  124154. */
  124155. getActiveIndices(): number;
  124156. /**
  124157. * Gets the performance counter for active indices
  124158. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124159. */
  124160. get totalActiveIndicesPerfCounter(): PerfCounter;
  124161. /**
  124162. * Gets the total number of active particles rendered per frame
  124163. * @returns the total number of active particles rendered per frame
  124164. */
  124165. getActiveParticles(): number;
  124166. /**
  124167. * Gets the performance counter for active particles
  124168. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124169. */
  124170. get activeParticlesPerfCounter(): PerfCounter;
  124171. /**
  124172. * Gets the total number of active bones rendered per frame
  124173. * @returns the total number of active bones rendered per frame
  124174. */
  124175. getActiveBones(): number;
  124176. /**
  124177. * Gets the performance counter for active bones
  124178. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124179. */
  124180. get activeBonesPerfCounter(): PerfCounter;
  124181. /**
  124182. * Gets the array of active meshes
  124183. * @returns an array of AbstractMesh
  124184. */
  124185. getActiveMeshes(): SmartArray<AbstractMesh>;
  124186. /**
  124187. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124188. * @returns a number
  124189. */
  124190. getAnimationRatio(): number;
  124191. /**
  124192. * Gets an unique Id for the current render phase
  124193. * @returns a number
  124194. */
  124195. getRenderId(): number;
  124196. /**
  124197. * Gets an unique Id for the current frame
  124198. * @returns a number
  124199. */
  124200. getFrameId(): number;
  124201. /** Call this function if you want to manually increment the render Id*/
  124202. incrementRenderId(): void;
  124203. private _createUbo;
  124204. /**
  124205. * Use this method to simulate a pointer move on a mesh
  124206. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124207. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124208. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124209. * @returns the current scene
  124210. */
  124211. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124212. /**
  124213. * Use this method to simulate a pointer down on a mesh
  124214. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124215. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124216. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124217. * @returns the current scene
  124218. */
  124219. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124220. /**
  124221. * Use this method to simulate a pointer up on a mesh
  124222. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124223. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124224. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124225. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124226. * @returns the current scene
  124227. */
  124228. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124229. /**
  124230. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124231. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124232. * @returns true if the pointer was captured
  124233. */
  124234. isPointerCaptured(pointerId?: number): boolean;
  124235. /**
  124236. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124237. * @param attachUp defines if you want to attach events to pointerup
  124238. * @param attachDown defines if you want to attach events to pointerdown
  124239. * @param attachMove defines if you want to attach events to pointermove
  124240. */
  124241. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124242. /** Detaches all event handlers*/
  124243. detachControl(): void;
  124244. /**
  124245. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124246. * Delay loaded resources are not taking in account
  124247. * @return true if all required resources are ready
  124248. */
  124249. isReady(): boolean;
  124250. /** Resets all cached information relative to material (including effect and visibility) */
  124251. resetCachedMaterial(): void;
  124252. /**
  124253. * Registers a function to be called before every frame render
  124254. * @param func defines the function to register
  124255. */
  124256. registerBeforeRender(func: () => void): void;
  124257. /**
  124258. * Unregisters a function called before every frame render
  124259. * @param func defines the function to unregister
  124260. */
  124261. unregisterBeforeRender(func: () => void): void;
  124262. /**
  124263. * Registers a function to be called after every frame render
  124264. * @param func defines the function to register
  124265. */
  124266. registerAfterRender(func: () => void): void;
  124267. /**
  124268. * Unregisters a function called after every frame render
  124269. * @param func defines the function to unregister
  124270. */
  124271. unregisterAfterRender(func: () => void): void;
  124272. private _executeOnceBeforeRender;
  124273. /**
  124274. * The provided function will run before render once and will be disposed afterwards.
  124275. * A timeout delay can be provided so that the function will be executed in N ms.
  124276. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124277. * @param func The function to be executed.
  124278. * @param timeout optional delay in ms
  124279. */
  124280. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124281. /** @hidden */
  124282. _addPendingData(data: any): void;
  124283. /** @hidden */
  124284. _removePendingData(data: any): void;
  124285. /**
  124286. * Returns the number of items waiting to be loaded
  124287. * @returns the number of items waiting to be loaded
  124288. */
  124289. getWaitingItemsCount(): number;
  124290. /**
  124291. * Returns a boolean indicating if the scene is still loading data
  124292. */
  124293. get isLoading(): boolean;
  124294. /**
  124295. * Registers a function to be executed when the scene is ready
  124296. * @param {Function} func - the function to be executed
  124297. */
  124298. executeWhenReady(func: () => void): void;
  124299. /**
  124300. * Returns a promise that resolves when the scene is ready
  124301. * @returns A promise that resolves when the scene is ready
  124302. */
  124303. whenReadyAsync(): Promise<void>;
  124304. /** @hidden */
  124305. _checkIsReady(): void;
  124306. /**
  124307. * Gets all animatable attached to the scene
  124308. */
  124309. get animatables(): Animatable[];
  124310. /**
  124311. * Resets the last animation time frame.
  124312. * Useful to override when animations start running when loading a scene for the first time.
  124313. */
  124314. resetLastAnimationTimeFrame(): void;
  124315. /**
  124316. * Gets the current view matrix
  124317. * @returns a Matrix
  124318. */
  124319. getViewMatrix(): Matrix;
  124320. /**
  124321. * Gets the current projection matrix
  124322. * @returns a Matrix
  124323. */
  124324. getProjectionMatrix(): Matrix;
  124325. /**
  124326. * Gets the current transform matrix
  124327. * @returns a Matrix made of View * Projection
  124328. */
  124329. getTransformMatrix(): Matrix;
  124330. /**
  124331. * Sets the current transform matrix
  124332. * @param viewL defines the View matrix to use
  124333. * @param projectionL defines the Projection matrix to use
  124334. * @param viewR defines the right View matrix to use (if provided)
  124335. * @param projectionR defines the right Projection matrix to use (if provided)
  124336. */
  124337. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124338. /**
  124339. * Gets the uniform buffer used to store scene data
  124340. * @returns a UniformBuffer
  124341. */
  124342. getSceneUniformBuffer(): UniformBuffer;
  124343. /**
  124344. * Gets an unique (relatively to the current scene) Id
  124345. * @returns an unique number for the scene
  124346. */
  124347. getUniqueId(): number;
  124348. /**
  124349. * Add a mesh to the list of scene's meshes
  124350. * @param newMesh defines the mesh to add
  124351. * @param recursive if all child meshes should also be added to the scene
  124352. */
  124353. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124354. /**
  124355. * Remove a mesh for the list of scene's meshes
  124356. * @param toRemove defines the mesh to remove
  124357. * @param recursive if all child meshes should also be removed from the scene
  124358. * @returns the index where the mesh was in the mesh list
  124359. */
  124360. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124361. /**
  124362. * Add a transform node to the list of scene's transform nodes
  124363. * @param newTransformNode defines the transform node to add
  124364. */
  124365. addTransformNode(newTransformNode: TransformNode): void;
  124366. /**
  124367. * Remove a transform node for the list of scene's transform nodes
  124368. * @param toRemove defines the transform node to remove
  124369. * @returns the index where the transform node was in the transform node list
  124370. */
  124371. removeTransformNode(toRemove: TransformNode): number;
  124372. /**
  124373. * Remove a skeleton for the list of scene's skeletons
  124374. * @param toRemove defines the skeleton to remove
  124375. * @returns the index where the skeleton was in the skeleton list
  124376. */
  124377. removeSkeleton(toRemove: Skeleton): number;
  124378. /**
  124379. * Remove a morph target for the list of scene's morph targets
  124380. * @param toRemove defines the morph target to remove
  124381. * @returns the index where the morph target was in the morph target list
  124382. */
  124383. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124384. /**
  124385. * Remove a light for the list of scene's lights
  124386. * @param toRemove defines the light to remove
  124387. * @returns the index where the light was in the light list
  124388. */
  124389. removeLight(toRemove: Light): number;
  124390. /**
  124391. * Remove a camera for the list of scene's cameras
  124392. * @param toRemove defines the camera to remove
  124393. * @returns the index where the camera was in the camera list
  124394. */
  124395. removeCamera(toRemove: Camera): number;
  124396. /**
  124397. * Remove a particle system for the list of scene's particle systems
  124398. * @param toRemove defines the particle system to remove
  124399. * @returns the index where the particle system was in the particle system list
  124400. */
  124401. removeParticleSystem(toRemove: IParticleSystem): number;
  124402. /**
  124403. * Remove a animation for the list of scene's animations
  124404. * @param toRemove defines the animation to remove
  124405. * @returns the index where the animation was in the animation list
  124406. */
  124407. removeAnimation(toRemove: Animation): number;
  124408. /**
  124409. * Will stop the animation of the given target
  124410. * @param target - the target
  124411. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124412. * @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)
  124413. */
  124414. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124415. /**
  124416. * Removes the given animation group from this scene.
  124417. * @param toRemove The animation group to remove
  124418. * @returns The index of the removed animation group
  124419. */
  124420. removeAnimationGroup(toRemove: AnimationGroup): number;
  124421. /**
  124422. * Removes the given multi-material from this scene.
  124423. * @param toRemove The multi-material to remove
  124424. * @returns The index of the removed multi-material
  124425. */
  124426. removeMultiMaterial(toRemove: MultiMaterial): number;
  124427. /**
  124428. * Removes the given material from this scene.
  124429. * @param toRemove The material to remove
  124430. * @returns The index of the removed material
  124431. */
  124432. removeMaterial(toRemove: Material): number;
  124433. /**
  124434. * Removes the given action manager from this scene.
  124435. * @param toRemove The action manager to remove
  124436. * @returns The index of the removed action manager
  124437. */
  124438. removeActionManager(toRemove: AbstractActionManager): number;
  124439. /**
  124440. * Removes the given texture from this scene.
  124441. * @param toRemove The texture to remove
  124442. * @returns The index of the removed texture
  124443. */
  124444. removeTexture(toRemove: BaseTexture): number;
  124445. /**
  124446. * Adds the given light to this scene
  124447. * @param newLight The light to add
  124448. */
  124449. addLight(newLight: Light): void;
  124450. /**
  124451. * Sorts the list list based on light priorities
  124452. */
  124453. sortLightsByPriority(): void;
  124454. /**
  124455. * Adds the given camera to this scene
  124456. * @param newCamera The camera to add
  124457. */
  124458. addCamera(newCamera: Camera): void;
  124459. /**
  124460. * Adds the given skeleton to this scene
  124461. * @param newSkeleton The skeleton to add
  124462. */
  124463. addSkeleton(newSkeleton: Skeleton): void;
  124464. /**
  124465. * Adds the given particle system to this scene
  124466. * @param newParticleSystem The particle system to add
  124467. */
  124468. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124469. /**
  124470. * Adds the given animation to this scene
  124471. * @param newAnimation The animation to add
  124472. */
  124473. addAnimation(newAnimation: Animation): void;
  124474. /**
  124475. * Adds the given animation group to this scene.
  124476. * @param newAnimationGroup The animation group to add
  124477. */
  124478. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124479. /**
  124480. * Adds the given multi-material to this scene
  124481. * @param newMultiMaterial The multi-material to add
  124482. */
  124483. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124484. /**
  124485. * Adds the given material to this scene
  124486. * @param newMaterial The material to add
  124487. */
  124488. addMaterial(newMaterial: Material): void;
  124489. /**
  124490. * Adds the given morph target to this scene
  124491. * @param newMorphTargetManager The morph target to add
  124492. */
  124493. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124494. /**
  124495. * Adds the given geometry to this scene
  124496. * @param newGeometry The geometry to add
  124497. */
  124498. addGeometry(newGeometry: Geometry): void;
  124499. /**
  124500. * Adds the given action manager to this scene
  124501. * @param newActionManager The action manager to add
  124502. */
  124503. addActionManager(newActionManager: AbstractActionManager): void;
  124504. /**
  124505. * Adds the given texture to this scene.
  124506. * @param newTexture The texture to add
  124507. */
  124508. addTexture(newTexture: BaseTexture): void;
  124509. /**
  124510. * Switch active camera
  124511. * @param newCamera defines the new active camera
  124512. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124513. */
  124514. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124515. /**
  124516. * sets the active camera of the scene using its ID
  124517. * @param id defines the camera's ID
  124518. * @return the new active camera or null if none found.
  124519. */
  124520. setActiveCameraByID(id: string): Nullable<Camera>;
  124521. /**
  124522. * sets the active camera of the scene using its name
  124523. * @param name defines the camera's name
  124524. * @returns the new active camera or null if none found.
  124525. */
  124526. setActiveCameraByName(name: string): Nullable<Camera>;
  124527. /**
  124528. * get an animation group using its name
  124529. * @param name defines the material's name
  124530. * @return the animation group or null if none found.
  124531. */
  124532. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124533. /**
  124534. * Get a material using its unique id
  124535. * @param uniqueId defines the material's unique id
  124536. * @return the material or null if none found.
  124537. */
  124538. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124539. /**
  124540. * get a material using its id
  124541. * @param id defines the material's ID
  124542. * @return the material or null if none found.
  124543. */
  124544. getMaterialByID(id: string): Nullable<Material>;
  124545. /**
  124546. * Gets a the last added material using a given id
  124547. * @param id defines the material's ID
  124548. * @return the last material with the given id or null if none found.
  124549. */
  124550. getLastMaterialByID(id: string): Nullable<Material>;
  124551. /**
  124552. * Gets a material using its name
  124553. * @param name defines the material's name
  124554. * @return the material or null if none found.
  124555. */
  124556. getMaterialByName(name: string): Nullable<Material>;
  124557. /**
  124558. * Get a texture using its unique id
  124559. * @param uniqueId defines the texture's unique id
  124560. * @return the texture or null if none found.
  124561. */
  124562. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124563. /**
  124564. * Gets a camera using its id
  124565. * @param id defines the id to look for
  124566. * @returns the camera or null if not found
  124567. */
  124568. getCameraByID(id: string): Nullable<Camera>;
  124569. /**
  124570. * Gets a camera using its unique id
  124571. * @param uniqueId defines the unique id to look for
  124572. * @returns the camera or null if not found
  124573. */
  124574. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124575. /**
  124576. * Gets a camera using its name
  124577. * @param name defines the camera's name
  124578. * @return the camera or null if none found.
  124579. */
  124580. getCameraByName(name: string): Nullable<Camera>;
  124581. /**
  124582. * Gets a bone using its id
  124583. * @param id defines the bone's id
  124584. * @return the bone or null if not found
  124585. */
  124586. getBoneByID(id: string): Nullable<Bone>;
  124587. /**
  124588. * Gets a bone using its id
  124589. * @param name defines the bone's name
  124590. * @return the bone or null if not found
  124591. */
  124592. getBoneByName(name: string): Nullable<Bone>;
  124593. /**
  124594. * Gets a light node using its name
  124595. * @param name defines the the light's name
  124596. * @return the light or null if none found.
  124597. */
  124598. getLightByName(name: string): Nullable<Light>;
  124599. /**
  124600. * Gets a light node using its id
  124601. * @param id defines the light's id
  124602. * @return the light or null if none found.
  124603. */
  124604. getLightByID(id: string): Nullable<Light>;
  124605. /**
  124606. * Gets a light node using its scene-generated unique ID
  124607. * @param uniqueId defines the light's unique id
  124608. * @return the light or null if none found.
  124609. */
  124610. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124611. /**
  124612. * Gets a particle system by id
  124613. * @param id defines the particle system id
  124614. * @return the corresponding system or null if none found
  124615. */
  124616. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124617. /**
  124618. * Gets a geometry using its ID
  124619. * @param id defines the geometry's id
  124620. * @return the geometry or null if none found.
  124621. */
  124622. getGeometryByID(id: string): Nullable<Geometry>;
  124623. private _getGeometryByUniqueID;
  124624. /**
  124625. * Add a new geometry to this scene
  124626. * @param geometry defines the geometry to be added to the scene.
  124627. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124628. * @return a boolean defining if the geometry was added or not
  124629. */
  124630. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124631. /**
  124632. * Removes an existing geometry
  124633. * @param geometry defines the geometry to be removed from the scene
  124634. * @return a boolean defining if the geometry was removed or not
  124635. */
  124636. removeGeometry(geometry: Geometry): boolean;
  124637. /**
  124638. * Gets the list of geometries attached to the scene
  124639. * @returns an array of Geometry
  124640. */
  124641. getGeometries(): Geometry[];
  124642. /**
  124643. * Gets the first added mesh found of a given ID
  124644. * @param id defines the id to search for
  124645. * @return the mesh found or null if not found at all
  124646. */
  124647. getMeshByID(id: string): Nullable<AbstractMesh>;
  124648. /**
  124649. * Gets a list of meshes using their id
  124650. * @param id defines the id to search for
  124651. * @returns a list of meshes
  124652. */
  124653. getMeshesByID(id: string): Array<AbstractMesh>;
  124654. /**
  124655. * Gets the first added transform node found of a given ID
  124656. * @param id defines the id to search for
  124657. * @return the found transform node or null if not found at all.
  124658. */
  124659. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124660. /**
  124661. * Gets a transform node with its auto-generated unique id
  124662. * @param uniqueId efines the unique id to search for
  124663. * @return the found transform node or null if not found at all.
  124664. */
  124665. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124666. /**
  124667. * Gets a list of transform nodes using their id
  124668. * @param id defines the id to search for
  124669. * @returns a list of transform nodes
  124670. */
  124671. getTransformNodesByID(id: string): Array<TransformNode>;
  124672. /**
  124673. * Gets a mesh with its auto-generated unique id
  124674. * @param uniqueId defines the unique id to search for
  124675. * @return the found mesh or null if not found at all.
  124676. */
  124677. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124678. /**
  124679. * Gets a the last added mesh using a given id
  124680. * @param id defines the id to search for
  124681. * @return the found mesh or null if not found at all.
  124682. */
  124683. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124684. /**
  124685. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124686. * @param id defines the id to search for
  124687. * @return the found node or null if not found at all
  124688. */
  124689. getLastEntryByID(id: string): Nullable<Node>;
  124690. /**
  124691. * Gets a node (Mesh, Camera, Light) using a given id
  124692. * @param id defines the id to search for
  124693. * @return the found node or null if not found at all
  124694. */
  124695. getNodeByID(id: string): Nullable<Node>;
  124696. /**
  124697. * Gets a node (Mesh, Camera, Light) using a given name
  124698. * @param name defines the name to search for
  124699. * @return the found node or null if not found at all.
  124700. */
  124701. getNodeByName(name: string): Nullable<Node>;
  124702. /**
  124703. * Gets a mesh using a given name
  124704. * @param name defines the name to search for
  124705. * @return the found mesh or null if not found at all.
  124706. */
  124707. getMeshByName(name: string): Nullable<AbstractMesh>;
  124708. /**
  124709. * Gets a transform node using a given name
  124710. * @param name defines the name to search for
  124711. * @return the found transform node or null if not found at all.
  124712. */
  124713. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124714. /**
  124715. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124716. * @param id defines the id to search for
  124717. * @return the found skeleton or null if not found at all.
  124718. */
  124719. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124720. /**
  124721. * Gets a skeleton using a given auto generated unique id
  124722. * @param uniqueId defines the unique id to search for
  124723. * @return the found skeleton or null if not found at all.
  124724. */
  124725. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124726. /**
  124727. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124728. * @param id defines the id to search for
  124729. * @return the found skeleton or null if not found at all.
  124730. */
  124731. getSkeletonById(id: string): Nullable<Skeleton>;
  124732. /**
  124733. * Gets a skeleton using a given name
  124734. * @param name defines the name to search for
  124735. * @return the found skeleton or null if not found at all.
  124736. */
  124737. getSkeletonByName(name: string): Nullable<Skeleton>;
  124738. /**
  124739. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124740. * @param id defines the id to search for
  124741. * @return the found morph target manager or null if not found at all.
  124742. */
  124743. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124744. /**
  124745. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124746. * @param id defines the id to search for
  124747. * @return the found morph target or null if not found at all.
  124748. */
  124749. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124750. /**
  124751. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124752. * @param name defines the name to search for
  124753. * @return the found morph target or null if not found at all.
  124754. */
  124755. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124756. /**
  124757. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124758. * @param name defines the name to search for
  124759. * @return the found post process or null if not found at all.
  124760. */
  124761. getPostProcessByName(name: string): Nullable<PostProcess>;
  124762. /**
  124763. * Gets a boolean indicating if the given mesh is active
  124764. * @param mesh defines the mesh to look for
  124765. * @returns true if the mesh is in the active list
  124766. */
  124767. isActiveMesh(mesh: AbstractMesh): boolean;
  124768. /**
  124769. * Return a unique id as a string which can serve as an identifier for the scene
  124770. */
  124771. get uid(): string;
  124772. /**
  124773. * Add an externaly attached data from its key.
  124774. * This method call will fail and return false, if such key already exists.
  124775. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124776. * @param key the unique key that identifies the data
  124777. * @param data the data object to associate to the key for this Engine instance
  124778. * @return true if no such key were already present and the data was added successfully, false otherwise
  124779. */
  124780. addExternalData<T>(key: string, data: T): boolean;
  124781. /**
  124782. * Get an externaly attached data from its key
  124783. * @param key the unique key that identifies the data
  124784. * @return the associated data, if present (can be null), or undefined if not present
  124785. */
  124786. getExternalData<T>(key: string): Nullable<T>;
  124787. /**
  124788. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124789. * @param key the unique key that identifies the data
  124790. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124791. * @return the associated data, can be null if the factory returned null.
  124792. */
  124793. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124794. /**
  124795. * Remove an externaly attached data from the Engine instance
  124796. * @param key the unique key that identifies the data
  124797. * @return true if the data was successfully removed, false if it doesn't exist
  124798. */
  124799. removeExternalData(key: string): boolean;
  124800. private _evaluateSubMesh;
  124801. /**
  124802. * Clear the processed materials smart array preventing retention point in material dispose.
  124803. */
  124804. freeProcessedMaterials(): void;
  124805. private _preventFreeActiveMeshesAndRenderingGroups;
  124806. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124807. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124808. * when disposing several meshes in a row or a hierarchy of meshes.
  124809. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124810. */
  124811. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124812. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124813. /**
  124814. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124815. */
  124816. freeActiveMeshes(): void;
  124817. /**
  124818. * Clear the info related to rendering groups preventing retention points during dispose.
  124819. */
  124820. freeRenderingGroups(): void;
  124821. /** @hidden */
  124822. _isInIntermediateRendering(): boolean;
  124823. /**
  124824. * Lambda returning the list of potentially active meshes.
  124825. */
  124826. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124827. /**
  124828. * Lambda returning the list of potentially active sub meshes.
  124829. */
  124830. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124831. /**
  124832. * Lambda returning the list of potentially intersecting sub meshes.
  124833. */
  124834. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124835. /**
  124836. * Lambda returning the list of potentially colliding sub meshes.
  124837. */
  124838. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124839. private _activeMeshesFrozen;
  124840. private _skipEvaluateActiveMeshesCompletely;
  124841. /**
  124842. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124843. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124844. * @param onSuccess optional success callback
  124845. * @param onError optional error callback
  124846. * @returns the current scene
  124847. */
  124848. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124849. /**
  124850. * Use this function to restart evaluating active meshes on every frame
  124851. * @returns the current scene
  124852. */
  124853. unfreezeActiveMeshes(): Scene;
  124854. private _evaluateActiveMeshes;
  124855. private _activeMesh;
  124856. /**
  124857. * Update the transform matrix to update from the current active camera
  124858. * @param force defines a boolean used to force the update even if cache is up to date
  124859. */
  124860. updateTransformMatrix(force?: boolean): void;
  124861. private _bindFrameBuffer;
  124862. /** @hidden */
  124863. _allowPostProcessClearColor: boolean;
  124864. /** @hidden */
  124865. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124866. private _processSubCameras;
  124867. private _checkIntersections;
  124868. /** @hidden */
  124869. _advancePhysicsEngineStep(step: number): void;
  124870. /**
  124871. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124872. */
  124873. getDeterministicFrameTime: () => number;
  124874. /** @hidden */
  124875. _animate(): void;
  124876. /** Execute all animations (for a frame) */
  124877. animate(): void;
  124878. /**
  124879. * Render the scene
  124880. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124881. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124882. */
  124883. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124884. /**
  124885. * Freeze all materials
  124886. * A frozen material will not be updatable but should be faster to render
  124887. */
  124888. freezeMaterials(): void;
  124889. /**
  124890. * Unfreeze all materials
  124891. * A frozen material will not be updatable but should be faster to render
  124892. */
  124893. unfreezeMaterials(): void;
  124894. /**
  124895. * Releases all held ressources
  124896. */
  124897. dispose(): void;
  124898. /**
  124899. * Gets if the scene is already disposed
  124900. */
  124901. get isDisposed(): boolean;
  124902. /**
  124903. * Call this function to reduce memory footprint of the scene.
  124904. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124905. */
  124906. clearCachedVertexData(): void;
  124907. /**
  124908. * This function will remove the local cached buffer data from texture.
  124909. * It will save memory but will prevent the texture from being rebuilt
  124910. */
  124911. cleanCachedTextureBuffer(): void;
  124912. /**
  124913. * Get the world extend vectors with an optional filter
  124914. *
  124915. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124916. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124917. */
  124918. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124919. min: Vector3;
  124920. max: Vector3;
  124921. };
  124922. /**
  124923. * Creates a ray that can be used to pick in the scene
  124924. * @param x defines the x coordinate of the origin (on-screen)
  124925. * @param y defines the y coordinate of the origin (on-screen)
  124926. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124927. * @param camera defines the camera to use for the picking
  124928. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124929. * @returns a Ray
  124930. */
  124931. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124932. /**
  124933. * Creates a ray that can be used to pick in the scene
  124934. * @param x defines the x coordinate of the origin (on-screen)
  124935. * @param y defines the y coordinate of the origin (on-screen)
  124936. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124937. * @param result defines the ray where to store the picking ray
  124938. * @param camera defines the camera to use for the picking
  124939. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124940. * @returns the current scene
  124941. */
  124942. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124943. /**
  124944. * Creates a ray that can be used to pick in the scene
  124945. * @param x defines the x coordinate of the origin (on-screen)
  124946. * @param y defines the y coordinate of the origin (on-screen)
  124947. * @param camera defines the camera to use for the picking
  124948. * @returns a Ray
  124949. */
  124950. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124951. /**
  124952. * Creates a ray that can be used to pick in the scene
  124953. * @param x defines the x coordinate of the origin (on-screen)
  124954. * @param y defines the y coordinate of the origin (on-screen)
  124955. * @param result defines the ray where to store the picking ray
  124956. * @param camera defines the camera to use for the picking
  124957. * @returns the current scene
  124958. */
  124959. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124960. /** Launch a ray to try to pick a mesh in the scene
  124961. * @param x position on screen
  124962. * @param y position on screen
  124963. * @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
  124964. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124965. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124966. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124967. * @returns a PickingInfo
  124968. */
  124969. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124970. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124971. * @param x position on screen
  124972. * @param y position on screen
  124973. * @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
  124974. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124975. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124976. * @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)
  124977. */
  124978. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124979. /** Use the given ray to pick a mesh in the scene
  124980. * @param ray The ray to use to pick meshes
  124981. * @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
  124982. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124983. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124984. * @returns a PickingInfo
  124985. */
  124986. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124987. /**
  124988. * Launch a ray to try to pick a mesh in the scene
  124989. * @param x X position on screen
  124990. * @param y Y position on screen
  124991. * @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
  124992. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124993. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124994. * @returns an array of PickingInfo
  124995. */
  124996. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124997. /**
  124998. * Launch a ray to try to pick a mesh in the scene
  124999. * @param ray Ray to use
  125000. * @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
  125001. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125002. * @returns an array of PickingInfo
  125003. */
  125004. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125005. /**
  125006. * Force the value of meshUnderPointer
  125007. * @param mesh defines the mesh to use
  125008. * @param pointerId optional pointer id when using more than one pointer
  125009. */
  125010. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  125011. /**
  125012. * Gets the mesh under the pointer
  125013. * @returns a Mesh or null if no mesh is under the pointer
  125014. */
  125015. getPointerOverMesh(): Nullable<AbstractMesh>;
  125016. /** @hidden */
  125017. _rebuildGeometries(): void;
  125018. /** @hidden */
  125019. _rebuildTextures(): void;
  125020. private _getByTags;
  125021. /**
  125022. * Get a list of meshes by tags
  125023. * @param tagsQuery defines the tags query to use
  125024. * @param forEach defines a predicate used to filter results
  125025. * @returns an array of Mesh
  125026. */
  125027. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  125028. /**
  125029. * Get a list of cameras by tags
  125030. * @param tagsQuery defines the tags query to use
  125031. * @param forEach defines a predicate used to filter results
  125032. * @returns an array of Camera
  125033. */
  125034. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  125035. /**
  125036. * Get a list of lights by tags
  125037. * @param tagsQuery defines the tags query to use
  125038. * @param forEach defines a predicate used to filter results
  125039. * @returns an array of Light
  125040. */
  125041. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  125042. /**
  125043. * Get a list of materials by tags
  125044. * @param tagsQuery defines the tags query to use
  125045. * @param forEach defines a predicate used to filter results
  125046. * @returns an array of Material
  125047. */
  125048. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  125049. /**
  125050. * Get a list of transform nodes by tags
  125051. * @param tagsQuery defines the tags query to use
  125052. * @param forEach defines a predicate used to filter results
  125053. * @returns an array of TransformNode
  125054. */
  125055. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125056. /**
  125057. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125058. * This allowed control for front to back rendering or reversly depending of the special needs.
  125059. *
  125060. * @param renderingGroupId The rendering group id corresponding to its index
  125061. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125062. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125063. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125064. */
  125065. 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;
  125066. /**
  125067. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125068. *
  125069. * @param renderingGroupId The rendering group id corresponding to its index
  125070. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125071. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125072. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125073. */
  125074. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125075. /**
  125076. * Gets the current auto clear configuration for one rendering group of the rendering
  125077. * manager.
  125078. * @param index the rendering group index to get the information for
  125079. * @returns The auto clear setup for the requested rendering group
  125080. */
  125081. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125082. private _blockMaterialDirtyMechanism;
  125083. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125084. get blockMaterialDirtyMechanism(): boolean;
  125085. set blockMaterialDirtyMechanism(value: boolean);
  125086. /**
  125087. * Will flag all materials as dirty to trigger new shader compilation
  125088. * @param flag defines the flag used to specify which material part must be marked as dirty
  125089. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125090. */
  125091. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125092. /** @hidden */
  125093. _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;
  125094. /** @hidden */
  125095. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125096. /** @hidden */
  125097. _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;
  125098. /** @hidden */
  125099. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125100. /** @hidden */
  125101. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125102. /** @hidden */
  125103. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125104. }
  125105. }
  125106. declare module BABYLON {
  125107. /**
  125108. * Set of assets to keep when moving a scene into an asset container.
  125109. */
  125110. export class KeepAssets extends AbstractScene {
  125111. }
  125112. /**
  125113. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125114. */
  125115. export class InstantiatedEntries {
  125116. /**
  125117. * List of new root nodes (eg. nodes with no parent)
  125118. */
  125119. rootNodes: TransformNode[];
  125120. /**
  125121. * List of new skeletons
  125122. */
  125123. skeletons: Skeleton[];
  125124. /**
  125125. * List of new animation groups
  125126. */
  125127. animationGroups: AnimationGroup[];
  125128. }
  125129. /**
  125130. * Container with a set of assets that can be added or removed from a scene.
  125131. */
  125132. export class AssetContainer extends AbstractScene {
  125133. private _wasAddedToScene;
  125134. /**
  125135. * The scene the AssetContainer belongs to.
  125136. */
  125137. scene: Scene;
  125138. /**
  125139. * Instantiates an AssetContainer.
  125140. * @param scene The scene the AssetContainer belongs to.
  125141. */
  125142. constructor(scene: Scene);
  125143. /**
  125144. * Instantiate or clone all meshes and add the new ones to the scene.
  125145. * Skeletons and animation groups will all be cloned
  125146. * @param nameFunction defines an optional function used to get new names for clones
  125147. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125148. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125149. */
  125150. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125151. /**
  125152. * Adds all the assets from the container to the scene.
  125153. */
  125154. addAllToScene(): void;
  125155. /**
  125156. * Removes all the assets in the container from the scene
  125157. */
  125158. removeAllFromScene(): void;
  125159. /**
  125160. * Disposes all the assets in the container
  125161. */
  125162. dispose(): void;
  125163. private _moveAssets;
  125164. /**
  125165. * Removes all the assets contained in the scene and adds them to the container.
  125166. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125167. */
  125168. moveAllFromScene(keepAssets?: KeepAssets): void;
  125169. /**
  125170. * 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.
  125171. * @returns the root mesh
  125172. */
  125173. createRootMesh(): Mesh;
  125174. /**
  125175. * Merge animations (direct and animation groups) from this asset container into a scene
  125176. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125177. * @param animatables set of animatables to retarget to a node from the scene
  125178. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125179. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125180. */
  125181. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125182. }
  125183. }
  125184. declare module BABYLON {
  125185. /**
  125186. * Defines how the parser contract is defined.
  125187. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125188. */
  125189. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125190. /**
  125191. * Defines how the individual parser contract is defined.
  125192. * These parser can parse an individual asset
  125193. */
  125194. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125195. /**
  125196. * Base class of the scene acting as a container for the different elements composing a scene.
  125197. * This class is dynamically extended by the different components of the scene increasing
  125198. * flexibility and reducing coupling
  125199. */
  125200. export abstract class AbstractScene {
  125201. /**
  125202. * Stores the list of available parsers in the application.
  125203. */
  125204. private static _BabylonFileParsers;
  125205. /**
  125206. * Stores the list of available individual parsers in the application.
  125207. */
  125208. private static _IndividualBabylonFileParsers;
  125209. /**
  125210. * Adds a parser in the list of available ones
  125211. * @param name Defines the name of the parser
  125212. * @param parser Defines the parser to add
  125213. */
  125214. static AddParser(name: string, parser: BabylonFileParser): void;
  125215. /**
  125216. * Gets a general parser from the list of avaialble ones
  125217. * @param name Defines the name of the parser
  125218. * @returns the requested parser or null
  125219. */
  125220. static GetParser(name: string): Nullable<BabylonFileParser>;
  125221. /**
  125222. * Adds n individual parser in the list of available ones
  125223. * @param name Defines the name of the parser
  125224. * @param parser Defines the parser to add
  125225. */
  125226. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125227. /**
  125228. * Gets an individual parser from the list of avaialble ones
  125229. * @param name Defines the name of the parser
  125230. * @returns the requested parser or null
  125231. */
  125232. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125233. /**
  125234. * Parser json data and populate both a scene and its associated container object
  125235. * @param jsonData Defines the data to parse
  125236. * @param scene Defines the scene to parse the data for
  125237. * @param container Defines the container attached to the parsing sequence
  125238. * @param rootUrl Defines the root url of the data
  125239. */
  125240. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125241. /**
  125242. * Gets the list of root nodes (ie. nodes with no parent)
  125243. */
  125244. rootNodes: Node[];
  125245. /** All of the cameras added to this scene
  125246. * @see https://doc.babylonjs.com/babylon101/cameras
  125247. */
  125248. cameras: Camera[];
  125249. /**
  125250. * All of the lights added to this scene
  125251. * @see https://doc.babylonjs.com/babylon101/lights
  125252. */
  125253. lights: Light[];
  125254. /**
  125255. * All of the (abstract) meshes added to this scene
  125256. */
  125257. meshes: AbstractMesh[];
  125258. /**
  125259. * The list of skeletons added to the scene
  125260. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125261. */
  125262. skeletons: Skeleton[];
  125263. /**
  125264. * All of the particle systems added to this scene
  125265. * @see https://doc.babylonjs.com/babylon101/particles
  125266. */
  125267. particleSystems: IParticleSystem[];
  125268. /**
  125269. * Gets a list of Animations associated with the scene
  125270. */
  125271. animations: Animation[];
  125272. /**
  125273. * All of the animation groups added to this scene
  125274. * @see https://doc.babylonjs.com/how_to/group
  125275. */
  125276. animationGroups: AnimationGroup[];
  125277. /**
  125278. * All of the multi-materials added to this scene
  125279. * @see https://doc.babylonjs.com/how_to/multi_materials
  125280. */
  125281. multiMaterials: MultiMaterial[];
  125282. /**
  125283. * All of the materials added to this scene
  125284. * In the context of a Scene, it is not supposed to be modified manually.
  125285. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125286. * Note also that the order of the Material within the array is not significant and might change.
  125287. * @see https://doc.babylonjs.com/babylon101/materials
  125288. */
  125289. materials: Material[];
  125290. /**
  125291. * The list of morph target managers added to the scene
  125292. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125293. */
  125294. morphTargetManagers: MorphTargetManager[];
  125295. /**
  125296. * The list of geometries used in the scene.
  125297. */
  125298. geometries: Geometry[];
  125299. /**
  125300. * All of the tranform nodes added to this scene
  125301. * In the context of a Scene, it is not supposed to be modified manually.
  125302. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125303. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125304. * @see https://doc.babylonjs.com/how_to/transformnode
  125305. */
  125306. transformNodes: TransformNode[];
  125307. /**
  125308. * ActionManagers available on the scene.
  125309. */
  125310. actionManagers: AbstractActionManager[];
  125311. /**
  125312. * Textures to keep.
  125313. */
  125314. textures: BaseTexture[];
  125315. /** @hidden */
  125316. protected _environmentTexture: Nullable<BaseTexture>;
  125317. /**
  125318. * Texture used in all pbr material as the reflection texture.
  125319. * As in the majority of the scene they are the same (exception for multi room and so on),
  125320. * this is easier to reference from here than from all the materials.
  125321. */
  125322. get environmentTexture(): Nullable<BaseTexture>;
  125323. set environmentTexture(value: Nullable<BaseTexture>);
  125324. /**
  125325. * The list of postprocesses added to the scene
  125326. */
  125327. postProcesses: PostProcess[];
  125328. /**
  125329. * @returns all meshes, lights, cameras, transformNodes and bones
  125330. */
  125331. getNodes(): Array<Node>;
  125332. }
  125333. }
  125334. declare module BABYLON {
  125335. /**
  125336. * Interface used to define options for Sound class
  125337. */
  125338. export interface ISoundOptions {
  125339. /**
  125340. * Does the sound autoplay once loaded.
  125341. */
  125342. autoplay?: boolean;
  125343. /**
  125344. * Does the sound loop after it finishes playing once.
  125345. */
  125346. loop?: boolean;
  125347. /**
  125348. * Sound's volume
  125349. */
  125350. volume?: number;
  125351. /**
  125352. * Is it a spatial sound?
  125353. */
  125354. spatialSound?: boolean;
  125355. /**
  125356. * Maximum distance to hear that sound
  125357. */
  125358. maxDistance?: number;
  125359. /**
  125360. * Uses user defined attenuation function
  125361. */
  125362. useCustomAttenuation?: boolean;
  125363. /**
  125364. * Define the roll off factor of spatial sounds.
  125365. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125366. */
  125367. rolloffFactor?: number;
  125368. /**
  125369. * Define the reference distance the sound should be heard perfectly.
  125370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125371. */
  125372. refDistance?: number;
  125373. /**
  125374. * Define the distance attenuation model the sound will follow.
  125375. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125376. */
  125377. distanceModel?: string;
  125378. /**
  125379. * Defines the playback speed (1 by default)
  125380. */
  125381. playbackRate?: number;
  125382. /**
  125383. * Defines if the sound is from a streaming source
  125384. */
  125385. streaming?: boolean;
  125386. /**
  125387. * Defines an optional length (in seconds) inside the sound file
  125388. */
  125389. length?: number;
  125390. /**
  125391. * Defines an optional offset (in seconds) inside the sound file
  125392. */
  125393. offset?: number;
  125394. /**
  125395. * If true, URLs will not be required to state the audio file codec to use.
  125396. */
  125397. skipCodecCheck?: boolean;
  125398. }
  125399. /**
  125400. * Defines a sound that can be played in the application.
  125401. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125403. */
  125404. export class Sound {
  125405. /**
  125406. * The name of the sound in the scene.
  125407. */
  125408. name: string;
  125409. /**
  125410. * Does the sound autoplay once loaded.
  125411. */
  125412. autoplay: boolean;
  125413. /**
  125414. * Does the sound loop after it finishes playing once.
  125415. */
  125416. loop: boolean;
  125417. /**
  125418. * Does the sound use a custom attenuation curve to simulate the falloff
  125419. * happening when the source gets further away from the camera.
  125420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125421. */
  125422. useCustomAttenuation: boolean;
  125423. /**
  125424. * The sound track id this sound belongs to.
  125425. */
  125426. soundTrackId: number;
  125427. /**
  125428. * Is this sound currently played.
  125429. */
  125430. isPlaying: boolean;
  125431. /**
  125432. * Is this sound currently paused.
  125433. */
  125434. isPaused: boolean;
  125435. /**
  125436. * Does this sound enables spatial sound.
  125437. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125438. */
  125439. spatialSound: boolean;
  125440. /**
  125441. * Define the reference distance the sound should be heard perfectly.
  125442. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125443. */
  125444. refDistance: number;
  125445. /**
  125446. * Define the roll off factor of spatial sounds.
  125447. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125448. */
  125449. rolloffFactor: number;
  125450. /**
  125451. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125452. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125453. */
  125454. maxDistance: number;
  125455. /**
  125456. * Define the distance attenuation model the sound will follow.
  125457. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125458. */
  125459. distanceModel: string;
  125460. /**
  125461. * @hidden
  125462. * Back Compat
  125463. **/
  125464. onended: () => any;
  125465. /**
  125466. * Gets or sets an object used to store user defined information for the sound.
  125467. */
  125468. metadata: any;
  125469. /**
  125470. * Observable event when the current playing sound finishes.
  125471. */
  125472. onEndedObservable: Observable<Sound>;
  125473. private _panningModel;
  125474. private _playbackRate;
  125475. private _streaming;
  125476. private _startTime;
  125477. private _startOffset;
  125478. private _position;
  125479. /** @hidden */
  125480. _positionInEmitterSpace: boolean;
  125481. private _localDirection;
  125482. private _volume;
  125483. private _isReadyToPlay;
  125484. private _isDirectional;
  125485. private _readyToPlayCallback;
  125486. private _audioBuffer;
  125487. private _soundSource;
  125488. private _streamingSource;
  125489. private _soundPanner;
  125490. private _soundGain;
  125491. private _inputAudioNode;
  125492. private _outputAudioNode;
  125493. private _coneInnerAngle;
  125494. private _coneOuterAngle;
  125495. private _coneOuterGain;
  125496. private _scene;
  125497. private _connectedTransformNode;
  125498. private _customAttenuationFunction;
  125499. private _registerFunc;
  125500. private _isOutputConnected;
  125501. private _htmlAudioElement;
  125502. private _urlType;
  125503. private _length?;
  125504. private _offset?;
  125505. /** @hidden */
  125506. static _SceneComponentInitialization: (scene: Scene) => void;
  125507. /**
  125508. * Create a sound and attach it to a scene
  125509. * @param name Name of your sound
  125510. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125511. * @param scene defines the scene the sound belongs to
  125512. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125513. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125514. */
  125515. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125516. /**
  125517. * Release the sound and its associated resources
  125518. */
  125519. dispose(): void;
  125520. /**
  125521. * Gets if the sounds is ready to be played or not.
  125522. * @returns true if ready, otherwise false
  125523. */
  125524. isReady(): boolean;
  125525. private _soundLoaded;
  125526. /**
  125527. * Sets the data of the sound from an audiobuffer
  125528. * @param audioBuffer The audioBuffer containing the data
  125529. */
  125530. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125531. /**
  125532. * Updates the current sounds options such as maxdistance, loop...
  125533. * @param options A JSON object containing values named as the object properties
  125534. */
  125535. updateOptions(options: ISoundOptions): void;
  125536. private _createSpatialParameters;
  125537. private _updateSpatialParameters;
  125538. /**
  125539. * Switch the panning model to HRTF:
  125540. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125542. */
  125543. switchPanningModelToHRTF(): void;
  125544. /**
  125545. * Switch the panning model to Equal Power:
  125546. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125547. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125548. */
  125549. switchPanningModelToEqualPower(): void;
  125550. private _switchPanningModel;
  125551. /**
  125552. * Connect this sound to a sound track audio node like gain...
  125553. * @param soundTrackAudioNode the sound track audio node to connect to
  125554. */
  125555. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125556. /**
  125557. * Transform this sound into a directional source
  125558. * @param coneInnerAngle Size of the inner cone in degree
  125559. * @param coneOuterAngle Size of the outer cone in degree
  125560. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125561. */
  125562. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125563. /**
  125564. * Gets or sets the inner angle for the directional cone.
  125565. */
  125566. get directionalConeInnerAngle(): number;
  125567. /**
  125568. * Gets or sets the inner angle for the directional cone.
  125569. */
  125570. set directionalConeInnerAngle(value: number);
  125571. /**
  125572. * Gets or sets the outer angle for the directional cone.
  125573. */
  125574. get directionalConeOuterAngle(): number;
  125575. /**
  125576. * Gets or sets the outer angle for the directional cone.
  125577. */
  125578. set directionalConeOuterAngle(value: number);
  125579. /**
  125580. * Sets the position of the emitter if spatial sound is enabled
  125581. * @param newPosition Defines the new posisiton
  125582. */
  125583. setPosition(newPosition: Vector3): void;
  125584. /**
  125585. * Sets the local direction of the emitter if spatial sound is enabled
  125586. * @param newLocalDirection Defines the new local direction
  125587. */
  125588. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125589. private _updateDirection;
  125590. /** @hidden */
  125591. updateDistanceFromListener(): void;
  125592. /**
  125593. * Sets a new custom attenuation function for the sound.
  125594. * @param callback Defines the function used for the attenuation
  125595. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125596. */
  125597. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125598. /**
  125599. * Play the sound
  125600. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125601. * @param offset (optional) Start the sound at a specific time in seconds
  125602. * @param length (optional) Sound duration (in seconds)
  125603. */
  125604. play(time?: number, offset?: number, length?: number): void;
  125605. private _onended;
  125606. /**
  125607. * Stop the sound
  125608. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125609. */
  125610. stop(time?: number): void;
  125611. /**
  125612. * Put the sound in pause
  125613. */
  125614. pause(): void;
  125615. /**
  125616. * Sets a dedicated volume for this sounds
  125617. * @param newVolume Define the new volume of the sound
  125618. * @param time Define time for gradual change to new volume
  125619. */
  125620. setVolume(newVolume: number, time?: number): void;
  125621. /**
  125622. * Set the sound play back rate
  125623. * @param newPlaybackRate Define the playback rate the sound should be played at
  125624. */
  125625. setPlaybackRate(newPlaybackRate: number): void;
  125626. /**
  125627. * Gets the volume of the sound.
  125628. * @returns the volume of the sound
  125629. */
  125630. getVolume(): number;
  125631. /**
  125632. * Attach the sound to a dedicated mesh
  125633. * @param transformNode The transform node to connect the sound with
  125634. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125635. */
  125636. attachToMesh(transformNode: TransformNode): void;
  125637. /**
  125638. * Detach the sound from the previously attached mesh
  125639. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125640. */
  125641. detachFromMesh(): void;
  125642. private _onRegisterAfterWorldMatrixUpdate;
  125643. /**
  125644. * Clone the current sound in the scene.
  125645. * @returns the new sound clone
  125646. */
  125647. clone(): Nullable<Sound>;
  125648. /**
  125649. * Gets the current underlying audio buffer containing the data
  125650. * @returns the audio buffer
  125651. */
  125652. getAudioBuffer(): Nullable<AudioBuffer>;
  125653. /**
  125654. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125655. * @returns the source node
  125656. */
  125657. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125658. /**
  125659. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125660. * @returns the gain node
  125661. */
  125662. getSoundGain(): Nullable<GainNode>;
  125663. /**
  125664. * Serializes the Sound in a JSON representation
  125665. * @returns the JSON representation of the sound
  125666. */
  125667. serialize(): any;
  125668. /**
  125669. * Parse a JSON representation of a sound to innstantiate in a given scene
  125670. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125671. * @param scene Define the scene the new parsed sound should be created in
  125672. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125673. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125674. * @returns the newly parsed sound
  125675. */
  125676. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125677. }
  125678. }
  125679. declare module BABYLON {
  125680. /**
  125681. * This defines an action helpful to play a defined sound on a triggered action.
  125682. */
  125683. export class PlaySoundAction extends Action {
  125684. private _sound;
  125685. /**
  125686. * Instantiate the action
  125687. * @param triggerOptions defines the trigger options
  125688. * @param sound defines the sound to play
  125689. * @param condition defines the trigger related conditions
  125690. */
  125691. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125692. /** @hidden */
  125693. _prepare(): void;
  125694. /**
  125695. * Execute the action and play the sound.
  125696. */
  125697. execute(): void;
  125698. /**
  125699. * Serializes the actions and its related information.
  125700. * @param parent defines the object to serialize in
  125701. * @returns the serialized object
  125702. */
  125703. serialize(parent: any): any;
  125704. }
  125705. /**
  125706. * This defines an action helpful to stop a defined sound on a triggered action.
  125707. */
  125708. export class StopSoundAction extends Action {
  125709. private _sound;
  125710. /**
  125711. * Instantiate the action
  125712. * @param triggerOptions defines the trigger options
  125713. * @param sound defines the sound to stop
  125714. * @param condition defines the trigger related conditions
  125715. */
  125716. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125717. /** @hidden */
  125718. _prepare(): void;
  125719. /**
  125720. * Execute the action and stop the sound.
  125721. */
  125722. execute(): void;
  125723. /**
  125724. * Serializes the actions and its related information.
  125725. * @param parent defines the object to serialize in
  125726. * @returns the serialized object
  125727. */
  125728. serialize(parent: any): any;
  125729. }
  125730. }
  125731. declare module BABYLON {
  125732. /**
  125733. * This defines an action responsible to change the value of a property
  125734. * by interpolating between its current value and the newly set one once triggered.
  125735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125736. */
  125737. export class InterpolateValueAction extends Action {
  125738. /**
  125739. * Defines the path of the property where the value should be interpolated
  125740. */
  125741. propertyPath: string;
  125742. /**
  125743. * Defines the target value at the end of the interpolation.
  125744. */
  125745. value: any;
  125746. /**
  125747. * Defines the time it will take for the property to interpolate to the value.
  125748. */
  125749. duration: number;
  125750. /**
  125751. * Defines if the other scene animations should be stopped when the action has been triggered
  125752. */
  125753. stopOtherAnimations?: boolean;
  125754. /**
  125755. * Defines a callback raised once the interpolation animation has been done.
  125756. */
  125757. onInterpolationDone?: () => void;
  125758. /**
  125759. * Observable triggered once the interpolation animation has been done.
  125760. */
  125761. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125762. private _target;
  125763. private _effectiveTarget;
  125764. private _property;
  125765. /**
  125766. * Instantiate the action
  125767. * @param triggerOptions defines the trigger options
  125768. * @param target defines the object containing the value to interpolate
  125769. * @param propertyPath defines the path to the property in the target object
  125770. * @param value defines the target value at the end of the interpolation
  125771. * @param duration deines the time it will take for the property to interpolate to the value.
  125772. * @param condition defines the trigger related conditions
  125773. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125774. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125775. */
  125776. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125777. /** @hidden */
  125778. _prepare(): void;
  125779. /**
  125780. * Execute the action starts the value interpolation.
  125781. */
  125782. execute(): void;
  125783. /**
  125784. * Serializes the actions and its related information.
  125785. * @param parent defines the object to serialize in
  125786. * @returns the serialized object
  125787. */
  125788. serialize(parent: any): any;
  125789. }
  125790. }
  125791. declare module BABYLON {
  125792. /**
  125793. * Options allowed during the creation of a sound track.
  125794. */
  125795. export interface ISoundTrackOptions {
  125796. /**
  125797. * The volume the sound track should take during creation
  125798. */
  125799. volume?: number;
  125800. /**
  125801. * Define if the sound track is the main sound track of the scene
  125802. */
  125803. mainTrack?: boolean;
  125804. }
  125805. /**
  125806. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125807. * It will be also used in a future release to apply effects on a specific track.
  125808. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125809. */
  125810. export class SoundTrack {
  125811. /**
  125812. * The unique identifier of the sound track in the scene.
  125813. */
  125814. id: number;
  125815. /**
  125816. * The list of sounds included in the sound track.
  125817. */
  125818. soundCollection: Array<Sound>;
  125819. private _outputAudioNode;
  125820. private _scene;
  125821. private _connectedAnalyser;
  125822. private _options;
  125823. private _isInitialized;
  125824. /**
  125825. * Creates a new sound track.
  125826. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125827. * @param scene Define the scene the sound track belongs to
  125828. * @param options
  125829. */
  125830. constructor(scene: Scene, options?: ISoundTrackOptions);
  125831. private _initializeSoundTrackAudioGraph;
  125832. /**
  125833. * Release the sound track and its associated resources
  125834. */
  125835. dispose(): void;
  125836. /**
  125837. * Adds a sound to this sound track
  125838. * @param sound define the cound to add
  125839. * @ignoreNaming
  125840. */
  125841. AddSound(sound: Sound): void;
  125842. /**
  125843. * Removes a sound to this sound track
  125844. * @param sound define the cound to remove
  125845. * @ignoreNaming
  125846. */
  125847. RemoveSound(sound: Sound): void;
  125848. /**
  125849. * Set a global volume for the full sound track.
  125850. * @param newVolume Define the new volume of the sound track
  125851. */
  125852. setVolume(newVolume: number): void;
  125853. /**
  125854. * Switch the panning model to HRTF:
  125855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125856. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125857. */
  125858. switchPanningModelToHRTF(): void;
  125859. /**
  125860. * Switch the panning model to Equal Power:
  125861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125862. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125863. */
  125864. switchPanningModelToEqualPower(): void;
  125865. /**
  125866. * Connect the sound track to an audio analyser allowing some amazing
  125867. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125869. * @param analyser The analyser to connect to the engine
  125870. */
  125871. connectToAnalyser(analyser: Analyser): void;
  125872. }
  125873. }
  125874. declare module BABYLON {
  125875. interface AbstractScene {
  125876. /**
  125877. * The list of sounds used in the scene.
  125878. */
  125879. sounds: Nullable<Array<Sound>>;
  125880. }
  125881. interface Scene {
  125882. /**
  125883. * @hidden
  125884. * Backing field
  125885. */
  125886. _mainSoundTrack: SoundTrack;
  125887. /**
  125888. * The main sound track played by the scene.
  125889. * It cotains your primary collection of sounds.
  125890. */
  125891. mainSoundTrack: SoundTrack;
  125892. /**
  125893. * The list of sound tracks added to the scene
  125894. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125895. */
  125896. soundTracks: Nullable<Array<SoundTrack>>;
  125897. /**
  125898. * Gets a sound using a given name
  125899. * @param name defines the name to search for
  125900. * @return the found sound or null if not found at all.
  125901. */
  125902. getSoundByName(name: string): Nullable<Sound>;
  125903. /**
  125904. * Gets or sets if audio support is enabled
  125905. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125906. */
  125907. audioEnabled: boolean;
  125908. /**
  125909. * Gets or sets if audio will be output to headphones
  125910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125911. */
  125912. headphone: boolean;
  125913. /**
  125914. * Gets or sets custom audio listener position provider
  125915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125916. */
  125917. audioListenerPositionProvider: Nullable<() => Vector3>;
  125918. /**
  125919. * Gets or sets a refresh rate when using 3D audio positioning
  125920. */
  125921. audioPositioningRefreshRate: number;
  125922. }
  125923. /**
  125924. * Defines the sound scene component responsible to manage any sounds
  125925. * in a given scene.
  125926. */
  125927. export class AudioSceneComponent implements ISceneSerializableComponent {
  125928. private static _CameraDirectionLH;
  125929. private static _CameraDirectionRH;
  125930. /**
  125931. * The component name helpfull to identify the component in the list of scene components.
  125932. */
  125933. readonly name: string;
  125934. /**
  125935. * The scene the component belongs to.
  125936. */
  125937. scene: Scene;
  125938. private _audioEnabled;
  125939. /**
  125940. * Gets whether audio is enabled or not.
  125941. * Please use related enable/disable method to switch state.
  125942. */
  125943. get audioEnabled(): boolean;
  125944. private _headphone;
  125945. /**
  125946. * Gets whether audio is outputing to headphone or not.
  125947. * Please use the according Switch methods to change output.
  125948. */
  125949. get headphone(): boolean;
  125950. /**
  125951. * Gets or sets a refresh rate when using 3D audio positioning
  125952. */
  125953. audioPositioningRefreshRate: number;
  125954. private _audioListenerPositionProvider;
  125955. /**
  125956. * Gets the current audio listener position provider
  125957. */
  125958. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125959. /**
  125960. * Sets a custom listener position for all sounds in the scene
  125961. * By default, this is the position of the first active camera
  125962. */
  125963. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125964. /**
  125965. * Creates a new instance of the component for the given scene
  125966. * @param scene Defines the scene to register the component in
  125967. */
  125968. constructor(scene: Scene);
  125969. /**
  125970. * Registers the component in a given scene
  125971. */
  125972. register(): void;
  125973. /**
  125974. * Rebuilds the elements related to this component in case of
  125975. * context lost for instance.
  125976. */
  125977. rebuild(): void;
  125978. /**
  125979. * Serializes the component data to the specified json object
  125980. * @param serializationObject The object to serialize to
  125981. */
  125982. serialize(serializationObject: any): void;
  125983. /**
  125984. * Adds all the elements from the container to the scene
  125985. * @param container the container holding the elements
  125986. */
  125987. addFromContainer(container: AbstractScene): void;
  125988. /**
  125989. * Removes all the elements in the container from the scene
  125990. * @param container contains the elements to remove
  125991. * @param dispose if the removed element should be disposed (default: false)
  125992. */
  125993. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125994. /**
  125995. * Disposes the component and the associated ressources.
  125996. */
  125997. dispose(): void;
  125998. /**
  125999. * Disables audio in the associated scene.
  126000. */
  126001. disableAudio(): void;
  126002. /**
  126003. * Enables audio in the associated scene.
  126004. */
  126005. enableAudio(): void;
  126006. /**
  126007. * Switch audio to headphone output.
  126008. */
  126009. switchAudioModeForHeadphones(): void;
  126010. /**
  126011. * Switch audio to normal speakers.
  126012. */
  126013. switchAudioModeForNormalSpeakers(): void;
  126014. private _cachedCameraDirection;
  126015. private _cachedCameraPosition;
  126016. private _lastCheck;
  126017. private _afterRender;
  126018. }
  126019. }
  126020. declare module BABYLON {
  126021. /**
  126022. * Wraps one or more Sound objects and selects one with random weight for playback.
  126023. */
  126024. export class WeightedSound {
  126025. /** When true a Sound will be selected and played when the current playing Sound completes. */
  126026. loop: boolean;
  126027. private _coneInnerAngle;
  126028. private _coneOuterAngle;
  126029. private _volume;
  126030. /** A Sound is currently playing. */
  126031. isPlaying: boolean;
  126032. /** A Sound is currently paused. */
  126033. isPaused: boolean;
  126034. private _sounds;
  126035. private _weights;
  126036. private _currentIndex?;
  126037. /**
  126038. * Creates a new WeightedSound from the list of sounds given.
  126039. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  126040. * @param sounds Array of Sounds that will be selected from.
  126041. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  126042. */
  126043. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  126044. /**
  126045. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  126046. */
  126047. get directionalConeInnerAngle(): number;
  126048. /**
  126049. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126050. */
  126051. set directionalConeInnerAngle(value: number);
  126052. /**
  126053. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126054. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126055. */
  126056. get directionalConeOuterAngle(): number;
  126057. /**
  126058. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126059. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126060. */
  126061. set directionalConeOuterAngle(value: number);
  126062. /**
  126063. * Playback volume.
  126064. */
  126065. get volume(): number;
  126066. /**
  126067. * Playback volume.
  126068. */
  126069. set volume(value: number);
  126070. private _onended;
  126071. /**
  126072. * Suspend playback
  126073. */
  126074. pause(): void;
  126075. /**
  126076. * Stop playback
  126077. */
  126078. stop(): void;
  126079. /**
  126080. * Start playback.
  126081. * @param startOffset Position the clip head at a specific time in seconds.
  126082. */
  126083. play(startOffset?: number): void;
  126084. }
  126085. }
  126086. declare module BABYLON {
  126087. /**
  126088. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126089. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126090. */
  126091. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126092. /**
  126093. * Gets the name of the behavior.
  126094. */
  126095. get name(): string;
  126096. /**
  126097. * The easing function used by animations
  126098. */
  126099. static EasingFunction: BackEase;
  126100. /**
  126101. * The easing mode used by animations
  126102. */
  126103. static EasingMode: number;
  126104. /**
  126105. * The duration of the animation, in milliseconds
  126106. */
  126107. transitionDuration: number;
  126108. /**
  126109. * Length of the distance animated by the transition when lower radius is reached
  126110. */
  126111. lowerRadiusTransitionRange: number;
  126112. /**
  126113. * Length of the distance animated by the transition when upper radius is reached
  126114. */
  126115. upperRadiusTransitionRange: number;
  126116. private _autoTransitionRange;
  126117. /**
  126118. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126119. */
  126120. get autoTransitionRange(): boolean;
  126121. /**
  126122. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126123. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126124. */
  126125. set autoTransitionRange(value: boolean);
  126126. private _attachedCamera;
  126127. private _onAfterCheckInputsObserver;
  126128. private _onMeshTargetChangedObserver;
  126129. /**
  126130. * Initializes the behavior.
  126131. */
  126132. init(): void;
  126133. /**
  126134. * Attaches the behavior to its arc rotate camera.
  126135. * @param camera Defines the camera to attach the behavior to
  126136. */
  126137. attach(camera: ArcRotateCamera): void;
  126138. /**
  126139. * Detaches the behavior from its current arc rotate camera.
  126140. */
  126141. detach(): void;
  126142. private _radiusIsAnimating;
  126143. private _radiusBounceTransition;
  126144. private _animatables;
  126145. private _cachedWheelPrecision;
  126146. /**
  126147. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126148. * @param radiusLimit The limit to check against.
  126149. * @return Bool to indicate if at limit.
  126150. */
  126151. private _isRadiusAtLimit;
  126152. /**
  126153. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126154. * @param radiusDelta The delta by which to animate to. Can be negative.
  126155. */
  126156. private _applyBoundRadiusAnimation;
  126157. /**
  126158. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126159. */
  126160. protected _clearAnimationLocks(): void;
  126161. /**
  126162. * Stops and removes all animations that have been applied to the camera
  126163. */
  126164. stopAllAnimations(): void;
  126165. }
  126166. }
  126167. declare module BABYLON {
  126168. /**
  126169. * 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.
  126170. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126171. */
  126172. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126173. /**
  126174. * Gets the name of the behavior.
  126175. */
  126176. get name(): string;
  126177. private _mode;
  126178. private _radiusScale;
  126179. private _positionScale;
  126180. private _defaultElevation;
  126181. private _elevationReturnTime;
  126182. private _elevationReturnWaitTime;
  126183. private _zoomStopsAnimation;
  126184. private _framingTime;
  126185. /**
  126186. * The easing function used by animations
  126187. */
  126188. static EasingFunction: ExponentialEase;
  126189. /**
  126190. * The easing mode used by animations
  126191. */
  126192. static EasingMode: number;
  126193. /**
  126194. * Sets the current mode used by the behavior
  126195. */
  126196. set mode(mode: number);
  126197. /**
  126198. * Gets current mode used by the behavior.
  126199. */
  126200. get mode(): number;
  126201. /**
  126202. * Sets the scale applied to the radius (1 by default)
  126203. */
  126204. set radiusScale(radius: number);
  126205. /**
  126206. * Gets the scale applied to the radius
  126207. */
  126208. get radiusScale(): number;
  126209. /**
  126210. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126211. */
  126212. set positionScale(scale: number);
  126213. /**
  126214. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126215. */
  126216. get positionScale(): number;
  126217. /**
  126218. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126219. * behaviour is triggered, in radians.
  126220. */
  126221. set defaultElevation(elevation: number);
  126222. /**
  126223. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126224. * behaviour is triggered, in radians.
  126225. */
  126226. get defaultElevation(): number;
  126227. /**
  126228. * Sets the time (in milliseconds) taken to return to the default beta position.
  126229. * Negative value indicates camera should not return to default.
  126230. */
  126231. set elevationReturnTime(speed: number);
  126232. /**
  126233. * Gets the time (in milliseconds) taken to return to the default beta position.
  126234. * Negative value indicates camera should not return to default.
  126235. */
  126236. get elevationReturnTime(): number;
  126237. /**
  126238. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126239. */
  126240. set elevationReturnWaitTime(time: number);
  126241. /**
  126242. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126243. */
  126244. get elevationReturnWaitTime(): number;
  126245. /**
  126246. * Sets the flag that indicates if user zooming should stop animation.
  126247. */
  126248. set zoomStopsAnimation(flag: boolean);
  126249. /**
  126250. * Gets the flag that indicates if user zooming should stop animation.
  126251. */
  126252. get zoomStopsAnimation(): boolean;
  126253. /**
  126254. * Sets the transition time when framing the mesh, in milliseconds
  126255. */
  126256. set framingTime(time: number);
  126257. /**
  126258. * Gets the transition time when framing the mesh, in milliseconds
  126259. */
  126260. get framingTime(): number;
  126261. /**
  126262. * Define if the behavior should automatically change the configured
  126263. * camera limits and sensibilities.
  126264. */
  126265. autoCorrectCameraLimitsAndSensibility: boolean;
  126266. private _onPrePointerObservableObserver;
  126267. private _onAfterCheckInputsObserver;
  126268. private _onMeshTargetChangedObserver;
  126269. private _attachedCamera;
  126270. private _isPointerDown;
  126271. private _lastInteractionTime;
  126272. /**
  126273. * Initializes the behavior.
  126274. */
  126275. init(): void;
  126276. /**
  126277. * Attaches the behavior to its arc rotate camera.
  126278. * @param camera Defines the camera to attach the behavior to
  126279. */
  126280. attach(camera: ArcRotateCamera): void;
  126281. /**
  126282. * Detaches the behavior from its current arc rotate camera.
  126283. */
  126284. detach(): void;
  126285. private _animatables;
  126286. private _betaIsAnimating;
  126287. private _betaTransition;
  126288. private _radiusTransition;
  126289. private _vectorTransition;
  126290. /**
  126291. * Targets the given mesh and updates zoom level accordingly.
  126292. * @param mesh The mesh to target.
  126293. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126294. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126295. */
  126296. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126297. /**
  126298. * Targets the given mesh with its children and updates zoom level accordingly.
  126299. * @param mesh The mesh to target.
  126300. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126301. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126302. */
  126303. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126304. /**
  126305. * Targets the given meshes with their children and updates zoom level accordingly.
  126306. * @param meshes The mesh to target.
  126307. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126308. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126309. */
  126310. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126311. /**
  126312. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126313. * @param minimumWorld Determines the smaller position of the bounding box extend
  126314. * @param maximumWorld Determines the bigger position of the bounding box extend
  126315. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126316. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126317. */
  126318. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126319. /**
  126320. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126321. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126322. * frustum width.
  126323. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126324. * to fully enclose the mesh in the viewing frustum.
  126325. */
  126326. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126327. /**
  126328. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126329. * is automatically returned to its default position (expected to be above ground plane).
  126330. */
  126331. private _maintainCameraAboveGround;
  126332. /**
  126333. * Returns the frustum slope based on the canvas ratio and camera FOV
  126334. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126335. */
  126336. private _getFrustumSlope;
  126337. /**
  126338. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126339. */
  126340. private _clearAnimationLocks;
  126341. /**
  126342. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126343. */
  126344. private _applyUserInteraction;
  126345. /**
  126346. * Stops and removes all animations that have been applied to the camera
  126347. */
  126348. stopAllAnimations(): void;
  126349. /**
  126350. * Gets a value indicating if the user is moving the camera
  126351. */
  126352. get isUserIsMoving(): boolean;
  126353. /**
  126354. * The camera can move all the way towards the mesh.
  126355. */
  126356. static IgnoreBoundsSizeMode: number;
  126357. /**
  126358. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126359. */
  126360. static FitFrustumSidesMode: number;
  126361. }
  126362. }
  126363. declare module BABYLON {
  126364. /**
  126365. * Base class for Camera Pointer Inputs.
  126366. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126367. * for example usage.
  126368. */
  126369. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126370. /**
  126371. * Defines the camera the input is attached to.
  126372. */
  126373. abstract camera: Camera;
  126374. /**
  126375. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126376. */
  126377. protected _altKey: boolean;
  126378. protected _ctrlKey: boolean;
  126379. protected _metaKey: boolean;
  126380. protected _shiftKey: boolean;
  126381. /**
  126382. * Which mouse buttons were pressed at time of last mouse event.
  126383. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126384. */
  126385. protected _buttonsPressed: number;
  126386. /**
  126387. * Defines the buttons associated with the input to handle camera move.
  126388. */
  126389. buttons: number[];
  126390. /**
  126391. * Attach the input controls to a specific dom element to get the input from.
  126392. * @param element Defines the element the controls should be listened from
  126393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126394. */
  126395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126396. /**
  126397. * Detach the current controls from the specified dom element.
  126398. * @param element Defines the element to stop listening the inputs from
  126399. */
  126400. detachControl(element: Nullable<HTMLElement>): void;
  126401. /**
  126402. * Gets the class name of the current input.
  126403. * @returns the class name
  126404. */
  126405. getClassName(): string;
  126406. /**
  126407. * Get the friendly name associated with the input class.
  126408. * @returns the input friendly name
  126409. */
  126410. getSimpleName(): string;
  126411. /**
  126412. * Called on pointer POINTERDOUBLETAP event.
  126413. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126414. */
  126415. protected onDoubleTap(type: string): void;
  126416. /**
  126417. * Called on pointer POINTERMOVE event if only a single touch is active.
  126418. * Override this method to provide functionality.
  126419. */
  126420. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126421. /**
  126422. * Called on pointer POINTERMOVE event if multiple touches are active.
  126423. * Override this method to provide functionality.
  126424. */
  126425. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126426. /**
  126427. * Called on JS contextmenu event.
  126428. * Override this method to provide functionality.
  126429. */
  126430. protected onContextMenu(evt: PointerEvent): void;
  126431. /**
  126432. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126433. * press.
  126434. * Override this method to provide functionality.
  126435. */
  126436. protected onButtonDown(evt: PointerEvent): void;
  126437. /**
  126438. * Called each time a new POINTERUP event occurs. Ie, for each button
  126439. * release.
  126440. * Override this method to provide functionality.
  126441. */
  126442. protected onButtonUp(evt: PointerEvent): void;
  126443. /**
  126444. * Called when window becomes inactive.
  126445. * Override this method to provide functionality.
  126446. */
  126447. protected onLostFocus(): void;
  126448. private _pointerInput;
  126449. private _observer;
  126450. private _onLostFocus;
  126451. private pointA;
  126452. private pointB;
  126453. }
  126454. }
  126455. declare module BABYLON {
  126456. /**
  126457. * Manage the pointers inputs to control an arc rotate camera.
  126458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126459. */
  126460. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126461. /**
  126462. * Defines the camera the input is attached to.
  126463. */
  126464. camera: ArcRotateCamera;
  126465. /**
  126466. * Gets the class name of the current input.
  126467. * @returns the class name
  126468. */
  126469. getClassName(): string;
  126470. /**
  126471. * Defines the buttons associated with the input to handle camera move.
  126472. */
  126473. buttons: number[];
  126474. /**
  126475. * Defines the pointer angular sensibility along the X axis or how fast is
  126476. * the camera rotating.
  126477. */
  126478. angularSensibilityX: number;
  126479. /**
  126480. * Defines the pointer angular sensibility along the Y axis or how fast is
  126481. * the camera rotating.
  126482. */
  126483. angularSensibilityY: number;
  126484. /**
  126485. * Defines the pointer pinch precision or how fast is the camera zooming.
  126486. */
  126487. pinchPrecision: number;
  126488. /**
  126489. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126490. * from 0.
  126491. * It defines the percentage of current camera.radius to use as delta when
  126492. * pinch zoom is used.
  126493. */
  126494. pinchDeltaPercentage: number;
  126495. /**
  126496. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126497. * that any object in the plane at the camera's target point will scale
  126498. * perfectly with finger motion.
  126499. * Overrides pinchDeltaPercentage and pinchPrecision.
  126500. */
  126501. useNaturalPinchZoom: boolean;
  126502. /**
  126503. * Defines the pointer panning sensibility or how fast is the camera moving.
  126504. */
  126505. panningSensibility: number;
  126506. /**
  126507. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126508. */
  126509. multiTouchPanning: boolean;
  126510. /**
  126511. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126512. * zoom (pinch) through multitouch.
  126513. */
  126514. multiTouchPanAndZoom: boolean;
  126515. /**
  126516. * Revers pinch action direction.
  126517. */
  126518. pinchInwards: boolean;
  126519. private _isPanClick;
  126520. private _twoFingerActivityCount;
  126521. private _isPinching;
  126522. /**
  126523. * Called on pointer POINTERMOVE event if only a single touch is active.
  126524. */
  126525. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126526. /**
  126527. * Called on pointer POINTERDOUBLETAP event.
  126528. */
  126529. protected onDoubleTap(type: string): void;
  126530. /**
  126531. * Called on pointer POINTERMOVE event if multiple touches are active.
  126532. */
  126533. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126534. /**
  126535. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126536. * press.
  126537. */
  126538. protected onButtonDown(evt: PointerEvent): void;
  126539. /**
  126540. * Called each time a new POINTERUP event occurs. Ie, for each button
  126541. * release.
  126542. */
  126543. protected onButtonUp(evt: PointerEvent): void;
  126544. /**
  126545. * Called when window becomes inactive.
  126546. */
  126547. protected onLostFocus(): void;
  126548. }
  126549. }
  126550. declare module BABYLON {
  126551. /**
  126552. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126553. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126554. */
  126555. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126556. /**
  126557. * Defines the camera the input is attached to.
  126558. */
  126559. camera: ArcRotateCamera;
  126560. /**
  126561. * Defines the list of key codes associated with the up action (increase alpha)
  126562. */
  126563. keysUp: number[];
  126564. /**
  126565. * Defines the list of key codes associated with the down action (decrease alpha)
  126566. */
  126567. keysDown: number[];
  126568. /**
  126569. * Defines the list of key codes associated with the left action (increase beta)
  126570. */
  126571. keysLeft: number[];
  126572. /**
  126573. * Defines the list of key codes associated with the right action (decrease beta)
  126574. */
  126575. keysRight: number[];
  126576. /**
  126577. * Defines the list of key codes associated with the reset action.
  126578. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126579. */
  126580. keysReset: number[];
  126581. /**
  126582. * Defines the panning sensibility of the inputs.
  126583. * (How fast is the camera panning)
  126584. */
  126585. panningSensibility: number;
  126586. /**
  126587. * Defines the zooming sensibility of the inputs.
  126588. * (How fast is the camera zooming)
  126589. */
  126590. zoomingSensibility: number;
  126591. /**
  126592. * Defines whether maintaining the alt key down switch the movement mode from
  126593. * orientation to zoom.
  126594. */
  126595. useAltToZoom: boolean;
  126596. /**
  126597. * Rotation speed of the camera
  126598. */
  126599. angularSpeed: number;
  126600. private _keys;
  126601. private _ctrlPressed;
  126602. private _altPressed;
  126603. private _onCanvasBlurObserver;
  126604. private _onKeyboardObserver;
  126605. private _engine;
  126606. private _scene;
  126607. /**
  126608. * Attach the input controls to a specific dom element to get the input from.
  126609. * @param element Defines the element the controls should be listened from
  126610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126611. */
  126612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126613. /**
  126614. * Detach the current controls from the specified dom element.
  126615. * @param element Defines the element to stop listening the inputs from
  126616. */
  126617. detachControl(element: Nullable<HTMLElement>): void;
  126618. /**
  126619. * Update the current camera state depending on the inputs that have been used this frame.
  126620. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126621. */
  126622. checkInputs(): void;
  126623. /**
  126624. * Gets the class name of the current intput.
  126625. * @returns the class name
  126626. */
  126627. getClassName(): string;
  126628. /**
  126629. * Get the friendly name associated with the input class.
  126630. * @returns the input friendly name
  126631. */
  126632. getSimpleName(): string;
  126633. }
  126634. }
  126635. declare module BABYLON {
  126636. /**
  126637. * Manage the mouse wheel inputs to control an arc rotate camera.
  126638. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126639. */
  126640. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126641. /**
  126642. * Defines the camera the input is attached to.
  126643. */
  126644. camera: ArcRotateCamera;
  126645. /**
  126646. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126647. */
  126648. wheelPrecision: number;
  126649. /**
  126650. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126651. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126652. */
  126653. wheelDeltaPercentage: number;
  126654. private _wheel;
  126655. private _observer;
  126656. private computeDeltaFromMouseWheelLegacyEvent;
  126657. /**
  126658. * Attach the input controls to a specific dom element to get the input from.
  126659. * @param element Defines the element the controls should be listened from
  126660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126661. */
  126662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126663. /**
  126664. * Detach the current controls from the specified dom element.
  126665. * @param element Defines the element to stop listening the inputs from
  126666. */
  126667. detachControl(element: Nullable<HTMLElement>): void;
  126668. /**
  126669. * Gets the class name of the current intput.
  126670. * @returns the class name
  126671. */
  126672. getClassName(): string;
  126673. /**
  126674. * Get the friendly name associated with the input class.
  126675. * @returns the input friendly name
  126676. */
  126677. getSimpleName(): string;
  126678. }
  126679. }
  126680. declare module BABYLON {
  126681. /**
  126682. * Default Inputs manager for the ArcRotateCamera.
  126683. * It groups all the default supported inputs for ease of use.
  126684. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126685. */
  126686. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126687. /**
  126688. * Instantiates a new ArcRotateCameraInputsManager.
  126689. * @param camera Defines the camera the inputs belong to
  126690. */
  126691. constructor(camera: ArcRotateCamera);
  126692. /**
  126693. * Add mouse wheel input support to the input manager.
  126694. * @returns the current input manager
  126695. */
  126696. addMouseWheel(): ArcRotateCameraInputsManager;
  126697. /**
  126698. * Add pointers input support to the input manager.
  126699. * @returns the current input manager
  126700. */
  126701. addPointers(): ArcRotateCameraInputsManager;
  126702. /**
  126703. * Add keyboard input support to the input manager.
  126704. * @returns the current input manager
  126705. */
  126706. addKeyboard(): ArcRotateCameraInputsManager;
  126707. }
  126708. }
  126709. declare module BABYLON {
  126710. /**
  126711. * This represents an orbital type of camera.
  126712. *
  126713. * 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.
  126714. * 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.
  126715. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126716. */
  126717. export class ArcRotateCamera extends TargetCamera {
  126718. /**
  126719. * Defines the rotation angle of the camera along the longitudinal axis.
  126720. */
  126721. alpha: number;
  126722. /**
  126723. * Defines the rotation angle of the camera along the latitudinal axis.
  126724. */
  126725. beta: number;
  126726. /**
  126727. * Defines the radius of the camera from it s target point.
  126728. */
  126729. radius: number;
  126730. protected _target: Vector3;
  126731. protected _targetHost: Nullable<AbstractMesh>;
  126732. /**
  126733. * Defines the target point of the camera.
  126734. * The camera looks towards it form the radius distance.
  126735. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126736. */
  126737. get target(): Vector3;
  126738. set target(value: Vector3);
  126739. /**
  126740. * Define the current local position of the camera in the scene
  126741. */
  126742. get position(): Vector3;
  126743. set position(newPosition: Vector3);
  126744. protected _upToYMatrix: Matrix;
  126745. protected _YToUpMatrix: Matrix;
  126746. /**
  126747. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126748. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126749. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126750. */
  126751. set upVector(vec: Vector3);
  126752. get upVector(): Vector3;
  126753. /**
  126754. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126755. */
  126756. setMatUp(): void;
  126757. /**
  126758. * Current inertia value on the longitudinal axis.
  126759. * The bigger this number the longer it will take for the camera to stop.
  126760. */
  126761. inertialAlphaOffset: number;
  126762. /**
  126763. * Current inertia value on the latitudinal axis.
  126764. * The bigger this number the longer it will take for the camera to stop.
  126765. */
  126766. inertialBetaOffset: number;
  126767. /**
  126768. * Current inertia value on the radius axis.
  126769. * The bigger this number the longer it will take for the camera to stop.
  126770. */
  126771. inertialRadiusOffset: number;
  126772. /**
  126773. * Minimum allowed angle on the longitudinal axis.
  126774. * This can help limiting how the Camera is able to move in the scene.
  126775. */
  126776. lowerAlphaLimit: Nullable<number>;
  126777. /**
  126778. * Maximum allowed angle on the longitudinal axis.
  126779. * This can help limiting how the Camera is able to move in the scene.
  126780. */
  126781. upperAlphaLimit: Nullable<number>;
  126782. /**
  126783. * Minimum allowed angle on the latitudinal axis.
  126784. * This can help limiting how the Camera is able to move in the scene.
  126785. */
  126786. lowerBetaLimit: number;
  126787. /**
  126788. * Maximum allowed angle on the latitudinal axis.
  126789. * This can help limiting how the Camera is able to move in the scene.
  126790. */
  126791. upperBetaLimit: number;
  126792. /**
  126793. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126794. * This can help limiting how the Camera is able to move in the scene.
  126795. */
  126796. lowerRadiusLimit: Nullable<number>;
  126797. /**
  126798. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126799. * This can help limiting how the Camera is able to move in the scene.
  126800. */
  126801. upperRadiusLimit: Nullable<number>;
  126802. /**
  126803. * Defines the current inertia value used during panning of the camera along the X axis.
  126804. */
  126805. inertialPanningX: number;
  126806. /**
  126807. * Defines the current inertia value used during panning of the camera along the Y axis.
  126808. */
  126809. inertialPanningY: number;
  126810. /**
  126811. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126812. * Basically if your fingers moves away from more than this distance you will be considered
  126813. * in pinch mode.
  126814. */
  126815. pinchToPanMaxDistance: number;
  126816. /**
  126817. * Defines the maximum distance the camera can pan.
  126818. * This could help keeping the cammera always in your scene.
  126819. */
  126820. panningDistanceLimit: Nullable<number>;
  126821. /**
  126822. * Defines the target of the camera before paning.
  126823. */
  126824. panningOriginTarget: Vector3;
  126825. /**
  126826. * Defines the value of the inertia used during panning.
  126827. * 0 would mean stop inertia and one would mean no decelleration at all.
  126828. */
  126829. panningInertia: number;
  126830. /**
  126831. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126832. */
  126833. get angularSensibilityX(): number;
  126834. set angularSensibilityX(value: number);
  126835. /**
  126836. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126837. */
  126838. get angularSensibilityY(): number;
  126839. set angularSensibilityY(value: number);
  126840. /**
  126841. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126842. */
  126843. get pinchPrecision(): number;
  126844. set pinchPrecision(value: number);
  126845. /**
  126846. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126847. * It will be used instead of pinchDeltaPrecision if different from 0.
  126848. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126849. */
  126850. get pinchDeltaPercentage(): number;
  126851. set pinchDeltaPercentage(value: number);
  126852. /**
  126853. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126854. * and pinch delta percentage.
  126855. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126856. * that any object in the plane at the camera's target point will scale
  126857. * perfectly with finger motion.
  126858. */
  126859. get useNaturalPinchZoom(): boolean;
  126860. set useNaturalPinchZoom(value: boolean);
  126861. /**
  126862. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126863. */
  126864. get panningSensibility(): number;
  126865. set panningSensibility(value: number);
  126866. /**
  126867. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126868. */
  126869. get keysUp(): number[];
  126870. set keysUp(value: number[]);
  126871. /**
  126872. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126873. */
  126874. get keysDown(): number[];
  126875. set keysDown(value: number[]);
  126876. /**
  126877. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126878. */
  126879. get keysLeft(): number[];
  126880. set keysLeft(value: number[]);
  126881. /**
  126882. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126883. */
  126884. get keysRight(): number[];
  126885. set keysRight(value: number[]);
  126886. /**
  126887. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126888. */
  126889. get wheelPrecision(): number;
  126890. set wheelPrecision(value: number);
  126891. /**
  126892. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126893. * It will be used instead of pinchDeltaPrecision if different from 0.
  126894. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126895. */
  126896. get wheelDeltaPercentage(): number;
  126897. set wheelDeltaPercentage(value: number);
  126898. /**
  126899. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126900. */
  126901. zoomOnFactor: number;
  126902. /**
  126903. * Defines a screen offset for the camera position.
  126904. */
  126905. targetScreenOffset: Vector2;
  126906. /**
  126907. * Allows the camera to be completely reversed.
  126908. * If false the camera can not arrive upside down.
  126909. */
  126910. allowUpsideDown: boolean;
  126911. /**
  126912. * Define if double tap/click is used to restore the previously saved state of the camera.
  126913. */
  126914. useInputToRestoreState: boolean;
  126915. /** @hidden */
  126916. _viewMatrix: Matrix;
  126917. /** @hidden */
  126918. _useCtrlForPanning: boolean;
  126919. /** @hidden */
  126920. _panningMouseButton: number;
  126921. /**
  126922. * Defines the input associated to the camera.
  126923. */
  126924. inputs: ArcRotateCameraInputsManager;
  126925. /** @hidden */
  126926. _reset: () => void;
  126927. /**
  126928. * Defines the allowed panning axis.
  126929. */
  126930. panningAxis: Vector3;
  126931. protected _localDirection: Vector3;
  126932. protected _transformedDirection: Vector3;
  126933. private _bouncingBehavior;
  126934. /**
  126935. * Gets the bouncing behavior of the camera if it has been enabled.
  126936. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126937. */
  126938. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126939. /**
  126940. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126941. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126942. */
  126943. get useBouncingBehavior(): boolean;
  126944. set useBouncingBehavior(value: boolean);
  126945. private _framingBehavior;
  126946. /**
  126947. * Gets the framing behavior of the camera if it has been enabled.
  126948. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126949. */
  126950. get framingBehavior(): Nullable<FramingBehavior>;
  126951. /**
  126952. * Defines if the framing behavior of the camera is enabled on the camera.
  126953. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126954. */
  126955. get useFramingBehavior(): boolean;
  126956. set useFramingBehavior(value: boolean);
  126957. private _autoRotationBehavior;
  126958. /**
  126959. * Gets the auto rotation behavior of the camera if it has been enabled.
  126960. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126961. */
  126962. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126963. /**
  126964. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126965. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126966. */
  126967. get useAutoRotationBehavior(): boolean;
  126968. set useAutoRotationBehavior(value: boolean);
  126969. /**
  126970. * Observable triggered when the mesh target has been changed on the camera.
  126971. */
  126972. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126973. /**
  126974. * Event raised when the camera is colliding with a mesh.
  126975. */
  126976. onCollide: (collidedMesh: AbstractMesh) => void;
  126977. /**
  126978. * Defines whether the camera should check collision with the objects oh the scene.
  126979. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126980. */
  126981. checkCollisions: boolean;
  126982. /**
  126983. * Defines the collision radius of the camera.
  126984. * This simulates a sphere around the camera.
  126985. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126986. */
  126987. collisionRadius: Vector3;
  126988. protected _collider: Collider;
  126989. protected _previousPosition: Vector3;
  126990. protected _collisionVelocity: Vector3;
  126991. protected _newPosition: Vector3;
  126992. protected _previousAlpha: number;
  126993. protected _previousBeta: number;
  126994. protected _previousRadius: number;
  126995. protected _collisionTriggered: boolean;
  126996. protected _targetBoundingCenter: Nullable<Vector3>;
  126997. private _computationVector;
  126998. /**
  126999. * Instantiates a new ArcRotateCamera in a given scene
  127000. * @param name Defines the name of the camera
  127001. * @param alpha Defines the camera rotation along the logitudinal axis
  127002. * @param beta Defines the camera rotation along the latitudinal axis
  127003. * @param radius Defines the camera distance from its target
  127004. * @param target Defines the camera target
  127005. * @param scene Defines the scene the camera belongs to
  127006. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  127007. */
  127008. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127009. /** @hidden */
  127010. _initCache(): void;
  127011. /** @hidden */
  127012. _updateCache(ignoreParentClass?: boolean): void;
  127013. protected _getTargetPosition(): Vector3;
  127014. private _storedAlpha;
  127015. private _storedBeta;
  127016. private _storedRadius;
  127017. private _storedTarget;
  127018. private _storedTargetScreenOffset;
  127019. /**
  127020. * Stores the current state of the camera (alpha, beta, radius and target)
  127021. * @returns the camera itself
  127022. */
  127023. storeState(): Camera;
  127024. /**
  127025. * @hidden
  127026. * Restored camera state. You must call storeState() first
  127027. */
  127028. _restoreStateValues(): boolean;
  127029. /** @hidden */
  127030. _isSynchronizedViewMatrix(): boolean;
  127031. /**
  127032. * Attached controls to the current camera.
  127033. * @param element Defines the element the controls should be listened from
  127034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127035. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127036. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  127037. */
  127038. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  127039. /**
  127040. * Detach the current controls from the camera.
  127041. * The camera will stop reacting to inputs.
  127042. * @param element Defines the element to stop listening the inputs from
  127043. */
  127044. detachControl(element: HTMLElement): void;
  127045. /** @hidden */
  127046. _checkInputs(): void;
  127047. protected _checkLimits(): void;
  127048. /**
  127049. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127050. */
  127051. rebuildAnglesAndRadius(): void;
  127052. /**
  127053. * Use a position to define the current camera related information like alpha, beta and radius
  127054. * @param position Defines the position to set the camera at
  127055. */
  127056. setPosition(position: Vector3): void;
  127057. /**
  127058. * Defines the target the camera should look at.
  127059. * This will automatically adapt alpha beta and radius to fit within the new target.
  127060. * @param target Defines the new target as a Vector or a mesh
  127061. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127062. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127063. */
  127064. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127065. /** @hidden */
  127066. _getViewMatrix(): Matrix;
  127067. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127068. /**
  127069. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127070. * @param meshes Defines the mesh to zoom on
  127071. * @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)
  127072. */
  127073. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127074. /**
  127075. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127076. * The target will be changed but the radius
  127077. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127078. * @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)
  127079. */
  127080. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127081. min: Vector3;
  127082. max: Vector3;
  127083. distance: number;
  127084. }, doNotUpdateMaxZ?: boolean): void;
  127085. /**
  127086. * @override
  127087. * Override Camera.createRigCamera
  127088. */
  127089. createRigCamera(name: string, cameraIndex: number): Camera;
  127090. /**
  127091. * @hidden
  127092. * @override
  127093. * Override Camera._updateRigCameras
  127094. */
  127095. _updateRigCameras(): void;
  127096. /**
  127097. * Destroy the camera and release the current resources hold by it.
  127098. */
  127099. dispose(): void;
  127100. /**
  127101. * Gets the current object class name.
  127102. * @return the class name
  127103. */
  127104. getClassName(): string;
  127105. }
  127106. }
  127107. declare module BABYLON {
  127108. /**
  127109. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127110. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127111. */
  127112. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127113. /**
  127114. * Gets the name of the behavior.
  127115. */
  127116. get name(): string;
  127117. private _zoomStopsAnimation;
  127118. private _idleRotationSpeed;
  127119. private _idleRotationWaitTime;
  127120. private _idleRotationSpinupTime;
  127121. /**
  127122. * Sets the flag that indicates if user zooming should stop animation.
  127123. */
  127124. set zoomStopsAnimation(flag: boolean);
  127125. /**
  127126. * Gets the flag that indicates if user zooming should stop animation.
  127127. */
  127128. get zoomStopsAnimation(): boolean;
  127129. /**
  127130. * Sets the default speed at which the camera rotates around the model.
  127131. */
  127132. set idleRotationSpeed(speed: number);
  127133. /**
  127134. * Gets the default speed at which the camera rotates around the model.
  127135. */
  127136. get idleRotationSpeed(): number;
  127137. /**
  127138. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127139. */
  127140. set idleRotationWaitTime(time: number);
  127141. /**
  127142. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127143. */
  127144. get idleRotationWaitTime(): number;
  127145. /**
  127146. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127147. */
  127148. set idleRotationSpinupTime(time: number);
  127149. /**
  127150. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127151. */
  127152. get idleRotationSpinupTime(): number;
  127153. /**
  127154. * Gets a value indicating if the camera is currently rotating because of this behavior
  127155. */
  127156. get rotationInProgress(): boolean;
  127157. private _onPrePointerObservableObserver;
  127158. private _onAfterCheckInputsObserver;
  127159. private _attachedCamera;
  127160. private _isPointerDown;
  127161. private _lastFrameTime;
  127162. private _lastInteractionTime;
  127163. private _cameraRotationSpeed;
  127164. /**
  127165. * Initializes the behavior.
  127166. */
  127167. init(): void;
  127168. /**
  127169. * Attaches the behavior to its arc rotate camera.
  127170. * @param camera Defines the camera to attach the behavior to
  127171. */
  127172. attach(camera: ArcRotateCamera): void;
  127173. /**
  127174. * Detaches the behavior from its current arc rotate camera.
  127175. */
  127176. detach(): void;
  127177. /**
  127178. * Returns true if user is scrolling.
  127179. * @return true if user is scrolling.
  127180. */
  127181. private _userIsZooming;
  127182. private _lastFrameRadius;
  127183. private _shouldAnimationStopForInteraction;
  127184. /**
  127185. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127186. */
  127187. private _applyUserInteraction;
  127188. private _userIsMoving;
  127189. }
  127190. }
  127191. declare module BABYLON {
  127192. /**
  127193. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127194. */
  127195. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127196. private ui;
  127197. /**
  127198. * The name of the behavior
  127199. */
  127200. name: string;
  127201. /**
  127202. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127203. */
  127204. distanceAwayFromFace: number;
  127205. /**
  127206. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127207. */
  127208. distanceAwayFromBottomOfFace: number;
  127209. private _faceVectors;
  127210. private _target;
  127211. private _scene;
  127212. private _onRenderObserver;
  127213. private _tmpMatrix;
  127214. private _tmpVector;
  127215. /**
  127216. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127217. * @param ui The transform node that should be attched to the mesh
  127218. */
  127219. constructor(ui: TransformNode);
  127220. /**
  127221. * Initializes the behavior
  127222. */
  127223. init(): void;
  127224. private _closestFace;
  127225. private _zeroVector;
  127226. private _lookAtTmpMatrix;
  127227. private _lookAtToRef;
  127228. /**
  127229. * Attaches the AttachToBoxBehavior to the passed in mesh
  127230. * @param target The mesh that the specified node will be attached to
  127231. */
  127232. attach(target: Mesh): void;
  127233. /**
  127234. * Detaches the behavior from the mesh
  127235. */
  127236. detach(): void;
  127237. }
  127238. }
  127239. declare module BABYLON {
  127240. /**
  127241. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127242. */
  127243. export class FadeInOutBehavior implements Behavior<Mesh> {
  127244. /**
  127245. * Time in milliseconds to delay before fading in (Default: 0)
  127246. */
  127247. delay: number;
  127248. /**
  127249. * Time in milliseconds for the mesh to fade in (Default: 300)
  127250. */
  127251. fadeInTime: number;
  127252. private _millisecondsPerFrame;
  127253. private _hovered;
  127254. private _hoverValue;
  127255. private _ownerNode;
  127256. /**
  127257. * Instatiates the FadeInOutBehavior
  127258. */
  127259. constructor();
  127260. /**
  127261. * The name of the behavior
  127262. */
  127263. get name(): string;
  127264. /**
  127265. * Initializes the behavior
  127266. */
  127267. init(): void;
  127268. /**
  127269. * Attaches the fade behavior on the passed in mesh
  127270. * @param ownerNode The mesh that will be faded in/out once attached
  127271. */
  127272. attach(ownerNode: Mesh): void;
  127273. /**
  127274. * Detaches the behavior from the mesh
  127275. */
  127276. detach(): void;
  127277. /**
  127278. * Triggers the mesh to begin fading in or out
  127279. * @param value if the object should fade in or out (true to fade in)
  127280. */
  127281. fadeIn(value: boolean): void;
  127282. private _update;
  127283. private _setAllVisibility;
  127284. }
  127285. }
  127286. declare module BABYLON {
  127287. /**
  127288. * Class containing a set of static utilities functions for managing Pivots
  127289. * @hidden
  127290. */
  127291. export class PivotTools {
  127292. private static _PivotCached;
  127293. private static _OldPivotPoint;
  127294. private static _PivotTranslation;
  127295. private static _PivotTmpVector;
  127296. private static _PivotPostMultiplyPivotMatrix;
  127297. /** @hidden */
  127298. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127299. /** @hidden */
  127300. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127301. }
  127302. }
  127303. declare module BABYLON {
  127304. /**
  127305. * Class containing static functions to help procedurally build meshes
  127306. */
  127307. export class PlaneBuilder {
  127308. /**
  127309. * Creates a plane mesh
  127310. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127311. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127312. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127316. * @param name defines the name of the mesh
  127317. * @param options defines the options used to create the mesh
  127318. * @param scene defines the hosting scene
  127319. * @returns the plane mesh
  127320. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127321. */
  127322. static CreatePlane(name: string, options: {
  127323. size?: number;
  127324. width?: number;
  127325. height?: number;
  127326. sideOrientation?: number;
  127327. frontUVs?: Vector4;
  127328. backUVs?: Vector4;
  127329. updatable?: boolean;
  127330. sourcePlane?: Plane;
  127331. }, scene?: Nullable<Scene>): Mesh;
  127332. }
  127333. }
  127334. declare module BABYLON {
  127335. /**
  127336. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127337. */
  127338. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127339. private static _AnyMouseID;
  127340. /**
  127341. * Abstract mesh the behavior is set on
  127342. */
  127343. attachedNode: AbstractMesh;
  127344. private _dragPlane;
  127345. private _scene;
  127346. private _pointerObserver;
  127347. private _beforeRenderObserver;
  127348. private static _planeScene;
  127349. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127350. /**
  127351. * 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)
  127352. */
  127353. maxDragAngle: number;
  127354. /**
  127355. * @hidden
  127356. */
  127357. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127358. /**
  127359. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127360. */
  127361. currentDraggingPointerID: number;
  127362. /**
  127363. * The last position where the pointer hit the drag plane in world space
  127364. */
  127365. lastDragPosition: Vector3;
  127366. /**
  127367. * If the behavior is currently in a dragging state
  127368. */
  127369. dragging: boolean;
  127370. /**
  127371. * 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)
  127372. */
  127373. dragDeltaRatio: number;
  127374. /**
  127375. * If the drag plane orientation should be updated during the dragging (Default: true)
  127376. */
  127377. updateDragPlane: boolean;
  127378. private _debugMode;
  127379. private _moving;
  127380. /**
  127381. * Fires each time the attached mesh is dragged with the pointer
  127382. * * delta between last drag position and current drag position in world space
  127383. * * dragDistance along the drag axis
  127384. * * dragPlaneNormal normal of the current drag plane used during the drag
  127385. * * dragPlanePoint in world space where the drag intersects the drag plane
  127386. */
  127387. onDragObservable: Observable<{
  127388. delta: Vector3;
  127389. dragPlanePoint: Vector3;
  127390. dragPlaneNormal: Vector3;
  127391. dragDistance: number;
  127392. pointerId: number;
  127393. }>;
  127394. /**
  127395. * Fires each time a drag begins (eg. mouse down on mesh)
  127396. */
  127397. onDragStartObservable: Observable<{
  127398. dragPlanePoint: Vector3;
  127399. pointerId: number;
  127400. }>;
  127401. /**
  127402. * Fires each time a drag ends (eg. mouse release after drag)
  127403. */
  127404. onDragEndObservable: Observable<{
  127405. dragPlanePoint: Vector3;
  127406. pointerId: number;
  127407. }>;
  127408. /**
  127409. * If the attached mesh should be moved when dragged
  127410. */
  127411. moveAttached: boolean;
  127412. /**
  127413. * If the drag behavior will react to drag events (Default: true)
  127414. */
  127415. enabled: boolean;
  127416. /**
  127417. * If pointer events should start and release the drag (Default: true)
  127418. */
  127419. startAndReleaseDragOnPointerEvents: boolean;
  127420. /**
  127421. * If camera controls should be detached during the drag
  127422. */
  127423. detachCameraControls: boolean;
  127424. /**
  127425. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127426. */
  127427. useObjectOrientationForDragging: boolean;
  127428. private _options;
  127429. /**
  127430. * Gets the options used by the behavior
  127431. */
  127432. get options(): {
  127433. dragAxis?: Vector3;
  127434. dragPlaneNormal?: Vector3;
  127435. };
  127436. /**
  127437. * Sets the options used by the behavior
  127438. */
  127439. set options(options: {
  127440. dragAxis?: Vector3;
  127441. dragPlaneNormal?: Vector3;
  127442. });
  127443. /**
  127444. * Creates a pointer drag behavior that can be attached to a mesh
  127445. * @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)
  127446. */
  127447. constructor(options?: {
  127448. dragAxis?: Vector3;
  127449. dragPlaneNormal?: Vector3;
  127450. });
  127451. /**
  127452. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127453. */
  127454. validateDrag: (targetPosition: Vector3) => boolean;
  127455. /**
  127456. * The name of the behavior
  127457. */
  127458. get name(): string;
  127459. /**
  127460. * Initializes the behavior
  127461. */
  127462. init(): void;
  127463. private _tmpVector;
  127464. private _alternatePickedPoint;
  127465. private _worldDragAxis;
  127466. private _targetPosition;
  127467. private _attachedElement;
  127468. /**
  127469. * Attaches the drag behavior the passed in mesh
  127470. * @param ownerNode The mesh that will be dragged around once attached
  127471. * @param predicate Predicate to use for pick filtering
  127472. */
  127473. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127474. /**
  127475. * Force relase the drag action by code.
  127476. */
  127477. releaseDrag(): void;
  127478. private _startDragRay;
  127479. private _lastPointerRay;
  127480. /**
  127481. * Simulates the start of a pointer drag event on the behavior
  127482. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127483. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127484. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127485. */
  127486. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127487. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127488. private _dragDelta;
  127489. protected _moveDrag(ray: Ray): void;
  127490. private _pickWithRayOnDragPlane;
  127491. private _pointA;
  127492. private _pointC;
  127493. private _localAxis;
  127494. private _lookAt;
  127495. private _updateDragPlanePosition;
  127496. /**
  127497. * Detaches the behavior from the mesh
  127498. */
  127499. detach(): void;
  127500. }
  127501. }
  127502. declare module BABYLON {
  127503. /**
  127504. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127505. */
  127506. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127507. private _dragBehaviorA;
  127508. private _dragBehaviorB;
  127509. private _startDistance;
  127510. private _initialScale;
  127511. private _targetScale;
  127512. private _ownerNode;
  127513. private _sceneRenderObserver;
  127514. /**
  127515. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127516. */
  127517. constructor();
  127518. /**
  127519. * The name of the behavior
  127520. */
  127521. get name(): string;
  127522. /**
  127523. * Initializes the behavior
  127524. */
  127525. init(): void;
  127526. private _getCurrentDistance;
  127527. /**
  127528. * Attaches the scale behavior the passed in mesh
  127529. * @param ownerNode The mesh that will be scaled around once attached
  127530. */
  127531. attach(ownerNode: Mesh): void;
  127532. /**
  127533. * Detaches the behavior from the mesh
  127534. */
  127535. detach(): void;
  127536. }
  127537. }
  127538. declare module BABYLON {
  127539. /**
  127540. * 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
  127541. */
  127542. export class SixDofDragBehavior implements Behavior<Mesh> {
  127543. private static _virtualScene;
  127544. private _ownerNode;
  127545. private _sceneRenderObserver;
  127546. private _scene;
  127547. private _targetPosition;
  127548. private _virtualOriginMesh;
  127549. private _virtualDragMesh;
  127550. private _pointerObserver;
  127551. private _moving;
  127552. private _startingOrientation;
  127553. private _attachedElement;
  127554. /**
  127555. * 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)
  127556. */
  127557. private zDragFactor;
  127558. /**
  127559. * If the object should rotate to face the drag origin
  127560. */
  127561. rotateDraggedObject: boolean;
  127562. /**
  127563. * If the behavior is currently in a dragging state
  127564. */
  127565. dragging: boolean;
  127566. /**
  127567. * 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)
  127568. */
  127569. dragDeltaRatio: number;
  127570. /**
  127571. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127572. */
  127573. currentDraggingPointerID: number;
  127574. /**
  127575. * If camera controls should be detached during the drag
  127576. */
  127577. detachCameraControls: boolean;
  127578. /**
  127579. * Fires each time a drag starts
  127580. */
  127581. onDragStartObservable: Observable<{}>;
  127582. /**
  127583. * Fires each time a drag ends (eg. mouse release after drag)
  127584. */
  127585. onDragEndObservable: Observable<{}>;
  127586. /**
  127587. * 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
  127588. */
  127589. constructor();
  127590. /**
  127591. * The name of the behavior
  127592. */
  127593. get name(): string;
  127594. /**
  127595. * Initializes the behavior
  127596. */
  127597. init(): void;
  127598. /**
  127599. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127600. */
  127601. private get _pointerCamera();
  127602. /**
  127603. * Attaches the scale behavior the passed in mesh
  127604. * @param ownerNode The mesh that will be scaled around once attached
  127605. */
  127606. attach(ownerNode: Mesh): void;
  127607. /**
  127608. * Detaches the behavior from the mesh
  127609. */
  127610. detach(): void;
  127611. }
  127612. }
  127613. declare module BABYLON {
  127614. /**
  127615. * Class used to apply inverse kinematics to bones
  127616. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127617. */
  127618. export class BoneIKController {
  127619. private static _tmpVecs;
  127620. private static _tmpQuat;
  127621. private static _tmpMats;
  127622. /**
  127623. * Gets or sets the target mesh
  127624. */
  127625. targetMesh: AbstractMesh;
  127626. /** Gets or sets the mesh used as pole */
  127627. poleTargetMesh: AbstractMesh;
  127628. /**
  127629. * Gets or sets the bone used as pole
  127630. */
  127631. poleTargetBone: Nullable<Bone>;
  127632. /**
  127633. * Gets or sets the target position
  127634. */
  127635. targetPosition: Vector3;
  127636. /**
  127637. * Gets or sets the pole target position
  127638. */
  127639. poleTargetPosition: Vector3;
  127640. /**
  127641. * Gets or sets the pole target local offset
  127642. */
  127643. poleTargetLocalOffset: Vector3;
  127644. /**
  127645. * Gets or sets the pole angle
  127646. */
  127647. poleAngle: number;
  127648. /**
  127649. * Gets or sets the mesh associated with the controller
  127650. */
  127651. mesh: AbstractMesh;
  127652. /**
  127653. * 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)
  127654. */
  127655. slerpAmount: number;
  127656. private _bone1Quat;
  127657. private _bone1Mat;
  127658. private _bone2Ang;
  127659. private _bone1;
  127660. private _bone2;
  127661. private _bone1Length;
  127662. private _bone2Length;
  127663. private _maxAngle;
  127664. private _maxReach;
  127665. private _rightHandedSystem;
  127666. private _bendAxis;
  127667. private _slerping;
  127668. private _adjustRoll;
  127669. /**
  127670. * Gets or sets maximum allowed angle
  127671. */
  127672. get maxAngle(): number;
  127673. set maxAngle(value: number);
  127674. /**
  127675. * Creates a new BoneIKController
  127676. * @param mesh defines the mesh to control
  127677. * @param bone defines the bone to control
  127678. * @param options defines options to set up the controller
  127679. */
  127680. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127681. targetMesh?: AbstractMesh;
  127682. poleTargetMesh?: AbstractMesh;
  127683. poleTargetBone?: Bone;
  127684. poleTargetLocalOffset?: Vector3;
  127685. poleAngle?: number;
  127686. bendAxis?: Vector3;
  127687. maxAngle?: number;
  127688. slerpAmount?: number;
  127689. });
  127690. private _setMaxAngle;
  127691. /**
  127692. * Force the controller to update the bones
  127693. */
  127694. update(): void;
  127695. }
  127696. }
  127697. declare module BABYLON {
  127698. /**
  127699. * Class used to make a bone look toward a point in space
  127700. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127701. */
  127702. export class BoneLookController {
  127703. private static _tmpVecs;
  127704. private static _tmpQuat;
  127705. private static _tmpMats;
  127706. /**
  127707. * The target Vector3 that the bone will look at
  127708. */
  127709. target: Vector3;
  127710. /**
  127711. * The mesh that the bone is attached to
  127712. */
  127713. mesh: AbstractMesh;
  127714. /**
  127715. * The bone that will be looking to the target
  127716. */
  127717. bone: Bone;
  127718. /**
  127719. * The up axis of the coordinate system that is used when the bone is rotated
  127720. */
  127721. upAxis: Vector3;
  127722. /**
  127723. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127724. */
  127725. upAxisSpace: Space;
  127726. /**
  127727. * Used to make an adjustment to the yaw of the bone
  127728. */
  127729. adjustYaw: number;
  127730. /**
  127731. * Used to make an adjustment to the pitch of the bone
  127732. */
  127733. adjustPitch: number;
  127734. /**
  127735. * Used to make an adjustment to the roll of the bone
  127736. */
  127737. adjustRoll: number;
  127738. /**
  127739. * 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)
  127740. */
  127741. slerpAmount: number;
  127742. private _minYaw;
  127743. private _maxYaw;
  127744. private _minPitch;
  127745. private _maxPitch;
  127746. private _minYawSin;
  127747. private _minYawCos;
  127748. private _maxYawSin;
  127749. private _maxYawCos;
  127750. private _midYawConstraint;
  127751. private _minPitchTan;
  127752. private _maxPitchTan;
  127753. private _boneQuat;
  127754. private _slerping;
  127755. private _transformYawPitch;
  127756. private _transformYawPitchInv;
  127757. private _firstFrameSkipped;
  127758. private _yawRange;
  127759. private _fowardAxis;
  127760. /**
  127761. * Gets or sets the minimum yaw angle that the bone can look to
  127762. */
  127763. get minYaw(): number;
  127764. set minYaw(value: number);
  127765. /**
  127766. * Gets or sets the maximum yaw angle that the bone can look to
  127767. */
  127768. get maxYaw(): number;
  127769. set maxYaw(value: number);
  127770. /**
  127771. * Gets or sets the minimum pitch angle that the bone can look to
  127772. */
  127773. get minPitch(): number;
  127774. set minPitch(value: number);
  127775. /**
  127776. * Gets or sets the maximum pitch angle that the bone can look to
  127777. */
  127778. get maxPitch(): number;
  127779. set maxPitch(value: number);
  127780. /**
  127781. * Create a BoneLookController
  127782. * @param mesh the mesh that the bone belongs to
  127783. * @param bone the bone that will be looking to the target
  127784. * @param target the target Vector3 to look at
  127785. * @param options optional settings:
  127786. * * maxYaw: the maximum angle the bone will yaw to
  127787. * * minYaw: the minimum angle the bone will yaw to
  127788. * * maxPitch: the maximum angle the bone will pitch to
  127789. * * minPitch: the minimum angle the bone will yaw to
  127790. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127791. * * upAxis: the up axis of the coordinate system
  127792. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127793. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127794. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127795. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127796. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127797. * * adjustRoll: used to make an adjustment to the roll of the bone
  127798. **/
  127799. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127800. maxYaw?: number;
  127801. minYaw?: number;
  127802. maxPitch?: number;
  127803. minPitch?: number;
  127804. slerpAmount?: number;
  127805. upAxis?: Vector3;
  127806. upAxisSpace?: Space;
  127807. yawAxis?: Vector3;
  127808. pitchAxis?: Vector3;
  127809. adjustYaw?: number;
  127810. adjustPitch?: number;
  127811. adjustRoll?: number;
  127812. });
  127813. /**
  127814. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127815. */
  127816. update(): void;
  127817. private _getAngleDiff;
  127818. private _getAngleBetween;
  127819. private _isAngleBetween;
  127820. }
  127821. }
  127822. declare module BABYLON {
  127823. /**
  127824. * Manage the gamepad inputs to control an arc rotate camera.
  127825. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127826. */
  127827. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127828. /**
  127829. * Defines the camera the input is attached to.
  127830. */
  127831. camera: ArcRotateCamera;
  127832. /**
  127833. * Defines the gamepad the input is gathering event from.
  127834. */
  127835. gamepad: Nullable<Gamepad>;
  127836. /**
  127837. * Defines the gamepad rotation sensiblity.
  127838. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127839. */
  127840. gamepadRotationSensibility: number;
  127841. /**
  127842. * Defines the gamepad move sensiblity.
  127843. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127844. */
  127845. gamepadMoveSensibility: number;
  127846. private _yAxisScale;
  127847. /**
  127848. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127849. */
  127850. get invertYAxis(): boolean;
  127851. set invertYAxis(value: boolean);
  127852. private _onGamepadConnectedObserver;
  127853. private _onGamepadDisconnectedObserver;
  127854. /**
  127855. * Attach the input controls to a specific dom element to get the input from.
  127856. * @param element Defines the element the controls should be listened from
  127857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127858. */
  127859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127860. /**
  127861. * Detach the current controls from the specified dom element.
  127862. * @param element Defines the element to stop listening the inputs from
  127863. */
  127864. detachControl(element: Nullable<HTMLElement>): void;
  127865. /**
  127866. * Update the current camera state depending on the inputs that have been used this frame.
  127867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127868. */
  127869. checkInputs(): void;
  127870. /**
  127871. * Gets the class name of the current intput.
  127872. * @returns the class name
  127873. */
  127874. getClassName(): string;
  127875. /**
  127876. * Get the friendly name associated with the input class.
  127877. * @returns the input friendly name
  127878. */
  127879. getSimpleName(): string;
  127880. }
  127881. }
  127882. declare module BABYLON {
  127883. interface ArcRotateCameraInputsManager {
  127884. /**
  127885. * Add orientation input support to the input manager.
  127886. * @returns the current input manager
  127887. */
  127888. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127889. }
  127890. /**
  127891. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127892. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127893. */
  127894. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127895. /**
  127896. * Defines the camera the input is attached to.
  127897. */
  127898. camera: ArcRotateCamera;
  127899. /**
  127900. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127901. */
  127902. alphaCorrection: number;
  127903. /**
  127904. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127905. */
  127906. gammaCorrection: number;
  127907. private _alpha;
  127908. private _gamma;
  127909. private _dirty;
  127910. private _deviceOrientationHandler;
  127911. /**
  127912. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127913. */
  127914. constructor();
  127915. /**
  127916. * Attach the input controls to a specific dom element to get the input from.
  127917. * @param element Defines the element the controls should be listened from
  127918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127919. */
  127920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127921. /** @hidden */
  127922. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127923. /**
  127924. * Update the current camera state depending on the inputs that have been used this frame.
  127925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127926. */
  127927. checkInputs(): void;
  127928. /**
  127929. * Detach the current controls from the specified dom element.
  127930. * @param element Defines the element to stop listening the inputs from
  127931. */
  127932. detachControl(element: Nullable<HTMLElement>): void;
  127933. /**
  127934. * Gets the class name of the current intput.
  127935. * @returns the class name
  127936. */
  127937. getClassName(): string;
  127938. /**
  127939. * Get the friendly name associated with the input class.
  127940. * @returns the input friendly name
  127941. */
  127942. getSimpleName(): string;
  127943. }
  127944. }
  127945. declare module BABYLON {
  127946. /**
  127947. * Listen to mouse events to control the camera.
  127948. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127949. */
  127950. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127951. /**
  127952. * Defines the camera the input is attached to.
  127953. */
  127954. camera: FlyCamera;
  127955. /**
  127956. * Defines if touch is enabled. (Default is true.)
  127957. */
  127958. touchEnabled: boolean;
  127959. /**
  127960. * Defines the buttons associated with the input to handle camera rotation.
  127961. */
  127962. buttons: number[];
  127963. /**
  127964. * Assign buttons for Yaw control.
  127965. */
  127966. buttonsYaw: number[];
  127967. /**
  127968. * Assign buttons for Pitch control.
  127969. */
  127970. buttonsPitch: number[];
  127971. /**
  127972. * Assign buttons for Roll control.
  127973. */
  127974. buttonsRoll: number[];
  127975. /**
  127976. * Detect if any button is being pressed while mouse is moved.
  127977. * -1 = Mouse locked.
  127978. * 0 = Left button.
  127979. * 1 = Middle Button.
  127980. * 2 = Right Button.
  127981. */
  127982. activeButton: number;
  127983. /**
  127984. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127985. * Higher values reduce its sensitivity.
  127986. */
  127987. angularSensibility: number;
  127988. private _observer;
  127989. private _rollObserver;
  127990. private previousPosition;
  127991. private noPreventDefault;
  127992. private element;
  127993. /**
  127994. * Listen to mouse events to control the camera.
  127995. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127996. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127997. */
  127998. constructor(touchEnabled?: boolean);
  127999. /**
  128000. * Attach the mouse control to the HTML DOM element.
  128001. * @param element Defines the element that listens to the input events.
  128002. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  128003. */
  128004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128005. /**
  128006. * Detach the current controls from the specified dom element.
  128007. * @param element Defines the element to stop listening the inputs from
  128008. */
  128009. detachControl(element: Nullable<HTMLElement>): void;
  128010. /**
  128011. * Gets the class name of the current input.
  128012. * @returns the class name.
  128013. */
  128014. getClassName(): string;
  128015. /**
  128016. * Get the friendly name associated with the input class.
  128017. * @returns the input's friendly name.
  128018. */
  128019. getSimpleName(): string;
  128020. private _pointerInput;
  128021. private _onMouseMove;
  128022. /**
  128023. * Rotate camera by mouse offset.
  128024. */
  128025. private rotateCamera;
  128026. }
  128027. }
  128028. declare module BABYLON {
  128029. /**
  128030. * Default Inputs manager for the FlyCamera.
  128031. * It groups all the default supported inputs for ease of use.
  128032. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128033. */
  128034. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  128035. /**
  128036. * Instantiates a new FlyCameraInputsManager.
  128037. * @param camera Defines the camera the inputs belong to.
  128038. */
  128039. constructor(camera: FlyCamera);
  128040. /**
  128041. * Add keyboard input support to the input manager.
  128042. * @returns the new FlyCameraKeyboardMoveInput().
  128043. */
  128044. addKeyboard(): FlyCameraInputsManager;
  128045. /**
  128046. * Add mouse input support to the input manager.
  128047. * @param touchEnabled Enable touch screen support.
  128048. * @returns the new FlyCameraMouseInput().
  128049. */
  128050. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128051. }
  128052. }
  128053. declare module BABYLON {
  128054. /**
  128055. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128056. * such as in a 3D Space Shooter or a Flight Simulator.
  128057. */
  128058. export class FlyCamera extends TargetCamera {
  128059. /**
  128060. * Define the collision ellipsoid of the camera.
  128061. * This is helpful for simulating a camera body, like a player's body.
  128062. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128063. */
  128064. ellipsoid: Vector3;
  128065. /**
  128066. * Define an offset for the position of the ellipsoid around the camera.
  128067. * This can be helpful if the camera is attached away from the player's body center,
  128068. * such as at its head.
  128069. */
  128070. ellipsoidOffset: Vector3;
  128071. /**
  128072. * Enable or disable collisions of the camera with the rest of the scene objects.
  128073. */
  128074. checkCollisions: boolean;
  128075. /**
  128076. * Enable or disable gravity on the camera.
  128077. */
  128078. applyGravity: boolean;
  128079. /**
  128080. * Define the current direction the camera is moving to.
  128081. */
  128082. cameraDirection: Vector3;
  128083. /**
  128084. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128085. * This overrides and empties cameraRotation.
  128086. */
  128087. rotationQuaternion: Quaternion;
  128088. /**
  128089. * Track Roll to maintain the wanted Rolling when looking around.
  128090. */
  128091. _trackRoll: number;
  128092. /**
  128093. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128094. */
  128095. rollCorrect: number;
  128096. /**
  128097. * Mimic a banked turn, Rolling the camera when Yawing.
  128098. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128099. */
  128100. bankedTurn: boolean;
  128101. /**
  128102. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128103. */
  128104. bankedTurnLimit: number;
  128105. /**
  128106. * Value of 0 disables the banked Roll.
  128107. * Value of 1 is equal to the Yaw angle in radians.
  128108. */
  128109. bankedTurnMultiplier: number;
  128110. /**
  128111. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128112. */
  128113. inputs: FlyCameraInputsManager;
  128114. /**
  128115. * Gets the input sensibility for mouse input.
  128116. * Higher values reduce sensitivity.
  128117. */
  128118. get angularSensibility(): number;
  128119. /**
  128120. * Sets the input sensibility for a mouse input.
  128121. * Higher values reduce sensitivity.
  128122. */
  128123. set angularSensibility(value: number);
  128124. /**
  128125. * Get the keys for camera movement forward.
  128126. */
  128127. get keysForward(): number[];
  128128. /**
  128129. * Set the keys for camera movement forward.
  128130. */
  128131. set keysForward(value: number[]);
  128132. /**
  128133. * Get the keys for camera movement backward.
  128134. */
  128135. get keysBackward(): number[];
  128136. set keysBackward(value: number[]);
  128137. /**
  128138. * Get the keys for camera movement up.
  128139. */
  128140. get keysUp(): number[];
  128141. /**
  128142. * Set the keys for camera movement up.
  128143. */
  128144. set keysUp(value: number[]);
  128145. /**
  128146. * Get the keys for camera movement down.
  128147. */
  128148. get keysDown(): number[];
  128149. /**
  128150. * Set the keys for camera movement down.
  128151. */
  128152. set keysDown(value: number[]);
  128153. /**
  128154. * Get the keys for camera movement left.
  128155. */
  128156. get keysLeft(): number[];
  128157. /**
  128158. * Set the keys for camera movement left.
  128159. */
  128160. set keysLeft(value: number[]);
  128161. /**
  128162. * Set the keys for camera movement right.
  128163. */
  128164. get keysRight(): number[];
  128165. /**
  128166. * Set the keys for camera movement right.
  128167. */
  128168. set keysRight(value: number[]);
  128169. /**
  128170. * Event raised when the camera collides with a mesh in the scene.
  128171. */
  128172. onCollide: (collidedMesh: AbstractMesh) => void;
  128173. private _collider;
  128174. private _needMoveForGravity;
  128175. private _oldPosition;
  128176. private _diffPosition;
  128177. private _newPosition;
  128178. /** @hidden */
  128179. _localDirection: Vector3;
  128180. /** @hidden */
  128181. _transformedDirection: Vector3;
  128182. /**
  128183. * Instantiates a FlyCamera.
  128184. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128185. * such as in a 3D Space Shooter or a Flight Simulator.
  128186. * @param name Define the name of the camera in the scene.
  128187. * @param position Define the starting position of the camera in the scene.
  128188. * @param scene Define the scene the camera belongs to.
  128189. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128190. */
  128191. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128192. /**
  128193. * Attach a control to the HTML DOM element.
  128194. * @param element Defines the element that listens to the input events.
  128195. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128196. */
  128197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128198. /**
  128199. * Detach a control from the HTML DOM element.
  128200. * The camera will stop reacting to that input.
  128201. * @param element Defines the element that listens to the input events.
  128202. */
  128203. detachControl(element: HTMLElement): void;
  128204. private _collisionMask;
  128205. /**
  128206. * Get the mask that the camera ignores in collision events.
  128207. */
  128208. get collisionMask(): number;
  128209. /**
  128210. * Set the mask that the camera ignores in collision events.
  128211. */
  128212. set collisionMask(mask: number);
  128213. /** @hidden */
  128214. _collideWithWorld(displacement: Vector3): void;
  128215. /** @hidden */
  128216. private _onCollisionPositionChange;
  128217. /** @hidden */
  128218. _checkInputs(): void;
  128219. /** @hidden */
  128220. _decideIfNeedsToMove(): boolean;
  128221. /** @hidden */
  128222. _updatePosition(): void;
  128223. /**
  128224. * Restore the Roll to its target value at the rate specified.
  128225. * @param rate - Higher means slower restoring.
  128226. * @hidden
  128227. */
  128228. restoreRoll(rate: number): void;
  128229. /**
  128230. * Destroy the camera and release the current resources held by it.
  128231. */
  128232. dispose(): void;
  128233. /**
  128234. * Get the current object class name.
  128235. * @returns the class name.
  128236. */
  128237. getClassName(): string;
  128238. }
  128239. }
  128240. declare module BABYLON {
  128241. /**
  128242. * Listen to keyboard events to control the camera.
  128243. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128244. */
  128245. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128246. /**
  128247. * Defines the camera the input is attached to.
  128248. */
  128249. camera: FlyCamera;
  128250. /**
  128251. * The list of keyboard keys used to control the forward move of the camera.
  128252. */
  128253. keysForward: number[];
  128254. /**
  128255. * The list of keyboard keys used to control the backward move of the camera.
  128256. */
  128257. keysBackward: number[];
  128258. /**
  128259. * The list of keyboard keys used to control the forward move of the camera.
  128260. */
  128261. keysUp: number[];
  128262. /**
  128263. * The list of keyboard keys used to control the backward move of the camera.
  128264. */
  128265. keysDown: number[];
  128266. /**
  128267. * The list of keyboard keys used to control the right strafe move of the camera.
  128268. */
  128269. keysRight: number[];
  128270. /**
  128271. * The list of keyboard keys used to control the left strafe move of the camera.
  128272. */
  128273. keysLeft: number[];
  128274. private _keys;
  128275. private _onCanvasBlurObserver;
  128276. private _onKeyboardObserver;
  128277. private _engine;
  128278. private _scene;
  128279. /**
  128280. * Attach the input controls to a specific dom element to get the input from.
  128281. * @param element Defines the element the controls should be listened from
  128282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128283. */
  128284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128285. /**
  128286. * Detach the current controls from the specified dom element.
  128287. * @param element Defines the element to stop listening the inputs from
  128288. */
  128289. detachControl(element: Nullable<HTMLElement>): void;
  128290. /**
  128291. * Gets the class name of the current intput.
  128292. * @returns the class name
  128293. */
  128294. getClassName(): string;
  128295. /** @hidden */
  128296. _onLostFocus(e: FocusEvent): void;
  128297. /**
  128298. * Get the friendly name associated with the input class.
  128299. * @returns the input friendly name
  128300. */
  128301. getSimpleName(): string;
  128302. /**
  128303. * Update the current camera state depending on the inputs that have been used this frame.
  128304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128305. */
  128306. checkInputs(): void;
  128307. }
  128308. }
  128309. declare module BABYLON {
  128310. /**
  128311. * Manage the mouse wheel inputs to control a follow camera.
  128312. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128313. */
  128314. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128315. /**
  128316. * Defines the camera the input is attached to.
  128317. */
  128318. camera: FollowCamera;
  128319. /**
  128320. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128321. */
  128322. axisControlRadius: boolean;
  128323. /**
  128324. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128325. */
  128326. axisControlHeight: boolean;
  128327. /**
  128328. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128329. */
  128330. axisControlRotation: boolean;
  128331. /**
  128332. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128333. * relation to mouseWheel events.
  128334. */
  128335. wheelPrecision: number;
  128336. /**
  128337. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128338. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128339. */
  128340. wheelDeltaPercentage: number;
  128341. private _wheel;
  128342. private _observer;
  128343. /**
  128344. * Attach the input controls to a specific dom element to get the input from.
  128345. * @param element Defines the element the controls should be listened from
  128346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128347. */
  128348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128349. /**
  128350. * Detach the current controls from the specified dom element.
  128351. * @param element Defines the element to stop listening the inputs from
  128352. */
  128353. detachControl(element: Nullable<HTMLElement>): void;
  128354. /**
  128355. * Gets the class name of the current intput.
  128356. * @returns the class name
  128357. */
  128358. getClassName(): string;
  128359. /**
  128360. * Get the friendly name associated with the input class.
  128361. * @returns the input friendly name
  128362. */
  128363. getSimpleName(): string;
  128364. }
  128365. }
  128366. declare module BABYLON {
  128367. /**
  128368. * Manage the pointers inputs to control an follow camera.
  128369. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128370. */
  128371. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128372. /**
  128373. * Defines the camera the input is attached to.
  128374. */
  128375. camera: FollowCamera;
  128376. /**
  128377. * Gets the class name of the current input.
  128378. * @returns the class name
  128379. */
  128380. getClassName(): string;
  128381. /**
  128382. * Defines the pointer angular sensibility along the X axis or how fast is
  128383. * the camera rotating.
  128384. * A negative number will reverse the axis direction.
  128385. */
  128386. angularSensibilityX: number;
  128387. /**
  128388. * Defines the pointer angular sensibility along the Y axis or how fast is
  128389. * the camera rotating.
  128390. * A negative number will reverse the axis direction.
  128391. */
  128392. angularSensibilityY: number;
  128393. /**
  128394. * Defines the pointer pinch precision or how fast is the camera zooming.
  128395. * A negative number will reverse the axis direction.
  128396. */
  128397. pinchPrecision: number;
  128398. /**
  128399. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128400. * from 0.
  128401. * It defines the percentage of current camera.radius to use as delta when
  128402. * pinch zoom is used.
  128403. */
  128404. pinchDeltaPercentage: number;
  128405. /**
  128406. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128407. */
  128408. axisXControlRadius: boolean;
  128409. /**
  128410. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128411. */
  128412. axisXControlHeight: boolean;
  128413. /**
  128414. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128415. */
  128416. axisXControlRotation: boolean;
  128417. /**
  128418. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128419. */
  128420. axisYControlRadius: boolean;
  128421. /**
  128422. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128423. */
  128424. axisYControlHeight: boolean;
  128425. /**
  128426. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128427. */
  128428. axisYControlRotation: boolean;
  128429. /**
  128430. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128431. */
  128432. axisPinchControlRadius: boolean;
  128433. /**
  128434. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128435. */
  128436. axisPinchControlHeight: boolean;
  128437. /**
  128438. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128439. */
  128440. axisPinchControlRotation: boolean;
  128441. /**
  128442. * Log error messages if basic misconfiguration has occurred.
  128443. */
  128444. warningEnable: boolean;
  128445. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128446. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128447. private _warningCounter;
  128448. private _warning;
  128449. }
  128450. }
  128451. declare module BABYLON {
  128452. /**
  128453. * Default Inputs manager for the FollowCamera.
  128454. * It groups all the default supported inputs for ease of use.
  128455. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128456. */
  128457. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128458. /**
  128459. * Instantiates a new FollowCameraInputsManager.
  128460. * @param camera Defines the camera the inputs belong to
  128461. */
  128462. constructor(camera: FollowCamera);
  128463. /**
  128464. * Add keyboard input support to the input manager.
  128465. * @returns the current input manager
  128466. */
  128467. addKeyboard(): FollowCameraInputsManager;
  128468. /**
  128469. * Add mouse wheel input support to the input manager.
  128470. * @returns the current input manager
  128471. */
  128472. addMouseWheel(): FollowCameraInputsManager;
  128473. /**
  128474. * Add pointers input support to the input manager.
  128475. * @returns the current input manager
  128476. */
  128477. addPointers(): FollowCameraInputsManager;
  128478. /**
  128479. * Add orientation input support to the input manager.
  128480. * @returns the current input manager
  128481. */
  128482. addVRDeviceOrientation(): FollowCameraInputsManager;
  128483. }
  128484. }
  128485. declare module BABYLON {
  128486. /**
  128487. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128488. * an arc rotate version arcFollowCamera are available.
  128489. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128490. */
  128491. export class FollowCamera extends TargetCamera {
  128492. /**
  128493. * Distance the follow camera should follow an object at
  128494. */
  128495. radius: number;
  128496. /**
  128497. * Minimum allowed distance of the camera to the axis of rotation
  128498. * (The camera can not get closer).
  128499. * This can help limiting how the Camera is able to move in the scene.
  128500. */
  128501. lowerRadiusLimit: Nullable<number>;
  128502. /**
  128503. * Maximum allowed distance of the camera to the axis of rotation
  128504. * (The camera can not get further).
  128505. * This can help limiting how the Camera is able to move in the scene.
  128506. */
  128507. upperRadiusLimit: Nullable<number>;
  128508. /**
  128509. * Define a rotation offset between the camera and the object it follows
  128510. */
  128511. rotationOffset: number;
  128512. /**
  128513. * Minimum allowed angle to camera position relative to target object.
  128514. * This can help limiting how the Camera is able to move in the scene.
  128515. */
  128516. lowerRotationOffsetLimit: Nullable<number>;
  128517. /**
  128518. * Maximum allowed angle to camera position relative to target object.
  128519. * This can help limiting how the Camera is able to move in the scene.
  128520. */
  128521. upperRotationOffsetLimit: Nullable<number>;
  128522. /**
  128523. * Define a height offset between the camera and the object it follows.
  128524. * It can help following an object from the top (like a car chaing a plane)
  128525. */
  128526. heightOffset: number;
  128527. /**
  128528. * Minimum allowed height of camera position relative to target object.
  128529. * This can help limiting how the Camera is able to move in the scene.
  128530. */
  128531. lowerHeightOffsetLimit: Nullable<number>;
  128532. /**
  128533. * Maximum allowed height of camera position relative to target object.
  128534. * This can help limiting how the Camera is able to move in the scene.
  128535. */
  128536. upperHeightOffsetLimit: Nullable<number>;
  128537. /**
  128538. * Define how fast the camera can accelerate to follow it s target.
  128539. */
  128540. cameraAcceleration: number;
  128541. /**
  128542. * Define the speed limit of the camera following an object.
  128543. */
  128544. maxCameraSpeed: number;
  128545. /**
  128546. * Define the target of the camera.
  128547. */
  128548. lockedTarget: Nullable<AbstractMesh>;
  128549. /**
  128550. * Defines the input associated with the camera.
  128551. */
  128552. inputs: FollowCameraInputsManager;
  128553. /**
  128554. * Instantiates the follow camera.
  128555. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128556. * @param name Define the name of the camera in the scene
  128557. * @param position Define the position of the camera
  128558. * @param scene Define the scene the camera belong to
  128559. * @param lockedTarget Define the target of the camera
  128560. */
  128561. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128562. private _follow;
  128563. /**
  128564. * Attached controls to the current camera.
  128565. * @param element Defines the element the controls should be listened from
  128566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128567. */
  128568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128569. /**
  128570. * Detach the current controls from the camera.
  128571. * The camera will stop reacting to inputs.
  128572. * @param element Defines the element to stop listening the inputs from
  128573. */
  128574. detachControl(element: HTMLElement): void;
  128575. /** @hidden */
  128576. _checkInputs(): void;
  128577. private _checkLimits;
  128578. /**
  128579. * Gets the camera class name.
  128580. * @returns the class name
  128581. */
  128582. getClassName(): string;
  128583. }
  128584. /**
  128585. * Arc Rotate version of the follow camera.
  128586. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128587. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128588. */
  128589. export class ArcFollowCamera extends TargetCamera {
  128590. /** The longitudinal angle of the camera */
  128591. alpha: number;
  128592. /** The latitudinal angle of the camera */
  128593. beta: number;
  128594. /** The radius of the camera from its target */
  128595. radius: number;
  128596. private _cartesianCoordinates;
  128597. /** Define the camera target (the mesh it should follow) */
  128598. private _meshTarget;
  128599. /**
  128600. * Instantiates a new ArcFollowCamera
  128601. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128602. * @param name Define the name of the camera
  128603. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128604. * @param beta Define the rotation angle of the camera around the elevation axis
  128605. * @param radius Define the radius of the camera from its target point
  128606. * @param target Define the target of the camera
  128607. * @param scene Define the scene the camera belongs to
  128608. */
  128609. constructor(name: string,
  128610. /** The longitudinal angle of the camera */
  128611. alpha: number,
  128612. /** The latitudinal angle of the camera */
  128613. beta: number,
  128614. /** The radius of the camera from its target */
  128615. radius: number,
  128616. /** Define the camera target (the mesh it should follow) */
  128617. target: Nullable<AbstractMesh>, scene: Scene);
  128618. private _follow;
  128619. /** @hidden */
  128620. _checkInputs(): void;
  128621. /**
  128622. * Returns the class name of the object.
  128623. * It is mostly used internally for serialization purposes.
  128624. */
  128625. getClassName(): string;
  128626. }
  128627. }
  128628. declare module BABYLON {
  128629. /**
  128630. * Manage the keyboard inputs to control the movement of a follow camera.
  128631. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128632. */
  128633. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128634. /**
  128635. * Defines the camera the input is attached to.
  128636. */
  128637. camera: FollowCamera;
  128638. /**
  128639. * Defines the list of key codes associated with the up action (increase heightOffset)
  128640. */
  128641. keysHeightOffsetIncr: number[];
  128642. /**
  128643. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128644. */
  128645. keysHeightOffsetDecr: number[];
  128646. /**
  128647. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128648. */
  128649. keysHeightOffsetModifierAlt: boolean;
  128650. /**
  128651. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128652. */
  128653. keysHeightOffsetModifierCtrl: boolean;
  128654. /**
  128655. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128656. */
  128657. keysHeightOffsetModifierShift: boolean;
  128658. /**
  128659. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128660. */
  128661. keysRotationOffsetIncr: number[];
  128662. /**
  128663. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128664. */
  128665. keysRotationOffsetDecr: number[];
  128666. /**
  128667. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128668. */
  128669. keysRotationOffsetModifierAlt: boolean;
  128670. /**
  128671. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128672. */
  128673. keysRotationOffsetModifierCtrl: boolean;
  128674. /**
  128675. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128676. */
  128677. keysRotationOffsetModifierShift: boolean;
  128678. /**
  128679. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128680. */
  128681. keysRadiusIncr: number[];
  128682. /**
  128683. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128684. */
  128685. keysRadiusDecr: number[];
  128686. /**
  128687. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128688. */
  128689. keysRadiusModifierAlt: boolean;
  128690. /**
  128691. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128692. */
  128693. keysRadiusModifierCtrl: boolean;
  128694. /**
  128695. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128696. */
  128697. keysRadiusModifierShift: boolean;
  128698. /**
  128699. * Defines the rate of change of heightOffset.
  128700. */
  128701. heightSensibility: number;
  128702. /**
  128703. * Defines the rate of change of rotationOffset.
  128704. */
  128705. rotationSensibility: number;
  128706. /**
  128707. * Defines the rate of change of radius.
  128708. */
  128709. radiusSensibility: number;
  128710. private _keys;
  128711. private _ctrlPressed;
  128712. private _altPressed;
  128713. private _shiftPressed;
  128714. private _onCanvasBlurObserver;
  128715. private _onKeyboardObserver;
  128716. private _engine;
  128717. private _scene;
  128718. /**
  128719. * Attach the input controls to a specific dom element to get the input from.
  128720. * @param element Defines the element the controls should be listened from
  128721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128722. */
  128723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128724. /**
  128725. * Detach the current controls from the specified dom element.
  128726. * @param element Defines the element to stop listening the inputs from
  128727. */
  128728. detachControl(element: Nullable<HTMLElement>): void;
  128729. /**
  128730. * Update the current camera state depending on the inputs that have been used this frame.
  128731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128732. */
  128733. checkInputs(): void;
  128734. /**
  128735. * Gets the class name of the current input.
  128736. * @returns the class name
  128737. */
  128738. getClassName(): string;
  128739. /**
  128740. * Get the friendly name associated with the input class.
  128741. * @returns the input friendly name
  128742. */
  128743. getSimpleName(): string;
  128744. /**
  128745. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128746. * allow modification of the heightOffset value.
  128747. */
  128748. private _modifierHeightOffset;
  128749. /**
  128750. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128751. * allow modification of the rotationOffset value.
  128752. */
  128753. private _modifierRotationOffset;
  128754. /**
  128755. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128756. * allow modification of the radius value.
  128757. */
  128758. private _modifierRadius;
  128759. }
  128760. }
  128761. declare module BABYLON {
  128762. interface FreeCameraInputsManager {
  128763. /**
  128764. * @hidden
  128765. */
  128766. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128767. /**
  128768. * Add orientation input support to the input manager.
  128769. * @returns the current input manager
  128770. */
  128771. addDeviceOrientation(): FreeCameraInputsManager;
  128772. }
  128773. /**
  128774. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128775. * Screen rotation is taken into account.
  128776. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128777. */
  128778. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128779. private _camera;
  128780. private _screenOrientationAngle;
  128781. private _constantTranform;
  128782. private _screenQuaternion;
  128783. private _alpha;
  128784. private _beta;
  128785. private _gamma;
  128786. /**
  128787. * Can be used to detect if a device orientation sensor is available on a device
  128788. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128789. * @returns a promise that will resolve on orientation change
  128790. */
  128791. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128792. /**
  128793. * @hidden
  128794. */
  128795. _onDeviceOrientationChangedObservable: Observable<void>;
  128796. /**
  128797. * Instantiates a new input
  128798. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128799. */
  128800. constructor();
  128801. /**
  128802. * Define the camera controlled by the input.
  128803. */
  128804. get camera(): FreeCamera;
  128805. set camera(camera: FreeCamera);
  128806. /**
  128807. * Attach the input controls to a specific dom element to get the input from.
  128808. * @param element Defines the element the controls should be listened from
  128809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128810. */
  128811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128812. private _orientationChanged;
  128813. private _deviceOrientation;
  128814. /**
  128815. * Detach the current controls from the specified dom element.
  128816. * @param element Defines the element to stop listening the inputs from
  128817. */
  128818. detachControl(element: Nullable<HTMLElement>): void;
  128819. /**
  128820. * Update the current camera state depending on the inputs that have been used this frame.
  128821. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128822. */
  128823. checkInputs(): void;
  128824. /**
  128825. * Gets the class name of the current intput.
  128826. * @returns the class name
  128827. */
  128828. getClassName(): string;
  128829. /**
  128830. * Get the friendly name associated with the input class.
  128831. * @returns the input friendly name
  128832. */
  128833. getSimpleName(): string;
  128834. }
  128835. }
  128836. declare module BABYLON {
  128837. /**
  128838. * Manage the gamepad inputs to control a free camera.
  128839. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128840. */
  128841. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128842. /**
  128843. * Define the camera the input is attached to.
  128844. */
  128845. camera: FreeCamera;
  128846. /**
  128847. * Define the Gamepad controlling the input
  128848. */
  128849. gamepad: Nullable<Gamepad>;
  128850. /**
  128851. * Defines the gamepad rotation sensiblity.
  128852. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128853. */
  128854. gamepadAngularSensibility: number;
  128855. /**
  128856. * Defines the gamepad move sensiblity.
  128857. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128858. */
  128859. gamepadMoveSensibility: number;
  128860. private _yAxisScale;
  128861. /**
  128862. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128863. */
  128864. get invertYAxis(): boolean;
  128865. set invertYAxis(value: boolean);
  128866. private _onGamepadConnectedObserver;
  128867. private _onGamepadDisconnectedObserver;
  128868. private _cameraTransform;
  128869. private _deltaTransform;
  128870. private _vector3;
  128871. private _vector2;
  128872. /**
  128873. * Attach the input controls to a specific dom element to get the input from.
  128874. * @param element Defines the element the controls should be listened from
  128875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128876. */
  128877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128878. /**
  128879. * Detach the current controls from the specified dom element.
  128880. * @param element Defines the element to stop listening the inputs from
  128881. */
  128882. detachControl(element: Nullable<HTMLElement>): void;
  128883. /**
  128884. * Update the current camera state depending on the inputs that have been used this frame.
  128885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128886. */
  128887. checkInputs(): void;
  128888. /**
  128889. * Gets the class name of the current intput.
  128890. * @returns the class name
  128891. */
  128892. getClassName(): string;
  128893. /**
  128894. * Get the friendly name associated with the input class.
  128895. * @returns the input friendly name
  128896. */
  128897. getSimpleName(): string;
  128898. }
  128899. }
  128900. declare module BABYLON {
  128901. /**
  128902. * Defines the potential axis of a Joystick
  128903. */
  128904. export enum JoystickAxis {
  128905. /** X axis */
  128906. X = 0,
  128907. /** Y axis */
  128908. Y = 1,
  128909. /** Z axis */
  128910. Z = 2
  128911. }
  128912. /**
  128913. * Represents the different customization options available
  128914. * for VirtualJoystick
  128915. */
  128916. interface VirtualJoystickCustomizations {
  128917. /**
  128918. * Size of the joystick's puck
  128919. */
  128920. puckSize: number;
  128921. /**
  128922. * Size of the joystick's container
  128923. */
  128924. containerSize: number;
  128925. /**
  128926. * Color of the joystick && puck
  128927. */
  128928. color: string;
  128929. /**
  128930. * Image URL for the joystick's puck
  128931. */
  128932. puckImage?: string;
  128933. /**
  128934. * Image URL for the joystick's container
  128935. */
  128936. containerImage?: string;
  128937. /**
  128938. * Defines the unmoving position of the joystick container
  128939. */
  128940. position?: {
  128941. x: number;
  128942. y: number;
  128943. };
  128944. /**
  128945. * Defines whether or not the joystick container is always visible
  128946. */
  128947. alwaysVisible: boolean;
  128948. /**
  128949. * Defines whether or not to limit the movement of the puck to the joystick's container
  128950. */
  128951. limitToContainer: boolean;
  128952. }
  128953. /**
  128954. * Class used to define virtual joystick (used in touch mode)
  128955. */
  128956. export class VirtualJoystick {
  128957. /**
  128958. * Gets or sets a boolean indicating that left and right values must be inverted
  128959. */
  128960. reverseLeftRight: boolean;
  128961. /**
  128962. * Gets or sets a boolean indicating that up and down values must be inverted
  128963. */
  128964. reverseUpDown: boolean;
  128965. /**
  128966. * Gets the offset value for the position (ie. the change of the position value)
  128967. */
  128968. deltaPosition: Vector3;
  128969. /**
  128970. * Gets a boolean indicating if the virtual joystick was pressed
  128971. */
  128972. pressed: boolean;
  128973. /**
  128974. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128975. */
  128976. static Canvas: Nullable<HTMLCanvasElement>;
  128977. /**
  128978. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128979. */
  128980. limitToContainer: boolean;
  128981. private static _globalJoystickIndex;
  128982. private static _alwaysVisibleSticks;
  128983. private static vjCanvasContext;
  128984. private static vjCanvasWidth;
  128985. private static vjCanvasHeight;
  128986. private static halfWidth;
  128987. private static _GetDefaultOptions;
  128988. private _action;
  128989. private _axisTargetedByLeftAndRight;
  128990. private _axisTargetedByUpAndDown;
  128991. private _joystickSensibility;
  128992. private _inversedSensibility;
  128993. private _joystickPointerID;
  128994. private _joystickColor;
  128995. private _joystickPointerPos;
  128996. private _joystickPreviousPointerPos;
  128997. private _joystickPointerStartPos;
  128998. private _deltaJoystickVector;
  128999. private _leftJoystick;
  129000. private _touches;
  129001. private _joystickPosition;
  129002. private _alwaysVisible;
  129003. private _puckImage;
  129004. private _containerImage;
  129005. private _joystickPuckSize;
  129006. private _joystickContainerSize;
  129007. private _clearPuckSize;
  129008. private _clearContainerSize;
  129009. private _clearPuckSizeOffset;
  129010. private _clearContainerSizeOffset;
  129011. private _onPointerDownHandlerRef;
  129012. private _onPointerMoveHandlerRef;
  129013. private _onPointerUpHandlerRef;
  129014. private _onResize;
  129015. /**
  129016. * Creates a new virtual joystick
  129017. * @param leftJoystick defines that the joystick is for left hand (false by default)
  129018. * @param customizations Defines the options we want to customize the VirtualJoystick
  129019. */
  129020. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  129021. /**
  129022. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  129023. * @param newJoystickSensibility defines the new sensibility
  129024. */
  129025. setJoystickSensibility(newJoystickSensibility: number): void;
  129026. private _onPointerDown;
  129027. private _onPointerMove;
  129028. private _onPointerUp;
  129029. /**
  129030. * Change the color of the virtual joystick
  129031. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  129032. */
  129033. setJoystickColor(newColor: string): void;
  129034. /**
  129035. * Size of the joystick's container
  129036. */
  129037. set containerSize(newSize: number);
  129038. get containerSize(): number;
  129039. /**
  129040. * Size of the joystick's puck
  129041. */
  129042. set puckSize(newSize: number);
  129043. get puckSize(): number;
  129044. /**
  129045. * Clears the set position of the joystick
  129046. */
  129047. clearPosition(): void;
  129048. /**
  129049. * Defines whether or not the joystick container is always visible
  129050. */
  129051. set alwaysVisible(value: boolean);
  129052. get alwaysVisible(): boolean;
  129053. /**
  129054. * Sets the constant position of the Joystick container
  129055. * @param x X axis coordinate
  129056. * @param y Y axis coordinate
  129057. */
  129058. setPosition(x: number, y: number): void;
  129059. /**
  129060. * Defines a callback to call when the joystick is touched
  129061. * @param action defines the callback
  129062. */
  129063. setActionOnTouch(action: () => any): void;
  129064. /**
  129065. * Defines which axis you'd like to control for left & right
  129066. * @param axis defines the axis to use
  129067. */
  129068. setAxisForLeftRight(axis: JoystickAxis): void;
  129069. /**
  129070. * Defines which axis you'd like to control for up & down
  129071. * @param axis defines the axis to use
  129072. */
  129073. setAxisForUpDown(axis: JoystickAxis): void;
  129074. /**
  129075. * Clears the canvas from the previous puck / container draw
  129076. */
  129077. private _clearPreviousDraw;
  129078. /**
  129079. * Loads `urlPath` to be used for the container's image
  129080. * @param urlPath defines the urlPath of an image to use
  129081. */
  129082. setContainerImage(urlPath: string): void;
  129083. /**
  129084. * Loads `urlPath` to be used for the puck's image
  129085. * @param urlPath defines the urlPath of an image to use
  129086. */
  129087. setPuckImage(urlPath: string): void;
  129088. /**
  129089. * Draws the Virtual Joystick's container
  129090. */
  129091. private _drawContainer;
  129092. /**
  129093. * Draws the Virtual Joystick's puck
  129094. */
  129095. private _drawPuck;
  129096. private _drawVirtualJoystick;
  129097. /**
  129098. * Release internal HTML canvas
  129099. */
  129100. releaseCanvas(): void;
  129101. }
  129102. }
  129103. declare module BABYLON {
  129104. interface FreeCameraInputsManager {
  129105. /**
  129106. * Add virtual joystick input support to the input manager.
  129107. * @returns the current input manager
  129108. */
  129109. addVirtualJoystick(): FreeCameraInputsManager;
  129110. }
  129111. /**
  129112. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129113. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129114. */
  129115. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129116. /**
  129117. * Defines the camera the input is attached to.
  129118. */
  129119. camera: FreeCamera;
  129120. private _leftjoystick;
  129121. private _rightjoystick;
  129122. /**
  129123. * Gets the left stick of the virtual joystick.
  129124. * @returns The virtual Joystick
  129125. */
  129126. getLeftJoystick(): VirtualJoystick;
  129127. /**
  129128. * Gets the right stick of the virtual joystick.
  129129. * @returns The virtual Joystick
  129130. */
  129131. getRightJoystick(): VirtualJoystick;
  129132. /**
  129133. * Update the current camera state depending on the inputs that have been used this frame.
  129134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129135. */
  129136. checkInputs(): void;
  129137. /**
  129138. * Attach the input controls to a specific dom element to get the input from.
  129139. * @param element Defines the element the controls should be listened from
  129140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129141. */
  129142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129143. /**
  129144. * Detach the current controls from the specified dom element.
  129145. * @param element Defines the element to stop listening the inputs from
  129146. */
  129147. detachControl(element: Nullable<HTMLElement>): void;
  129148. /**
  129149. * Gets the class name of the current intput.
  129150. * @returns the class name
  129151. */
  129152. getClassName(): string;
  129153. /**
  129154. * Get the friendly name associated with the input class.
  129155. * @returns the input friendly name
  129156. */
  129157. getSimpleName(): string;
  129158. }
  129159. }
  129160. declare module BABYLON {
  129161. /**
  129162. * This represents a FPS type of camera controlled by touch.
  129163. * This is like a universal camera minus the Gamepad controls.
  129164. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129165. */
  129166. export class TouchCamera extends FreeCamera {
  129167. /**
  129168. * Defines the touch sensibility for rotation.
  129169. * The higher the faster.
  129170. */
  129171. get touchAngularSensibility(): number;
  129172. set touchAngularSensibility(value: number);
  129173. /**
  129174. * Defines the touch sensibility for move.
  129175. * The higher the faster.
  129176. */
  129177. get touchMoveSensibility(): number;
  129178. set touchMoveSensibility(value: number);
  129179. /**
  129180. * Instantiates a new touch camera.
  129181. * This represents a FPS type of camera controlled by touch.
  129182. * This is like a universal camera minus the Gamepad controls.
  129183. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129184. * @param name Define the name of the camera in the scene
  129185. * @param position Define the start position of the camera in the scene
  129186. * @param scene Define the scene the camera belongs to
  129187. */
  129188. constructor(name: string, position: Vector3, scene: Scene);
  129189. /**
  129190. * Gets the current object class name.
  129191. * @return the class name
  129192. */
  129193. getClassName(): string;
  129194. /** @hidden */
  129195. _setupInputs(): void;
  129196. }
  129197. }
  129198. declare module BABYLON {
  129199. /**
  129200. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129201. * being tilted forward or back and left or right.
  129202. */
  129203. export class DeviceOrientationCamera extends FreeCamera {
  129204. private _initialQuaternion;
  129205. private _quaternionCache;
  129206. private _tmpDragQuaternion;
  129207. private _disablePointerInputWhenUsingDeviceOrientation;
  129208. /**
  129209. * Creates a new device orientation camera
  129210. * @param name The name of the camera
  129211. * @param position The start position camera
  129212. * @param scene The scene the camera belongs to
  129213. */
  129214. constructor(name: string, position: Vector3, scene: Scene);
  129215. /**
  129216. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129217. */
  129218. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129219. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129220. private _dragFactor;
  129221. /**
  129222. * Enabled turning on the y axis when the orientation sensor is active
  129223. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129224. */
  129225. enableHorizontalDragging(dragFactor?: number): void;
  129226. /**
  129227. * Gets the current instance class name ("DeviceOrientationCamera").
  129228. * This helps avoiding instanceof at run time.
  129229. * @returns the class name
  129230. */
  129231. getClassName(): string;
  129232. /**
  129233. * @hidden
  129234. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129235. */
  129236. _checkInputs(): void;
  129237. /**
  129238. * Reset the camera to its default orientation on the specified axis only.
  129239. * @param axis The axis to reset
  129240. */
  129241. resetToCurrentRotation(axis?: Axis): void;
  129242. }
  129243. }
  129244. declare module BABYLON {
  129245. /**
  129246. * Defines supported buttons for XBox360 compatible gamepads
  129247. */
  129248. export enum Xbox360Button {
  129249. /** A */
  129250. A = 0,
  129251. /** B */
  129252. B = 1,
  129253. /** X */
  129254. X = 2,
  129255. /** Y */
  129256. Y = 3,
  129257. /** Left button */
  129258. LB = 4,
  129259. /** Right button */
  129260. RB = 5,
  129261. /** Back */
  129262. Back = 8,
  129263. /** Start */
  129264. Start = 9,
  129265. /** Left stick */
  129266. LeftStick = 10,
  129267. /** Right stick */
  129268. RightStick = 11
  129269. }
  129270. /** Defines values for XBox360 DPad */
  129271. export enum Xbox360Dpad {
  129272. /** Up */
  129273. Up = 12,
  129274. /** Down */
  129275. Down = 13,
  129276. /** Left */
  129277. Left = 14,
  129278. /** Right */
  129279. Right = 15
  129280. }
  129281. /**
  129282. * Defines a XBox360 gamepad
  129283. */
  129284. export class Xbox360Pad extends Gamepad {
  129285. private _leftTrigger;
  129286. private _rightTrigger;
  129287. private _onlefttriggerchanged;
  129288. private _onrighttriggerchanged;
  129289. private _onbuttondown;
  129290. private _onbuttonup;
  129291. private _ondpaddown;
  129292. private _ondpadup;
  129293. /** Observable raised when a button is pressed */
  129294. onButtonDownObservable: Observable<Xbox360Button>;
  129295. /** Observable raised when a button is released */
  129296. onButtonUpObservable: Observable<Xbox360Button>;
  129297. /** Observable raised when a pad is pressed */
  129298. onPadDownObservable: Observable<Xbox360Dpad>;
  129299. /** Observable raised when a pad is released */
  129300. onPadUpObservable: Observable<Xbox360Dpad>;
  129301. private _buttonA;
  129302. private _buttonB;
  129303. private _buttonX;
  129304. private _buttonY;
  129305. private _buttonBack;
  129306. private _buttonStart;
  129307. private _buttonLB;
  129308. private _buttonRB;
  129309. private _buttonLeftStick;
  129310. private _buttonRightStick;
  129311. private _dPadUp;
  129312. private _dPadDown;
  129313. private _dPadLeft;
  129314. private _dPadRight;
  129315. private _isXboxOnePad;
  129316. /**
  129317. * Creates a new XBox360 gamepad object
  129318. * @param id defines the id of this gamepad
  129319. * @param index defines its index
  129320. * @param gamepad defines the internal HTML gamepad object
  129321. * @param xboxOne defines if it is a XBox One gamepad
  129322. */
  129323. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129324. /**
  129325. * Defines the callback to call when left trigger is pressed
  129326. * @param callback defines the callback to use
  129327. */
  129328. onlefttriggerchanged(callback: (value: number) => void): void;
  129329. /**
  129330. * Defines the callback to call when right trigger is pressed
  129331. * @param callback defines the callback to use
  129332. */
  129333. onrighttriggerchanged(callback: (value: number) => void): void;
  129334. /**
  129335. * Gets the left trigger value
  129336. */
  129337. get leftTrigger(): number;
  129338. /**
  129339. * Sets the left trigger value
  129340. */
  129341. set leftTrigger(newValue: number);
  129342. /**
  129343. * Gets the right trigger value
  129344. */
  129345. get rightTrigger(): number;
  129346. /**
  129347. * Sets the right trigger value
  129348. */
  129349. set rightTrigger(newValue: number);
  129350. /**
  129351. * Defines the callback to call when a button is pressed
  129352. * @param callback defines the callback to use
  129353. */
  129354. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129355. /**
  129356. * Defines the callback to call when a button is released
  129357. * @param callback defines the callback to use
  129358. */
  129359. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129360. /**
  129361. * Defines the callback to call when a pad is pressed
  129362. * @param callback defines the callback to use
  129363. */
  129364. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129365. /**
  129366. * Defines the callback to call when a pad is released
  129367. * @param callback defines the callback to use
  129368. */
  129369. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129370. private _setButtonValue;
  129371. private _setDPadValue;
  129372. /**
  129373. * Gets the value of the `A` button
  129374. */
  129375. get buttonA(): number;
  129376. /**
  129377. * Sets the value of the `A` button
  129378. */
  129379. set buttonA(value: number);
  129380. /**
  129381. * Gets the value of the `B` button
  129382. */
  129383. get buttonB(): number;
  129384. /**
  129385. * Sets the value of the `B` button
  129386. */
  129387. set buttonB(value: number);
  129388. /**
  129389. * Gets the value of the `X` button
  129390. */
  129391. get buttonX(): number;
  129392. /**
  129393. * Sets the value of the `X` button
  129394. */
  129395. set buttonX(value: number);
  129396. /**
  129397. * Gets the value of the `Y` button
  129398. */
  129399. get buttonY(): number;
  129400. /**
  129401. * Sets the value of the `Y` button
  129402. */
  129403. set buttonY(value: number);
  129404. /**
  129405. * Gets the value of the `Start` button
  129406. */
  129407. get buttonStart(): number;
  129408. /**
  129409. * Sets the value of the `Start` button
  129410. */
  129411. set buttonStart(value: number);
  129412. /**
  129413. * Gets the value of the `Back` button
  129414. */
  129415. get buttonBack(): number;
  129416. /**
  129417. * Sets the value of the `Back` button
  129418. */
  129419. set buttonBack(value: number);
  129420. /**
  129421. * Gets the value of the `Left` button
  129422. */
  129423. get buttonLB(): number;
  129424. /**
  129425. * Sets the value of the `Left` button
  129426. */
  129427. set buttonLB(value: number);
  129428. /**
  129429. * Gets the value of the `Right` button
  129430. */
  129431. get buttonRB(): number;
  129432. /**
  129433. * Sets the value of the `Right` button
  129434. */
  129435. set buttonRB(value: number);
  129436. /**
  129437. * Gets the value of the Left joystick
  129438. */
  129439. get buttonLeftStick(): number;
  129440. /**
  129441. * Sets the value of the Left joystick
  129442. */
  129443. set buttonLeftStick(value: number);
  129444. /**
  129445. * Gets the value of the Right joystick
  129446. */
  129447. get buttonRightStick(): number;
  129448. /**
  129449. * Sets the value of the Right joystick
  129450. */
  129451. set buttonRightStick(value: number);
  129452. /**
  129453. * Gets the value of D-pad up
  129454. */
  129455. get dPadUp(): number;
  129456. /**
  129457. * Sets the value of D-pad up
  129458. */
  129459. set dPadUp(value: number);
  129460. /**
  129461. * Gets the value of D-pad down
  129462. */
  129463. get dPadDown(): number;
  129464. /**
  129465. * Sets the value of D-pad down
  129466. */
  129467. set dPadDown(value: number);
  129468. /**
  129469. * Gets the value of D-pad left
  129470. */
  129471. get dPadLeft(): number;
  129472. /**
  129473. * Sets the value of D-pad left
  129474. */
  129475. set dPadLeft(value: number);
  129476. /**
  129477. * Gets the value of D-pad right
  129478. */
  129479. get dPadRight(): number;
  129480. /**
  129481. * Sets the value of D-pad right
  129482. */
  129483. set dPadRight(value: number);
  129484. /**
  129485. * Force the gamepad to synchronize with device values
  129486. */
  129487. update(): void;
  129488. /**
  129489. * Disposes the gamepad
  129490. */
  129491. dispose(): void;
  129492. }
  129493. }
  129494. declare module BABYLON {
  129495. /**
  129496. * Defines supported buttons for DualShock compatible gamepads
  129497. */
  129498. export enum DualShockButton {
  129499. /** Cross */
  129500. Cross = 0,
  129501. /** Circle */
  129502. Circle = 1,
  129503. /** Square */
  129504. Square = 2,
  129505. /** Triangle */
  129506. Triangle = 3,
  129507. /** L1 */
  129508. L1 = 4,
  129509. /** R1 */
  129510. R1 = 5,
  129511. /** Share */
  129512. Share = 8,
  129513. /** Options */
  129514. Options = 9,
  129515. /** Left stick */
  129516. LeftStick = 10,
  129517. /** Right stick */
  129518. RightStick = 11
  129519. }
  129520. /** Defines values for DualShock DPad */
  129521. export enum DualShockDpad {
  129522. /** Up */
  129523. Up = 12,
  129524. /** Down */
  129525. Down = 13,
  129526. /** Left */
  129527. Left = 14,
  129528. /** Right */
  129529. Right = 15
  129530. }
  129531. /**
  129532. * Defines a DualShock gamepad
  129533. */
  129534. export class DualShockPad extends Gamepad {
  129535. private _leftTrigger;
  129536. private _rightTrigger;
  129537. private _onlefttriggerchanged;
  129538. private _onrighttriggerchanged;
  129539. private _onbuttondown;
  129540. private _onbuttonup;
  129541. private _ondpaddown;
  129542. private _ondpadup;
  129543. /** Observable raised when a button is pressed */
  129544. onButtonDownObservable: Observable<DualShockButton>;
  129545. /** Observable raised when a button is released */
  129546. onButtonUpObservable: Observable<DualShockButton>;
  129547. /** Observable raised when a pad is pressed */
  129548. onPadDownObservable: Observable<DualShockDpad>;
  129549. /** Observable raised when a pad is released */
  129550. onPadUpObservable: Observable<DualShockDpad>;
  129551. private _buttonCross;
  129552. private _buttonCircle;
  129553. private _buttonSquare;
  129554. private _buttonTriangle;
  129555. private _buttonShare;
  129556. private _buttonOptions;
  129557. private _buttonL1;
  129558. private _buttonR1;
  129559. private _buttonLeftStick;
  129560. private _buttonRightStick;
  129561. private _dPadUp;
  129562. private _dPadDown;
  129563. private _dPadLeft;
  129564. private _dPadRight;
  129565. /**
  129566. * Creates a new DualShock gamepad object
  129567. * @param id defines the id of this gamepad
  129568. * @param index defines its index
  129569. * @param gamepad defines the internal HTML gamepad object
  129570. */
  129571. constructor(id: string, index: number, gamepad: any);
  129572. /**
  129573. * Defines the callback to call when left trigger is pressed
  129574. * @param callback defines the callback to use
  129575. */
  129576. onlefttriggerchanged(callback: (value: number) => void): void;
  129577. /**
  129578. * Defines the callback to call when right trigger is pressed
  129579. * @param callback defines the callback to use
  129580. */
  129581. onrighttriggerchanged(callback: (value: number) => void): void;
  129582. /**
  129583. * Gets the left trigger value
  129584. */
  129585. get leftTrigger(): number;
  129586. /**
  129587. * Sets the left trigger value
  129588. */
  129589. set leftTrigger(newValue: number);
  129590. /**
  129591. * Gets the right trigger value
  129592. */
  129593. get rightTrigger(): number;
  129594. /**
  129595. * Sets the right trigger value
  129596. */
  129597. set rightTrigger(newValue: number);
  129598. /**
  129599. * Defines the callback to call when a button is pressed
  129600. * @param callback defines the callback to use
  129601. */
  129602. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129603. /**
  129604. * Defines the callback to call when a button is released
  129605. * @param callback defines the callback to use
  129606. */
  129607. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129608. /**
  129609. * Defines the callback to call when a pad is pressed
  129610. * @param callback defines the callback to use
  129611. */
  129612. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129613. /**
  129614. * Defines the callback to call when a pad is released
  129615. * @param callback defines the callback to use
  129616. */
  129617. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129618. private _setButtonValue;
  129619. private _setDPadValue;
  129620. /**
  129621. * Gets the value of the `Cross` button
  129622. */
  129623. get buttonCross(): number;
  129624. /**
  129625. * Sets the value of the `Cross` button
  129626. */
  129627. set buttonCross(value: number);
  129628. /**
  129629. * Gets the value of the `Circle` button
  129630. */
  129631. get buttonCircle(): number;
  129632. /**
  129633. * Sets the value of the `Circle` button
  129634. */
  129635. set buttonCircle(value: number);
  129636. /**
  129637. * Gets the value of the `Square` button
  129638. */
  129639. get buttonSquare(): number;
  129640. /**
  129641. * Sets the value of the `Square` button
  129642. */
  129643. set buttonSquare(value: number);
  129644. /**
  129645. * Gets the value of the `Triangle` button
  129646. */
  129647. get buttonTriangle(): number;
  129648. /**
  129649. * Sets the value of the `Triangle` button
  129650. */
  129651. set buttonTriangle(value: number);
  129652. /**
  129653. * Gets the value of the `Options` button
  129654. */
  129655. get buttonOptions(): number;
  129656. /**
  129657. * Sets the value of the `Options` button
  129658. */
  129659. set buttonOptions(value: number);
  129660. /**
  129661. * Gets the value of the `Share` button
  129662. */
  129663. get buttonShare(): number;
  129664. /**
  129665. * Sets the value of the `Share` button
  129666. */
  129667. set buttonShare(value: number);
  129668. /**
  129669. * Gets the value of the `L1` button
  129670. */
  129671. get buttonL1(): number;
  129672. /**
  129673. * Sets the value of the `L1` button
  129674. */
  129675. set buttonL1(value: number);
  129676. /**
  129677. * Gets the value of the `R1` button
  129678. */
  129679. get buttonR1(): number;
  129680. /**
  129681. * Sets the value of the `R1` button
  129682. */
  129683. set buttonR1(value: number);
  129684. /**
  129685. * Gets the value of the Left joystick
  129686. */
  129687. get buttonLeftStick(): number;
  129688. /**
  129689. * Sets the value of the Left joystick
  129690. */
  129691. set buttonLeftStick(value: number);
  129692. /**
  129693. * Gets the value of the Right joystick
  129694. */
  129695. get buttonRightStick(): number;
  129696. /**
  129697. * Sets the value of the Right joystick
  129698. */
  129699. set buttonRightStick(value: number);
  129700. /**
  129701. * Gets the value of D-pad up
  129702. */
  129703. get dPadUp(): number;
  129704. /**
  129705. * Sets the value of D-pad up
  129706. */
  129707. set dPadUp(value: number);
  129708. /**
  129709. * Gets the value of D-pad down
  129710. */
  129711. get dPadDown(): number;
  129712. /**
  129713. * Sets the value of D-pad down
  129714. */
  129715. set dPadDown(value: number);
  129716. /**
  129717. * Gets the value of D-pad left
  129718. */
  129719. get dPadLeft(): number;
  129720. /**
  129721. * Sets the value of D-pad left
  129722. */
  129723. set dPadLeft(value: number);
  129724. /**
  129725. * Gets the value of D-pad right
  129726. */
  129727. get dPadRight(): number;
  129728. /**
  129729. * Sets the value of D-pad right
  129730. */
  129731. set dPadRight(value: number);
  129732. /**
  129733. * Force the gamepad to synchronize with device values
  129734. */
  129735. update(): void;
  129736. /**
  129737. * Disposes the gamepad
  129738. */
  129739. dispose(): void;
  129740. }
  129741. }
  129742. declare module BABYLON {
  129743. /**
  129744. * Manager for handling gamepads
  129745. */
  129746. export class GamepadManager {
  129747. private _scene?;
  129748. private _babylonGamepads;
  129749. private _oneGamepadConnected;
  129750. /** @hidden */
  129751. _isMonitoring: boolean;
  129752. private _gamepadEventSupported;
  129753. private _gamepadSupport?;
  129754. /**
  129755. * observable to be triggered when the gamepad controller has been connected
  129756. */
  129757. onGamepadConnectedObservable: Observable<Gamepad>;
  129758. /**
  129759. * observable to be triggered when the gamepad controller has been disconnected
  129760. */
  129761. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129762. private _onGamepadConnectedEvent;
  129763. private _onGamepadDisconnectedEvent;
  129764. /**
  129765. * Initializes the gamepad manager
  129766. * @param _scene BabylonJS scene
  129767. */
  129768. constructor(_scene?: Scene | undefined);
  129769. /**
  129770. * The gamepads in the game pad manager
  129771. */
  129772. get gamepads(): Gamepad[];
  129773. /**
  129774. * Get the gamepad controllers based on type
  129775. * @param type The type of gamepad controller
  129776. * @returns Nullable gamepad
  129777. */
  129778. getGamepadByType(type?: number): Nullable<Gamepad>;
  129779. /**
  129780. * Disposes the gamepad manager
  129781. */
  129782. dispose(): void;
  129783. private _addNewGamepad;
  129784. private _startMonitoringGamepads;
  129785. private _stopMonitoringGamepads;
  129786. /** @hidden */
  129787. _checkGamepadsStatus(): void;
  129788. private _updateGamepadObjects;
  129789. }
  129790. }
  129791. declare module BABYLON {
  129792. interface Scene {
  129793. /** @hidden */
  129794. _gamepadManager: Nullable<GamepadManager>;
  129795. /**
  129796. * Gets the gamepad manager associated with the scene
  129797. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129798. */
  129799. gamepadManager: GamepadManager;
  129800. }
  129801. /**
  129802. * Interface representing a free camera inputs manager
  129803. */
  129804. interface FreeCameraInputsManager {
  129805. /**
  129806. * Adds gamepad input support to the FreeCameraInputsManager.
  129807. * @returns the FreeCameraInputsManager
  129808. */
  129809. addGamepad(): FreeCameraInputsManager;
  129810. }
  129811. /**
  129812. * Interface representing an arc rotate camera inputs manager
  129813. */
  129814. interface ArcRotateCameraInputsManager {
  129815. /**
  129816. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129817. * @returns the camera inputs manager
  129818. */
  129819. addGamepad(): ArcRotateCameraInputsManager;
  129820. }
  129821. /**
  129822. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129823. */
  129824. export class GamepadSystemSceneComponent implements ISceneComponent {
  129825. /**
  129826. * The component name helpfull to identify the component in the list of scene components.
  129827. */
  129828. readonly name: string;
  129829. /**
  129830. * The scene the component belongs to.
  129831. */
  129832. scene: Scene;
  129833. /**
  129834. * Creates a new instance of the component for the given scene
  129835. * @param scene Defines the scene to register the component in
  129836. */
  129837. constructor(scene: Scene);
  129838. /**
  129839. * Registers the component in a given scene
  129840. */
  129841. register(): void;
  129842. /**
  129843. * Rebuilds the elements related to this component in case of
  129844. * context lost for instance.
  129845. */
  129846. rebuild(): void;
  129847. /**
  129848. * Disposes the component and the associated ressources
  129849. */
  129850. dispose(): void;
  129851. private _beforeCameraUpdate;
  129852. }
  129853. }
  129854. declare module BABYLON {
  129855. /**
  129856. * 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,
  129857. * which still works and will still be found in many Playgrounds.
  129858. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129859. */
  129860. export class UniversalCamera extends TouchCamera {
  129861. /**
  129862. * Defines the gamepad rotation sensiblity.
  129863. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129864. */
  129865. get gamepadAngularSensibility(): number;
  129866. set gamepadAngularSensibility(value: number);
  129867. /**
  129868. * Defines the gamepad move sensiblity.
  129869. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129870. */
  129871. get gamepadMoveSensibility(): number;
  129872. set gamepadMoveSensibility(value: number);
  129873. /**
  129874. * 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,
  129875. * which still works and will still be found in many Playgrounds.
  129876. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129877. * @param name Define the name of the camera in the scene
  129878. * @param position Define the start position of the camera in the scene
  129879. * @param scene Define the scene the camera belongs to
  129880. */
  129881. constructor(name: string, position: Vector3, scene: Scene);
  129882. /**
  129883. * Gets the current object class name.
  129884. * @return the class name
  129885. */
  129886. getClassName(): string;
  129887. }
  129888. }
  129889. declare module BABYLON {
  129890. /**
  129891. * This represents a FPS type of camera. This is only here for back compat purpose.
  129892. * Please use the UniversalCamera instead as both are identical.
  129893. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129894. */
  129895. export class GamepadCamera extends UniversalCamera {
  129896. /**
  129897. * Instantiates a new Gamepad Camera
  129898. * This represents a FPS type of camera. This is only here for back compat purpose.
  129899. * Please use the UniversalCamera instead as both are identical.
  129900. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129901. * @param name Define the name of the camera in the scene
  129902. * @param position Define the start position of the camera in the scene
  129903. * @param scene Define the scene the camera belongs to
  129904. */
  129905. constructor(name: string, position: Vector3, scene: Scene);
  129906. /**
  129907. * Gets the current object class name.
  129908. * @return the class name
  129909. */
  129910. getClassName(): string;
  129911. }
  129912. }
  129913. declare module BABYLON {
  129914. /** @hidden */
  129915. export var passPixelShader: {
  129916. name: string;
  129917. shader: string;
  129918. };
  129919. }
  129920. declare module BABYLON {
  129921. /** @hidden */
  129922. export var passCubePixelShader: {
  129923. name: string;
  129924. shader: string;
  129925. };
  129926. }
  129927. declare module BABYLON {
  129928. /**
  129929. * PassPostProcess which produces an output the same as it's input
  129930. */
  129931. export class PassPostProcess extends PostProcess {
  129932. /**
  129933. * Gets a string identifying the name of the class
  129934. * @returns "PassPostProcess" string
  129935. */
  129936. getClassName(): string;
  129937. /**
  129938. * Creates the PassPostProcess
  129939. * @param name The name of the effect.
  129940. * @param options The required width/height ratio to downsize to before computing the render pass.
  129941. * @param camera The camera to apply the render pass to.
  129942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129943. * @param engine The engine which the post process will be applied. (default: current engine)
  129944. * @param reusable If the post process can be reused on the same frame. (default: false)
  129945. * @param textureType The type of texture to be used when performing the post processing.
  129946. * @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)
  129947. */
  129948. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129949. /** @hidden */
  129950. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129951. }
  129952. /**
  129953. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129954. */
  129955. export class PassCubePostProcess extends PostProcess {
  129956. private _face;
  129957. /**
  129958. * Gets or sets the cube face to display.
  129959. * * 0 is +X
  129960. * * 1 is -X
  129961. * * 2 is +Y
  129962. * * 3 is -Y
  129963. * * 4 is +Z
  129964. * * 5 is -Z
  129965. */
  129966. get face(): number;
  129967. set face(value: number);
  129968. /**
  129969. * Gets a string identifying the name of the class
  129970. * @returns "PassCubePostProcess" string
  129971. */
  129972. getClassName(): string;
  129973. /**
  129974. * Creates the PassCubePostProcess
  129975. * @param name The name of the effect.
  129976. * @param options The required width/height ratio to downsize to before computing the render pass.
  129977. * @param camera The camera to apply the render pass to.
  129978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129979. * @param engine The engine which the post process will be applied. (default: current engine)
  129980. * @param reusable If the post process can be reused on the same frame. (default: false)
  129981. * @param textureType The type of texture to be used when performing the post processing.
  129982. * @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)
  129983. */
  129984. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129985. /** @hidden */
  129986. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129987. }
  129988. }
  129989. declare module BABYLON {
  129990. /** @hidden */
  129991. export var anaglyphPixelShader: {
  129992. name: string;
  129993. shader: string;
  129994. };
  129995. }
  129996. declare module BABYLON {
  129997. /**
  129998. * Postprocess used to generate anaglyphic rendering
  129999. */
  130000. export class AnaglyphPostProcess extends PostProcess {
  130001. private _passedProcess;
  130002. /**
  130003. * Gets a string identifying the name of the class
  130004. * @returns "AnaglyphPostProcess" string
  130005. */
  130006. getClassName(): string;
  130007. /**
  130008. * Creates a new AnaglyphPostProcess
  130009. * @param name defines postprocess name
  130010. * @param options defines creation options or target ratio scale
  130011. * @param rigCameras defines cameras using this postprocess
  130012. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  130013. * @param engine defines hosting engine
  130014. * @param reusable defines if the postprocess will be reused multiple times per frame
  130015. */
  130016. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  130017. }
  130018. }
  130019. declare module BABYLON {
  130020. /**
  130021. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  130022. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130023. */
  130024. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  130025. /**
  130026. * Creates a new AnaglyphArcRotateCamera
  130027. * @param name defines camera name
  130028. * @param alpha defines alpha angle (in radians)
  130029. * @param beta defines beta angle (in radians)
  130030. * @param radius defines radius
  130031. * @param target defines camera target
  130032. * @param interaxialDistance defines distance between each color axis
  130033. * @param scene defines the hosting scene
  130034. */
  130035. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  130036. /**
  130037. * Gets camera class name
  130038. * @returns AnaglyphArcRotateCamera
  130039. */
  130040. getClassName(): string;
  130041. }
  130042. }
  130043. declare module BABYLON {
  130044. /**
  130045. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  130046. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130047. */
  130048. export class AnaglyphFreeCamera extends FreeCamera {
  130049. /**
  130050. * Creates a new AnaglyphFreeCamera
  130051. * @param name defines camera name
  130052. * @param position defines initial position
  130053. * @param interaxialDistance defines distance between each color axis
  130054. * @param scene defines the hosting scene
  130055. */
  130056. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130057. /**
  130058. * Gets camera class name
  130059. * @returns AnaglyphFreeCamera
  130060. */
  130061. getClassName(): string;
  130062. }
  130063. }
  130064. declare module BABYLON {
  130065. /**
  130066. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130067. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130068. */
  130069. export class AnaglyphGamepadCamera extends GamepadCamera {
  130070. /**
  130071. * Creates a new AnaglyphGamepadCamera
  130072. * @param name defines camera name
  130073. * @param position defines initial position
  130074. * @param interaxialDistance defines distance between each color axis
  130075. * @param scene defines the hosting scene
  130076. */
  130077. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130078. /**
  130079. * Gets camera class name
  130080. * @returns AnaglyphGamepadCamera
  130081. */
  130082. getClassName(): string;
  130083. }
  130084. }
  130085. declare module BABYLON {
  130086. /**
  130087. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130088. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130089. */
  130090. export class AnaglyphUniversalCamera extends UniversalCamera {
  130091. /**
  130092. * Creates a new AnaglyphUniversalCamera
  130093. * @param name defines camera name
  130094. * @param position defines initial position
  130095. * @param interaxialDistance defines distance between each color axis
  130096. * @param scene defines the hosting scene
  130097. */
  130098. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130099. /**
  130100. * Gets camera class name
  130101. * @returns AnaglyphUniversalCamera
  130102. */
  130103. getClassName(): string;
  130104. }
  130105. }
  130106. declare module BABYLON {
  130107. /**
  130108. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130109. * @see https://doc.babylonjs.com/features/cameras
  130110. */
  130111. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130112. /**
  130113. * Creates a new StereoscopicArcRotateCamera
  130114. * @param name defines camera name
  130115. * @param alpha defines alpha angle (in radians)
  130116. * @param beta defines beta angle (in radians)
  130117. * @param radius defines radius
  130118. * @param target defines camera target
  130119. * @param interaxialDistance defines distance between each color axis
  130120. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130121. * @param scene defines the hosting scene
  130122. */
  130123. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130124. /**
  130125. * Gets camera class name
  130126. * @returns StereoscopicArcRotateCamera
  130127. */
  130128. getClassName(): string;
  130129. }
  130130. }
  130131. declare module BABYLON {
  130132. /**
  130133. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130134. * @see https://doc.babylonjs.com/features/cameras
  130135. */
  130136. export class StereoscopicFreeCamera extends FreeCamera {
  130137. /**
  130138. * Creates a new StereoscopicFreeCamera
  130139. * @param name defines camera name
  130140. * @param position defines initial position
  130141. * @param interaxialDistance defines distance between each color axis
  130142. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130143. * @param scene defines the hosting scene
  130144. */
  130145. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130146. /**
  130147. * Gets camera class name
  130148. * @returns StereoscopicFreeCamera
  130149. */
  130150. getClassName(): string;
  130151. }
  130152. }
  130153. declare module BABYLON {
  130154. /**
  130155. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130156. * @see https://doc.babylonjs.com/features/cameras
  130157. */
  130158. export class StereoscopicGamepadCamera extends GamepadCamera {
  130159. /**
  130160. * Creates a new StereoscopicGamepadCamera
  130161. * @param name defines camera name
  130162. * @param position defines initial position
  130163. * @param interaxialDistance defines distance between each color axis
  130164. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130165. * @param scene defines the hosting scene
  130166. */
  130167. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130168. /**
  130169. * Gets camera class name
  130170. * @returns StereoscopicGamepadCamera
  130171. */
  130172. getClassName(): string;
  130173. }
  130174. }
  130175. declare module BABYLON {
  130176. /**
  130177. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130178. * @see https://doc.babylonjs.com/features/cameras
  130179. */
  130180. export class StereoscopicUniversalCamera extends UniversalCamera {
  130181. /**
  130182. * Creates a new StereoscopicUniversalCamera
  130183. * @param name defines camera name
  130184. * @param position defines initial position
  130185. * @param interaxialDistance defines distance between each color axis
  130186. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130187. * @param scene defines the hosting scene
  130188. */
  130189. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130190. /**
  130191. * Gets camera class name
  130192. * @returns StereoscopicUniversalCamera
  130193. */
  130194. getClassName(): string;
  130195. }
  130196. }
  130197. declare module BABYLON {
  130198. /**
  130199. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130200. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130201. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130202. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130203. */
  130204. export class VirtualJoysticksCamera extends FreeCamera {
  130205. /**
  130206. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130207. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130208. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130209. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130210. * @param name Define the name of the camera in the scene
  130211. * @param position Define the start position of the camera in the scene
  130212. * @param scene Define the scene the camera belongs to
  130213. */
  130214. constructor(name: string, position: Vector3, scene: Scene);
  130215. /**
  130216. * Gets the current object class name.
  130217. * @return the class name
  130218. */
  130219. getClassName(): string;
  130220. }
  130221. }
  130222. declare module BABYLON {
  130223. /**
  130224. * This represents all the required metrics to create a VR camera.
  130225. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130226. */
  130227. export class VRCameraMetrics {
  130228. /**
  130229. * Define the horizontal resolution off the screen.
  130230. */
  130231. hResolution: number;
  130232. /**
  130233. * Define the vertical resolution off the screen.
  130234. */
  130235. vResolution: number;
  130236. /**
  130237. * Define the horizontal screen size.
  130238. */
  130239. hScreenSize: number;
  130240. /**
  130241. * Define the vertical screen size.
  130242. */
  130243. vScreenSize: number;
  130244. /**
  130245. * Define the vertical screen center position.
  130246. */
  130247. vScreenCenter: number;
  130248. /**
  130249. * Define the distance of the eyes to the screen.
  130250. */
  130251. eyeToScreenDistance: number;
  130252. /**
  130253. * Define the distance between both lenses
  130254. */
  130255. lensSeparationDistance: number;
  130256. /**
  130257. * Define the distance between both viewer's eyes.
  130258. */
  130259. interpupillaryDistance: number;
  130260. /**
  130261. * Define the distortion factor of the VR postprocess.
  130262. * Please, touch with care.
  130263. */
  130264. distortionK: number[];
  130265. /**
  130266. * Define the chromatic aberration correction factors for the VR post process.
  130267. */
  130268. chromaAbCorrection: number[];
  130269. /**
  130270. * Define the scale factor of the post process.
  130271. * The smaller the better but the slower.
  130272. */
  130273. postProcessScaleFactor: number;
  130274. /**
  130275. * Define an offset for the lens center.
  130276. */
  130277. lensCenterOffset: number;
  130278. /**
  130279. * Define if the current vr camera should compensate the distortion of the lense or not.
  130280. */
  130281. compensateDistortion: boolean;
  130282. /**
  130283. * Defines if multiview should be enabled when rendering (Default: false)
  130284. */
  130285. multiviewEnabled: boolean;
  130286. /**
  130287. * Gets the rendering aspect ratio based on the provided resolutions.
  130288. */
  130289. get aspectRatio(): number;
  130290. /**
  130291. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130292. */
  130293. get aspectRatioFov(): number;
  130294. /**
  130295. * @hidden
  130296. */
  130297. get leftHMatrix(): Matrix;
  130298. /**
  130299. * @hidden
  130300. */
  130301. get rightHMatrix(): Matrix;
  130302. /**
  130303. * @hidden
  130304. */
  130305. get leftPreViewMatrix(): Matrix;
  130306. /**
  130307. * @hidden
  130308. */
  130309. get rightPreViewMatrix(): Matrix;
  130310. /**
  130311. * Get the default VRMetrics based on the most generic setup.
  130312. * @returns the default vr metrics
  130313. */
  130314. static GetDefault(): VRCameraMetrics;
  130315. }
  130316. }
  130317. declare module BABYLON {
  130318. /** @hidden */
  130319. export var vrDistortionCorrectionPixelShader: {
  130320. name: string;
  130321. shader: string;
  130322. };
  130323. }
  130324. declare module BABYLON {
  130325. /**
  130326. * VRDistortionCorrectionPostProcess used for mobile VR
  130327. */
  130328. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130329. private _isRightEye;
  130330. private _distortionFactors;
  130331. private _postProcessScaleFactor;
  130332. private _lensCenterOffset;
  130333. private _scaleIn;
  130334. private _scaleFactor;
  130335. private _lensCenter;
  130336. /**
  130337. * Gets a string identifying the name of the class
  130338. * @returns "VRDistortionCorrectionPostProcess" string
  130339. */
  130340. getClassName(): string;
  130341. /**
  130342. * Initializes the VRDistortionCorrectionPostProcess
  130343. * @param name The name of the effect.
  130344. * @param camera The camera to apply the render pass to.
  130345. * @param isRightEye If this is for the right eye distortion
  130346. * @param vrMetrics All the required metrics for the VR camera
  130347. */
  130348. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130349. }
  130350. }
  130351. declare module BABYLON {
  130352. /**
  130353. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130354. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130355. */
  130356. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130357. /**
  130358. * Creates a new VRDeviceOrientationArcRotateCamera
  130359. * @param name defines camera name
  130360. * @param alpha defines the camera rotation along the logitudinal axis
  130361. * @param beta defines the camera rotation along the latitudinal axis
  130362. * @param radius defines the camera distance from its target
  130363. * @param target defines the camera target
  130364. * @param scene defines the scene the camera belongs to
  130365. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130366. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130367. */
  130368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130369. /**
  130370. * Gets camera class name
  130371. * @returns VRDeviceOrientationArcRotateCamera
  130372. */
  130373. getClassName(): string;
  130374. }
  130375. }
  130376. declare module BABYLON {
  130377. /**
  130378. * Camera used to simulate VR rendering (based on FreeCamera)
  130379. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130380. */
  130381. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130382. /**
  130383. * Creates a new VRDeviceOrientationFreeCamera
  130384. * @param name defines camera name
  130385. * @param position defines the start position of the camera
  130386. * @param scene defines the scene the camera belongs to
  130387. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130388. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130389. */
  130390. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130391. /**
  130392. * Gets camera class name
  130393. * @returns VRDeviceOrientationFreeCamera
  130394. */
  130395. getClassName(): string;
  130396. }
  130397. }
  130398. declare module BABYLON {
  130399. /**
  130400. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130401. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130402. */
  130403. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130404. /**
  130405. * Creates a new VRDeviceOrientationGamepadCamera
  130406. * @param name defines camera name
  130407. * @param position defines the start position of the camera
  130408. * @param scene defines the scene the camera belongs to
  130409. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130410. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130411. */
  130412. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130413. /**
  130414. * Gets camera class name
  130415. * @returns VRDeviceOrientationGamepadCamera
  130416. */
  130417. getClassName(): string;
  130418. }
  130419. }
  130420. declare module BABYLON {
  130421. /**
  130422. * A class extending Texture allowing drawing on a texture
  130423. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130424. */
  130425. export class DynamicTexture extends Texture {
  130426. private _generateMipMaps;
  130427. private _canvas;
  130428. private _context;
  130429. /**
  130430. * Creates a DynamicTexture
  130431. * @param name defines the name of the texture
  130432. * @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
  130433. * @param scene defines the scene where you want the texture
  130434. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130435. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130436. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130437. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130438. */
  130439. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130440. /**
  130441. * Get the current class name of the texture useful for serialization or dynamic coding.
  130442. * @returns "DynamicTexture"
  130443. */
  130444. getClassName(): string;
  130445. /**
  130446. * Gets the current state of canRescale
  130447. */
  130448. get canRescale(): boolean;
  130449. private _recreate;
  130450. /**
  130451. * Scales the texture
  130452. * @param ratio the scale factor to apply to both width and height
  130453. */
  130454. scale(ratio: number): void;
  130455. /**
  130456. * Resizes the texture
  130457. * @param width the new width
  130458. * @param height the new height
  130459. */
  130460. scaleTo(width: number, height: number): void;
  130461. /**
  130462. * Gets the context of the canvas used by the texture
  130463. * @returns the canvas context of the dynamic texture
  130464. */
  130465. getContext(): CanvasRenderingContext2D;
  130466. /**
  130467. * Clears the texture
  130468. */
  130469. clear(): void;
  130470. /**
  130471. * Updates the texture
  130472. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130473. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130474. */
  130475. update(invertY?: boolean, premulAlpha?: boolean): void;
  130476. /**
  130477. * Draws text onto the texture
  130478. * @param text defines the text to be drawn
  130479. * @param x defines the placement of the text from the left
  130480. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130481. * @param font defines the font to be used with font-style, font-size, font-name
  130482. * @param color defines the color used for the text
  130483. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130484. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130485. * @param update defines whether texture is immediately update (default is true)
  130486. */
  130487. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130488. /**
  130489. * Clones the texture
  130490. * @returns the clone of the texture.
  130491. */
  130492. clone(): DynamicTexture;
  130493. /**
  130494. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130495. * @returns a serialized dynamic texture object
  130496. */
  130497. serialize(): any;
  130498. private _IsCanvasElement;
  130499. /** @hidden */
  130500. _rebuild(): void;
  130501. }
  130502. }
  130503. declare module BABYLON {
  130504. /**
  130505. * Class containing static functions to help procedurally build meshes
  130506. */
  130507. export class GroundBuilder {
  130508. /**
  130509. * Creates a ground mesh
  130510. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130511. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130513. * @param name defines the name of the mesh
  130514. * @param options defines the options used to create the mesh
  130515. * @param scene defines the hosting scene
  130516. * @returns the ground mesh
  130517. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130518. */
  130519. static CreateGround(name: string, options: {
  130520. width?: number;
  130521. height?: number;
  130522. subdivisions?: number;
  130523. subdivisionsX?: number;
  130524. subdivisionsY?: number;
  130525. updatable?: boolean;
  130526. }, scene: any): Mesh;
  130527. /**
  130528. * Creates a tiled ground mesh
  130529. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130530. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130531. * * 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
  130532. * * 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
  130533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130534. * @param name defines the name of the mesh
  130535. * @param options defines the options used to create the mesh
  130536. * @param scene defines the hosting scene
  130537. * @returns the tiled ground mesh
  130538. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130539. */
  130540. static CreateTiledGround(name: string, options: {
  130541. xmin: number;
  130542. zmin: number;
  130543. xmax: number;
  130544. zmax: number;
  130545. subdivisions?: {
  130546. w: number;
  130547. h: number;
  130548. };
  130549. precision?: {
  130550. w: number;
  130551. h: number;
  130552. };
  130553. updatable?: boolean;
  130554. }, scene?: Nullable<Scene>): Mesh;
  130555. /**
  130556. * Creates a ground mesh from a height map
  130557. * * The parameter `url` sets the URL of the height map image resource.
  130558. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130559. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130560. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130561. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130562. * * 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.
  130563. * * 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).
  130564. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130566. * @param name defines the name of the mesh
  130567. * @param url defines the url to the height map
  130568. * @param options defines the options used to create the mesh
  130569. * @param scene defines the hosting scene
  130570. * @returns the ground mesh
  130571. * @see https://doc.babylonjs.com/babylon101/height_map
  130572. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130573. */
  130574. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130575. width?: number;
  130576. height?: number;
  130577. subdivisions?: number;
  130578. minHeight?: number;
  130579. maxHeight?: number;
  130580. colorFilter?: Color3;
  130581. alphaFilter?: number;
  130582. updatable?: boolean;
  130583. onReady?: (mesh: GroundMesh) => void;
  130584. }, scene?: Nullable<Scene>): GroundMesh;
  130585. }
  130586. }
  130587. declare module BABYLON {
  130588. /**
  130589. * Class containing static functions to help procedurally build meshes
  130590. */
  130591. export class TorusBuilder {
  130592. /**
  130593. * Creates a torus mesh
  130594. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130595. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130596. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130600. * @param name defines the name of the mesh
  130601. * @param options defines the options used to create the mesh
  130602. * @param scene defines the hosting scene
  130603. * @returns the torus mesh
  130604. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130605. */
  130606. static CreateTorus(name: string, options: {
  130607. diameter?: number;
  130608. thickness?: number;
  130609. tessellation?: number;
  130610. updatable?: boolean;
  130611. sideOrientation?: number;
  130612. frontUVs?: Vector4;
  130613. backUVs?: Vector4;
  130614. }, scene: any): Mesh;
  130615. }
  130616. }
  130617. declare module BABYLON {
  130618. /**
  130619. * Class containing static functions to help procedurally build meshes
  130620. */
  130621. export class CylinderBuilder {
  130622. /**
  130623. * Creates a cylinder or a cone mesh
  130624. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130625. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130626. * * 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.
  130627. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130628. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130629. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130630. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130631. * * 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).
  130632. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130633. * * 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).
  130634. * * 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
  130635. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130636. * * 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
  130637. * * 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.
  130638. * * If `enclose` is false, a ring surface is one element.
  130639. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130640. * * 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
  130641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130644. * @param name defines the name of the mesh
  130645. * @param options defines the options used to create the mesh
  130646. * @param scene defines the hosting scene
  130647. * @returns the cylinder mesh
  130648. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130649. */
  130650. static CreateCylinder(name: string, options: {
  130651. height?: number;
  130652. diameterTop?: number;
  130653. diameterBottom?: number;
  130654. diameter?: number;
  130655. tessellation?: number;
  130656. subdivisions?: number;
  130657. arc?: number;
  130658. faceColors?: Color4[];
  130659. faceUV?: Vector4[];
  130660. updatable?: boolean;
  130661. hasRings?: boolean;
  130662. enclose?: boolean;
  130663. cap?: number;
  130664. sideOrientation?: number;
  130665. frontUVs?: Vector4;
  130666. backUVs?: Vector4;
  130667. }, scene: any): Mesh;
  130668. }
  130669. }
  130670. declare module BABYLON {
  130671. /**
  130672. * States of the webXR experience
  130673. */
  130674. export enum WebXRState {
  130675. /**
  130676. * Transitioning to being in XR mode
  130677. */
  130678. ENTERING_XR = 0,
  130679. /**
  130680. * Transitioning to non XR mode
  130681. */
  130682. EXITING_XR = 1,
  130683. /**
  130684. * In XR mode and presenting
  130685. */
  130686. IN_XR = 2,
  130687. /**
  130688. * Not entered XR mode
  130689. */
  130690. NOT_IN_XR = 3
  130691. }
  130692. /**
  130693. * The state of the XR camera's tracking
  130694. */
  130695. export enum WebXRTrackingState {
  130696. /**
  130697. * No transformation received, device is not being tracked
  130698. */
  130699. NOT_TRACKING = 0,
  130700. /**
  130701. * Tracking lost - using emulated position
  130702. */
  130703. TRACKING_LOST = 1,
  130704. /**
  130705. * Transformation tracking works normally
  130706. */
  130707. TRACKING = 2
  130708. }
  130709. /**
  130710. * Abstraction of the XR render target
  130711. */
  130712. export interface WebXRRenderTarget extends IDisposable {
  130713. /**
  130714. * xrpresent context of the canvas which can be used to display/mirror xr content
  130715. */
  130716. canvasContext: WebGLRenderingContext;
  130717. /**
  130718. * xr layer for the canvas
  130719. */
  130720. xrLayer: Nullable<XRWebGLLayer>;
  130721. /**
  130722. * Initializes the xr layer for the session
  130723. * @param xrSession xr session
  130724. * @returns a promise that will resolve once the XR Layer has been created
  130725. */
  130726. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130727. }
  130728. }
  130729. declare module BABYLON {
  130730. /**
  130731. * COnfiguration object for WebXR output canvas
  130732. */
  130733. export class WebXRManagedOutputCanvasOptions {
  130734. /**
  130735. * An optional canvas in case you wish to create it yourself and provide it here.
  130736. * If not provided, a new canvas will be created
  130737. */
  130738. canvasElement?: HTMLCanvasElement;
  130739. /**
  130740. * Options for this XR Layer output
  130741. */
  130742. canvasOptions?: XRWebGLLayerOptions;
  130743. /**
  130744. * CSS styling for a newly created canvas (if not provided)
  130745. */
  130746. newCanvasCssStyle?: string;
  130747. /**
  130748. * Get the default values of the configuration object
  130749. * @param engine defines the engine to use (can be null)
  130750. * @returns default values of this configuration object
  130751. */
  130752. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130753. }
  130754. /**
  130755. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130756. */
  130757. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130758. private _options;
  130759. private _canvas;
  130760. private _engine;
  130761. private _originalCanvasSize;
  130762. /**
  130763. * Rendering context of the canvas which can be used to display/mirror xr content
  130764. */
  130765. canvasContext: WebGLRenderingContext;
  130766. /**
  130767. * xr layer for the canvas
  130768. */
  130769. xrLayer: Nullable<XRWebGLLayer>;
  130770. /**
  130771. * Obseervers registered here will be triggered when the xr layer was initialized
  130772. */
  130773. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130774. /**
  130775. * Initializes the canvas to be added/removed upon entering/exiting xr
  130776. * @param _xrSessionManager The XR Session manager
  130777. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130778. */
  130779. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130780. /**
  130781. * Disposes of the object
  130782. */
  130783. dispose(): void;
  130784. /**
  130785. * Initializes the xr layer for the session
  130786. * @param xrSession xr session
  130787. * @returns a promise that will resolve once the XR Layer has been created
  130788. */
  130789. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130790. private _addCanvas;
  130791. private _removeCanvas;
  130792. private _setCanvasSize;
  130793. private _setManagedOutputCanvas;
  130794. }
  130795. }
  130796. declare module BABYLON {
  130797. /**
  130798. * Manages an XRSession to work with Babylon's engine
  130799. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130800. */
  130801. export class WebXRSessionManager implements IDisposable {
  130802. /** The scene which the session should be created for */
  130803. scene: Scene;
  130804. private _referenceSpace;
  130805. private _rttProvider;
  130806. private _sessionEnded;
  130807. private _xrNavigator;
  130808. private baseLayer;
  130809. /**
  130810. * The base reference space from which the session started. good if you want to reset your
  130811. * reference space
  130812. */
  130813. baseReferenceSpace: XRReferenceSpace;
  130814. /**
  130815. * Current XR frame
  130816. */
  130817. currentFrame: Nullable<XRFrame>;
  130818. /** WebXR timestamp updated every frame */
  130819. currentTimestamp: number;
  130820. /**
  130821. * Used just in case of a failure to initialize an immersive session.
  130822. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130823. */
  130824. defaultHeightCompensation: number;
  130825. /**
  130826. * Fires every time a new xrFrame arrives which can be used to update the camera
  130827. */
  130828. onXRFrameObservable: Observable<XRFrame>;
  130829. /**
  130830. * Fires when the reference space changed
  130831. */
  130832. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130833. /**
  130834. * Fires when the xr session is ended either by the device or manually done
  130835. */
  130836. onXRSessionEnded: Observable<any>;
  130837. /**
  130838. * Fires when the xr session is ended either by the device or manually done
  130839. */
  130840. onXRSessionInit: Observable<XRSession>;
  130841. /**
  130842. * Underlying xr session
  130843. */
  130844. session: XRSession;
  130845. /**
  130846. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130847. * or get the offset the player is currently at.
  130848. */
  130849. viewerReferenceSpace: XRReferenceSpace;
  130850. /**
  130851. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130852. * @param scene The scene which the session should be created for
  130853. */
  130854. constructor(
  130855. /** The scene which the session should be created for */
  130856. scene: Scene);
  130857. /**
  130858. * The current reference space used in this session. This reference space can constantly change!
  130859. * It is mainly used to offset the camera's position.
  130860. */
  130861. get referenceSpace(): XRReferenceSpace;
  130862. /**
  130863. * Set a new reference space and triggers the observable
  130864. */
  130865. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130866. /**
  130867. * Disposes of the session manager
  130868. */
  130869. dispose(): void;
  130870. /**
  130871. * Stops the xrSession and restores the render loop
  130872. * @returns Promise which resolves after it exits XR
  130873. */
  130874. exitXRAsync(): Promise<void>;
  130875. /**
  130876. * Gets the correct render target texture to be rendered this frame for this eye
  130877. * @param eye the eye for which to get the render target
  130878. * @returns the render target for the specified eye
  130879. */
  130880. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130881. /**
  130882. * Creates a WebXRRenderTarget object for the XR session
  130883. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130884. * @param options optional options to provide when creating a new render target
  130885. * @returns a WebXR render target to which the session can render
  130886. */
  130887. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130888. /**
  130889. * Initializes the manager
  130890. * After initialization enterXR can be called to start an XR session
  130891. * @returns Promise which resolves after it is initialized
  130892. */
  130893. initializeAsync(): Promise<void>;
  130894. /**
  130895. * Initializes an xr session
  130896. * @param xrSessionMode mode to initialize
  130897. * @param xrSessionInit defines optional and required values to pass to the session builder
  130898. * @returns a promise which will resolve once the session has been initialized
  130899. */
  130900. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130901. /**
  130902. * Checks if a session would be supported for the creation options specified
  130903. * @param sessionMode session mode to check if supported eg. immersive-vr
  130904. * @returns A Promise that resolves to true if supported and false if not
  130905. */
  130906. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130907. /**
  130908. * Resets the reference space to the one started the session
  130909. */
  130910. resetReferenceSpace(): void;
  130911. /**
  130912. * Starts rendering to the xr layer
  130913. */
  130914. runXRRenderLoop(): void;
  130915. /**
  130916. * Sets the reference space on the xr session
  130917. * @param referenceSpaceType space to set
  130918. * @returns a promise that will resolve once the reference space has been set
  130919. */
  130920. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130921. /**
  130922. * Updates the render state of the session
  130923. * @param state state to set
  130924. * @returns a promise that resolves once the render state has been updated
  130925. */
  130926. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130927. /**
  130928. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130929. * @param sessionMode defines the session to test
  130930. * @returns a promise with boolean as final value
  130931. */
  130932. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130933. private _createRenderTargetTexture;
  130934. }
  130935. }
  130936. declare module BABYLON {
  130937. /**
  130938. * WebXR Camera which holds the views for the xrSession
  130939. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130940. */
  130941. export class WebXRCamera extends FreeCamera {
  130942. private _xrSessionManager;
  130943. private _firstFrame;
  130944. private _referenceQuaternion;
  130945. private _referencedPosition;
  130946. private _xrInvPositionCache;
  130947. private _xrInvQuaternionCache;
  130948. private _trackingState;
  130949. /**
  130950. * Observable raised before camera teleportation
  130951. */
  130952. onBeforeCameraTeleport: Observable<Vector3>;
  130953. /**
  130954. * Observable raised after camera teleportation
  130955. */
  130956. onAfterCameraTeleport: Observable<Vector3>;
  130957. /**
  130958. * Notifies when the camera's tracking state has changed.
  130959. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  130960. */
  130961. onTrackingStateChanged: Observable<WebXRTrackingState>;
  130962. /**
  130963. * Should position compensation execute on first frame.
  130964. * This is used when copying the position from a native (non XR) camera
  130965. */
  130966. compensateOnFirstFrame: boolean;
  130967. /**
  130968. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130969. * @param name the name of the camera
  130970. * @param scene the scene to add the camera to
  130971. * @param _xrSessionManager a constructed xr session manager
  130972. */
  130973. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130974. /**
  130975. * Get the current XR tracking state of the camera
  130976. */
  130977. get trackingState(): WebXRTrackingState;
  130978. private _setTrackingState;
  130979. /**
  130980. * Return the user's height, unrelated to the current ground.
  130981. * This will be the y position of this camera, when ground level is 0.
  130982. */
  130983. get realWorldHeight(): number;
  130984. /** @hidden */
  130985. _updateForDualEyeDebugging(): void;
  130986. /**
  130987. * Sets this camera's transformation based on a non-vr camera
  130988. * @param otherCamera the non-vr camera to copy the transformation from
  130989. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130990. */
  130991. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130992. /**
  130993. * Gets the current instance class name ("WebXRCamera").
  130994. * @returns the class name
  130995. */
  130996. getClassName(): string;
  130997. private _rotate180;
  130998. private _updateFromXRSession;
  130999. private _updateNumberOfRigCameras;
  131000. private _updateReferenceSpace;
  131001. private _updateReferenceSpaceOffset;
  131002. }
  131003. }
  131004. declare module BABYLON {
  131005. /**
  131006. * Defining the interface required for a (webxr) feature
  131007. */
  131008. export interface IWebXRFeature extends IDisposable {
  131009. /**
  131010. * Is this feature attached
  131011. */
  131012. attached: boolean;
  131013. /**
  131014. * Should auto-attach be disabled?
  131015. */
  131016. disableAutoAttach: boolean;
  131017. /**
  131018. * Attach the feature to the session
  131019. * Will usually be called by the features manager
  131020. *
  131021. * @param force should attachment be forced (even when already attached)
  131022. * @returns true if successful.
  131023. */
  131024. attach(force?: boolean): boolean;
  131025. /**
  131026. * Detach the feature from the session
  131027. * Will usually be called by the features manager
  131028. *
  131029. * @returns true if successful.
  131030. */
  131031. detach(): boolean;
  131032. /**
  131033. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  131034. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  131035. *
  131036. * @returns whether or not the feature is compatible in this environment
  131037. */
  131038. isCompatible(): boolean;
  131039. /**
  131040. * Was this feature disposed;
  131041. */
  131042. isDisposed: boolean;
  131043. /**
  131044. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  131045. */
  131046. xrNativeFeatureName?: string;
  131047. /**
  131048. * A list of (Babylon WebXR) features this feature depends on
  131049. */
  131050. dependsOn?: string[];
  131051. }
  131052. /**
  131053. * A list of the currently available features without referencing them
  131054. */
  131055. export class WebXRFeatureName {
  131056. /**
  131057. * The name of the anchor system feature
  131058. */
  131059. static readonly ANCHOR_SYSTEM: string;
  131060. /**
  131061. * The name of the background remover feature
  131062. */
  131063. static readonly BACKGROUND_REMOVER: string;
  131064. /**
  131065. * The name of the hit test feature
  131066. */
  131067. static readonly HIT_TEST: string;
  131068. /**
  131069. * physics impostors for xr controllers feature
  131070. */
  131071. static readonly PHYSICS_CONTROLLERS: string;
  131072. /**
  131073. * The name of the plane detection feature
  131074. */
  131075. static readonly PLANE_DETECTION: string;
  131076. /**
  131077. * The name of the pointer selection feature
  131078. */
  131079. static readonly POINTER_SELECTION: string;
  131080. /**
  131081. * The name of the teleportation feature
  131082. */
  131083. static readonly TELEPORTATION: string;
  131084. /**
  131085. * The name of the feature points feature.
  131086. */
  131087. static readonly FEATURE_POINTS: string;
  131088. /**
  131089. * The name of the hand tracking feature.
  131090. */
  131091. static readonly HAND_TRACKING: string;
  131092. }
  131093. /**
  131094. * Defining the constructor of a feature. Used to register the modules.
  131095. */
  131096. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131097. /**
  131098. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131099. * It is mainly used in AR sessions.
  131100. *
  131101. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131102. */
  131103. export class WebXRFeaturesManager implements IDisposable {
  131104. private _xrSessionManager;
  131105. private static readonly _AvailableFeatures;
  131106. private _features;
  131107. /**
  131108. * constructs a new features manages.
  131109. *
  131110. * @param _xrSessionManager an instance of WebXRSessionManager
  131111. */
  131112. constructor(_xrSessionManager: WebXRSessionManager);
  131113. /**
  131114. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131115. * Mainly used internally.
  131116. *
  131117. * @param featureName the name of the feature to register
  131118. * @param constructorFunction the function used to construct the module
  131119. * @param version the (babylon) version of the module
  131120. * @param stable is that a stable version of this module
  131121. */
  131122. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131123. /**
  131124. * Returns a constructor of a specific feature.
  131125. *
  131126. * @param featureName the name of the feature to construct
  131127. * @param version the version of the feature to load
  131128. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131129. * @param options optional options provided to the module.
  131130. * @returns a function that, when called, will return a new instance of this feature
  131131. */
  131132. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131133. /**
  131134. * Can be used to return the list of features currently registered
  131135. *
  131136. * @returns an Array of available features
  131137. */
  131138. static GetAvailableFeatures(): string[];
  131139. /**
  131140. * Gets the versions available for a specific feature
  131141. * @param featureName the name of the feature
  131142. * @returns an array with the available versions
  131143. */
  131144. static GetAvailableVersions(featureName: string): string[];
  131145. /**
  131146. * Return the latest unstable version of this feature
  131147. * @param featureName the name of the feature to search
  131148. * @returns the version number. if not found will return -1
  131149. */
  131150. static GetLatestVersionOfFeature(featureName: string): number;
  131151. /**
  131152. * Return the latest stable version of this feature
  131153. * @param featureName the name of the feature to search
  131154. * @returns the version number. if not found will return -1
  131155. */
  131156. static GetStableVersionOfFeature(featureName: string): number;
  131157. /**
  131158. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131159. * Can be used during a session to start a feature
  131160. * @param featureName the name of feature to attach
  131161. */
  131162. attachFeature(featureName: string): void;
  131163. /**
  131164. * Can be used inside a session or when the session ends to detach a specific feature
  131165. * @param featureName the name of the feature to detach
  131166. */
  131167. detachFeature(featureName: string): void;
  131168. /**
  131169. * Used to disable an already-enabled feature
  131170. * The feature will be disposed and will be recreated once enabled.
  131171. * @param featureName the feature to disable
  131172. * @returns true if disable was successful
  131173. */
  131174. disableFeature(featureName: string | {
  131175. Name: string;
  131176. }): boolean;
  131177. /**
  131178. * dispose this features manager
  131179. */
  131180. dispose(): void;
  131181. /**
  131182. * 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.
  131183. * 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.
  131184. *
  131185. * @param featureName the name of the feature to load or the class of the feature
  131186. * @param version optional version to load. if not provided the latest version will be enabled
  131187. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131188. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131189. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131190. * @returns a new constructed feature or throws an error if feature not found.
  131191. */
  131192. enableFeature(featureName: string | {
  131193. Name: string;
  131194. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131195. /**
  131196. * get the implementation of an enabled feature.
  131197. * @param featureName the name of the feature to load
  131198. * @returns the feature class, if found
  131199. */
  131200. getEnabledFeature(featureName: string): IWebXRFeature;
  131201. /**
  131202. * Get the list of enabled features
  131203. * @returns an array of enabled features
  131204. */
  131205. getEnabledFeatures(): string[];
  131206. /**
  131207. * This function will exten the session creation configuration object with enabled features.
  131208. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131209. * according to the defined "required" variable, provided during enableFeature call
  131210. * @param xrSessionInit the xr Session init object to extend
  131211. *
  131212. * @returns an extended XRSessionInit object
  131213. */
  131214. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131215. }
  131216. }
  131217. declare module BABYLON {
  131218. /**
  131219. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131220. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131221. */
  131222. export class WebXRExperienceHelper implements IDisposable {
  131223. private scene;
  131224. private _nonVRCamera;
  131225. private _originalSceneAutoClear;
  131226. private _supported;
  131227. /**
  131228. * Camera used to render xr content
  131229. */
  131230. camera: WebXRCamera;
  131231. /** A features manager for this xr session */
  131232. featuresManager: WebXRFeaturesManager;
  131233. /**
  131234. * Observers registered here will be triggered after the camera's initial transformation is set
  131235. * This can be used to set a different ground level or an extra rotation.
  131236. *
  131237. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131238. * to the position set after this observable is done executing.
  131239. */
  131240. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131241. /**
  131242. * Fires when the state of the experience helper has changed
  131243. */
  131244. onStateChangedObservable: Observable<WebXRState>;
  131245. /** Session manager used to keep track of xr session */
  131246. sessionManager: WebXRSessionManager;
  131247. /**
  131248. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131249. */
  131250. state: WebXRState;
  131251. /**
  131252. * Creates a WebXRExperienceHelper
  131253. * @param scene The scene the helper should be created in
  131254. */
  131255. private constructor();
  131256. /**
  131257. * Creates the experience helper
  131258. * @param scene the scene to attach the experience helper to
  131259. * @returns a promise for the experience helper
  131260. */
  131261. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131262. /**
  131263. * Disposes of the experience helper
  131264. */
  131265. dispose(): void;
  131266. /**
  131267. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131268. * @param sessionMode options for the XR session
  131269. * @param referenceSpaceType frame of reference of the XR session
  131270. * @param renderTarget the output canvas that will be used to enter XR mode
  131271. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131272. * @returns promise that resolves after xr mode has entered
  131273. */
  131274. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131275. /**
  131276. * Exits XR mode and returns the scene to its original state
  131277. * @returns promise that resolves after xr mode has exited
  131278. */
  131279. exitXRAsync(): Promise<void>;
  131280. private _nonXRToXRCamera;
  131281. private _setState;
  131282. }
  131283. }
  131284. declare module BABYLON {
  131285. /**
  131286. * X-Y values for axes in WebXR
  131287. */
  131288. export interface IWebXRMotionControllerAxesValue {
  131289. /**
  131290. * The value of the x axis
  131291. */
  131292. x: number;
  131293. /**
  131294. * The value of the y-axis
  131295. */
  131296. y: number;
  131297. }
  131298. /**
  131299. * changed / previous values for the values of this component
  131300. */
  131301. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131302. /**
  131303. * current (this frame) value
  131304. */
  131305. current: T;
  131306. /**
  131307. * previous (last change) value
  131308. */
  131309. previous: T;
  131310. }
  131311. /**
  131312. * Represents changes in the component between current frame and last values recorded
  131313. */
  131314. export interface IWebXRMotionControllerComponentChanges {
  131315. /**
  131316. * will be populated with previous and current values if axes changed
  131317. */
  131318. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131319. /**
  131320. * will be populated with previous and current values if pressed changed
  131321. */
  131322. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131323. /**
  131324. * will be populated with previous and current values if touched changed
  131325. */
  131326. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131327. /**
  131328. * will be populated with previous and current values if value changed
  131329. */
  131330. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131331. }
  131332. /**
  131333. * This class represents a single component (for example button or thumbstick) of a motion controller
  131334. */
  131335. export class WebXRControllerComponent implements IDisposable {
  131336. /**
  131337. * the id of this component
  131338. */
  131339. id: string;
  131340. /**
  131341. * the type of the component
  131342. */
  131343. type: MotionControllerComponentType;
  131344. private _buttonIndex;
  131345. private _axesIndices;
  131346. private _axes;
  131347. private _changes;
  131348. private _currentValue;
  131349. private _hasChanges;
  131350. private _pressed;
  131351. private _touched;
  131352. /**
  131353. * button component type
  131354. */
  131355. static BUTTON_TYPE: MotionControllerComponentType;
  131356. /**
  131357. * squeeze component type
  131358. */
  131359. static SQUEEZE_TYPE: MotionControllerComponentType;
  131360. /**
  131361. * Thumbstick component type
  131362. */
  131363. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131364. /**
  131365. * Touchpad component type
  131366. */
  131367. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131368. /**
  131369. * trigger component type
  131370. */
  131371. static TRIGGER_TYPE: MotionControllerComponentType;
  131372. /**
  131373. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131374. * the axes data changes
  131375. */
  131376. onAxisValueChangedObservable: Observable<{
  131377. x: number;
  131378. y: number;
  131379. }>;
  131380. /**
  131381. * Observers registered here will be triggered when the state of a button changes
  131382. * State change is either pressed / touched / value
  131383. */
  131384. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131385. /**
  131386. * Creates a new component for a motion controller.
  131387. * It is created by the motion controller itself
  131388. *
  131389. * @param id the id of this component
  131390. * @param type the type of the component
  131391. * @param _buttonIndex index in the buttons array of the gamepad
  131392. * @param _axesIndices indices of the values in the axes array of the gamepad
  131393. */
  131394. constructor(
  131395. /**
  131396. * the id of this component
  131397. */
  131398. id: string,
  131399. /**
  131400. * the type of the component
  131401. */
  131402. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131403. /**
  131404. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131405. */
  131406. get axes(): IWebXRMotionControllerAxesValue;
  131407. /**
  131408. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131409. */
  131410. get changes(): IWebXRMotionControllerComponentChanges;
  131411. /**
  131412. * Return whether or not the component changed the last frame
  131413. */
  131414. get hasChanges(): boolean;
  131415. /**
  131416. * is the button currently pressed
  131417. */
  131418. get pressed(): boolean;
  131419. /**
  131420. * is the button currently touched
  131421. */
  131422. get touched(): boolean;
  131423. /**
  131424. * Get the current value of this component
  131425. */
  131426. get value(): number;
  131427. /**
  131428. * Dispose this component
  131429. */
  131430. dispose(): void;
  131431. /**
  131432. * Are there axes correlating to this component
  131433. * @return true is axes data is available
  131434. */
  131435. isAxes(): boolean;
  131436. /**
  131437. * Is this component a button (hence - pressable)
  131438. * @returns true if can be pressed
  131439. */
  131440. isButton(): boolean;
  131441. /**
  131442. * update this component using the gamepad object it is in. Called on every frame
  131443. * @param nativeController the native gamepad controller object
  131444. */
  131445. update(nativeController: IMinimalMotionControllerObject): void;
  131446. }
  131447. }
  131448. declare module BABYLON {
  131449. /**
  131450. * Interface used to represent data loading progression
  131451. */
  131452. export interface ISceneLoaderProgressEvent {
  131453. /**
  131454. * Defines if data length to load can be evaluated
  131455. */
  131456. readonly lengthComputable: boolean;
  131457. /**
  131458. * Defines the loaded data length
  131459. */
  131460. readonly loaded: number;
  131461. /**
  131462. * Defines the data length to load
  131463. */
  131464. readonly total: number;
  131465. }
  131466. /**
  131467. * Interface used by SceneLoader plugins to define supported file extensions
  131468. */
  131469. export interface ISceneLoaderPluginExtensions {
  131470. /**
  131471. * Defines the list of supported extensions
  131472. */
  131473. [extension: string]: {
  131474. isBinary: boolean;
  131475. };
  131476. }
  131477. /**
  131478. * Interface used by SceneLoader plugin factory
  131479. */
  131480. export interface ISceneLoaderPluginFactory {
  131481. /**
  131482. * Defines the name of the factory
  131483. */
  131484. name: string;
  131485. /**
  131486. * Function called to create a new plugin
  131487. * @return the new plugin
  131488. */
  131489. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131490. /**
  131491. * The callback that returns true if the data can be directly loaded.
  131492. * @param data string containing the file data
  131493. * @returns if the data can be loaded directly
  131494. */
  131495. canDirectLoad?(data: string): boolean;
  131496. }
  131497. /**
  131498. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131499. */
  131500. export interface ISceneLoaderPluginBase {
  131501. /**
  131502. * The friendly name of this plugin.
  131503. */
  131504. name: string;
  131505. /**
  131506. * The file extensions supported by this plugin.
  131507. */
  131508. extensions: string | ISceneLoaderPluginExtensions;
  131509. /**
  131510. * The callback called when loading from a url.
  131511. * @param scene scene loading this url
  131512. * @param url url to load
  131513. * @param onSuccess callback called when the file successfully loads
  131514. * @param onProgress callback called while file is loading (if the server supports this mode)
  131515. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131516. * @param onError callback called when the file fails to load
  131517. * @returns a file request object
  131518. */
  131519. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131520. /**
  131521. * The callback called when loading from a file object.
  131522. * @param scene scene loading this file
  131523. * @param file defines the file to load
  131524. * @param onSuccess defines the callback to call when data is loaded
  131525. * @param onProgress defines the callback to call during loading process
  131526. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131527. * @param onError defines the callback to call when an error occurs
  131528. * @returns a file request object
  131529. */
  131530. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131531. /**
  131532. * The callback that returns true if the data can be directly loaded.
  131533. * @param data string containing the file data
  131534. * @returns if the data can be loaded directly
  131535. */
  131536. canDirectLoad?(data: string): boolean;
  131537. /**
  131538. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131539. * @param scene scene loading this data
  131540. * @param data string containing the data
  131541. * @returns data to pass to the plugin
  131542. */
  131543. directLoad?(scene: Scene, data: string): any;
  131544. /**
  131545. * The callback that allows custom handling of the root url based on the response url.
  131546. * @param rootUrl the original root url
  131547. * @param responseURL the response url if available
  131548. * @returns the new root url
  131549. */
  131550. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131551. }
  131552. /**
  131553. * Interface used to define a SceneLoader plugin
  131554. */
  131555. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131556. /**
  131557. * Import meshes into a scene.
  131558. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131559. * @param scene The scene to import into
  131560. * @param data The data to import
  131561. * @param rootUrl The root url for scene and resources
  131562. * @param meshes The meshes array to import into
  131563. * @param particleSystems The particle systems array to import into
  131564. * @param skeletons The skeletons array to import into
  131565. * @param onError The callback when import fails
  131566. * @returns True if successful or false otherwise
  131567. */
  131568. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131569. /**
  131570. * Load into a scene.
  131571. * @param scene The scene to load into
  131572. * @param data The data to import
  131573. * @param rootUrl The root url for scene and resources
  131574. * @param onError The callback when import fails
  131575. * @returns True if successful or false otherwise
  131576. */
  131577. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131578. /**
  131579. * Load into an asset container.
  131580. * @param scene The scene to load into
  131581. * @param data The data to import
  131582. * @param rootUrl The root url for scene and resources
  131583. * @param onError The callback when import fails
  131584. * @returns The loaded asset container
  131585. */
  131586. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131587. }
  131588. /**
  131589. * Interface used to define an async SceneLoader plugin
  131590. */
  131591. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131592. /**
  131593. * Import meshes into a scene.
  131594. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131595. * @param scene The scene to import into
  131596. * @param data The data to import
  131597. * @param rootUrl The root url for scene and resources
  131598. * @param onProgress The callback when the load progresses
  131599. * @param fileName Defines the name of the file to load
  131600. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131601. */
  131602. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131603. meshes: AbstractMesh[];
  131604. particleSystems: IParticleSystem[];
  131605. skeletons: Skeleton[];
  131606. animationGroups: AnimationGroup[];
  131607. }>;
  131608. /**
  131609. * Load into a scene.
  131610. * @param scene The scene to load into
  131611. * @param data The data to import
  131612. * @param rootUrl The root url for scene and resources
  131613. * @param onProgress The callback when the load progresses
  131614. * @param fileName Defines the name of the file to load
  131615. * @returns Nothing
  131616. */
  131617. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131618. /**
  131619. * Load into an asset container.
  131620. * @param scene The scene to load into
  131621. * @param data The data to import
  131622. * @param rootUrl The root url for scene and resources
  131623. * @param onProgress The callback when the load progresses
  131624. * @param fileName Defines the name of the file to load
  131625. * @returns The loaded asset container
  131626. */
  131627. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131628. }
  131629. /**
  131630. * Mode that determines how to handle old animation groups before loading new ones.
  131631. */
  131632. export enum SceneLoaderAnimationGroupLoadingMode {
  131633. /**
  131634. * Reset all old animations to initial state then dispose them.
  131635. */
  131636. Clean = 0,
  131637. /**
  131638. * Stop all old animations.
  131639. */
  131640. Stop = 1,
  131641. /**
  131642. * Restart old animations from first frame.
  131643. */
  131644. Sync = 2,
  131645. /**
  131646. * Old animations remains untouched.
  131647. */
  131648. NoSync = 3
  131649. }
  131650. /**
  131651. * Defines a plugin registered by the SceneLoader
  131652. */
  131653. interface IRegisteredPlugin {
  131654. /**
  131655. * Defines the plugin to use
  131656. */
  131657. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131658. /**
  131659. * Defines if the plugin supports binary data
  131660. */
  131661. isBinary: boolean;
  131662. }
  131663. /**
  131664. * Class used to load scene from various file formats using registered plugins
  131665. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131666. */
  131667. export class SceneLoader {
  131668. /**
  131669. * No logging while loading
  131670. */
  131671. static readonly NO_LOGGING: number;
  131672. /**
  131673. * Minimal logging while loading
  131674. */
  131675. static readonly MINIMAL_LOGGING: number;
  131676. /**
  131677. * Summary logging while loading
  131678. */
  131679. static readonly SUMMARY_LOGGING: number;
  131680. /**
  131681. * Detailled logging while loading
  131682. */
  131683. static readonly DETAILED_LOGGING: number;
  131684. /**
  131685. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131686. */
  131687. static get ForceFullSceneLoadingForIncremental(): boolean;
  131688. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131689. /**
  131690. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131691. */
  131692. static get ShowLoadingScreen(): boolean;
  131693. static set ShowLoadingScreen(value: boolean);
  131694. /**
  131695. * Defines the current logging level (while loading the scene)
  131696. * @ignorenaming
  131697. */
  131698. static get loggingLevel(): number;
  131699. static set loggingLevel(value: number);
  131700. /**
  131701. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131702. */
  131703. static get CleanBoneMatrixWeights(): boolean;
  131704. static set CleanBoneMatrixWeights(value: boolean);
  131705. /**
  131706. * Event raised when a plugin is used to load a scene
  131707. */
  131708. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131709. private static _registeredPlugins;
  131710. private static _showingLoadingScreen;
  131711. /**
  131712. * Gets the default plugin (used to load Babylon files)
  131713. * @returns the .babylon plugin
  131714. */
  131715. static GetDefaultPlugin(): IRegisteredPlugin;
  131716. private static _GetPluginForExtension;
  131717. private static _GetPluginForDirectLoad;
  131718. private static _GetPluginForFilename;
  131719. private static _GetDirectLoad;
  131720. private static _LoadData;
  131721. private static _GetFileInfo;
  131722. /**
  131723. * Gets a plugin that can load the given extension
  131724. * @param extension defines the extension to load
  131725. * @returns a plugin or null if none works
  131726. */
  131727. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131728. /**
  131729. * Gets a boolean indicating that the given extension can be loaded
  131730. * @param extension defines the extension to load
  131731. * @returns true if the extension is supported
  131732. */
  131733. static IsPluginForExtensionAvailable(extension: string): boolean;
  131734. /**
  131735. * Adds a new plugin to the list of registered plugins
  131736. * @param plugin defines the plugin to add
  131737. */
  131738. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131739. /**
  131740. * Import meshes into a scene
  131741. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131742. * @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)
  131743. * @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)
  131744. * @param scene the instance of BABYLON.Scene to append to
  131745. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131746. * @param onProgress a callback with a progress event for each file being loaded
  131747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131748. * @param pluginExtension the extension used to determine the plugin
  131749. * @returns The loaded plugin
  131750. */
  131751. 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>;
  131752. /**
  131753. * Import meshes into a scene
  131754. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131755. * @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)
  131756. * @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)
  131757. * @param scene the instance of BABYLON.Scene to append to
  131758. * @param onProgress a callback with a progress event for each file being loaded
  131759. * @param pluginExtension the extension used to determine the plugin
  131760. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131761. */
  131762. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131763. meshes: AbstractMesh[];
  131764. particleSystems: IParticleSystem[];
  131765. skeletons: Skeleton[];
  131766. animationGroups: AnimationGroup[];
  131767. }>;
  131768. /**
  131769. * Load a scene
  131770. * @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)
  131771. * @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)
  131772. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131773. * @param onSuccess a callback with the scene when import succeeds
  131774. * @param onProgress a callback with a progress event for each file being loaded
  131775. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131776. * @param pluginExtension the extension used to determine the plugin
  131777. * @returns The loaded plugin
  131778. */
  131779. 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>;
  131780. /**
  131781. * Load a scene
  131782. * @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)
  131783. * @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)
  131784. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131785. * @param onProgress a callback with a progress event for each file being loaded
  131786. * @param pluginExtension the extension used to determine the plugin
  131787. * @returns The loaded scene
  131788. */
  131789. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131790. /**
  131791. * Append a scene
  131792. * @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)
  131793. * @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)
  131794. * @param scene is the instance of BABYLON.Scene to append to
  131795. * @param onSuccess a callback with the scene when import succeeds
  131796. * @param onProgress a callback with a progress event for each file being loaded
  131797. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131798. * @param pluginExtension the extension used to determine the plugin
  131799. * @returns The loaded plugin
  131800. */
  131801. 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>;
  131802. /**
  131803. * Append a scene
  131804. * @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)
  131805. * @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)
  131806. * @param scene is the instance of BABYLON.Scene to append to
  131807. * @param onProgress a callback with a progress event for each file being loaded
  131808. * @param pluginExtension the extension used to determine the plugin
  131809. * @returns The given scene
  131810. */
  131811. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131812. /**
  131813. * Load a scene into an asset container
  131814. * @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)
  131815. * @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)
  131816. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131817. * @param onSuccess a callback with the scene when import succeeds
  131818. * @param onProgress a callback with a progress event for each file being loaded
  131819. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131820. * @param pluginExtension the extension used to determine the plugin
  131821. * @returns The loaded plugin
  131822. */
  131823. 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>;
  131824. /**
  131825. * Load a scene into an asset container
  131826. * @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)
  131827. * @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)
  131828. * @param scene is the instance of Scene to append to
  131829. * @param onProgress a callback with a progress event for each file being loaded
  131830. * @param pluginExtension the extension used to determine the plugin
  131831. * @returns The loaded asset container
  131832. */
  131833. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131834. /**
  131835. * Import animations from a file into a scene
  131836. * @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)
  131837. * @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)
  131838. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131839. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131840. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131841. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131842. * @param onSuccess a callback with the scene when import succeeds
  131843. * @param onProgress a callback with a progress event for each file being loaded
  131844. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131845. * @param pluginExtension the extension used to determine the plugin
  131846. */
  131847. 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;
  131848. /**
  131849. * Import animations from a file into a scene
  131850. * @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)
  131851. * @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)
  131852. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131853. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131854. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131855. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131856. * @param onSuccess a callback with the scene when import succeeds
  131857. * @param onProgress a callback with a progress event for each file being loaded
  131858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131859. * @param pluginExtension the extension used to determine the plugin
  131860. * @returns the updated scene with imported animations
  131861. */
  131862. 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>;
  131863. }
  131864. }
  131865. declare module BABYLON {
  131866. /**
  131867. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131868. */
  131869. export type MotionControllerHandedness = "none" | "left" | "right";
  131870. /**
  131871. * The type of components available in motion controllers.
  131872. * This is not the name of the component.
  131873. */
  131874. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131875. /**
  131876. * The state of a controller component
  131877. */
  131878. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131879. /**
  131880. * The schema of motion controller layout.
  131881. * No object will be initialized using this interface
  131882. * This is used just to define the profile.
  131883. */
  131884. export interface IMotionControllerLayout {
  131885. /**
  131886. * Path to load the assets. Usually relative to the base path
  131887. */
  131888. assetPath: string;
  131889. /**
  131890. * Available components (unsorted)
  131891. */
  131892. components: {
  131893. /**
  131894. * A map of component Ids
  131895. */
  131896. [componentId: string]: {
  131897. /**
  131898. * The type of input the component outputs
  131899. */
  131900. type: MotionControllerComponentType;
  131901. /**
  131902. * The indices of this component in the gamepad object
  131903. */
  131904. gamepadIndices: {
  131905. /**
  131906. * Index of button
  131907. */
  131908. button?: number;
  131909. /**
  131910. * If available, index of x-axis
  131911. */
  131912. xAxis?: number;
  131913. /**
  131914. * If available, index of y-axis
  131915. */
  131916. yAxis?: number;
  131917. };
  131918. /**
  131919. * The mesh's root node name
  131920. */
  131921. rootNodeName: string;
  131922. /**
  131923. * Animation definitions for this model
  131924. */
  131925. visualResponses: {
  131926. [stateKey: string]: {
  131927. /**
  131928. * What property will be animated
  131929. */
  131930. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131931. /**
  131932. * What states influence this visual response
  131933. */
  131934. states: MotionControllerComponentStateType[];
  131935. /**
  131936. * Type of animation - movement or visibility
  131937. */
  131938. valueNodeProperty: "transform" | "visibility";
  131939. /**
  131940. * Base node name to move. Its position will be calculated according to the min and max nodes
  131941. */
  131942. valueNodeName?: string;
  131943. /**
  131944. * Minimum movement node
  131945. */
  131946. minNodeName?: string;
  131947. /**
  131948. * Max movement node
  131949. */
  131950. maxNodeName?: string;
  131951. };
  131952. };
  131953. /**
  131954. * If touch enabled, what is the name of node to display user feedback
  131955. */
  131956. touchPointNodeName?: string;
  131957. };
  131958. };
  131959. /**
  131960. * Is it xr standard mapping or not
  131961. */
  131962. gamepadMapping: "" | "xr-standard";
  131963. /**
  131964. * Base root node of this entire model
  131965. */
  131966. rootNodeName: string;
  131967. /**
  131968. * Defines the main button component id
  131969. */
  131970. selectComponentId: string;
  131971. }
  131972. /**
  131973. * A definition for the layout map in the input profile
  131974. */
  131975. export interface IMotionControllerLayoutMap {
  131976. /**
  131977. * Layouts with handedness type as a key
  131978. */
  131979. [handedness: string]: IMotionControllerLayout;
  131980. }
  131981. /**
  131982. * The XR Input profile schema
  131983. * Profiles can be found here:
  131984. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131985. */
  131986. export interface IMotionControllerProfile {
  131987. /**
  131988. * fallback profiles for this profileId
  131989. */
  131990. fallbackProfileIds: string[];
  131991. /**
  131992. * The layout map, with handedness as key
  131993. */
  131994. layouts: IMotionControllerLayoutMap;
  131995. /**
  131996. * The id of this profile
  131997. * correlates to the profile(s) in the xrInput.profiles array
  131998. */
  131999. profileId: string;
  132000. }
  132001. /**
  132002. * A helper-interface for the 3 meshes needed for controller button animation
  132003. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  132004. */
  132005. export interface IMotionControllerButtonMeshMap {
  132006. /**
  132007. * the mesh that defines the pressed value mesh position.
  132008. * This is used to find the max-position of this button
  132009. */
  132010. pressedMesh: AbstractMesh;
  132011. /**
  132012. * the mesh that defines the unpressed value mesh position.
  132013. * This is used to find the min (or initial) position of this button
  132014. */
  132015. unpressedMesh: AbstractMesh;
  132016. /**
  132017. * The mesh that will be changed when value changes
  132018. */
  132019. valueMesh: AbstractMesh;
  132020. }
  132021. /**
  132022. * A helper-interface for the 3 meshes needed for controller axis animation.
  132023. * This will be expanded when touchpad animations are fully supported
  132024. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  132025. */
  132026. export interface IMotionControllerMeshMap {
  132027. /**
  132028. * the mesh that defines the maximum value mesh position.
  132029. */
  132030. maxMesh?: AbstractMesh;
  132031. /**
  132032. * the mesh that defines the minimum value mesh position.
  132033. */
  132034. minMesh?: AbstractMesh;
  132035. /**
  132036. * The mesh that will be changed when axis value changes
  132037. */
  132038. valueMesh?: AbstractMesh;
  132039. }
  132040. /**
  132041. * The elements needed for change-detection of the gamepad objects in motion controllers
  132042. */
  132043. export interface IMinimalMotionControllerObject {
  132044. /**
  132045. * Available axes of this controller
  132046. */
  132047. axes: number[];
  132048. /**
  132049. * An array of available buttons
  132050. */
  132051. buttons: Array<{
  132052. /**
  132053. * Value of the button/trigger
  132054. */
  132055. value: number;
  132056. /**
  132057. * If the button/trigger is currently touched
  132058. */
  132059. touched: boolean;
  132060. /**
  132061. * If the button/trigger is currently pressed
  132062. */
  132063. pressed: boolean;
  132064. }>;
  132065. /**
  132066. * EXPERIMENTAL haptic support.
  132067. */
  132068. hapticActuators?: Array<{
  132069. pulse: (value: number, duration: number) => Promise<boolean>;
  132070. }>;
  132071. }
  132072. /**
  132073. * An Abstract Motion controller
  132074. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132075. * Each component has an observable to check for changes in value and state
  132076. */
  132077. export abstract class WebXRAbstractMotionController implements IDisposable {
  132078. protected scene: Scene;
  132079. protected layout: IMotionControllerLayout;
  132080. /**
  132081. * The gamepad object correlating to this controller
  132082. */
  132083. gamepadObject: IMinimalMotionControllerObject;
  132084. /**
  132085. * handedness (left/right/none) of this controller
  132086. */
  132087. handedness: MotionControllerHandedness;
  132088. private _initComponent;
  132089. private _modelReady;
  132090. /**
  132091. * A map of components (WebXRControllerComponent) in this motion controller
  132092. * Components have a ComponentType and can also have both button and axis definitions
  132093. */
  132094. readonly components: {
  132095. [id: string]: WebXRControllerComponent;
  132096. };
  132097. /**
  132098. * Disable the model's animation. Can be set at any time.
  132099. */
  132100. disableAnimation: boolean;
  132101. /**
  132102. * Observers registered here will be triggered when the model of this controller is done loading
  132103. */
  132104. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132105. /**
  132106. * The profile id of this motion controller
  132107. */
  132108. abstract profileId: string;
  132109. /**
  132110. * The root mesh of the model. It is null if the model was not yet initialized
  132111. */
  132112. rootMesh: Nullable<AbstractMesh>;
  132113. /**
  132114. * constructs a new abstract motion controller
  132115. * @param scene the scene to which the model of the controller will be added
  132116. * @param layout The profile layout to load
  132117. * @param gamepadObject The gamepad object correlating to this controller
  132118. * @param handedness handedness (left/right/none) of this controller
  132119. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132120. */
  132121. constructor(scene: Scene, layout: IMotionControllerLayout,
  132122. /**
  132123. * The gamepad object correlating to this controller
  132124. */
  132125. gamepadObject: IMinimalMotionControllerObject,
  132126. /**
  132127. * handedness (left/right/none) of this controller
  132128. */
  132129. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132130. /**
  132131. * Dispose this controller, the model mesh and all its components
  132132. */
  132133. dispose(): void;
  132134. /**
  132135. * Returns all components of specific type
  132136. * @param type the type to search for
  132137. * @return an array of components with this type
  132138. */
  132139. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132140. /**
  132141. * get a component based an its component id as defined in layout.components
  132142. * @param id the id of the component
  132143. * @returns the component correlates to the id or undefined if not found
  132144. */
  132145. getComponent(id: string): WebXRControllerComponent;
  132146. /**
  132147. * Get the list of components available in this motion controller
  132148. * @returns an array of strings correlating to available components
  132149. */
  132150. getComponentIds(): string[];
  132151. /**
  132152. * Get the first component of specific type
  132153. * @param type type of component to find
  132154. * @return a controller component or null if not found
  132155. */
  132156. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132157. /**
  132158. * Get the main (Select) component of this controller as defined in the layout
  132159. * @returns the main component of this controller
  132160. */
  132161. getMainComponent(): WebXRControllerComponent;
  132162. /**
  132163. * Loads the model correlating to this controller
  132164. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132165. * @returns A promise fulfilled with the result of the model loading
  132166. */
  132167. loadModel(): Promise<boolean>;
  132168. /**
  132169. * Update this model using the current XRFrame
  132170. * @param xrFrame the current xr frame to use and update the model
  132171. */
  132172. updateFromXRFrame(xrFrame: XRFrame): void;
  132173. /**
  132174. * Backwards compatibility due to a deeply-integrated typo
  132175. */
  132176. get handness(): XREye;
  132177. /**
  132178. * Pulse (vibrate) this controller
  132179. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132180. * Consecutive calls to this function will cancel the last pulse call
  132181. *
  132182. * @param value the strength of the pulse in 0.0...1.0 range
  132183. * @param duration Duration of the pulse in milliseconds
  132184. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132185. * @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
  132186. */
  132187. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132188. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132189. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132190. /**
  132191. * Moves the axis on the controller mesh based on its current state
  132192. * @param axis the index of the axis
  132193. * @param axisValue the value of the axis which determines the meshes new position
  132194. * @hidden
  132195. */
  132196. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132197. /**
  132198. * Update the model itself with the current frame data
  132199. * @param xrFrame the frame to use for updating the model mesh
  132200. */
  132201. protected updateModel(xrFrame: XRFrame): void;
  132202. /**
  132203. * Get the filename and path for this controller's model
  132204. * @returns a map of filename and path
  132205. */
  132206. protected abstract _getFilenameAndPath(): {
  132207. filename: string;
  132208. path: string;
  132209. };
  132210. /**
  132211. * This function is called before the mesh is loaded. It checks for loading constraints.
  132212. * For example, this function can check if the GLB loader is available
  132213. * If this function returns false, the generic controller will be loaded instead
  132214. * @returns Is the client ready to load the mesh
  132215. */
  132216. protected abstract _getModelLoadingConstraints(): boolean;
  132217. /**
  132218. * This function will be called after the model was successfully loaded and can be used
  132219. * for mesh transformations before it is available for the user
  132220. * @param meshes the loaded meshes
  132221. */
  132222. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132223. /**
  132224. * Set the root mesh for this controller. Important for the WebXR controller class
  132225. * @param meshes the loaded meshes
  132226. */
  132227. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132228. /**
  132229. * A function executed each frame that updates the mesh (if needed)
  132230. * @param xrFrame the current xrFrame
  132231. */
  132232. protected abstract _updateModel(xrFrame: XRFrame): void;
  132233. private _getGenericFilenameAndPath;
  132234. private _getGenericParentMesh;
  132235. }
  132236. }
  132237. declare module BABYLON {
  132238. /**
  132239. * A generic trigger-only motion controller for WebXR
  132240. */
  132241. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132242. /**
  132243. * Static version of the profile id of this controller
  132244. */
  132245. static ProfileId: string;
  132246. profileId: string;
  132247. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132248. protected _getFilenameAndPath(): {
  132249. filename: string;
  132250. path: string;
  132251. };
  132252. protected _getModelLoadingConstraints(): boolean;
  132253. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132254. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132255. protected _updateModel(): void;
  132256. }
  132257. }
  132258. declare module BABYLON {
  132259. /**
  132260. * Class containing static functions to help procedurally build meshes
  132261. */
  132262. export class SphereBuilder {
  132263. /**
  132264. * Creates a sphere mesh
  132265. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132266. * * 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`)
  132267. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132268. * * 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
  132269. * * 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)
  132270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132273. * @param name defines the name of the mesh
  132274. * @param options defines the options used to create the mesh
  132275. * @param scene defines the hosting scene
  132276. * @returns the sphere mesh
  132277. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132278. */
  132279. static CreateSphere(name: string, options: {
  132280. segments?: number;
  132281. diameter?: number;
  132282. diameterX?: number;
  132283. diameterY?: number;
  132284. diameterZ?: number;
  132285. arc?: number;
  132286. slice?: number;
  132287. sideOrientation?: number;
  132288. frontUVs?: Vector4;
  132289. backUVs?: Vector4;
  132290. updatable?: boolean;
  132291. }, scene?: Nullable<Scene>): Mesh;
  132292. }
  132293. }
  132294. declare module BABYLON {
  132295. /**
  132296. * A profiled motion controller has its profile loaded from an online repository.
  132297. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132298. */
  132299. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132300. private _repositoryUrl;
  132301. private _buttonMeshMapping;
  132302. private _touchDots;
  132303. /**
  132304. * The profile ID of this controller. Will be populated when the controller initializes.
  132305. */
  132306. profileId: string;
  132307. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132308. dispose(): void;
  132309. protected _getFilenameAndPath(): {
  132310. filename: string;
  132311. path: string;
  132312. };
  132313. protected _getModelLoadingConstraints(): boolean;
  132314. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132315. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132316. protected _updateModel(_xrFrame: XRFrame): void;
  132317. }
  132318. }
  132319. declare module BABYLON {
  132320. /**
  132321. * A construction function type to create a new controller based on an xrInput object
  132322. */
  132323. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132324. /**
  132325. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132326. *
  132327. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132328. * it should be replaced with auto-loaded controllers.
  132329. *
  132330. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132331. */
  132332. export class WebXRMotionControllerManager {
  132333. private static _AvailableControllers;
  132334. private static _Fallbacks;
  132335. private static _ProfileLoadingPromises;
  132336. private static _ProfilesList;
  132337. /**
  132338. * The base URL of the online controller repository. Can be changed at any time.
  132339. */
  132340. static BaseRepositoryUrl: string;
  132341. /**
  132342. * Which repository gets priority - local or online
  132343. */
  132344. static PrioritizeOnlineRepository: boolean;
  132345. /**
  132346. * Use the online repository, or use only locally-defined controllers
  132347. */
  132348. static UseOnlineRepository: boolean;
  132349. /**
  132350. * Clear the cache used for profile loading and reload when requested again
  132351. */
  132352. static ClearProfilesCache(): void;
  132353. /**
  132354. * Register the default fallbacks.
  132355. * This function is called automatically when this file is imported.
  132356. */
  132357. static DefaultFallbacks(): void;
  132358. /**
  132359. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132360. * @param profileId the profile to which a fallback needs to be found
  132361. * @return an array with corresponding fallback profiles
  132362. */
  132363. static FindFallbackWithProfileId(profileId: string): string[];
  132364. /**
  132365. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132366. * The order of search:
  132367. *
  132368. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132369. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132370. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132371. * 4) return the generic trigger controller if none were found
  132372. *
  132373. * @param xrInput the xrInput to which a new controller is initialized
  132374. * @param scene the scene to which the model will be added
  132375. * @param forceProfile force a certain profile for this controller
  132376. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132377. */
  132378. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132379. /**
  132380. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132381. *
  132382. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132383. *
  132384. * @param type the profile type to register
  132385. * @param constructFunction the function to be called when loading this profile
  132386. */
  132387. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132388. /**
  132389. * Register a fallback to a specific profile.
  132390. * @param profileId the profileId that will receive the fallbacks
  132391. * @param fallbacks A list of fallback profiles
  132392. */
  132393. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132394. /**
  132395. * Will update the list of profiles available in the repository
  132396. * @return a promise that resolves to a map of profiles available online
  132397. */
  132398. static UpdateProfilesList(): Promise<{
  132399. [profile: string]: string;
  132400. }>;
  132401. private static _LoadProfileFromRepository;
  132402. private static _LoadProfilesFromAvailableControllers;
  132403. }
  132404. }
  132405. declare module BABYLON {
  132406. /**
  132407. * Configuration options for the WebXR controller creation
  132408. */
  132409. export interface IWebXRControllerOptions {
  132410. /**
  132411. * Should the controller mesh be animated when a user interacts with it
  132412. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132413. */
  132414. disableMotionControllerAnimation?: boolean;
  132415. /**
  132416. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132417. */
  132418. doNotLoadControllerMesh?: boolean;
  132419. /**
  132420. * Force a specific controller type for this controller.
  132421. * This can be used when creating your own profile or when testing different controllers
  132422. */
  132423. forceControllerProfile?: string;
  132424. /**
  132425. * Defines a rendering group ID for meshes that will be loaded.
  132426. * This is for the default controllers only.
  132427. */
  132428. renderingGroupId?: number;
  132429. }
  132430. /**
  132431. * Represents an XR controller
  132432. */
  132433. export class WebXRInputSource {
  132434. private _scene;
  132435. /** The underlying input source for the controller */
  132436. inputSource: XRInputSource;
  132437. private _options;
  132438. private _tmpVector;
  132439. private _uniqueId;
  132440. private _disposed;
  132441. /**
  132442. * 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
  132443. */
  132444. grip?: AbstractMesh;
  132445. /**
  132446. * If available, this is the gamepad object related to this controller.
  132447. * Using this object it is possible to get click events and trackpad changes of the
  132448. * webxr controller that is currently being used.
  132449. */
  132450. motionController?: WebXRAbstractMotionController;
  132451. /**
  132452. * Event that fires when the controller is removed/disposed.
  132453. * The object provided as event data is this controller, after associated assets were disposed.
  132454. * uniqueId is still available.
  132455. */
  132456. onDisposeObservable: Observable<WebXRInputSource>;
  132457. /**
  132458. * Will be triggered when the mesh associated with the motion controller is done loading.
  132459. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132460. * A shortened version of controller -> motion controller -> on mesh loaded.
  132461. */
  132462. onMeshLoadedObservable: Observable<AbstractMesh>;
  132463. /**
  132464. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132465. */
  132466. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132467. /**
  132468. * Pointer which can be used to select objects or attach a visible laser to
  132469. */
  132470. pointer: AbstractMesh;
  132471. /**
  132472. * Creates the input source object
  132473. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132474. * @param _scene the scene which the controller should be associated to
  132475. * @param inputSource the underlying input source for the controller
  132476. * @param _options options for this controller creation
  132477. */
  132478. constructor(_scene: Scene,
  132479. /** The underlying input source for the controller */
  132480. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132481. /**
  132482. * Get this controllers unique id
  132483. */
  132484. get uniqueId(): string;
  132485. /**
  132486. * Disposes of the object
  132487. */
  132488. dispose(): void;
  132489. /**
  132490. * Gets a world space ray coming from the pointer or grip
  132491. * @param result the resulting ray
  132492. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132493. */
  132494. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132495. /**
  132496. * Updates the controller pose based on the given XRFrame
  132497. * @param xrFrame xr frame to update the pose with
  132498. * @param referenceSpace reference space to use
  132499. */
  132500. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132501. }
  132502. }
  132503. declare module BABYLON {
  132504. /**
  132505. * The schema for initialization options of the XR Input class
  132506. */
  132507. export interface IWebXRInputOptions {
  132508. /**
  132509. * If set to true no model will be automatically loaded
  132510. */
  132511. doNotLoadControllerMeshes?: boolean;
  132512. /**
  132513. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132514. * If not found, the xr input profile data will be used.
  132515. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132516. */
  132517. forceInputProfile?: string;
  132518. /**
  132519. * Do not send a request to the controller repository to load the profile.
  132520. *
  132521. * Instead, use the controllers available in babylon itself.
  132522. */
  132523. disableOnlineControllerRepository?: boolean;
  132524. /**
  132525. * A custom URL for the controllers repository
  132526. */
  132527. customControllersRepositoryURL?: string;
  132528. /**
  132529. * Should the controller model's components not move according to the user input
  132530. */
  132531. disableControllerAnimation?: boolean;
  132532. /**
  132533. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132534. */
  132535. controllerOptions?: IWebXRControllerOptions;
  132536. }
  132537. /**
  132538. * XR input used to track XR inputs such as controllers/rays
  132539. */
  132540. export class WebXRInput implements IDisposable {
  132541. /**
  132542. * the xr session manager for this session
  132543. */
  132544. xrSessionManager: WebXRSessionManager;
  132545. /**
  132546. * the WebXR camera for this session. Mainly used for teleportation
  132547. */
  132548. xrCamera: WebXRCamera;
  132549. private readonly options;
  132550. /**
  132551. * XR controllers being tracked
  132552. */
  132553. controllers: Array<WebXRInputSource>;
  132554. private _frameObserver;
  132555. private _sessionEndedObserver;
  132556. private _sessionInitObserver;
  132557. /**
  132558. * Event when a controller has been connected/added
  132559. */
  132560. onControllerAddedObservable: Observable<WebXRInputSource>;
  132561. /**
  132562. * Event when a controller has been removed/disconnected
  132563. */
  132564. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132565. /**
  132566. * Initializes the WebXRInput
  132567. * @param xrSessionManager the xr session manager for this session
  132568. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132569. * @param options = initialization options for this xr input
  132570. */
  132571. constructor(
  132572. /**
  132573. * the xr session manager for this session
  132574. */
  132575. xrSessionManager: WebXRSessionManager,
  132576. /**
  132577. * the WebXR camera for this session. Mainly used for teleportation
  132578. */
  132579. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132580. private _onInputSourcesChange;
  132581. private _addAndRemoveControllers;
  132582. /**
  132583. * Disposes of the object
  132584. */
  132585. dispose(): void;
  132586. }
  132587. }
  132588. declare module BABYLON {
  132589. /**
  132590. * This is the base class for all WebXR features.
  132591. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132592. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132593. */
  132594. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132595. protected _xrSessionManager: WebXRSessionManager;
  132596. private _attached;
  132597. private _removeOnDetach;
  132598. /**
  132599. * Is this feature disposed?
  132600. */
  132601. isDisposed: boolean;
  132602. /**
  132603. * Should auto-attach be disabled?
  132604. */
  132605. disableAutoAttach: boolean;
  132606. /**
  132607. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132608. */
  132609. xrNativeFeatureName: string;
  132610. /**
  132611. * Construct a new (abstract) WebXR feature
  132612. * @param _xrSessionManager the xr session manager for this feature
  132613. */
  132614. constructor(_xrSessionManager: WebXRSessionManager);
  132615. /**
  132616. * Is this feature attached
  132617. */
  132618. get attached(): boolean;
  132619. /**
  132620. * attach this feature
  132621. *
  132622. * @param force should attachment be forced (even when already attached)
  132623. * @returns true if successful, false is failed or already attached
  132624. */
  132625. attach(force?: boolean): boolean;
  132626. /**
  132627. * detach this feature.
  132628. *
  132629. * @returns true if successful, false if failed or already detached
  132630. */
  132631. detach(): boolean;
  132632. /**
  132633. * Dispose this feature and all of the resources attached
  132634. */
  132635. dispose(): void;
  132636. /**
  132637. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132638. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132639. *
  132640. * @returns whether or not the feature is compatible in this environment
  132641. */
  132642. isCompatible(): boolean;
  132643. /**
  132644. * This is used to register callbacks that will automatically be removed when detach is called.
  132645. * @param observable the observable to which the observer will be attached
  132646. * @param callback the callback to register
  132647. */
  132648. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132649. /**
  132650. * Code in this function will be executed on each xrFrame received from the browser.
  132651. * This function will not execute after the feature is detached.
  132652. * @param _xrFrame the current frame
  132653. */
  132654. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132655. }
  132656. }
  132657. declare module BABYLON {
  132658. /**
  132659. * Renders a layer on top of an existing scene
  132660. */
  132661. export class UtilityLayerRenderer implements IDisposable {
  132662. /** the original scene that will be rendered on top of */
  132663. originalScene: Scene;
  132664. private _pointerCaptures;
  132665. private _lastPointerEvents;
  132666. private static _DefaultUtilityLayer;
  132667. private static _DefaultKeepDepthUtilityLayer;
  132668. private _sharedGizmoLight;
  132669. private _renderCamera;
  132670. /**
  132671. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132672. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132673. * @returns the camera that is used when rendering the utility layer
  132674. */
  132675. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132676. /**
  132677. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132678. * @param cam the camera that should be used when rendering the utility layer
  132679. */
  132680. setRenderCamera(cam: Nullable<Camera>): void;
  132681. /**
  132682. * @hidden
  132683. * Light which used by gizmos to get light shading
  132684. */
  132685. _getSharedGizmoLight(): HemisphericLight;
  132686. /**
  132687. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132688. */
  132689. pickUtilitySceneFirst: boolean;
  132690. /**
  132691. * 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)
  132692. */
  132693. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132694. /**
  132695. * 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)
  132696. */
  132697. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132698. /**
  132699. * The scene that is rendered on top of the original scene
  132700. */
  132701. utilityLayerScene: Scene;
  132702. /**
  132703. * If the utility layer should automatically be rendered on top of existing scene
  132704. */
  132705. shouldRender: boolean;
  132706. /**
  132707. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132708. */
  132709. onlyCheckPointerDownEvents: boolean;
  132710. /**
  132711. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132712. */
  132713. processAllEvents: boolean;
  132714. /**
  132715. * Observable raised when the pointer move from the utility layer scene to the main scene
  132716. */
  132717. onPointerOutObservable: Observable<number>;
  132718. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132719. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132720. private _afterRenderObserver;
  132721. private _sceneDisposeObserver;
  132722. private _originalPointerObserver;
  132723. /**
  132724. * Instantiates a UtilityLayerRenderer
  132725. * @param originalScene the original scene that will be rendered on top of
  132726. * @param handleEvents boolean indicating if the utility layer should handle events
  132727. */
  132728. constructor(
  132729. /** the original scene that will be rendered on top of */
  132730. originalScene: Scene, handleEvents?: boolean);
  132731. private _notifyObservers;
  132732. /**
  132733. * Renders the utility layers scene on top of the original scene
  132734. */
  132735. render(): void;
  132736. /**
  132737. * Disposes of the renderer
  132738. */
  132739. dispose(): void;
  132740. private _updateCamera;
  132741. }
  132742. }
  132743. declare module BABYLON {
  132744. /**
  132745. * Options interface for the pointer selection module
  132746. */
  132747. export interface IWebXRControllerPointerSelectionOptions {
  132748. /**
  132749. * if provided, this scene will be used to render meshes.
  132750. */
  132751. customUtilityLayerScene?: Scene;
  132752. /**
  132753. * 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)
  132754. * If not disabled, the last picked point will be used to execute a pointer up event
  132755. * If disabled, pointer up event will be triggered right after the pointer down event.
  132756. * Used in screen and gaze target ray mode only
  132757. */
  132758. disablePointerUpOnTouchOut: boolean;
  132759. /**
  132760. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132761. */
  132762. forceGazeMode: boolean;
  132763. /**
  132764. * 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
  132765. * to start a new countdown to the pointer down event.
  132766. * Defaults to 1.
  132767. */
  132768. gazeModePointerMovedFactor?: number;
  132769. /**
  132770. * Different button type to use instead of the main component
  132771. */
  132772. overrideButtonId?: string;
  132773. /**
  132774. * use this rendering group id for the meshes (optional)
  132775. */
  132776. renderingGroupId?: number;
  132777. /**
  132778. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132779. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132780. * 3000 means 3 seconds between pointing at something and selecting it
  132781. */
  132782. timeToSelect?: number;
  132783. /**
  132784. * Should meshes created here be added to a utility layer or the main scene
  132785. */
  132786. useUtilityLayer?: boolean;
  132787. /**
  132788. * Optional WebXR camera to be used for gaze selection
  132789. */
  132790. gazeCamera?: WebXRCamera;
  132791. /**
  132792. * the xr input to use with this pointer selection
  132793. */
  132794. xrInput: WebXRInput;
  132795. /**
  132796. * Should the scene pointerX and pointerY update be disabled
  132797. * This is required for fullscreen AR GUI, but might slow down other experiences.
  132798. * Disable in VR, if not needed.
  132799. * The first rig camera (left eye) will be used to calculate the projection
  132800. */
  132801. disableScenePointerVectorUpdate: boolean;
  132802. /**
  132803. * Enable pointer selection on all controllers instead of switching between them
  132804. */
  132805. enablePointerSelectionOnAllControllers?: boolean;
  132806. /**
  132807. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  132808. * If switch is enabled, it will still allow the user to switch between the different controllers
  132809. */
  132810. preferredHandedness?: XRHandedness;
  132811. /**
  132812. * Disable switching the pointer selection from one controller to the other.
  132813. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  132814. */
  132815. disableSwitchOnClick?: boolean;
  132816. /**
  132817. * The maximum distance of the pointer selection feature. Defaults to 100.
  132818. */
  132819. maxPointerDistance?: number;
  132820. }
  132821. /**
  132822. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132823. */
  132824. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132825. private readonly _options;
  132826. private static _idCounter;
  132827. private _attachController;
  132828. private _controllers;
  132829. private _scene;
  132830. private _tmpVectorForPickCompare;
  132831. private _attachedController;
  132832. /**
  132833. * The module's name
  132834. */
  132835. static readonly Name: string;
  132836. /**
  132837. * The (Babylon) version of this module.
  132838. * This is an integer representing the implementation version.
  132839. * This number does not correspond to the WebXR specs version
  132840. */
  132841. static readonly Version: number;
  132842. /**
  132843. * Disable lighting on the laser pointer (so it will always be visible)
  132844. */
  132845. disablePointerLighting: boolean;
  132846. /**
  132847. * Disable lighting on the selection mesh (so it will always be visible)
  132848. */
  132849. disableSelectionMeshLighting: boolean;
  132850. /**
  132851. * Should the laser pointer be displayed
  132852. */
  132853. displayLaserPointer: boolean;
  132854. /**
  132855. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132856. */
  132857. displaySelectionMesh: boolean;
  132858. /**
  132859. * This color will be set to the laser pointer when selection is triggered
  132860. */
  132861. laserPointerPickedColor: Color3;
  132862. /**
  132863. * Default color of the laser pointer
  132864. */
  132865. laserPointerDefaultColor: Color3;
  132866. /**
  132867. * default color of the selection ring
  132868. */
  132869. selectionMeshDefaultColor: Color3;
  132870. /**
  132871. * This color will be applied to the selection ring when selection is triggered
  132872. */
  132873. selectionMeshPickedColor: Color3;
  132874. /**
  132875. * Optional filter to be used for ray selection. This predicate shares behavior with
  132876. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132877. */
  132878. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132879. /**
  132880. * constructs a new background remover module
  132881. * @param _xrSessionManager the session manager for this module
  132882. * @param _options read-only options to be used in this module
  132883. */
  132884. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132885. /**
  132886. * attach this feature
  132887. * Will usually be called by the features manager
  132888. *
  132889. * @returns true if successful.
  132890. */
  132891. attach(): boolean;
  132892. /**
  132893. * detach this feature.
  132894. * Will usually be called by the features manager
  132895. *
  132896. * @returns true if successful.
  132897. */
  132898. detach(): boolean;
  132899. /**
  132900. * Will get the mesh under a specific pointer.
  132901. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132902. * @param controllerId the controllerId to check
  132903. * @returns The mesh under pointer or null if no mesh is under the pointer
  132904. */
  132905. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132906. /**
  132907. * Get the xr controller that correlates to the pointer id in the pointer event
  132908. *
  132909. * @param id the pointer id to search for
  132910. * @returns the controller that correlates to this id or null if not found
  132911. */
  132912. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132913. private _identityMatrix;
  132914. private _screenCoordinatesRef;
  132915. private _viewportRef;
  132916. protected _onXRFrame(_xrFrame: XRFrame): void;
  132917. private _attachGazeMode;
  132918. private _attachScreenRayMode;
  132919. private _attachTrackedPointerRayMode;
  132920. private _convertNormalToDirectionOfRay;
  132921. private _detachController;
  132922. private _generateNewMeshPair;
  132923. private _pickingMoved;
  132924. private _updatePointerDistance;
  132925. /** @hidden */
  132926. get lasterPointerDefaultColor(): Color3;
  132927. }
  132928. }
  132929. declare module BABYLON {
  132930. /**
  132931. * Button which can be used to enter a different mode of XR
  132932. */
  132933. export class WebXREnterExitUIButton {
  132934. /** button element */
  132935. element: HTMLElement;
  132936. /** XR initialization options for the button */
  132937. sessionMode: XRSessionMode;
  132938. /** Reference space type */
  132939. referenceSpaceType: XRReferenceSpaceType;
  132940. /**
  132941. * Creates a WebXREnterExitUIButton
  132942. * @param element button element
  132943. * @param sessionMode XR initialization session mode
  132944. * @param referenceSpaceType the type of reference space to be used
  132945. */
  132946. constructor(
  132947. /** button element */
  132948. element: HTMLElement,
  132949. /** XR initialization options for the button */
  132950. sessionMode: XRSessionMode,
  132951. /** Reference space type */
  132952. referenceSpaceType: XRReferenceSpaceType);
  132953. /**
  132954. * Extendable function which can be used to update the button's visuals when the state changes
  132955. * @param activeButton the current active button in the UI
  132956. */
  132957. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132958. }
  132959. /**
  132960. * Options to create the webXR UI
  132961. */
  132962. export class WebXREnterExitUIOptions {
  132963. /**
  132964. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132965. */
  132966. customButtons?: Array<WebXREnterExitUIButton>;
  132967. /**
  132968. * A reference space type to use when creating the default button.
  132969. * Default is local-floor
  132970. */
  132971. referenceSpaceType?: XRReferenceSpaceType;
  132972. /**
  132973. * Context to enter xr with
  132974. */
  132975. renderTarget?: Nullable<WebXRRenderTarget>;
  132976. /**
  132977. * A session mode to use when creating the default button.
  132978. * Default is immersive-vr
  132979. */
  132980. sessionMode?: XRSessionMode;
  132981. /**
  132982. * A list of optional features to init the session with
  132983. */
  132984. optionalFeatures?: string[];
  132985. /**
  132986. * A list of optional features to init the session with
  132987. */
  132988. requiredFeatures?: string[];
  132989. }
  132990. /**
  132991. * UI to allow the user to enter/exit XR mode
  132992. */
  132993. export class WebXREnterExitUI implements IDisposable {
  132994. private scene;
  132995. /** version of the options passed to this UI */
  132996. options: WebXREnterExitUIOptions;
  132997. private _activeButton;
  132998. private _buttons;
  132999. /**
  133000. * The HTML Div Element to which buttons are added.
  133001. */
  133002. readonly overlay: HTMLDivElement;
  133003. /**
  133004. * Fired every time the active button is changed.
  133005. *
  133006. * When xr is entered via a button that launches xr that button will be the callback parameter
  133007. *
  133008. * When exiting xr the callback parameter will be null)
  133009. */
  133010. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  133011. /**
  133012. *
  133013. * @param scene babylon scene object to use
  133014. * @param options (read-only) version of the options passed to this UI
  133015. */
  133016. private constructor();
  133017. /**
  133018. * Creates UI to allow the user to enter/exit XR mode
  133019. * @param scene the scene to add the ui to
  133020. * @param helper the xr experience helper to enter/exit xr with
  133021. * @param options options to configure the UI
  133022. * @returns the created ui
  133023. */
  133024. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  133025. /**
  133026. * Disposes of the XR UI component
  133027. */
  133028. dispose(): void;
  133029. private _updateButtons;
  133030. }
  133031. }
  133032. declare module BABYLON {
  133033. /**
  133034. * Class containing static functions to help procedurally build meshes
  133035. */
  133036. export class LinesBuilder {
  133037. /**
  133038. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133039. * * 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
  133040. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133041. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133042. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133043. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133044. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133045. * * 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
  133046. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133049. * @param name defines the name of the new line system
  133050. * @param options defines the options used to create the line system
  133051. * @param scene defines the hosting scene
  133052. * @returns a new line system mesh
  133053. */
  133054. static CreateLineSystem(name: string, options: {
  133055. lines: Vector3[][];
  133056. updatable?: boolean;
  133057. instance?: Nullable<LinesMesh>;
  133058. colors?: Nullable<Color4[][]>;
  133059. useVertexAlpha?: boolean;
  133060. }, scene: Nullable<Scene>): LinesMesh;
  133061. /**
  133062. * Creates a line mesh
  133063. * 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
  133064. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133065. * * The parameter `points` is an array successive Vector3
  133066. * * 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
  133067. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133068. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133069. * * When updating an instance, remember that only point positions can change, not the number of points
  133070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133072. * @param name defines the name of the new line system
  133073. * @param options defines the options used to create the line system
  133074. * @param scene defines the hosting scene
  133075. * @returns a new line mesh
  133076. */
  133077. static CreateLines(name: string, options: {
  133078. points: Vector3[];
  133079. updatable?: boolean;
  133080. instance?: Nullable<LinesMesh>;
  133081. colors?: Color4[];
  133082. useVertexAlpha?: boolean;
  133083. }, scene?: Nullable<Scene>): LinesMesh;
  133084. /**
  133085. * Creates a dashed line mesh
  133086. * * 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
  133087. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133088. * * The parameter `points` is an array successive Vector3
  133089. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133090. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133091. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133092. * * 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
  133093. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133094. * * When updating an instance, remember that only point positions can change, not the number of points
  133095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133096. * @param name defines the name of the mesh
  133097. * @param options defines the options used to create the mesh
  133098. * @param scene defines the hosting scene
  133099. * @returns the dashed line mesh
  133100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133101. */
  133102. static CreateDashedLines(name: string, options: {
  133103. points: Vector3[];
  133104. dashSize?: number;
  133105. gapSize?: number;
  133106. dashNb?: number;
  133107. updatable?: boolean;
  133108. instance?: LinesMesh;
  133109. useVertexAlpha?: boolean;
  133110. }, scene?: Nullable<Scene>): LinesMesh;
  133111. }
  133112. }
  133113. declare module BABYLON {
  133114. /**
  133115. * Construction options for a timer
  133116. */
  133117. export interface ITimerOptions<T> {
  133118. /**
  133119. * Time-to-end
  133120. */
  133121. timeout: number;
  133122. /**
  133123. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133124. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133125. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133126. */
  133127. contextObservable: Observable<T>;
  133128. /**
  133129. * Optional parameters when adding an observer to the observable
  133130. */
  133131. observableParameters?: {
  133132. mask?: number;
  133133. insertFirst?: boolean;
  133134. scope?: any;
  133135. };
  133136. /**
  133137. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133138. */
  133139. breakCondition?: (data?: ITimerData<T>) => boolean;
  133140. /**
  133141. * Will be triggered when the time condition has met
  133142. */
  133143. onEnded?: (data: ITimerData<any>) => void;
  133144. /**
  133145. * Will be triggered when the break condition has met (prematurely ended)
  133146. */
  133147. onAborted?: (data: ITimerData<any>) => void;
  133148. /**
  133149. * Optional function to execute on each tick (or count)
  133150. */
  133151. onTick?: (data: ITimerData<any>) => void;
  133152. }
  133153. /**
  133154. * An interface defining the data sent by the timer
  133155. */
  133156. export interface ITimerData<T> {
  133157. /**
  133158. * When did it start
  133159. */
  133160. startTime: number;
  133161. /**
  133162. * Time now
  133163. */
  133164. currentTime: number;
  133165. /**
  133166. * Time passed since started
  133167. */
  133168. deltaTime: number;
  133169. /**
  133170. * How much is completed, in [0.0...1.0].
  133171. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133172. */
  133173. completeRate: number;
  133174. /**
  133175. * What the registered observable sent in the last count
  133176. */
  133177. payload: T;
  133178. }
  133179. /**
  133180. * The current state of the timer
  133181. */
  133182. export enum TimerState {
  133183. /**
  133184. * Timer initialized, not yet started
  133185. */
  133186. INIT = 0,
  133187. /**
  133188. * Timer started and counting
  133189. */
  133190. STARTED = 1,
  133191. /**
  133192. * Timer ended (whether aborted or time reached)
  133193. */
  133194. ENDED = 2
  133195. }
  133196. /**
  133197. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133198. *
  133199. * @param options options with which to initialize this timer
  133200. */
  133201. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133202. /**
  133203. * An advanced implementation of a timer class
  133204. */
  133205. export class AdvancedTimer<T = any> implements IDisposable {
  133206. /**
  133207. * Will notify each time the timer calculates the remaining time
  133208. */
  133209. onEachCountObservable: Observable<ITimerData<T>>;
  133210. /**
  133211. * Will trigger when the timer was aborted due to the break condition
  133212. */
  133213. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133214. /**
  133215. * Will trigger when the timer ended successfully
  133216. */
  133217. onTimerEndedObservable: Observable<ITimerData<T>>;
  133218. /**
  133219. * Will trigger when the timer state has changed
  133220. */
  133221. onStateChangedObservable: Observable<TimerState>;
  133222. private _observer;
  133223. private _contextObservable;
  133224. private _observableParameters;
  133225. private _startTime;
  133226. private _timer;
  133227. private _state;
  133228. private _breakCondition;
  133229. private _timeToEnd;
  133230. private _breakOnNextTick;
  133231. /**
  133232. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133233. * @param options construction options for this advanced timer
  133234. */
  133235. constructor(options: ITimerOptions<T>);
  133236. /**
  133237. * set a breaking condition for this timer. Default is to never break during count
  133238. * @param predicate the new break condition. Returns true to break, false otherwise
  133239. */
  133240. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133241. /**
  133242. * Reset ALL associated observables in this advanced timer
  133243. */
  133244. clearObservables(): void;
  133245. /**
  133246. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133247. *
  133248. * @param timeToEnd how much time to measure until timer ended
  133249. */
  133250. start(timeToEnd?: number): void;
  133251. /**
  133252. * Will force a stop on the next tick.
  133253. */
  133254. stop(): void;
  133255. /**
  133256. * Dispose this timer, clearing all resources
  133257. */
  133258. dispose(): void;
  133259. private _setState;
  133260. private _tick;
  133261. private _stop;
  133262. }
  133263. }
  133264. declare module BABYLON {
  133265. /**
  133266. * The options container for the teleportation module
  133267. */
  133268. export interface IWebXRTeleportationOptions {
  133269. /**
  133270. * if provided, this scene will be used to render meshes.
  133271. */
  133272. customUtilityLayerScene?: Scene;
  133273. /**
  133274. * Values to configure the default target mesh
  133275. */
  133276. defaultTargetMeshOptions?: {
  133277. /**
  133278. * Fill color of the teleportation area
  133279. */
  133280. teleportationFillColor?: string;
  133281. /**
  133282. * Border color for the teleportation area
  133283. */
  133284. teleportationBorderColor?: string;
  133285. /**
  133286. * Disable the mesh's animation sequence
  133287. */
  133288. disableAnimation?: boolean;
  133289. /**
  133290. * Disable lighting on the material or the ring and arrow
  133291. */
  133292. disableLighting?: boolean;
  133293. /**
  133294. * Override the default material of the torus and arrow
  133295. */
  133296. torusArrowMaterial?: Material;
  133297. };
  133298. /**
  133299. * A list of meshes to use as floor meshes.
  133300. * Meshes can be added and removed after initializing the feature using the
  133301. * addFloorMesh and removeFloorMesh functions
  133302. * If empty, rotation will still work
  133303. */
  133304. floorMeshes?: AbstractMesh[];
  133305. /**
  133306. * use this rendering group id for the meshes (optional)
  133307. */
  133308. renderingGroupId?: number;
  133309. /**
  133310. * Should teleportation move only to snap points
  133311. */
  133312. snapPointsOnly?: boolean;
  133313. /**
  133314. * An array of points to which the teleportation will snap to.
  133315. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133316. */
  133317. snapPositions?: Vector3[];
  133318. /**
  133319. * How close should the teleportation ray be in order to snap to position.
  133320. * Default to 0.8 units (meters)
  133321. */
  133322. snapToPositionRadius?: number;
  133323. /**
  133324. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133325. * If you want to support rotation, make sure your mesh has a direction indicator.
  133326. *
  133327. * When left untouched, the default mesh will be initialized.
  133328. */
  133329. teleportationTargetMesh?: AbstractMesh;
  133330. /**
  133331. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133332. */
  133333. timeToTeleport?: number;
  133334. /**
  133335. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133336. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133337. */
  133338. useMainComponentOnly?: boolean;
  133339. /**
  133340. * Should meshes created here be added to a utility layer or the main scene
  133341. */
  133342. useUtilityLayer?: boolean;
  133343. /**
  133344. * Babylon XR Input class for controller
  133345. */
  133346. xrInput: WebXRInput;
  133347. /**
  133348. * Meshes that the teleportation ray cannot go through
  133349. */
  133350. pickBlockerMeshes?: AbstractMesh[];
  133351. }
  133352. /**
  133353. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133354. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133355. * the input of the attached controllers.
  133356. */
  133357. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133358. private _options;
  133359. private _controllers;
  133360. private _currentTeleportationControllerId;
  133361. private _floorMeshes;
  133362. private _quadraticBezierCurve;
  133363. private _selectionFeature;
  133364. private _snapToPositions;
  133365. private _snappedToPoint;
  133366. private _teleportationRingMaterial?;
  133367. private _tmpRay;
  133368. private _tmpVector;
  133369. private _tmpQuaternion;
  133370. /**
  133371. * The module's name
  133372. */
  133373. static readonly Name: string;
  133374. /**
  133375. * The (Babylon) version of this module.
  133376. * This is an integer representing the implementation version.
  133377. * This number does not correspond to the webxr specs version
  133378. */
  133379. static readonly Version: number;
  133380. /**
  133381. * Is movement backwards enabled
  133382. */
  133383. backwardsMovementEnabled: boolean;
  133384. /**
  133385. * Distance to travel when moving backwards
  133386. */
  133387. backwardsTeleportationDistance: number;
  133388. /**
  133389. * The distance from the user to the inspection point in the direction of the controller
  133390. * A higher number will allow the user to move further
  133391. * defaults to 5 (meters, in xr units)
  133392. */
  133393. parabolicCheckRadius: number;
  133394. /**
  133395. * Should the module support parabolic ray on top of direct ray
  133396. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133397. * Very helpful when moving between floors / different heights
  133398. */
  133399. parabolicRayEnabled: boolean;
  133400. /**
  133401. * How much rotation should be applied when rotating right and left
  133402. */
  133403. rotationAngle: number;
  133404. /**
  133405. * Is rotation enabled when moving forward?
  133406. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133407. */
  133408. rotationEnabled: boolean;
  133409. /**
  133410. * constructs a new anchor system
  133411. * @param _xrSessionManager an instance of WebXRSessionManager
  133412. * @param _options configuration object for this feature
  133413. */
  133414. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133415. /**
  133416. * Get the snapPointsOnly flag
  133417. */
  133418. get snapPointsOnly(): boolean;
  133419. /**
  133420. * Sets the snapPointsOnly flag
  133421. * @param snapToPoints should teleportation be exclusively to snap points
  133422. */
  133423. set snapPointsOnly(snapToPoints: boolean);
  133424. /**
  133425. * Add a new mesh to the floor meshes array
  133426. * @param mesh the mesh to use as floor mesh
  133427. */
  133428. addFloorMesh(mesh: AbstractMesh): void;
  133429. /**
  133430. * Add a new snap-to point to fix teleportation to this position
  133431. * @param newSnapPoint The new Snap-To point
  133432. */
  133433. addSnapPoint(newSnapPoint: Vector3): void;
  133434. attach(): boolean;
  133435. detach(): boolean;
  133436. dispose(): void;
  133437. /**
  133438. * Remove a mesh from the floor meshes array
  133439. * @param mesh the mesh to remove
  133440. */
  133441. removeFloorMesh(mesh: AbstractMesh): void;
  133442. /**
  133443. * Remove a mesh from the floor meshes array using its name
  133444. * @param name the mesh name to remove
  133445. */
  133446. removeFloorMeshByName(name: string): void;
  133447. /**
  133448. * 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
  133449. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133450. * @returns was the point found and removed or not
  133451. */
  133452. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133453. /**
  133454. * This function sets a selection feature that will be disabled when
  133455. * the forward ray is shown and will be reattached when hidden.
  133456. * This is used to remove the selection rays when moving.
  133457. * @param selectionFeature the feature to disable when forward movement is enabled
  133458. */
  133459. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133460. protected _onXRFrame(_xrFrame: XRFrame): void;
  133461. private _attachController;
  133462. private _createDefaultTargetMesh;
  133463. private _detachController;
  133464. private _findClosestSnapPointWithRadius;
  133465. private _setTargetMeshPosition;
  133466. private _setTargetMeshVisibility;
  133467. private _showParabolicPath;
  133468. private _teleportForward;
  133469. }
  133470. }
  133471. declare module BABYLON {
  133472. /**
  133473. * Options for the default xr helper
  133474. */
  133475. export class WebXRDefaultExperienceOptions {
  133476. /**
  133477. * Enable or disable default UI to enter XR
  133478. */
  133479. disableDefaultUI?: boolean;
  133480. /**
  133481. * Should teleportation not initialize. defaults to false.
  133482. */
  133483. disableTeleportation?: boolean;
  133484. /**
  133485. * Floor meshes that will be used for teleport
  133486. */
  133487. floorMeshes?: Array<AbstractMesh>;
  133488. /**
  133489. * If set to true, the first frame will not be used to reset position
  133490. * The first frame is mainly used when copying transformation from the old camera
  133491. * Mainly used in AR
  133492. */
  133493. ignoreNativeCameraTransformation?: boolean;
  133494. /**
  133495. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133496. */
  133497. inputOptions?: IWebXRInputOptions;
  133498. /**
  133499. * optional configuration for the output canvas
  133500. */
  133501. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133502. /**
  133503. * optional UI options. This can be used among other to change session mode and reference space type
  133504. */
  133505. uiOptions?: WebXREnterExitUIOptions;
  133506. /**
  133507. * When loading teleportation and pointer select, use stable versions instead of latest.
  133508. */
  133509. useStablePlugins?: boolean;
  133510. /**
  133511. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133512. */
  133513. renderingGroupId?: number;
  133514. /**
  133515. * A list of optional features to init the session with
  133516. * If set to true, all features we support will be added
  133517. */
  133518. optionalFeatures?: boolean | string[];
  133519. }
  133520. /**
  133521. * Default experience which provides a similar setup to the previous webVRExperience
  133522. */
  133523. export class WebXRDefaultExperience {
  133524. /**
  133525. * Base experience
  133526. */
  133527. baseExperience: WebXRExperienceHelper;
  133528. /**
  133529. * Enables ui for entering/exiting xr
  133530. */
  133531. enterExitUI: WebXREnterExitUI;
  133532. /**
  133533. * Input experience extension
  133534. */
  133535. input: WebXRInput;
  133536. /**
  133537. * Enables laser pointer and selection
  133538. */
  133539. pointerSelection: WebXRControllerPointerSelection;
  133540. /**
  133541. * Default target xr should render to
  133542. */
  133543. renderTarget: WebXRRenderTarget;
  133544. /**
  133545. * Enables teleportation
  133546. */
  133547. teleportation: WebXRMotionControllerTeleportation;
  133548. private constructor();
  133549. /**
  133550. * Creates the default xr experience
  133551. * @param scene scene
  133552. * @param options options for basic configuration
  133553. * @returns resulting WebXRDefaultExperience
  133554. */
  133555. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133556. /**
  133557. * DIsposes of the experience helper
  133558. */
  133559. dispose(): void;
  133560. }
  133561. }
  133562. declare module BABYLON {
  133563. /**
  133564. * Options to modify the vr teleportation behavior.
  133565. */
  133566. export interface VRTeleportationOptions {
  133567. /**
  133568. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133569. */
  133570. floorMeshName?: string;
  133571. /**
  133572. * A list of meshes to be used as the teleportation floor. (default: empty)
  133573. */
  133574. floorMeshes?: Mesh[];
  133575. /**
  133576. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133577. */
  133578. teleportationMode?: number;
  133579. /**
  133580. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133581. */
  133582. teleportationTime?: number;
  133583. /**
  133584. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133585. */
  133586. teleportationSpeed?: number;
  133587. /**
  133588. * The easing function used in the animation or null for Linear. (default CircleEase)
  133589. */
  133590. easingFunction?: EasingFunction;
  133591. }
  133592. /**
  133593. * Options to modify the vr experience helper's behavior.
  133594. */
  133595. export interface VRExperienceHelperOptions extends WebVROptions {
  133596. /**
  133597. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133598. */
  133599. createDeviceOrientationCamera?: boolean;
  133600. /**
  133601. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133602. */
  133603. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133604. /**
  133605. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133606. */
  133607. laserToggle?: boolean;
  133608. /**
  133609. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133610. */
  133611. floorMeshes?: Mesh[];
  133612. /**
  133613. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133614. */
  133615. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133616. /**
  133617. * Defines if WebXR should be used instead of WebVR (if available)
  133618. */
  133619. useXR?: boolean;
  133620. }
  133621. /**
  133622. * Event containing information after VR has been entered
  133623. */
  133624. export class OnAfterEnteringVRObservableEvent {
  133625. /**
  133626. * If entering vr was successful
  133627. */
  133628. success: boolean;
  133629. }
  133630. /**
  133631. * Helps to quickly add VR support to an existing scene.
  133632. * See https://doc.babylonjs.com/how_to/webvr_helper
  133633. */
  133634. export class VRExperienceHelper {
  133635. /** Options to modify the vr experience helper's behavior. */
  133636. webVROptions: VRExperienceHelperOptions;
  133637. private _scene;
  133638. private _position;
  133639. private _btnVR;
  133640. private _btnVRDisplayed;
  133641. private _webVRsupported;
  133642. private _webVRready;
  133643. private _webVRrequesting;
  133644. private _webVRpresenting;
  133645. private _hasEnteredVR;
  133646. private _fullscreenVRpresenting;
  133647. private _inputElement;
  133648. private _webVRCamera;
  133649. private _vrDeviceOrientationCamera;
  133650. private _deviceOrientationCamera;
  133651. private _existingCamera;
  133652. private _onKeyDown;
  133653. private _onVrDisplayPresentChange;
  133654. private _onVRDisplayChanged;
  133655. private _onVRRequestPresentStart;
  133656. private _onVRRequestPresentComplete;
  133657. /**
  133658. * 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)
  133659. */
  133660. enableGazeEvenWhenNoPointerLock: boolean;
  133661. /**
  133662. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133663. */
  133664. exitVROnDoubleTap: boolean;
  133665. /**
  133666. * Observable raised right before entering VR.
  133667. */
  133668. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133669. /**
  133670. * Observable raised when entering VR has completed.
  133671. */
  133672. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133673. /**
  133674. * Observable raised when exiting VR.
  133675. */
  133676. onExitingVRObservable: Observable<VRExperienceHelper>;
  133677. /**
  133678. * Observable raised when controller mesh is loaded.
  133679. */
  133680. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133681. /** Return this.onEnteringVRObservable
  133682. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133683. */
  133684. get onEnteringVR(): Observable<VRExperienceHelper>;
  133685. /** Return this.onExitingVRObservable
  133686. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133687. */
  133688. get onExitingVR(): Observable<VRExperienceHelper>;
  133689. /** Return this.onControllerMeshLoadedObservable
  133690. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133691. */
  133692. get onControllerMeshLoaded(): Observable<WebVRController>;
  133693. private _rayLength;
  133694. private _useCustomVRButton;
  133695. private _teleportationRequested;
  133696. private _teleportActive;
  133697. private _floorMeshName;
  133698. private _floorMeshesCollection;
  133699. private _teleportationMode;
  133700. private _teleportationTime;
  133701. private _teleportationSpeed;
  133702. private _teleportationEasing;
  133703. private _rotationAllowed;
  133704. private _teleportBackwardsVector;
  133705. private _teleportationTarget;
  133706. private _isDefaultTeleportationTarget;
  133707. private _postProcessMove;
  133708. private _teleportationFillColor;
  133709. private _teleportationBorderColor;
  133710. private _rotationAngle;
  133711. private _haloCenter;
  133712. private _cameraGazer;
  133713. private _padSensibilityUp;
  133714. private _padSensibilityDown;
  133715. private _leftController;
  133716. private _rightController;
  133717. private _gazeColor;
  133718. private _laserColor;
  133719. private _pickedLaserColor;
  133720. private _pickedGazeColor;
  133721. /**
  133722. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133723. */
  133724. onNewMeshSelected: Observable<AbstractMesh>;
  133725. /**
  133726. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133727. * This observable will provide the mesh and the controller used to select the mesh
  133728. */
  133729. onMeshSelectedWithController: Observable<{
  133730. mesh: AbstractMesh;
  133731. controller: WebVRController;
  133732. }>;
  133733. /**
  133734. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133735. */
  133736. onNewMeshPicked: Observable<PickingInfo>;
  133737. private _circleEase;
  133738. /**
  133739. * Observable raised before camera teleportation
  133740. */
  133741. onBeforeCameraTeleport: Observable<Vector3>;
  133742. /**
  133743. * Observable raised after camera teleportation
  133744. */
  133745. onAfterCameraTeleport: Observable<Vector3>;
  133746. /**
  133747. * Observable raised when current selected mesh gets unselected
  133748. */
  133749. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133750. private _raySelectionPredicate;
  133751. /**
  133752. * To be optionaly changed by user to define custom ray selection
  133753. */
  133754. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133755. /**
  133756. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133757. */
  133758. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133759. /**
  133760. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133761. */
  133762. teleportationEnabled: boolean;
  133763. private _defaultHeight;
  133764. private _teleportationInitialized;
  133765. private _interactionsEnabled;
  133766. private _interactionsRequested;
  133767. private _displayGaze;
  133768. private _displayLaserPointer;
  133769. /**
  133770. * The mesh used to display where the user is going to teleport.
  133771. */
  133772. get teleportationTarget(): Mesh;
  133773. /**
  133774. * Sets the mesh to be used to display where the user is going to teleport.
  133775. */
  133776. set teleportationTarget(value: Mesh);
  133777. /**
  133778. * 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
  133779. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133780. * See https://doc.babylonjs.com/resources/baking_transformations
  133781. */
  133782. get gazeTrackerMesh(): Mesh;
  133783. set gazeTrackerMesh(value: Mesh);
  133784. /**
  133785. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133786. */
  133787. updateGazeTrackerScale: boolean;
  133788. /**
  133789. * If the gaze trackers color should be updated when selecting meshes
  133790. */
  133791. updateGazeTrackerColor: boolean;
  133792. /**
  133793. * If the controller laser color should be updated when selecting meshes
  133794. */
  133795. updateControllerLaserColor: boolean;
  133796. /**
  133797. * The gaze tracking mesh corresponding to the left controller
  133798. */
  133799. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133800. /**
  133801. * The gaze tracking mesh corresponding to the right controller
  133802. */
  133803. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133804. /**
  133805. * If the ray of the gaze should be displayed.
  133806. */
  133807. get displayGaze(): boolean;
  133808. /**
  133809. * Sets if the ray of the gaze should be displayed.
  133810. */
  133811. set displayGaze(value: boolean);
  133812. /**
  133813. * If the ray of the LaserPointer should be displayed.
  133814. */
  133815. get displayLaserPointer(): boolean;
  133816. /**
  133817. * Sets if the ray of the LaserPointer should be displayed.
  133818. */
  133819. set displayLaserPointer(value: boolean);
  133820. /**
  133821. * The deviceOrientationCamera used as the camera when not in VR.
  133822. */
  133823. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133824. /**
  133825. * Based on the current WebVR support, returns the current VR camera used.
  133826. */
  133827. get currentVRCamera(): Nullable<Camera>;
  133828. /**
  133829. * The webVRCamera which is used when in VR.
  133830. */
  133831. get webVRCamera(): WebVRFreeCamera;
  133832. /**
  133833. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133834. */
  133835. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133836. /**
  133837. * The html button that is used to trigger entering into VR.
  133838. */
  133839. get vrButton(): Nullable<HTMLButtonElement>;
  133840. private get _teleportationRequestInitiated();
  133841. /**
  133842. * Defines whether or not Pointer lock should be requested when switching to
  133843. * full screen.
  133844. */
  133845. requestPointerLockOnFullScreen: boolean;
  133846. /**
  133847. * If asking to force XR, this will be populated with the default xr experience
  133848. */
  133849. xr: WebXRDefaultExperience;
  133850. /**
  133851. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133852. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133853. */
  133854. xrTestDone: boolean;
  133855. /**
  133856. * Instantiates a VRExperienceHelper.
  133857. * Helps to quickly add VR support to an existing scene.
  133858. * @param scene The scene the VRExperienceHelper belongs to.
  133859. * @param webVROptions Options to modify the vr experience helper's behavior.
  133860. */
  133861. constructor(scene: Scene,
  133862. /** Options to modify the vr experience helper's behavior. */
  133863. webVROptions?: VRExperienceHelperOptions);
  133864. private completeVRInit;
  133865. private _onDefaultMeshLoaded;
  133866. private _onResize;
  133867. private _onFullscreenChange;
  133868. /**
  133869. * Gets a value indicating if we are currently in VR mode.
  133870. */
  133871. get isInVRMode(): boolean;
  133872. private onVrDisplayPresentChange;
  133873. private onVRDisplayChanged;
  133874. private moveButtonToBottomRight;
  133875. private displayVRButton;
  133876. private updateButtonVisibility;
  133877. private _cachedAngularSensibility;
  133878. /**
  133879. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133880. * Otherwise, will use the fullscreen API.
  133881. */
  133882. enterVR(): void;
  133883. /**
  133884. * Attempt to exit VR, or fullscreen.
  133885. */
  133886. exitVR(): void;
  133887. /**
  133888. * The position of the vr experience helper.
  133889. */
  133890. get position(): Vector3;
  133891. /**
  133892. * Sets the position of the vr experience helper.
  133893. */
  133894. set position(value: Vector3);
  133895. /**
  133896. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133897. */
  133898. enableInteractions(): void;
  133899. private get _noControllerIsActive();
  133900. private beforeRender;
  133901. private _isTeleportationFloor;
  133902. /**
  133903. * Adds a floor mesh to be used for teleportation.
  133904. * @param floorMesh the mesh to be used for teleportation.
  133905. */
  133906. addFloorMesh(floorMesh: Mesh): void;
  133907. /**
  133908. * Removes a floor mesh from being used for teleportation.
  133909. * @param floorMesh the mesh to be removed.
  133910. */
  133911. removeFloorMesh(floorMesh: Mesh): void;
  133912. /**
  133913. * Enables interactions and teleportation using the VR controllers and gaze.
  133914. * @param vrTeleportationOptions options to modify teleportation behavior.
  133915. */
  133916. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133917. private _onNewGamepadConnected;
  133918. private _tryEnableInteractionOnController;
  133919. private _onNewGamepadDisconnected;
  133920. private _enableInteractionOnController;
  133921. private _checkTeleportWithRay;
  133922. private _checkRotate;
  133923. private _checkTeleportBackwards;
  133924. private _enableTeleportationOnController;
  133925. private _createTeleportationCircles;
  133926. private _displayTeleportationTarget;
  133927. private _hideTeleportationTarget;
  133928. private _rotateCamera;
  133929. private _moveTeleportationSelectorTo;
  133930. private _workingVector;
  133931. private _workingQuaternion;
  133932. private _workingMatrix;
  133933. /**
  133934. * Time Constant Teleportation Mode
  133935. */
  133936. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133937. /**
  133938. * Speed Constant Teleportation Mode
  133939. */
  133940. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133941. /**
  133942. * Teleports the users feet to the desired location
  133943. * @param location The location where the user's feet should be placed
  133944. */
  133945. teleportCamera(location: Vector3): void;
  133946. private _convertNormalToDirectionOfRay;
  133947. private _castRayAndSelectObject;
  133948. private _notifySelectedMeshUnselected;
  133949. /**
  133950. * Permanently set new colors for the laser pointer
  133951. * @param color the new laser color
  133952. * @param pickedColor the new laser color when picked mesh detected
  133953. */
  133954. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133955. /**
  133956. * Set lighting enabled / disabled on the laser pointer of both controllers
  133957. * @param enabled should the lighting be enabled on the laser pointer
  133958. */
  133959. setLaserLightingState(enabled?: boolean): void;
  133960. /**
  133961. * Permanently set new colors for the gaze pointer
  133962. * @param color the new gaze color
  133963. * @param pickedColor the new gaze color when picked mesh detected
  133964. */
  133965. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133966. /**
  133967. * Sets the color of the laser ray from the vr controllers.
  133968. * @param color new color for the ray.
  133969. */
  133970. changeLaserColor(color: Color3): void;
  133971. /**
  133972. * Sets the color of the ray from the vr headsets gaze.
  133973. * @param color new color for the ray.
  133974. */
  133975. changeGazeColor(color: Color3): void;
  133976. /**
  133977. * Exits VR and disposes of the vr experience helper
  133978. */
  133979. dispose(): void;
  133980. /**
  133981. * Gets the name of the VRExperienceHelper class
  133982. * @returns "VRExperienceHelper"
  133983. */
  133984. getClassName(): string;
  133985. }
  133986. }
  133987. declare module BABYLON {
  133988. /**
  133989. * Contains an array of blocks representing the octree
  133990. */
  133991. export interface IOctreeContainer<T> {
  133992. /**
  133993. * Blocks within the octree
  133994. */
  133995. blocks: Array<OctreeBlock<T>>;
  133996. }
  133997. /**
  133998. * Class used to store a cell in an octree
  133999. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134000. */
  134001. export class OctreeBlock<T> {
  134002. /**
  134003. * Gets the content of the current block
  134004. */
  134005. entries: T[];
  134006. /**
  134007. * Gets the list of block children
  134008. */
  134009. blocks: Array<OctreeBlock<T>>;
  134010. private _depth;
  134011. private _maxDepth;
  134012. private _capacity;
  134013. private _minPoint;
  134014. private _maxPoint;
  134015. private _boundingVectors;
  134016. private _creationFunc;
  134017. /**
  134018. * Creates a new block
  134019. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  134020. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  134021. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134022. * @param depth defines the current depth of this block in the octree
  134023. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  134024. * @param creationFunc defines a callback to call when an element is added to the block
  134025. */
  134026. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  134027. /**
  134028. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134029. */
  134030. get capacity(): number;
  134031. /**
  134032. * Gets the minimum vector (in world space) of the block's bounding box
  134033. */
  134034. get minPoint(): Vector3;
  134035. /**
  134036. * Gets the maximum vector (in world space) of the block's bounding box
  134037. */
  134038. get maxPoint(): Vector3;
  134039. /**
  134040. * Add a new element to this block
  134041. * @param entry defines the element to add
  134042. */
  134043. addEntry(entry: T): void;
  134044. /**
  134045. * Remove an element from this block
  134046. * @param entry defines the element to remove
  134047. */
  134048. removeEntry(entry: T): void;
  134049. /**
  134050. * Add an array of elements to this block
  134051. * @param entries defines the array of elements to add
  134052. */
  134053. addEntries(entries: T[]): void;
  134054. /**
  134055. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  134056. * @param frustumPlanes defines the frustum planes to test
  134057. * @param selection defines the array to store current content if selection is positive
  134058. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134059. */
  134060. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134061. /**
  134062. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  134063. * @param sphereCenter defines the bounding sphere center
  134064. * @param sphereRadius defines the bounding sphere radius
  134065. * @param selection defines the array to store current content if selection is positive
  134066. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134067. */
  134068. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134069. /**
  134070. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134071. * @param ray defines the ray to test with
  134072. * @param selection defines the array to store current content if selection is positive
  134073. */
  134074. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134075. /**
  134076. * Subdivide the content into child blocks (this block will then be empty)
  134077. */
  134078. createInnerBlocks(): void;
  134079. /**
  134080. * @hidden
  134081. */
  134082. 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;
  134083. }
  134084. }
  134085. declare module BABYLON {
  134086. /**
  134087. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134088. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134089. */
  134090. export class Octree<T> {
  134091. /** 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.) */
  134092. maxDepth: number;
  134093. /**
  134094. * Blocks within the octree containing objects
  134095. */
  134096. blocks: Array<OctreeBlock<T>>;
  134097. /**
  134098. * Content stored in the octree
  134099. */
  134100. dynamicContent: T[];
  134101. private _maxBlockCapacity;
  134102. private _selectionContent;
  134103. private _creationFunc;
  134104. /**
  134105. * Creates a octree
  134106. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134107. * @param creationFunc function to be used to instatiate the octree
  134108. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134109. * @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.)
  134110. */
  134111. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134112. /** 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.) */
  134113. maxDepth?: number);
  134114. /**
  134115. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134116. * @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);
  134117. * @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);
  134118. * @param entries meshes to be added to the octree blocks
  134119. */
  134120. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134121. /**
  134122. * Adds a mesh to the octree
  134123. * @param entry Mesh to add to the octree
  134124. */
  134125. addMesh(entry: T): void;
  134126. /**
  134127. * Remove an element from the octree
  134128. * @param entry defines the element to remove
  134129. */
  134130. removeMesh(entry: T): void;
  134131. /**
  134132. * Selects an array of meshes within the frustum
  134133. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134134. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134135. * @returns array of meshes within the frustum
  134136. */
  134137. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134138. /**
  134139. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134140. * @param sphereCenter defines the bounding sphere center
  134141. * @param sphereRadius defines the bounding sphere radius
  134142. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134143. * @returns an array of objects that intersect the sphere
  134144. */
  134145. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134146. /**
  134147. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134148. * @param ray defines the ray to test with
  134149. * @returns array of intersected objects
  134150. */
  134151. intersectsRay(ray: Ray): SmartArray<T>;
  134152. /**
  134153. * Adds a mesh into the octree block if it intersects the block
  134154. */
  134155. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134156. /**
  134157. * Adds a submesh into the octree block if it intersects the block
  134158. */
  134159. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134160. }
  134161. }
  134162. declare module BABYLON {
  134163. interface Scene {
  134164. /**
  134165. * @hidden
  134166. * Backing Filed
  134167. */
  134168. _selectionOctree: Octree<AbstractMesh>;
  134169. /**
  134170. * Gets the octree used to boost mesh selection (picking)
  134171. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134172. */
  134173. selectionOctree: Octree<AbstractMesh>;
  134174. /**
  134175. * Creates or updates the octree used to boost selection (picking)
  134176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134177. * @param maxCapacity defines the maximum capacity per leaf
  134178. * @param maxDepth defines the maximum depth of the octree
  134179. * @returns an octree of AbstractMesh
  134180. */
  134181. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134182. }
  134183. interface AbstractMesh {
  134184. /**
  134185. * @hidden
  134186. * Backing Field
  134187. */
  134188. _submeshesOctree: Octree<SubMesh>;
  134189. /**
  134190. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134191. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134192. * @param maxCapacity defines the maximum size of each block (64 by default)
  134193. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134194. * @returns the new octree
  134195. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134196. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134197. */
  134198. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134199. }
  134200. /**
  134201. * Defines the octree scene component responsible to manage any octrees
  134202. * in a given scene.
  134203. */
  134204. export class OctreeSceneComponent {
  134205. /**
  134206. * The component name help to identify the component in the list of scene components.
  134207. */
  134208. readonly name: string;
  134209. /**
  134210. * The scene the component belongs to.
  134211. */
  134212. scene: Scene;
  134213. /**
  134214. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134215. */
  134216. readonly checksIsEnabled: boolean;
  134217. /**
  134218. * Creates a new instance of the component for the given scene
  134219. * @param scene Defines the scene to register the component in
  134220. */
  134221. constructor(scene: Scene);
  134222. /**
  134223. * Registers the component in a given scene
  134224. */
  134225. register(): void;
  134226. /**
  134227. * Return the list of active meshes
  134228. * @returns the list of active meshes
  134229. */
  134230. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134231. /**
  134232. * Return the list of active sub meshes
  134233. * @param mesh The mesh to get the candidates sub meshes from
  134234. * @returns the list of active sub meshes
  134235. */
  134236. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134237. private _tempRay;
  134238. /**
  134239. * Return the list of sub meshes intersecting with a given local ray
  134240. * @param mesh defines the mesh to find the submesh for
  134241. * @param localRay defines the ray in local space
  134242. * @returns the list of intersecting sub meshes
  134243. */
  134244. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134245. /**
  134246. * Return the list of sub meshes colliding with a collider
  134247. * @param mesh defines the mesh to find the submesh for
  134248. * @param collider defines the collider to evaluate the collision against
  134249. * @returns the list of colliding sub meshes
  134250. */
  134251. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134252. /**
  134253. * Rebuilds the elements related to this component in case of
  134254. * context lost for instance.
  134255. */
  134256. rebuild(): void;
  134257. /**
  134258. * Disposes the component and the associated ressources.
  134259. */
  134260. dispose(): void;
  134261. }
  134262. }
  134263. declare module BABYLON {
  134264. /**
  134265. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134266. */
  134267. export class Gizmo implements IDisposable {
  134268. /** The utility layer the gizmo will be added to */
  134269. gizmoLayer: UtilityLayerRenderer;
  134270. /**
  134271. * The root mesh of the gizmo
  134272. */
  134273. _rootMesh: Mesh;
  134274. private _attachedMesh;
  134275. private _attachedNode;
  134276. /**
  134277. * Ratio for the scale of the gizmo (Default: 1)
  134278. */
  134279. protected _scaleRatio: number;
  134280. /**
  134281. * boolean updated by pointermove when a gizmo mesh is hovered
  134282. */
  134283. protected _isHovered: boolean;
  134284. /**
  134285. * Ratio for the scale of the gizmo (Default: 1)
  134286. */
  134287. set scaleRatio(value: number);
  134288. get scaleRatio(): number;
  134289. /**
  134290. * True when the mouse pointer is hovered a gizmo mesh
  134291. */
  134292. get isHovered(): boolean;
  134293. /**
  134294. * If a custom mesh has been set (Default: false)
  134295. */
  134296. protected _customMeshSet: boolean;
  134297. /**
  134298. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134299. * * When set, interactions will be enabled
  134300. */
  134301. get attachedMesh(): Nullable<AbstractMesh>;
  134302. set attachedMesh(value: Nullable<AbstractMesh>);
  134303. /**
  134304. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134305. * * When set, interactions will be enabled
  134306. */
  134307. get attachedNode(): Nullable<Node>;
  134308. set attachedNode(value: Nullable<Node>);
  134309. /**
  134310. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134311. * @param mesh The mesh to replace the default mesh of the gizmo
  134312. */
  134313. setCustomMesh(mesh: Mesh): void;
  134314. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134315. /**
  134316. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134317. */
  134318. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134319. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134320. /**
  134321. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134322. */
  134323. updateGizmoPositionToMatchAttachedMesh: boolean;
  134324. /**
  134325. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134326. */
  134327. updateScale: boolean;
  134328. protected _interactionsEnabled: boolean;
  134329. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134330. private _beforeRenderObserver;
  134331. private _tempQuaternion;
  134332. private _tempVector;
  134333. private _tempVector2;
  134334. private _tempMatrix1;
  134335. private _tempMatrix2;
  134336. private _rightHandtoLeftHandMatrix;
  134337. /**
  134338. * Creates a gizmo
  134339. * @param gizmoLayer The utility layer the gizmo will be added to
  134340. */
  134341. constructor(
  134342. /** The utility layer the gizmo will be added to */
  134343. gizmoLayer?: UtilityLayerRenderer);
  134344. /**
  134345. * Updates the gizmo to match the attached mesh's position/rotation
  134346. */
  134347. protected _update(): void;
  134348. /**
  134349. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134350. * @param value Node, TransformNode or mesh
  134351. */
  134352. protected _matrixChanged(): void;
  134353. /**
  134354. * Disposes of the gizmo
  134355. */
  134356. dispose(): void;
  134357. }
  134358. }
  134359. declare module BABYLON {
  134360. /**
  134361. * Single plane drag gizmo
  134362. */
  134363. export class PlaneDragGizmo extends Gizmo {
  134364. /**
  134365. * Drag behavior responsible for the gizmos dragging interactions
  134366. */
  134367. dragBehavior: PointerDragBehavior;
  134368. private _pointerObserver;
  134369. /**
  134370. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134371. */
  134372. snapDistance: number;
  134373. /**
  134374. * Event that fires each time the gizmo snaps to a new location.
  134375. * * snapDistance is the the change in distance
  134376. */
  134377. onSnapObservable: Observable<{
  134378. snapDistance: number;
  134379. }>;
  134380. private _plane;
  134381. private _coloredMaterial;
  134382. private _hoverMaterial;
  134383. private _isEnabled;
  134384. private _parent;
  134385. /** @hidden */
  134386. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134387. /** @hidden */
  134388. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134389. /**
  134390. * Creates a PlaneDragGizmo
  134391. * @param gizmoLayer The utility layer the gizmo will be added to
  134392. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134393. * @param color The color of the gizmo
  134394. */
  134395. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134396. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134397. /**
  134398. * If the gizmo is enabled
  134399. */
  134400. set isEnabled(value: boolean);
  134401. get isEnabled(): boolean;
  134402. /**
  134403. * Disposes of the gizmo
  134404. */
  134405. dispose(): void;
  134406. }
  134407. }
  134408. declare module BABYLON {
  134409. /**
  134410. * Gizmo that enables dragging a mesh along 3 axis
  134411. */
  134412. export class PositionGizmo extends Gizmo {
  134413. /**
  134414. * Internal gizmo used for interactions on the x axis
  134415. */
  134416. xGizmo: AxisDragGizmo;
  134417. /**
  134418. * Internal gizmo used for interactions on the y axis
  134419. */
  134420. yGizmo: AxisDragGizmo;
  134421. /**
  134422. * Internal gizmo used for interactions on the z axis
  134423. */
  134424. zGizmo: AxisDragGizmo;
  134425. /**
  134426. * Internal gizmo used for interactions on the yz plane
  134427. */
  134428. xPlaneGizmo: PlaneDragGizmo;
  134429. /**
  134430. * Internal gizmo used for interactions on the xz plane
  134431. */
  134432. yPlaneGizmo: PlaneDragGizmo;
  134433. /**
  134434. * Internal gizmo used for interactions on the xy plane
  134435. */
  134436. zPlaneGizmo: PlaneDragGizmo;
  134437. /**
  134438. * private variables
  134439. */
  134440. private _meshAttached;
  134441. private _nodeAttached;
  134442. private _snapDistance;
  134443. /** Fires an event when any of it's sub gizmos are dragged */
  134444. onDragStartObservable: Observable<unknown>;
  134445. /** Fires an event when any of it's sub gizmos are released from dragging */
  134446. onDragEndObservable: Observable<unknown>;
  134447. /**
  134448. * If set to true, planar drag is enabled
  134449. */
  134450. private _planarGizmoEnabled;
  134451. get attachedMesh(): Nullable<AbstractMesh>;
  134452. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134453. get attachedNode(): Nullable<Node>;
  134454. set attachedNode(node: Nullable<Node>);
  134455. /**
  134456. * True when the mouse pointer is hovering a gizmo mesh
  134457. */
  134458. get isHovered(): boolean;
  134459. /**
  134460. * Creates a PositionGizmo
  134461. * @param gizmoLayer The utility layer the gizmo will be added to
  134462. @param thickness display gizmo axis thickness
  134463. */
  134464. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134465. /**
  134466. * If the planar drag gizmo is enabled
  134467. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134468. */
  134469. set planarGizmoEnabled(value: boolean);
  134470. get planarGizmoEnabled(): boolean;
  134471. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134472. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134473. /**
  134474. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134475. */
  134476. set snapDistance(value: number);
  134477. get snapDistance(): number;
  134478. /**
  134479. * Ratio for the scale of the gizmo (Default: 1)
  134480. */
  134481. set scaleRatio(value: number);
  134482. get scaleRatio(): number;
  134483. /**
  134484. * Disposes of the gizmo
  134485. */
  134486. dispose(): void;
  134487. /**
  134488. * CustomMeshes are not supported by this gizmo
  134489. * @param mesh The mesh to replace the default mesh of the gizmo
  134490. */
  134491. setCustomMesh(mesh: Mesh): void;
  134492. }
  134493. }
  134494. declare module BABYLON {
  134495. /**
  134496. * Single axis drag gizmo
  134497. */
  134498. export class AxisDragGizmo extends Gizmo {
  134499. /**
  134500. * Drag behavior responsible for the gizmos dragging interactions
  134501. */
  134502. dragBehavior: PointerDragBehavior;
  134503. private _pointerObserver;
  134504. /**
  134505. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134506. */
  134507. snapDistance: number;
  134508. /**
  134509. * Event that fires each time the gizmo snaps to a new location.
  134510. * * snapDistance is the the change in distance
  134511. */
  134512. onSnapObservable: Observable<{
  134513. snapDistance: number;
  134514. }>;
  134515. private _isEnabled;
  134516. private _parent;
  134517. private _arrow;
  134518. private _coloredMaterial;
  134519. private _hoverMaterial;
  134520. /** @hidden */
  134521. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134522. /** @hidden */
  134523. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134524. /**
  134525. * Creates an AxisDragGizmo
  134526. * @param gizmoLayer The utility layer the gizmo will be added to
  134527. * @param dragAxis The axis which the gizmo will be able to drag on
  134528. * @param color The color of the gizmo
  134529. * @param thickness display gizmo axis thickness
  134530. */
  134531. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134532. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134533. /**
  134534. * If the gizmo is enabled
  134535. */
  134536. set isEnabled(value: boolean);
  134537. get isEnabled(): boolean;
  134538. /**
  134539. * Disposes of the gizmo
  134540. */
  134541. dispose(): void;
  134542. }
  134543. }
  134544. declare module BABYLON.Debug {
  134545. /**
  134546. * The Axes viewer will show 3 axes in a specific point in space
  134547. */
  134548. export class AxesViewer {
  134549. private _xAxis;
  134550. private _yAxis;
  134551. private _zAxis;
  134552. private _scaleLinesFactor;
  134553. private _instanced;
  134554. /**
  134555. * Gets the hosting scene
  134556. */
  134557. scene: Nullable<Scene>;
  134558. /**
  134559. * Gets or sets a number used to scale line length
  134560. */
  134561. scaleLines: number;
  134562. /** Gets the node hierarchy used to render x-axis */
  134563. get xAxis(): TransformNode;
  134564. /** Gets the node hierarchy used to render y-axis */
  134565. get yAxis(): TransformNode;
  134566. /** Gets the node hierarchy used to render z-axis */
  134567. get zAxis(): TransformNode;
  134568. /**
  134569. * Creates a new AxesViewer
  134570. * @param scene defines the hosting scene
  134571. * @param scaleLines defines a number used to scale line length (1 by default)
  134572. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134573. * @param xAxis defines the node hierarchy used to render the x-axis
  134574. * @param yAxis defines the node hierarchy used to render the y-axis
  134575. * @param zAxis defines the node hierarchy used to render the z-axis
  134576. */
  134577. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134578. /**
  134579. * Force the viewer to update
  134580. * @param position defines the position of the viewer
  134581. * @param xaxis defines the x axis of the viewer
  134582. * @param yaxis defines the y axis of the viewer
  134583. * @param zaxis defines the z axis of the viewer
  134584. */
  134585. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134586. /**
  134587. * Creates an instance of this axes viewer.
  134588. * @returns a new axes viewer with instanced meshes
  134589. */
  134590. createInstance(): AxesViewer;
  134591. /** Releases resources */
  134592. dispose(): void;
  134593. private static _SetRenderingGroupId;
  134594. }
  134595. }
  134596. declare module BABYLON.Debug {
  134597. /**
  134598. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134599. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134600. */
  134601. export class BoneAxesViewer extends AxesViewer {
  134602. /**
  134603. * Gets or sets the target mesh where to display the axes viewer
  134604. */
  134605. mesh: Nullable<Mesh>;
  134606. /**
  134607. * Gets or sets the target bone where to display the axes viewer
  134608. */
  134609. bone: Nullable<Bone>;
  134610. /** Gets current position */
  134611. pos: Vector3;
  134612. /** Gets direction of X axis */
  134613. xaxis: Vector3;
  134614. /** Gets direction of Y axis */
  134615. yaxis: Vector3;
  134616. /** Gets direction of Z axis */
  134617. zaxis: Vector3;
  134618. /**
  134619. * Creates a new BoneAxesViewer
  134620. * @param scene defines the hosting scene
  134621. * @param bone defines the target bone
  134622. * @param mesh defines the target mesh
  134623. * @param scaleLines defines a scaling factor for line length (1 by default)
  134624. */
  134625. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134626. /**
  134627. * Force the viewer to update
  134628. */
  134629. update(): void;
  134630. /** Releases resources */
  134631. dispose(): void;
  134632. }
  134633. }
  134634. declare module BABYLON {
  134635. /**
  134636. * Interface used to define scene explorer extensibility option
  134637. */
  134638. export interface IExplorerExtensibilityOption {
  134639. /**
  134640. * Define the option label
  134641. */
  134642. label: string;
  134643. /**
  134644. * Defines the action to execute on click
  134645. */
  134646. action: (entity: any) => void;
  134647. }
  134648. /**
  134649. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134650. */
  134651. export interface IExplorerExtensibilityGroup {
  134652. /**
  134653. * Defines a predicate to test if a given type mut be extended
  134654. */
  134655. predicate: (entity: any) => boolean;
  134656. /**
  134657. * Gets the list of options added to a type
  134658. */
  134659. entries: IExplorerExtensibilityOption[];
  134660. }
  134661. /**
  134662. * Interface used to define the options to use to create the Inspector
  134663. */
  134664. export interface IInspectorOptions {
  134665. /**
  134666. * Display in overlay mode (default: false)
  134667. */
  134668. overlay?: boolean;
  134669. /**
  134670. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134671. */
  134672. globalRoot?: HTMLElement;
  134673. /**
  134674. * Display the Scene explorer
  134675. */
  134676. showExplorer?: boolean;
  134677. /**
  134678. * Display the property inspector
  134679. */
  134680. showInspector?: boolean;
  134681. /**
  134682. * Display in embed mode (both panes on the right)
  134683. */
  134684. embedMode?: boolean;
  134685. /**
  134686. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134687. */
  134688. handleResize?: boolean;
  134689. /**
  134690. * Allow the panes to popup (default: true)
  134691. */
  134692. enablePopup?: boolean;
  134693. /**
  134694. * Allow the panes to be closed by users (default: true)
  134695. */
  134696. enableClose?: boolean;
  134697. /**
  134698. * Optional list of extensibility entries
  134699. */
  134700. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134701. /**
  134702. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134703. */
  134704. inspectorURL?: string;
  134705. /**
  134706. * Optional initial tab (default to DebugLayerTab.Properties)
  134707. */
  134708. initialTab?: DebugLayerTab;
  134709. }
  134710. interface Scene {
  134711. /**
  134712. * @hidden
  134713. * Backing field
  134714. */
  134715. _debugLayer: DebugLayer;
  134716. /**
  134717. * Gets the debug layer (aka Inspector) associated with the scene
  134718. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134719. */
  134720. debugLayer: DebugLayer;
  134721. }
  134722. /**
  134723. * Enum of inspector action tab
  134724. */
  134725. export enum DebugLayerTab {
  134726. /**
  134727. * Properties tag (default)
  134728. */
  134729. Properties = 0,
  134730. /**
  134731. * Debug tab
  134732. */
  134733. Debug = 1,
  134734. /**
  134735. * Statistics tab
  134736. */
  134737. Statistics = 2,
  134738. /**
  134739. * Tools tab
  134740. */
  134741. Tools = 3,
  134742. /**
  134743. * Settings tab
  134744. */
  134745. Settings = 4
  134746. }
  134747. /**
  134748. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134749. * what is happening in your scene
  134750. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134751. */
  134752. export class DebugLayer {
  134753. /**
  134754. * Define the url to get the inspector script from.
  134755. * By default it uses the babylonjs CDN.
  134756. * @ignoreNaming
  134757. */
  134758. static InspectorURL: string;
  134759. private _scene;
  134760. private BJSINSPECTOR;
  134761. private _onPropertyChangedObservable?;
  134762. /**
  134763. * Observable triggered when a property is changed through the inspector.
  134764. */
  134765. get onPropertyChangedObservable(): any;
  134766. /**
  134767. * Instantiates a new debug layer.
  134768. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134769. * what is happening in your scene
  134770. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134771. * @param scene Defines the scene to inspect
  134772. */
  134773. constructor(scene: Scene);
  134774. /** Creates the inspector window. */
  134775. private _createInspector;
  134776. /**
  134777. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134778. * @param entity defines the entity to select
  134779. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134780. */
  134781. select(entity: any, lineContainerTitles?: string | string[]): void;
  134782. /** Get the inspector from bundle or global */
  134783. private _getGlobalInspector;
  134784. /**
  134785. * Get if the inspector is visible or not.
  134786. * @returns true if visible otherwise, false
  134787. */
  134788. isVisible(): boolean;
  134789. /**
  134790. * Hide the inspector and close its window.
  134791. */
  134792. hide(): void;
  134793. /**
  134794. * Update the scene in the inspector
  134795. */
  134796. setAsActiveScene(): void;
  134797. /**
  134798. * Launch the debugLayer.
  134799. * @param config Define the configuration of the inspector
  134800. * @return a promise fulfilled when the debug layer is visible
  134801. */
  134802. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134803. }
  134804. }
  134805. declare module BABYLON {
  134806. /**
  134807. * Class containing static functions to help procedurally build meshes
  134808. */
  134809. export class BoxBuilder {
  134810. /**
  134811. * Creates a box mesh
  134812. * * The parameter `size` sets the size (float) of each box side (default 1)
  134813. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134814. * * 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)
  134815. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134819. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134820. * @param name defines the name of the mesh
  134821. * @param options defines the options used to create the mesh
  134822. * @param scene defines the hosting scene
  134823. * @returns the box mesh
  134824. */
  134825. static CreateBox(name: string, options: {
  134826. size?: number;
  134827. width?: number;
  134828. height?: number;
  134829. depth?: number;
  134830. faceUV?: Vector4[];
  134831. faceColors?: Color4[];
  134832. sideOrientation?: number;
  134833. frontUVs?: Vector4;
  134834. backUVs?: Vector4;
  134835. wrap?: boolean;
  134836. topBaseAt?: number;
  134837. bottomBaseAt?: number;
  134838. updatable?: boolean;
  134839. }, scene?: Nullable<Scene>): Mesh;
  134840. }
  134841. }
  134842. declare module BABYLON.Debug {
  134843. /**
  134844. * Used to show the physics impostor around the specific mesh
  134845. */
  134846. export class PhysicsViewer {
  134847. /** @hidden */
  134848. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134849. /** @hidden */
  134850. protected _meshes: Array<Nullable<AbstractMesh>>;
  134851. /** @hidden */
  134852. protected _scene: Nullable<Scene>;
  134853. /** @hidden */
  134854. protected _numMeshes: number;
  134855. /** @hidden */
  134856. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134857. private _renderFunction;
  134858. private _utilityLayer;
  134859. private _debugBoxMesh;
  134860. private _debugSphereMesh;
  134861. private _debugCylinderMesh;
  134862. private _debugMaterial;
  134863. private _debugMeshMeshes;
  134864. /**
  134865. * Creates a new PhysicsViewer
  134866. * @param scene defines the hosting scene
  134867. */
  134868. constructor(scene: Scene);
  134869. /** @hidden */
  134870. protected _updateDebugMeshes(): void;
  134871. /**
  134872. * Renders a specified physic impostor
  134873. * @param impostor defines the impostor to render
  134874. * @param targetMesh defines the mesh represented by the impostor
  134875. * @returns the new debug mesh used to render the impostor
  134876. */
  134877. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134878. /**
  134879. * Hides a specified physic impostor
  134880. * @param impostor defines the impostor to hide
  134881. */
  134882. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134883. private _getDebugMaterial;
  134884. private _getDebugBoxMesh;
  134885. private _getDebugSphereMesh;
  134886. private _getDebugCylinderMesh;
  134887. private _getDebugMeshMesh;
  134888. private _getDebugMesh;
  134889. /** Releases all resources */
  134890. dispose(): void;
  134891. }
  134892. }
  134893. declare module BABYLON {
  134894. /**
  134895. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134896. * in order to better appreciate the issue one might have.
  134897. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134898. */
  134899. export class RayHelper {
  134900. /**
  134901. * Defines the ray we are currently tryin to visualize.
  134902. */
  134903. ray: Nullable<Ray>;
  134904. private _renderPoints;
  134905. private _renderLine;
  134906. private _renderFunction;
  134907. private _scene;
  134908. private _onAfterRenderObserver;
  134909. private _onAfterStepObserver;
  134910. private _attachedToMesh;
  134911. private _meshSpaceDirection;
  134912. private _meshSpaceOrigin;
  134913. /**
  134914. * Helper function to create a colored helper in a scene in one line.
  134915. * @param ray Defines the ray we are currently tryin to visualize
  134916. * @param scene Defines the scene the ray is used in
  134917. * @param color Defines the color we want to see the ray in
  134918. * @returns The newly created ray helper.
  134919. */
  134920. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134921. /**
  134922. * Instantiate a new ray helper.
  134923. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134924. * in order to better appreciate the issue one might have.
  134925. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134926. * @param ray Defines the ray we are currently tryin to visualize
  134927. */
  134928. constructor(ray: Ray);
  134929. /**
  134930. * Shows the ray we are willing to debug.
  134931. * @param scene Defines the scene the ray needs to be rendered in
  134932. * @param color Defines the color the ray needs to be rendered in
  134933. */
  134934. show(scene: Scene, color?: Color3): void;
  134935. /**
  134936. * Hides the ray we are debugging.
  134937. */
  134938. hide(): void;
  134939. private _render;
  134940. /**
  134941. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134942. * @param mesh Defines the mesh we want the helper attached to
  134943. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134944. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134945. * @param length Defines the length of the ray
  134946. */
  134947. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134948. /**
  134949. * Detach the ray helper from the mesh it has previously been attached to.
  134950. */
  134951. detachFromMesh(): void;
  134952. private _updateToMesh;
  134953. /**
  134954. * Dispose the helper and release its associated resources.
  134955. */
  134956. dispose(): void;
  134957. }
  134958. }
  134959. declare module BABYLON {
  134960. /**
  134961. * Defines the options associated with the creation of a SkeletonViewer.
  134962. */
  134963. export interface ISkeletonViewerOptions {
  134964. /** Should the system pause animations before building the Viewer? */
  134965. pauseAnimations: boolean;
  134966. /** Should the system return the skeleton to rest before building? */
  134967. returnToRest: boolean;
  134968. /** public Display Mode of the Viewer */
  134969. displayMode: number;
  134970. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134971. displayOptions: ISkeletonViewerDisplayOptions;
  134972. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134973. computeBonesUsingShaders: boolean;
  134974. /** Flag ignore non weighted bones */
  134975. useAllBones: boolean;
  134976. }
  134977. /**
  134978. * Defines how to display the various bone meshes for the viewer.
  134979. */
  134980. export interface ISkeletonViewerDisplayOptions {
  134981. /** How far down to start tapering the bone spurs */
  134982. midStep?: number;
  134983. /** How big is the midStep? */
  134984. midStepFactor?: number;
  134985. /** Base for the Sphere Size */
  134986. sphereBaseSize?: number;
  134987. /** The ratio of the sphere to the longest bone in units */
  134988. sphereScaleUnit?: number;
  134989. /** Ratio for the Sphere Size */
  134990. sphereFactor?: number;
  134991. /** Whether a spur should attach its far end to the child bone position */
  134992. spurFollowsChild?: boolean;
  134993. /** Whether to show local axes or not */
  134994. showLocalAxes?: boolean;
  134995. /** Length of each local axis */
  134996. localAxesSize?: number;
  134997. }
  134998. /**
  134999. * Defines the constructor options for the BoneWeight Shader.
  135000. */
  135001. export interface IBoneWeightShaderOptions {
  135002. /** Skeleton to Map */
  135003. skeleton: Skeleton;
  135004. /** Colors for Uninfluenced bones */
  135005. colorBase?: Color3;
  135006. /** Colors for 0.0-0.25 Weight bones */
  135007. colorZero?: Color3;
  135008. /** Color for 0.25-0.5 Weight Influence */
  135009. colorQuarter?: Color3;
  135010. /** Color for 0.5-0.75 Weight Influence */
  135011. colorHalf?: Color3;
  135012. /** Color for 0.75-1 Weight Influence */
  135013. colorFull?: Color3;
  135014. /** Color for Zero Weight Influence */
  135015. targetBoneIndex?: number;
  135016. }
  135017. /**
  135018. * Simple structure of the gradient steps for the Color Map.
  135019. */
  135020. export interface ISkeletonMapShaderColorMapKnot {
  135021. /** Color of the Knot */
  135022. color: Color3;
  135023. /** Location of the Knot */
  135024. location: number;
  135025. }
  135026. /**
  135027. * Defines the constructor options for the SkeletonMap Shader.
  135028. */
  135029. export interface ISkeletonMapShaderOptions {
  135030. /** Skeleton to Map */
  135031. skeleton: Skeleton;
  135032. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  135033. colorMap?: ISkeletonMapShaderColorMapKnot[];
  135034. }
  135035. }
  135036. declare module BABYLON {
  135037. /**
  135038. * Class containing static functions to help procedurally build meshes
  135039. */
  135040. export class RibbonBuilder {
  135041. /**
  135042. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135043. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135044. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135045. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135046. * * 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
  135047. * * 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
  135048. * * 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
  135049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135052. * * 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
  135053. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135054. * * 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
  135055. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135057. * @param name defines the name of the mesh
  135058. * @param options defines the options used to create the mesh
  135059. * @param scene defines the hosting scene
  135060. * @returns the ribbon mesh
  135061. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135063. */
  135064. static CreateRibbon(name: string, options: {
  135065. pathArray: Vector3[][];
  135066. closeArray?: boolean;
  135067. closePath?: boolean;
  135068. offset?: number;
  135069. updatable?: boolean;
  135070. sideOrientation?: number;
  135071. frontUVs?: Vector4;
  135072. backUVs?: Vector4;
  135073. instance?: Mesh;
  135074. invertUV?: boolean;
  135075. uvs?: Vector2[];
  135076. colors?: Color4[];
  135077. }, scene?: Nullable<Scene>): Mesh;
  135078. }
  135079. }
  135080. declare module BABYLON {
  135081. /**
  135082. * Class containing static functions to help procedurally build meshes
  135083. */
  135084. export class ShapeBuilder {
  135085. /**
  135086. * 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.
  135087. * * 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.
  135088. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135089. * * 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.
  135090. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135091. * * 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
  135092. * * 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
  135093. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135098. * @param name defines the name of the mesh
  135099. * @param options defines the options used to create the mesh
  135100. * @param scene defines the hosting scene
  135101. * @returns the extruded shape mesh
  135102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135104. */
  135105. static ExtrudeShape(name: string, options: {
  135106. shape: Vector3[];
  135107. path: Vector3[];
  135108. scale?: number;
  135109. rotation?: number;
  135110. cap?: number;
  135111. updatable?: boolean;
  135112. sideOrientation?: number;
  135113. frontUVs?: Vector4;
  135114. backUVs?: Vector4;
  135115. instance?: Mesh;
  135116. invertUV?: boolean;
  135117. }, scene?: Nullable<Scene>): Mesh;
  135118. /**
  135119. * Creates an custom extruded shape mesh.
  135120. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135121. * * 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.
  135122. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135123. * * 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
  135124. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135125. * * 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
  135126. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135127. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135128. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135129. * * 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
  135130. * * 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
  135131. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135136. * @param name defines the name of the mesh
  135137. * @param options defines the options used to create the mesh
  135138. * @param scene defines the hosting scene
  135139. * @returns the custom extruded shape mesh
  135140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135141. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135143. */
  135144. static ExtrudeShapeCustom(name: string, options: {
  135145. shape: Vector3[];
  135146. path: Vector3[];
  135147. scaleFunction?: any;
  135148. rotationFunction?: any;
  135149. ribbonCloseArray?: boolean;
  135150. ribbonClosePath?: boolean;
  135151. cap?: number;
  135152. updatable?: boolean;
  135153. sideOrientation?: number;
  135154. frontUVs?: Vector4;
  135155. backUVs?: Vector4;
  135156. instance?: Mesh;
  135157. invertUV?: boolean;
  135158. }, scene?: Nullable<Scene>): Mesh;
  135159. private static _ExtrudeShapeGeneric;
  135160. }
  135161. }
  135162. declare module BABYLON.Debug {
  135163. /**
  135164. * Class used to render a debug view of a given skeleton
  135165. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135166. */
  135167. export class SkeletonViewer {
  135168. /** defines the skeleton to render */
  135169. skeleton: Skeleton;
  135170. /** defines the mesh attached to the skeleton */
  135171. mesh: AbstractMesh;
  135172. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135173. autoUpdateBonesMatrices: boolean;
  135174. /** defines the rendering group id to use with the viewer */
  135175. renderingGroupId: number;
  135176. /** is the options for the viewer */
  135177. options: Partial<ISkeletonViewerOptions>;
  135178. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135179. static readonly DISPLAY_LINES: number;
  135180. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135181. static readonly DISPLAY_SPHERES: number;
  135182. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135183. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135184. /** public static method to create a BoneWeight Shader
  135185. * @param options The constructor options
  135186. * @param scene The scene that the shader is scoped to
  135187. * @returns The created ShaderMaterial
  135188. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135189. */
  135190. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135191. /** public static method to create a BoneWeight Shader
  135192. * @param options The constructor options
  135193. * @param scene The scene that the shader is scoped to
  135194. * @returns The created ShaderMaterial
  135195. */
  135196. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135197. /** private static method to create a BoneWeight Shader
  135198. * @param size The size of the buffer to create (usually the bone count)
  135199. * @param colorMap The gradient data to generate
  135200. * @param scene The scene that the shader is scoped to
  135201. * @returns an Array of floats from the color gradient values
  135202. */
  135203. private static _CreateBoneMapColorBuffer;
  135204. /** If SkeletonViewer scene scope. */
  135205. private _scene;
  135206. /** Gets or sets the color used to render the skeleton */
  135207. color: Color3;
  135208. /** Array of the points of the skeleton fo the line view. */
  135209. private _debugLines;
  135210. /** The SkeletonViewers Mesh. */
  135211. private _debugMesh;
  135212. /** The local axes Meshes. */
  135213. private _localAxes;
  135214. /** If SkeletonViewer is enabled. */
  135215. private _isEnabled;
  135216. /** If SkeletonViewer is ready. */
  135217. private _ready;
  135218. /** SkeletonViewer render observable. */
  135219. private _obs;
  135220. /** The Utility Layer to render the gizmos in. */
  135221. private _utilityLayer;
  135222. private _boneIndices;
  135223. /** Gets the Scene. */
  135224. get scene(): Scene;
  135225. /** Gets the utilityLayer. */
  135226. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135227. /** Checks Ready Status. */
  135228. get isReady(): Boolean;
  135229. /** Sets Ready Status. */
  135230. set ready(value: boolean);
  135231. /** Gets the debugMesh */
  135232. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135233. /** Sets the debugMesh */
  135234. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135235. /** Gets the displayMode */
  135236. get displayMode(): number;
  135237. /** Sets the displayMode */
  135238. set displayMode(value: number);
  135239. /**
  135240. * Creates a new SkeletonViewer
  135241. * @param skeleton defines the skeleton to render
  135242. * @param mesh defines the mesh attached to the skeleton
  135243. * @param scene defines the hosting scene
  135244. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135245. * @param renderingGroupId defines the rendering group id to use with the viewer
  135246. * @param options All of the extra constructor options for the SkeletonViewer
  135247. */
  135248. constructor(
  135249. /** defines the skeleton to render */
  135250. skeleton: Skeleton,
  135251. /** defines the mesh attached to the skeleton */
  135252. mesh: AbstractMesh,
  135253. /** The Scene scope*/
  135254. scene: Scene,
  135255. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135256. autoUpdateBonesMatrices?: boolean,
  135257. /** defines the rendering group id to use with the viewer */
  135258. renderingGroupId?: number,
  135259. /** is the options for the viewer */
  135260. options?: Partial<ISkeletonViewerOptions>);
  135261. /** The Dynamic bindings for the update functions */
  135262. private _bindObs;
  135263. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135264. update(): void;
  135265. /** Gets or sets a boolean indicating if the viewer is enabled */
  135266. set isEnabled(value: boolean);
  135267. get isEnabled(): boolean;
  135268. private _getBonePosition;
  135269. private _getLinesForBonesWithLength;
  135270. private _getLinesForBonesNoLength;
  135271. /** function to revert the mesh and scene back to the initial state. */
  135272. private _revert;
  135273. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135274. private _getAbsoluteBindPoseToRef;
  135275. /** function to build and bind sphere joint points and spur bone representations. */
  135276. private _buildSpheresAndSpurs;
  135277. private _buildLocalAxes;
  135278. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135279. private _displayLinesUpdate;
  135280. /** Changes the displayMode of the skeleton viewer
  135281. * @param mode The displayMode numerical value
  135282. */
  135283. changeDisplayMode(mode: number): void;
  135284. /** Sets a display option of the skeleton viewer
  135285. *
  135286. * | Option | Type | Default | Description |
  135287. * | ---------------- | ------- | ------- | ----------- |
  135288. * | 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`. |
  135289. * | 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`. |
  135290. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135291. * | 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`. |
  135292. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135293. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135294. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135295. *
  135296. * @param option String of the option name
  135297. * @param value The numerical option value
  135298. */
  135299. changeDisplayOptions(option: string, value: number): void;
  135300. /** Release associated resources */
  135301. dispose(): void;
  135302. }
  135303. }
  135304. declare module BABYLON {
  135305. /**
  135306. * Enum for Device Types
  135307. */
  135308. export enum DeviceType {
  135309. /** Generic */
  135310. Generic = 0,
  135311. /** Keyboard */
  135312. Keyboard = 1,
  135313. /** Mouse */
  135314. Mouse = 2,
  135315. /** Touch Pointers */
  135316. Touch = 3,
  135317. /** PS4 Dual Shock */
  135318. DualShock = 4,
  135319. /** Xbox */
  135320. Xbox = 5,
  135321. /** Switch Controller */
  135322. Switch = 6
  135323. }
  135324. /**
  135325. * Enum for All Pointers (Touch/Mouse)
  135326. */
  135327. export enum PointerInput {
  135328. /** Horizontal Axis */
  135329. Horizontal = 0,
  135330. /** Vertical Axis */
  135331. Vertical = 1,
  135332. /** Left Click or Touch */
  135333. LeftClick = 2,
  135334. /** Middle Click */
  135335. MiddleClick = 3,
  135336. /** Right Click */
  135337. RightClick = 4,
  135338. /** Browser Back */
  135339. BrowserBack = 5,
  135340. /** Browser Forward */
  135341. BrowserForward = 6
  135342. }
  135343. /**
  135344. * Enum for Dual Shock Gamepad
  135345. */
  135346. export enum DualShockInput {
  135347. /** Cross */
  135348. Cross = 0,
  135349. /** Circle */
  135350. Circle = 1,
  135351. /** Square */
  135352. Square = 2,
  135353. /** Triangle */
  135354. Triangle = 3,
  135355. /** L1 */
  135356. L1 = 4,
  135357. /** R1 */
  135358. R1 = 5,
  135359. /** L2 */
  135360. L2 = 6,
  135361. /** R2 */
  135362. R2 = 7,
  135363. /** Share */
  135364. Share = 8,
  135365. /** Options */
  135366. Options = 9,
  135367. /** L3 */
  135368. L3 = 10,
  135369. /** R3 */
  135370. R3 = 11,
  135371. /** DPadUp */
  135372. DPadUp = 12,
  135373. /** DPadDown */
  135374. DPadDown = 13,
  135375. /** DPadLeft */
  135376. DPadLeft = 14,
  135377. /** DRight */
  135378. DPadRight = 15,
  135379. /** Home */
  135380. Home = 16,
  135381. /** TouchPad */
  135382. TouchPad = 17,
  135383. /** LStickXAxis */
  135384. LStickXAxis = 18,
  135385. /** LStickYAxis */
  135386. LStickYAxis = 19,
  135387. /** RStickXAxis */
  135388. RStickXAxis = 20,
  135389. /** RStickYAxis */
  135390. RStickYAxis = 21
  135391. }
  135392. /**
  135393. * Enum for Xbox Gamepad
  135394. */
  135395. export enum XboxInput {
  135396. /** A */
  135397. A = 0,
  135398. /** B */
  135399. B = 1,
  135400. /** X */
  135401. X = 2,
  135402. /** Y */
  135403. Y = 3,
  135404. /** LB */
  135405. LB = 4,
  135406. /** RB */
  135407. RB = 5,
  135408. /** LT */
  135409. LT = 6,
  135410. /** RT */
  135411. RT = 7,
  135412. /** Back */
  135413. Back = 8,
  135414. /** Start */
  135415. Start = 9,
  135416. /** LS */
  135417. LS = 10,
  135418. /** RS */
  135419. RS = 11,
  135420. /** DPadUp */
  135421. DPadUp = 12,
  135422. /** DPadDown */
  135423. DPadDown = 13,
  135424. /** DPadLeft */
  135425. DPadLeft = 14,
  135426. /** DRight */
  135427. DPadRight = 15,
  135428. /** Home */
  135429. Home = 16,
  135430. /** LStickXAxis */
  135431. LStickXAxis = 17,
  135432. /** LStickYAxis */
  135433. LStickYAxis = 18,
  135434. /** RStickXAxis */
  135435. RStickXAxis = 19,
  135436. /** RStickYAxis */
  135437. RStickYAxis = 20
  135438. }
  135439. /**
  135440. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135441. */
  135442. export enum SwitchInput {
  135443. /** B */
  135444. B = 0,
  135445. /** A */
  135446. A = 1,
  135447. /** Y */
  135448. Y = 2,
  135449. /** X */
  135450. X = 3,
  135451. /** L */
  135452. L = 4,
  135453. /** R */
  135454. R = 5,
  135455. /** ZL */
  135456. ZL = 6,
  135457. /** ZR */
  135458. ZR = 7,
  135459. /** Minus */
  135460. Minus = 8,
  135461. /** Plus */
  135462. Plus = 9,
  135463. /** LS */
  135464. LS = 10,
  135465. /** RS */
  135466. RS = 11,
  135467. /** DPadUp */
  135468. DPadUp = 12,
  135469. /** DPadDown */
  135470. DPadDown = 13,
  135471. /** DPadLeft */
  135472. DPadLeft = 14,
  135473. /** DRight */
  135474. DPadRight = 15,
  135475. /** Home */
  135476. Home = 16,
  135477. /** Capture */
  135478. Capture = 17,
  135479. /** LStickXAxis */
  135480. LStickXAxis = 18,
  135481. /** LStickYAxis */
  135482. LStickYAxis = 19,
  135483. /** RStickXAxis */
  135484. RStickXAxis = 20,
  135485. /** RStickYAxis */
  135486. RStickYAxis = 21
  135487. }
  135488. }
  135489. declare module BABYLON {
  135490. /**
  135491. * This class will take all inputs from Keyboard, Pointer, and
  135492. * any Gamepads and provide a polling system that all devices
  135493. * will use. This class assumes that there will only be one
  135494. * pointer device and one keyboard.
  135495. */
  135496. export class DeviceInputSystem implements IDisposable {
  135497. /**
  135498. * Callback to be triggered when a device is connected
  135499. */
  135500. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135501. /**
  135502. * Callback to be triggered when a device is disconnected
  135503. */
  135504. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135505. /**
  135506. * Callback to be triggered when event driven input is updated
  135507. */
  135508. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135509. private _inputs;
  135510. private _gamepads;
  135511. private _keyboardActive;
  135512. private _pointerActive;
  135513. private _elementToAttachTo;
  135514. private _keyboardDownEvent;
  135515. private _keyboardUpEvent;
  135516. private _pointerMoveEvent;
  135517. private _pointerDownEvent;
  135518. private _pointerUpEvent;
  135519. private _gamepadConnectedEvent;
  135520. private _gamepadDisconnectedEvent;
  135521. private static _MAX_KEYCODES;
  135522. private static _MAX_POINTER_INPUTS;
  135523. private constructor();
  135524. /**
  135525. * Creates a new DeviceInputSystem instance
  135526. * @param engine Engine to pull input element from
  135527. * @returns The new instance
  135528. */
  135529. static Create(engine: Engine): DeviceInputSystem;
  135530. /**
  135531. * Checks for current device input value, given an id and input index
  135532. * @param deviceName Id of connected device
  135533. * @param inputIndex Index of device input
  135534. * @returns Current value of input
  135535. */
  135536. /**
  135537. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135538. * @param deviceType Enum specifiying device type
  135539. * @param deviceSlot "Slot" or index that device is referenced in
  135540. * @param inputIndex Id of input to be checked
  135541. * @returns Current value of input
  135542. */
  135543. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135544. /**
  135545. * Dispose of all the eventlisteners
  135546. */
  135547. dispose(): void;
  135548. /**
  135549. * Add device and inputs to device array
  135550. * @param deviceType Enum specifiying device type
  135551. * @param deviceSlot "Slot" or index that device is referenced in
  135552. * @param numberOfInputs Number of input entries to create for given device
  135553. */
  135554. private _registerDevice;
  135555. /**
  135556. * Given a specific device name, remove that device from the device map
  135557. * @param deviceType Enum specifiying device type
  135558. * @param deviceSlot "Slot" or index that device is referenced in
  135559. */
  135560. private _unregisterDevice;
  135561. /**
  135562. * Handle all actions that come from keyboard interaction
  135563. */
  135564. private _handleKeyActions;
  135565. /**
  135566. * Handle all actions that come from pointer interaction
  135567. */
  135568. private _handlePointerActions;
  135569. /**
  135570. * Handle all actions that come from gamepad interaction
  135571. */
  135572. private _handleGamepadActions;
  135573. /**
  135574. * Update all non-event based devices with each frame
  135575. * @param deviceType Enum specifiying device type
  135576. * @param deviceSlot "Slot" or index that device is referenced in
  135577. * @param inputIndex Id of input to be checked
  135578. */
  135579. private _updateDevice;
  135580. /**
  135581. * Gets DeviceType from the device name
  135582. * @param deviceName Name of Device from DeviceInputSystem
  135583. * @returns DeviceType enum value
  135584. */
  135585. private _getGamepadDeviceType;
  135586. }
  135587. }
  135588. declare module BABYLON {
  135589. /**
  135590. * Type to handle enforcement of inputs
  135591. */
  135592. 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;
  135593. }
  135594. declare module BABYLON {
  135595. /**
  135596. * Class that handles all input for a specific device
  135597. */
  135598. export class DeviceSource<T extends DeviceType> {
  135599. /** Type of device */
  135600. readonly deviceType: DeviceType;
  135601. /** "Slot" or index that device is referenced in */
  135602. readonly deviceSlot: number;
  135603. /**
  135604. * Observable to handle device input changes per device
  135605. */
  135606. readonly onInputChangedObservable: Observable<{
  135607. inputIndex: DeviceInput<T>;
  135608. previousState: Nullable<number>;
  135609. currentState: Nullable<number>;
  135610. }>;
  135611. private readonly _deviceInputSystem;
  135612. /**
  135613. * Default Constructor
  135614. * @param deviceInputSystem Reference to DeviceInputSystem
  135615. * @param deviceType Type of device
  135616. * @param deviceSlot "Slot" or index that device is referenced in
  135617. */
  135618. constructor(deviceInputSystem: DeviceInputSystem,
  135619. /** Type of device */
  135620. deviceType: DeviceType,
  135621. /** "Slot" or index that device is referenced in */
  135622. deviceSlot?: number);
  135623. /**
  135624. * Get input for specific input
  135625. * @param inputIndex index of specific input on device
  135626. * @returns Input value from DeviceInputSystem
  135627. */
  135628. getInput(inputIndex: DeviceInput<T>): number;
  135629. }
  135630. /**
  135631. * Class to keep track of devices
  135632. */
  135633. export class DeviceSourceManager implements IDisposable {
  135634. /**
  135635. * Observable to be triggered when before a device is connected
  135636. */
  135637. readonly onBeforeDeviceConnectedObservable: Observable<{
  135638. deviceType: DeviceType;
  135639. deviceSlot: number;
  135640. }>;
  135641. /**
  135642. * Observable to be triggered when before a device is disconnected
  135643. */
  135644. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135645. deviceType: DeviceType;
  135646. deviceSlot: number;
  135647. }>;
  135648. /**
  135649. * Observable to be triggered when after a device is connected
  135650. */
  135651. readonly onAfterDeviceConnectedObservable: Observable<{
  135652. deviceType: DeviceType;
  135653. deviceSlot: number;
  135654. }>;
  135655. /**
  135656. * Observable to be triggered when after a device is disconnected
  135657. */
  135658. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135659. deviceType: DeviceType;
  135660. deviceSlot: number;
  135661. }>;
  135662. private readonly _devices;
  135663. private readonly _firstDevice;
  135664. private readonly _deviceInputSystem;
  135665. /**
  135666. * Default Constructor
  135667. * @param engine engine to pull input element from
  135668. */
  135669. constructor(engine: Engine);
  135670. /**
  135671. * Gets a DeviceSource, given a type and slot
  135672. * @param deviceType Enum specifying device type
  135673. * @param deviceSlot "Slot" or index that device is referenced in
  135674. * @returns DeviceSource object
  135675. */
  135676. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135677. /**
  135678. * Gets an array of DeviceSource objects for a given device type
  135679. * @param deviceType Enum specifying device type
  135680. * @returns Array of DeviceSource objects
  135681. */
  135682. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135683. /**
  135684. * Dispose of DeviceInputSystem and other parts
  135685. */
  135686. dispose(): void;
  135687. /**
  135688. * Function to add device name to device list
  135689. * @param deviceType Enum specifying device type
  135690. * @param deviceSlot "Slot" or index that device is referenced in
  135691. */
  135692. private _addDevice;
  135693. /**
  135694. * Function to remove device name to device list
  135695. * @param deviceType Enum specifying device type
  135696. * @param deviceSlot "Slot" or index that device is referenced in
  135697. */
  135698. private _removeDevice;
  135699. /**
  135700. * Updates array storing first connected device of each type
  135701. * @param type Type of Device
  135702. */
  135703. private _updateFirstDevices;
  135704. }
  135705. }
  135706. declare module BABYLON {
  135707. /**
  135708. * Options to create the null engine
  135709. */
  135710. export class NullEngineOptions {
  135711. /**
  135712. * Render width (Default: 512)
  135713. */
  135714. renderWidth: number;
  135715. /**
  135716. * Render height (Default: 256)
  135717. */
  135718. renderHeight: number;
  135719. /**
  135720. * Texture size (Default: 512)
  135721. */
  135722. textureSize: number;
  135723. /**
  135724. * If delta time between frames should be constant
  135725. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135726. */
  135727. deterministicLockstep: boolean;
  135728. /**
  135729. * Maximum about of steps between frames (Default: 4)
  135730. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135731. */
  135732. lockstepMaxSteps: number;
  135733. /**
  135734. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135735. */
  135736. useHighPrecisionMatrix?: boolean;
  135737. }
  135738. /**
  135739. * The null engine class provides support for headless version of babylon.js.
  135740. * This can be used in server side scenario or for testing purposes
  135741. */
  135742. export class NullEngine extends Engine {
  135743. private _options;
  135744. /**
  135745. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135746. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135747. * @returns true if engine is in deterministic lock step mode
  135748. */
  135749. isDeterministicLockStep(): boolean;
  135750. /**
  135751. * Gets the max steps when engine is running in deterministic lock step
  135752. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135753. * @returns the max steps
  135754. */
  135755. getLockstepMaxSteps(): number;
  135756. /**
  135757. * Gets the current hardware scaling level.
  135758. * By default the hardware scaling level is computed from the window device ratio.
  135759. * 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.
  135760. * @returns a number indicating the current hardware scaling level
  135761. */
  135762. getHardwareScalingLevel(): number;
  135763. constructor(options?: NullEngineOptions);
  135764. /**
  135765. * Creates a vertex buffer
  135766. * @param vertices the data for the vertex buffer
  135767. * @returns the new WebGL static buffer
  135768. */
  135769. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135770. /**
  135771. * Creates a new index buffer
  135772. * @param indices defines the content of the index buffer
  135773. * @param updatable defines if the index buffer must be updatable
  135774. * @returns a new webGL buffer
  135775. */
  135776. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135777. /**
  135778. * Clear the current render buffer or the current render target (if any is set up)
  135779. * @param color defines the color to use
  135780. * @param backBuffer defines if the back buffer must be cleared
  135781. * @param depth defines if the depth buffer must be cleared
  135782. * @param stencil defines if the stencil buffer must be cleared
  135783. */
  135784. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135785. /**
  135786. * Gets the current render width
  135787. * @param useScreen defines if screen size must be used (or the current render target if any)
  135788. * @returns a number defining the current render width
  135789. */
  135790. getRenderWidth(useScreen?: boolean): number;
  135791. /**
  135792. * Gets the current render height
  135793. * @param useScreen defines if screen size must be used (or the current render target if any)
  135794. * @returns a number defining the current render height
  135795. */
  135796. getRenderHeight(useScreen?: boolean): number;
  135797. /**
  135798. * Set the WebGL's viewport
  135799. * @param viewport defines the viewport element to be used
  135800. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135801. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135802. */
  135803. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135804. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135805. /**
  135806. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135807. * @param pipelineContext defines the pipeline context to use
  135808. * @param uniformsNames defines the list of uniform names
  135809. * @returns an array of webGL uniform locations
  135810. */
  135811. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135812. /**
  135813. * Gets the lsit of active attributes for a given webGL program
  135814. * @param pipelineContext defines the pipeline context to use
  135815. * @param attributesNames defines the list of attribute names to get
  135816. * @returns an array of indices indicating the offset of each attribute
  135817. */
  135818. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135819. /**
  135820. * Binds an effect to the webGL context
  135821. * @param effect defines the effect to bind
  135822. */
  135823. bindSamplers(effect: Effect): void;
  135824. /**
  135825. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135826. * @param effect defines the effect to activate
  135827. */
  135828. enableEffect(effect: Effect): void;
  135829. /**
  135830. * Set various states to the webGL context
  135831. * @param culling defines backface culling state
  135832. * @param zOffset defines the value to apply to zOffset (0 by default)
  135833. * @param force defines if states must be applied even if cache is up to date
  135834. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135835. */
  135836. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135837. /**
  135838. * Set the value of an uniform to an array of int32
  135839. * @param uniform defines the webGL uniform location where to store the value
  135840. * @param array defines the array of int32 to store
  135841. * @returns true if value was set
  135842. */
  135843. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135844. /**
  135845. * Set the value of an uniform to an array of int32 (stored as vec2)
  135846. * @param uniform defines the webGL uniform location where to store the value
  135847. * @param array defines the array of int32 to store
  135848. * @returns true if value was set
  135849. */
  135850. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135851. /**
  135852. * Set the value of an uniform to an array of int32 (stored as vec3)
  135853. * @param uniform defines the webGL uniform location where to store the value
  135854. * @param array defines the array of int32 to store
  135855. * @returns true if value was set
  135856. */
  135857. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135858. /**
  135859. * Set the value of an uniform to an array of int32 (stored as vec4)
  135860. * @param uniform defines the webGL uniform location where to store the value
  135861. * @param array defines the array of int32 to store
  135862. * @returns true if value was set
  135863. */
  135864. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135865. /**
  135866. * Set the value of an uniform to an array of float32
  135867. * @param uniform defines the webGL uniform location where to store the value
  135868. * @param array defines the array of float32 to store
  135869. * @returns true if value was set
  135870. */
  135871. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135872. /**
  135873. * Set the value of an uniform to an array of float32 (stored as vec2)
  135874. * @param uniform defines the webGL uniform location where to store the value
  135875. * @param array defines the array of float32 to store
  135876. * @returns true if value was set
  135877. */
  135878. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135879. /**
  135880. * Set the value of an uniform to an array of float32 (stored as vec3)
  135881. * @param uniform defines the webGL uniform location where to store the value
  135882. * @param array defines the array of float32 to store
  135883. * @returns true if value was set
  135884. */
  135885. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135886. /**
  135887. * Set the value of an uniform to an array of float32 (stored as vec4)
  135888. * @param uniform defines the webGL uniform location where to store the value
  135889. * @param array defines the array of float32 to store
  135890. * @returns true if value was set
  135891. */
  135892. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135893. /**
  135894. * Set the value of an uniform to an array of number
  135895. * @param uniform defines the webGL uniform location where to store the value
  135896. * @param array defines the array of number to store
  135897. * @returns true if value was set
  135898. */
  135899. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135900. /**
  135901. * Set the value of an uniform to an array of number (stored as vec2)
  135902. * @param uniform defines the webGL uniform location where to store the value
  135903. * @param array defines the array of number to store
  135904. * @returns true if value was set
  135905. */
  135906. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135907. /**
  135908. * Set the value of an uniform to an array of number (stored as vec3)
  135909. * @param uniform defines the webGL uniform location where to store the value
  135910. * @param array defines the array of number to store
  135911. * @returns true if value was set
  135912. */
  135913. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135914. /**
  135915. * Set the value of an uniform to an array of number (stored as vec4)
  135916. * @param uniform defines the webGL uniform location where to store the value
  135917. * @param array defines the array of number to store
  135918. * @returns true if value was set
  135919. */
  135920. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135921. /**
  135922. * Set the value of an uniform to an array of float32 (stored as matrices)
  135923. * @param uniform defines the webGL uniform location where to store the value
  135924. * @param matrices defines the array of float32 to store
  135925. * @returns true if value was set
  135926. */
  135927. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135928. /**
  135929. * Set the value of an uniform to a matrix (3x3)
  135930. * @param uniform defines the webGL uniform location where to store the value
  135931. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135932. * @returns true if value was set
  135933. */
  135934. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135935. /**
  135936. * Set the value of an uniform to a matrix (2x2)
  135937. * @param uniform defines the webGL uniform location where to store the value
  135938. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135939. * @returns true if value was set
  135940. */
  135941. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135942. /**
  135943. * Set the value of an uniform to a number (float)
  135944. * @param uniform defines the webGL uniform location where to store the value
  135945. * @param value defines the float number to store
  135946. * @returns true if value was set
  135947. */
  135948. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135949. /**
  135950. * Set the value of an uniform to a vec2
  135951. * @param uniform defines the webGL uniform location where to store the value
  135952. * @param x defines the 1st component of the value
  135953. * @param y defines the 2nd component of the value
  135954. * @returns true if value was set
  135955. */
  135956. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135957. /**
  135958. * Set the value of an uniform to a vec3
  135959. * @param uniform defines the webGL uniform location where to store the value
  135960. * @param x defines the 1st component of the value
  135961. * @param y defines the 2nd component of the value
  135962. * @param z defines the 3rd component of the value
  135963. * @returns true if value was set
  135964. */
  135965. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135966. /**
  135967. * Set the value of an uniform to a boolean
  135968. * @param uniform defines the webGL uniform location where to store the value
  135969. * @param bool defines the boolean to store
  135970. * @returns true if value was set
  135971. */
  135972. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135973. /**
  135974. * Set the value of an uniform to a vec4
  135975. * @param uniform defines the webGL uniform location where to store the value
  135976. * @param x defines the 1st component of the value
  135977. * @param y defines the 2nd component of the value
  135978. * @param z defines the 3rd component of the value
  135979. * @param w defines the 4th component of the value
  135980. * @returns true if value was set
  135981. */
  135982. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135983. /**
  135984. * Sets the current alpha mode
  135985. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135986. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135987. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135988. */
  135989. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135990. /**
  135991. * Bind webGl buffers directly to the webGL context
  135992. * @param vertexBuffers defines the vertex buffer to bind
  135993. * @param indexBuffer defines the index buffer to bind
  135994. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135995. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135996. * @param effect defines the effect associated with the vertex buffer
  135997. */
  135998. bindBuffers(vertexBuffers: {
  135999. [key: string]: VertexBuffer;
  136000. }, indexBuffer: DataBuffer, effect: Effect): void;
  136001. /**
  136002. * Force the entire cache to be cleared
  136003. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  136004. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  136005. */
  136006. wipeCaches(bruteForce?: boolean): void;
  136007. /**
  136008. * Send a draw order
  136009. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  136010. * @param indexStart defines the starting index
  136011. * @param indexCount defines the number of index to draw
  136012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136013. */
  136014. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  136015. /**
  136016. * Draw a list of indexed primitives
  136017. * @param fillMode defines the primitive to use
  136018. * @param indexStart defines the starting index
  136019. * @param indexCount defines the number of index to draw
  136020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136021. */
  136022. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136023. /**
  136024. * Draw a list of unindexed primitives
  136025. * @param fillMode defines the primitive to use
  136026. * @param verticesStart defines the index of first vertex to draw
  136027. * @param verticesCount defines the count of vertices to draw
  136028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136029. */
  136030. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136031. /** @hidden */
  136032. _createTexture(): WebGLTexture;
  136033. /** @hidden */
  136034. _releaseTexture(texture: InternalTexture): void;
  136035. /**
  136036. * Usually called from Texture.ts.
  136037. * Passed information to create a WebGLTexture
  136038. * @param urlArg defines a value which contains one of the following:
  136039. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136040. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136041. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136042. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136043. * @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)
  136044. * @param scene needed for loading to the correct scene
  136045. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136046. * @param onLoad optional callback to be called upon successful completion
  136047. * @param onError optional callback to be called upon failure
  136048. * @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
  136049. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136050. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136051. * @param forcedExtension defines the extension to use to pick the right loader
  136052. * @param mimeType defines an optional mime type
  136053. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136054. */
  136055. 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;
  136056. /**
  136057. * Creates a new render target texture
  136058. * @param size defines the size of the texture
  136059. * @param options defines the options used to create the texture
  136060. * @returns a new render target texture stored in an InternalTexture
  136061. */
  136062. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  136063. /**
  136064. * Update the sampling mode of a given texture
  136065. * @param samplingMode defines the required sampling mode
  136066. * @param texture defines the texture to update
  136067. */
  136068. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136069. /**
  136070. * Binds the frame buffer to the specified texture.
  136071. * @param texture The texture to render to or null for the default canvas
  136072. * @param faceIndex The face of the texture to render to in case of cube texture
  136073. * @param requiredWidth The width of the target to render to
  136074. * @param requiredHeight The height of the target to render to
  136075. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136076. * @param lodLevel defines le lod level to bind to the frame buffer
  136077. */
  136078. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136079. /**
  136080. * Unbind the current render target texture from the webGL context
  136081. * @param texture defines the render target texture to unbind
  136082. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136083. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136084. */
  136085. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136086. /**
  136087. * Creates a dynamic vertex buffer
  136088. * @param vertices the data for the dynamic vertex buffer
  136089. * @returns the new WebGL dynamic buffer
  136090. */
  136091. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136092. /**
  136093. * Update the content of a dynamic texture
  136094. * @param texture defines the texture to update
  136095. * @param canvas defines the canvas containing the source
  136096. * @param invertY defines if data must be stored with Y axis inverted
  136097. * @param premulAlpha defines if alpha is stored as premultiplied
  136098. * @param format defines the format of the data
  136099. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136100. */
  136101. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136102. /**
  136103. * Gets a boolean indicating if all created effects are ready
  136104. * @returns true if all effects are ready
  136105. */
  136106. areAllEffectsReady(): boolean;
  136107. /**
  136108. * @hidden
  136109. * Get the current error code of the webGL context
  136110. * @returns the error code
  136111. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136112. */
  136113. getError(): number;
  136114. /** @hidden */
  136115. _getUnpackAlignement(): number;
  136116. /** @hidden */
  136117. _unpackFlipY(value: boolean): void;
  136118. /**
  136119. * Update a dynamic index buffer
  136120. * @param indexBuffer defines the target index buffer
  136121. * @param indices defines the data to update
  136122. * @param offset defines the offset in the target index buffer where update should start
  136123. */
  136124. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136125. /**
  136126. * Updates a dynamic vertex buffer.
  136127. * @param vertexBuffer the vertex buffer to update
  136128. * @param vertices the data used to update the vertex buffer
  136129. * @param byteOffset the byte offset of the data (optional)
  136130. * @param byteLength the byte length of the data (optional)
  136131. */
  136132. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136133. /** @hidden */
  136134. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136135. /** @hidden */
  136136. _bindTexture(channel: number, texture: InternalTexture): void;
  136137. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136138. /**
  136139. * 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
  136140. */
  136141. releaseEffects(): void;
  136142. displayLoadingUI(): void;
  136143. hideLoadingUI(): void;
  136144. /** @hidden */
  136145. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136146. /** @hidden */
  136147. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136148. /** @hidden */
  136149. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136150. /** @hidden */
  136151. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136152. }
  136153. }
  136154. declare module BABYLON {
  136155. /**
  136156. * @hidden
  136157. **/
  136158. export class _TimeToken {
  136159. _startTimeQuery: Nullable<WebGLQuery>;
  136160. _endTimeQuery: Nullable<WebGLQuery>;
  136161. _timeElapsedQuery: Nullable<WebGLQuery>;
  136162. _timeElapsedQueryEnded: boolean;
  136163. }
  136164. }
  136165. declare module BABYLON {
  136166. /** @hidden */
  136167. export class _OcclusionDataStorage {
  136168. /** @hidden */
  136169. occlusionInternalRetryCounter: number;
  136170. /** @hidden */
  136171. isOcclusionQueryInProgress: boolean;
  136172. /** @hidden */
  136173. isOccluded: boolean;
  136174. /** @hidden */
  136175. occlusionRetryCount: number;
  136176. /** @hidden */
  136177. occlusionType: number;
  136178. /** @hidden */
  136179. occlusionQueryAlgorithmType: number;
  136180. }
  136181. interface Engine {
  136182. /**
  136183. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136184. * @return the new query
  136185. */
  136186. createQuery(): WebGLQuery;
  136187. /**
  136188. * Delete and release a webGL query
  136189. * @param query defines the query to delete
  136190. * @return the current engine
  136191. */
  136192. deleteQuery(query: WebGLQuery): Engine;
  136193. /**
  136194. * Check if a given query has resolved and got its value
  136195. * @param query defines the query to check
  136196. * @returns true if the query got its value
  136197. */
  136198. isQueryResultAvailable(query: WebGLQuery): boolean;
  136199. /**
  136200. * Gets the value of a given query
  136201. * @param query defines the query to check
  136202. * @returns the value of the query
  136203. */
  136204. getQueryResult(query: WebGLQuery): number;
  136205. /**
  136206. * Initiates an occlusion query
  136207. * @param algorithmType defines the algorithm to use
  136208. * @param query defines the query to use
  136209. * @returns the current engine
  136210. * @see https://doc.babylonjs.com/features/occlusionquery
  136211. */
  136212. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136213. /**
  136214. * Ends an occlusion query
  136215. * @see https://doc.babylonjs.com/features/occlusionquery
  136216. * @param algorithmType defines the algorithm to use
  136217. * @returns the current engine
  136218. */
  136219. endOcclusionQuery(algorithmType: number): Engine;
  136220. /**
  136221. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136222. * Please note that only one query can be issued at a time
  136223. * @returns a time token used to track the time span
  136224. */
  136225. startTimeQuery(): Nullable<_TimeToken>;
  136226. /**
  136227. * Ends a time query
  136228. * @param token defines the token used to measure the time span
  136229. * @returns the time spent (in ns)
  136230. */
  136231. endTimeQuery(token: _TimeToken): int;
  136232. /** @hidden */
  136233. _currentNonTimestampToken: Nullable<_TimeToken>;
  136234. /** @hidden */
  136235. _createTimeQuery(): WebGLQuery;
  136236. /** @hidden */
  136237. _deleteTimeQuery(query: WebGLQuery): void;
  136238. /** @hidden */
  136239. _getGlAlgorithmType(algorithmType: number): number;
  136240. /** @hidden */
  136241. _getTimeQueryResult(query: WebGLQuery): any;
  136242. /** @hidden */
  136243. _getTimeQueryAvailability(query: WebGLQuery): any;
  136244. }
  136245. interface AbstractMesh {
  136246. /**
  136247. * Backing filed
  136248. * @hidden
  136249. */
  136250. __occlusionDataStorage: _OcclusionDataStorage;
  136251. /**
  136252. * Access property
  136253. * @hidden
  136254. */
  136255. _occlusionDataStorage: _OcclusionDataStorage;
  136256. /**
  136257. * 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.
  136258. * The default value is -1 which means don't break the query and wait till the result
  136259. * @see https://doc.babylonjs.com/features/occlusionquery
  136260. */
  136261. occlusionRetryCount: number;
  136262. /**
  136263. * 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:
  136264. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136265. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136266. * * 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.
  136267. * @see https://doc.babylonjs.com/features/occlusionquery
  136268. */
  136269. occlusionType: number;
  136270. /**
  136271. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136272. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136273. * * 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.
  136274. * @see https://doc.babylonjs.com/features/occlusionquery
  136275. */
  136276. occlusionQueryAlgorithmType: number;
  136277. /**
  136278. * 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
  136279. * @see https://doc.babylonjs.com/features/occlusionquery
  136280. */
  136281. isOccluded: boolean;
  136282. /**
  136283. * Flag to check the progress status of the query
  136284. * @see https://doc.babylonjs.com/features/occlusionquery
  136285. */
  136286. isOcclusionQueryInProgress: boolean;
  136287. }
  136288. }
  136289. declare module BABYLON {
  136290. /** @hidden */
  136291. export var _forceTransformFeedbackToBundle: boolean;
  136292. interface Engine {
  136293. /**
  136294. * Creates a webGL transform feedback object
  136295. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136296. * @returns the webGL transform feedback object
  136297. */
  136298. createTransformFeedback(): WebGLTransformFeedback;
  136299. /**
  136300. * Delete a webGL transform feedback object
  136301. * @param value defines the webGL transform feedback object to delete
  136302. */
  136303. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136304. /**
  136305. * Bind a webGL transform feedback object to the webgl context
  136306. * @param value defines the webGL transform feedback object to bind
  136307. */
  136308. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136309. /**
  136310. * Begins a transform feedback operation
  136311. * @param usePoints defines if points or triangles must be used
  136312. */
  136313. beginTransformFeedback(usePoints: boolean): void;
  136314. /**
  136315. * Ends a transform feedback operation
  136316. */
  136317. endTransformFeedback(): void;
  136318. /**
  136319. * Specify the varyings to use with transform feedback
  136320. * @param program defines the associated webGL program
  136321. * @param value defines the list of strings representing the varying names
  136322. */
  136323. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136324. /**
  136325. * Bind a webGL buffer for a transform feedback operation
  136326. * @param value defines the webGL buffer to bind
  136327. */
  136328. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136329. }
  136330. }
  136331. declare module BABYLON {
  136332. /**
  136333. * Class used to define an additional view for the engine
  136334. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136335. */
  136336. export class EngineView {
  136337. /** Defines the canvas where to render the view */
  136338. target: HTMLCanvasElement;
  136339. /** Defines an optional camera used to render the view (will use active camera else) */
  136340. camera?: Camera;
  136341. }
  136342. interface Engine {
  136343. /**
  136344. * Gets or sets the HTML element to use for attaching events
  136345. */
  136346. inputElement: Nullable<HTMLElement>;
  136347. /**
  136348. * Gets the current engine view
  136349. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136350. */
  136351. activeView: Nullable<EngineView>;
  136352. /** Gets or sets the list of views */
  136353. views: EngineView[];
  136354. /**
  136355. * Register a new child canvas
  136356. * @param canvas defines the canvas to register
  136357. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136358. * @returns the associated view
  136359. */
  136360. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136361. /**
  136362. * Remove a registered child canvas
  136363. * @param canvas defines the canvas to remove
  136364. * @returns the current engine
  136365. */
  136366. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136367. }
  136368. }
  136369. declare module BABYLON {
  136370. interface Engine {
  136371. /** @hidden */
  136372. _excludedCompressedTextures: string[];
  136373. /** @hidden */
  136374. _textureFormatInUse: string;
  136375. /**
  136376. * Gets the list of texture formats supported
  136377. */
  136378. readonly texturesSupported: Array<string>;
  136379. /**
  136380. * Gets the texture format in use
  136381. */
  136382. readonly textureFormatInUse: Nullable<string>;
  136383. /**
  136384. * Set the compressed texture extensions or file names to skip.
  136385. *
  136386. * @param skippedFiles defines the list of those texture files you want to skip
  136387. * Example: [".dds", ".env", "myfile.png"]
  136388. */
  136389. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136390. /**
  136391. * Set the compressed texture format to use, based on the formats you have, and the formats
  136392. * supported by the hardware / browser.
  136393. *
  136394. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136395. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136396. * to API arguments needed to compressed textures. This puts the burden on the container
  136397. * generator to house the arcane code for determining these for current & future formats.
  136398. *
  136399. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136400. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136401. *
  136402. * Note: The result of this call is not taken into account when a texture is base64.
  136403. *
  136404. * @param formatsAvailable defines the list of those format families you have created
  136405. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136406. *
  136407. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136408. * @returns The extension selected.
  136409. */
  136410. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136411. }
  136412. }
  136413. declare module BABYLON {
  136414. /** @hidden */
  136415. export var rgbdEncodePixelShader: {
  136416. name: string;
  136417. shader: string;
  136418. };
  136419. }
  136420. declare module BABYLON {
  136421. /**
  136422. * Raw texture data and descriptor sufficient for WebGL texture upload
  136423. */
  136424. export interface EnvironmentTextureInfo {
  136425. /**
  136426. * Version of the environment map
  136427. */
  136428. version: number;
  136429. /**
  136430. * Width of image
  136431. */
  136432. width: number;
  136433. /**
  136434. * Irradiance information stored in the file.
  136435. */
  136436. irradiance: any;
  136437. /**
  136438. * Specular information stored in the file.
  136439. */
  136440. specular: any;
  136441. }
  136442. /**
  136443. * Defines One Image in the file. It requires only the position in the file
  136444. * as well as the length.
  136445. */
  136446. interface BufferImageData {
  136447. /**
  136448. * Length of the image data.
  136449. */
  136450. length: number;
  136451. /**
  136452. * Position of the data from the null terminator delimiting the end of the JSON.
  136453. */
  136454. position: number;
  136455. }
  136456. /**
  136457. * Defines the specular data enclosed in the file.
  136458. * This corresponds to the version 1 of the data.
  136459. */
  136460. export interface EnvironmentTextureSpecularInfoV1 {
  136461. /**
  136462. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136463. */
  136464. specularDataPosition?: number;
  136465. /**
  136466. * This contains all the images data needed to reconstruct the cubemap.
  136467. */
  136468. mipmaps: Array<BufferImageData>;
  136469. /**
  136470. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136471. */
  136472. lodGenerationScale: number;
  136473. }
  136474. /**
  136475. * Sets of helpers addressing the serialization and deserialization of environment texture
  136476. * stored in a BabylonJS env file.
  136477. * Those files are usually stored as .env files.
  136478. */
  136479. export class EnvironmentTextureTools {
  136480. /**
  136481. * Magic number identifying the env file.
  136482. */
  136483. private static _MagicBytes;
  136484. /**
  136485. * Gets the environment info from an env file.
  136486. * @param data The array buffer containing the .env bytes.
  136487. * @returns the environment file info (the json header) if successfully parsed.
  136488. */
  136489. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136490. /**
  136491. * Creates an environment texture from a loaded cube texture.
  136492. * @param texture defines the cube texture to convert in env file
  136493. * @return a promise containing the environment data if succesfull.
  136494. */
  136495. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136496. /**
  136497. * Creates a JSON representation of the spherical data.
  136498. * @param texture defines the texture containing the polynomials
  136499. * @return the JSON representation of the spherical info
  136500. */
  136501. private static _CreateEnvTextureIrradiance;
  136502. /**
  136503. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136504. * @param data the image data
  136505. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136506. * @return the views described by info providing access to the underlying buffer
  136507. */
  136508. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136509. /**
  136510. * Uploads the texture info contained in the env file to the GPU.
  136511. * @param texture defines the internal texture to upload to
  136512. * @param data defines the data to load
  136513. * @param info defines the texture info retrieved through the GetEnvInfo method
  136514. * @returns a promise
  136515. */
  136516. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136517. private static _OnImageReadyAsync;
  136518. /**
  136519. * Uploads the levels of image data to the GPU.
  136520. * @param texture defines the internal texture to upload to
  136521. * @param imageData defines the array buffer views of image data [mipmap][face]
  136522. * @returns a promise
  136523. */
  136524. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136525. /**
  136526. * Uploads spherical polynomials information to the texture.
  136527. * @param texture defines the texture we are trying to upload the information to
  136528. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136529. */
  136530. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136531. /** @hidden */
  136532. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136533. }
  136534. }
  136535. declare module BABYLON {
  136536. /**
  136537. * Class used to inline functions in shader code
  136538. */
  136539. export class ShaderCodeInliner {
  136540. private static readonly _RegexpFindFunctionNameAndType;
  136541. private _sourceCode;
  136542. private _functionDescr;
  136543. private _numMaxIterations;
  136544. /** Gets or sets the token used to mark the functions to inline */
  136545. inlineToken: string;
  136546. /** Gets or sets the debug mode */
  136547. debug: boolean;
  136548. /** Gets the code after the inlining process */
  136549. get code(): string;
  136550. /**
  136551. * Initializes the inliner
  136552. * @param sourceCode shader code source to inline
  136553. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136554. */
  136555. constructor(sourceCode: string, numMaxIterations?: number);
  136556. /**
  136557. * Start the processing of the shader code
  136558. */
  136559. processCode(): void;
  136560. private _collectFunctions;
  136561. private _processInlining;
  136562. private _extractBetweenMarkers;
  136563. private _skipWhitespaces;
  136564. private _removeComments;
  136565. private _replaceFunctionCallsByCode;
  136566. private _findBackward;
  136567. private _escapeRegExp;
  136568. private _replaceNames;
  136569. }
  136570. }
  136571. declare module BABYLON {
  136572. /**
  136573. * Container for accessors for natively-stored mesh data buffers.
  136574. */
  136575. class NativeDataBuffer extends DataBuffer {
  136576. /**
  136577. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136578. */
  136579. nativeIndexBuffer?: any;
  136580. /**
  136581. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136582. */
  136583. nativeVertexBuffer?: any;
  136584. }
  136585. /** @hidden */
  136586. class NativeTexture extends InternalTexture {
  136587. getInternalTexture(): InternalTexture;
  136588. getViewCount(): number;
  136589. }
  136590. /** @hidden */
  136591. export class NativeEngine extends Engine {
  136592. private readonly _native;
  136593. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136594. private readonly INVALID_HANDLE;
  136595. private _boundBuffersVertexArray;
  136596. private _currentDepthTest;
  136597. getHardwareScalingLevel(): number;
  136598. constructor();
  136599. dispose(): void;
  136600. /**
  136601. * Can be used to override the current requestAnimationFrame requester.
  136602. * @hidden
  136603. */
  136604. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136605. /**
  136606. * Override default engine behavior.
  136607. * @param color
  136608. * @param backBuffer
  136609. * @param depth
  136610. * @param stencil
  136611. */
  136612. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136613. /**
  136614. * Gets host document
  136615. * @returns the host document object
  136616. */
  136617. getHostDocument(): Nullable<Document>;
  136618. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136619. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136620. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136621. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136622. [key: string]: VertexBuffer;
  136623. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136624. bindBuffers(vertexBuffers: {
  136625. [key: string]: VertexBuffer;
  136626. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136627. recordVertexArrayObject(vertexBuffers: {
  136628. [key: string]: VertexBuffer;
  136629. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136630. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136631. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136632. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136633. /**
  136634. * Draw a list of indexed primitives
  136635. * @param fillMode defines the primitive to use
  136636. * @param indexStart defines the starting index
  136637. * @param indexCount defines the number of index to draw
  136638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136639. */
  136640. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136641. /**
  136642. * Draw a list of unindexed primitives
  136643. * @param fillMode defines the primitive to use
  136644. * @param verticesStart defines the index of first vertex to draw
  136645. * @param verticesCount defines the count of vertices to draw
  136646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136647. */
  136648. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136649. createPipelineContext(): IPipelineContext;
  136650. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136651. /** @hidden */
  136652. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136653. /** @hidden */
  136654. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136655. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136656. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136657. protected _setProgram(program: WebGLProgram): void;
  136658. _releaseEffect(effect: Effect): void;
  136659. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136660. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136661. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136662. bindSamplers(effect: Effect): void;
  136663. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136664. getRenderWidth(useScreen?: boolean): number;
  136665. getRenderHeight(useScreen?: boolean): number;
  136666. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136667. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136668. /**
  136669. * Set the z offset to apply to current rendering
  136670. * @param value defines the offset to apply
  136671. */
  136672. setZOffset(value: number): void;
  136673. /**
  136674. * Gets the current value of the zOffset
  136675. * @returns the current zOffset state
  136676. */
  136677. getZOffset(): number;
  136678. /**
  136679. * Enable or disable depth buffering
  136680. * @param enable defines the state to set
  136681. */
  136682. setDepthBuffer(enable: boolean): void;
  136683. /**
  136684. * Gets a boolean indicating if depth writing is enabled
  136685. * @returns the current depth writing state
  136686. */
  136687. getDepthWrite(): boolean;
  136688. setDepthFunctionToGreater(): void;
  136689. setDepthFunctionToGreaterOrEqual(): void;
  136690. setDepthFunctionToLess(): void;
  136691. setDepthFunctionToLessOrEqual(): void;
  136692. /**
  136693. * Enable or disable depth writing
  136694. * @param enable defines the state to set
  136695. */
  136696. setDepthWrite(enable: boolean): void;
  136697. /**
  136698. * Enable or disable color writing
  136699. * @param enable defines the state to set
  136700. */
  136701. setColorWrite(enable: boolean): void;
  136702. /**
  136703. * Gets a boolean indicating if color writing is enabled
  136704. * @returns the current color writing state
  136705. */
  136706. getColorWrite(): boolean;
  136707. /**
  136708. * Sets alpha constants used by some alpha blending modes
  136709. * @param r defines the red component
  136710. * @param g defines the green component
  136711. * @param b defines the blue component
  136712. * @param a defines the alpha component
  136713. */
  136714. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136715. /**
  136716. * Sets the current alpha mode
  136717. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136718. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136719. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136720. */
  136721. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136722. /**
  136723. * Gets the current alpha mode
  136724. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136725. * @returns the current alpha mode
  136726. */
  136727. getAlphaMode(): number;
  136728. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136729. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136730. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136731. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136732. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136733. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136734. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136735. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136736. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136737. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136738. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136739. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136740. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136741. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136742. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136743. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136744. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136745. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136746. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136747. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136748. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136749. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136750. wipeCaches(bruteForce?: boolean): void;
  136751. _createTexture(): WebGLTexture;
  136752. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136753. /**
  136754. * Update the content of a dynamic texture
  136755. * @param texture defines the texture to update
  136756. * @param canvas defines the canvas containing the source
  136757. * @param invertY defines if data must be stored with Y axis inverted
  136758. * @param premulAlpha defines if alpha is stored as premultiplied
  136759. * @param format defines the format of the data
  136760. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136761. */
  136762. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136763. /**
  136764. * Usually called from Texture.ts.
  136765. * Passed information to create a WebGLTexture
  136766. * @param url defines a value which contains one of the following:
  136767. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136768. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136769. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136770. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136771. * @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)
  136772. * @param scene needed for loading to the correct scene
  136773. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136774. * @param onLoad optional callback to be called upon successful completion
  136775. * @param onError optional callback to be called upon failure
  136776. * @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
  136777. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136778. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136779. * @param forcedExtension defines the extension to use to pick the right loader
  136780. * @param mimeType defines an optional mime type
  136781. * @param loaderOptions options to be passed to the loader
  136782. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136783. */
  136784. 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, loaderOptions?: any): InternalTexture;
  136785. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136786. _releaseFramebufferObjects(texture: InternalTexture): void;
  136787. /**
  136788. * Creates a cube texture
  136789. * @param rootUrl defines the url where the files to load is located
  136790. * @param scene defines the current scene
  136791. * @param files defines the list of files to load (1 per face)
  136792. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136793. * @param onLoad defines an optional callback raised when the texture is loaded
  136794. * @param onError defines an optional callback raised if there is an issue to load the texture
  136795. * @param format defines the format of the data
  136796. * @param forcedExtension defines the extension to use to pick the right loader
  136797. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136798. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136799. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136800. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136801. * @returns the cube texture as an InternalTexture
  136802. */
  136803. 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;
  136804. createRenderTargetTexture(size: number | {
  136805. width: number;
  136806. height: number;
  136807. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136808. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136809. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136810. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136811. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136812. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136813. /**
  136814. * Updates a dynamic vertex buffer.
  136815. * @param vertexBuffer the vertex buffer to update
  136816. * @param data the data used to update the vertex buffer
  136817. * @param byteOffset the byte offset of the data (optional)
  136818. * @param byteLength the byte length of the data (optional)
  136819. */
  136820. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136821. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136822. private _updateAnisotropicLevel;
  136823. private _getAddressMode;
  136824. /** @hidden */
  136825. _bindTexture(channel: number, texture: InternalTexture): void;
  136826. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136827. releaseEffects(): void;
  136828. /** @hidden */
  136829. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136830. /** @hidden */
  136831. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136832. /** @hidden */
  136833. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136834. /** @hidden */
  136835. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136836. private _getNativeSamplingMode;
  136837. private _getNativeTextureFormat;
  136838. private _getNativeAlphaMode;
  136839. private _getNativeAttribType;
  136840. }
  136841. }
  136842. declare module BABYLON {
  136843. /**
  136844. * Gather the list of clipboard event types as constants.
  136845. */
  136846. export class ClipboardEventTypes {
  136847. /**
  136848. * The clipboard event is fired when a copy command is active (pressed).
  136849. */
  136850. static readonly COPY: number;
  136851. /**
  136852. * The clipboard event is fired when a cut command is active (pressed).
  136853. */
  136854. static readonly CUT: number;
  136855. /**
  136856. * The clipboard event is fired when a paste command is active (pressed).
  136857. */
  136858. static readonly PASTE: number;
  136859. }
  136860. /**
  136861. * This class is used to store clipboard related info for the onClipboardObservable event.
  136862. */
  136863. export class ClipboardInfo {
  136864. /**
  136865. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136866. */
  136867. type: number;
  136868. /**
  136869. * Defines the related dom event
  136870. */
  136871. event: ClipboardEvent;
  136872. /**
  136873. *Creates an instance of ClipboardInfo.
  136874. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136875. * @param event Defines the related dom event
  136876. */
  136877. constructor(
  136878. /**
  136879. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136880. */
  136881. type: number,
  136882. /**
  136883. * Defines the related dom event
  136884. */
  136885. event: ClipboardEvent);
  136886. /**
  136887. * Get the clipboard event's type from the keycode.
  136888. * @param keyCode Defines the keyCode for the current keyboard event.
  136889. * @return {number}
  136890. */
  136891. static GetTypeFromCharacter(keyCode: number): number;
  136892. }
  136893. }
  136894. declare module BABYLON {
  136895. /**
  136896. * Google Daydream controller
  136897. */
  136898. export class DaydreamController extends WebVRController {
  136899. /**
  136900. * Base Url for the controller model.
  136901. */
  136902. static MODEL_BASE_URL: string;
  136903. /**
  136904. * File name for the controller model.
  136905. */
  136906. static MODEL_FILENAME: string;
  136907. /**
  136908. * Gamepad Id prefix used to identify Daydream Controller.
  136909. */
  136910. static readonly GAMEPAD_ID_PREFIX: string;
  136911. /**
  136912. * Creates a new DaydreamController from a gamepad
  136913. * @param vrGamepad the gamepad that the controller should be created from
  136914. */
  136915. constructor(vrGamepad: any);
  136916. /**
  136917. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136918. * @param scene scene in which to add meshes
  136919. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136920. */
  136921. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136922. /**
  136923. * Called once for each button that changed state since the last frame
  136924. * @param buttonIdx Which button index changed
  136925. * @param state New state of the button
  136926. * @param changes Which properties on the state changed since last frame
  136927. */
  136928. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136929. }
  136930. }
  136931. declare module BABYLON {
  136932. /**
  136933. * Gear VR Controller
  136934. */
  136935. export class GearVRController extends WebVRController {
  136936. /**
  136937. * Base Url for the controller model.
  136938. */
  136939. static MODEL_BASE_URL: string;
  136940. /**
  136941. * File name for the controller model.
  136942. */
  136943. static MODEL_FILENAME: string;
  136944. /**
  136945. * Gamepad Id prefix used to identify this controller.
  136946. */
  136947. static readonly GAMEPAD_ID_PREFIX: string;
  136948. private readonly _buttonIndexToObservableNameMap;
  136949. /**
  136950. * Creates a new GearVRController from a gamepad
  136951. * @param vrGamepad the gamepad that the controller should be created from
  136952. */
  136953. constructor(vrGamepad: any);
  136954. /**
  136955. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136956. * @param scene scene in which to add meshes
  136957. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136958. */
  136959. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136960. /**
  136961. * Called once for each button that changed state since the last frame
  136962. * @param buttonIdx Which button index changed
  136963. * @param state New state of the button
  136964. * @param changes Which properties on the state changed since last frame
  136965. */
  136966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136967. }
  136968. }
  136969. declare module BABYLON {
  136970. /**
  136971. * Generic Controller
  136972. */
  136973. export class GenericController extends WebVRController {
  136974. /**
  136975. * Base Url for the controller model.
  136976. */
  136977. static readonly MODEL_BASE_URL: string;
  136978. /**
  136979. * File name for the controller model.
  136980. */
  136981. static readonly MODEL_FILENAME: string;
  136982. /**
  136983. * Creates a new GenericController from a gamepad
  136984. * @param vrGamepad the gamepad that the controller should be created from
  136985. */
  136986. constructor(vrGamepad: any);
  136987. /**
  136988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136989. * @param scene scene in which to add meshes
  136990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136991. */
  136992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136993. /**
  136994. * Called once for each button that changed state since the last frame
  136995. * @param buttonIdx Which button index changed
  136996. * @param state New state of the button
  136997. * @param changes Which properties on the state changed since last frame
  136998. */
  136999. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137000. }
  137001. }
  137002. declare module BABYLON {
  137003. /**
  137004. * Oculus Touch Controller
  137005. */
  137006. export class OculusTouchController extends WebVRController {
  137007. /**
  137008. * Base Url for the controller model.
  137009. */
  137010. static MODEL_BASE_URL: string;
  137011. /**
  137012. * File name for the left controller model.
  137013. */
  137014. static MODEL_LEFT_FILENAME: string;
  137015. /**
  137016. * File name for the right controller model.
  137017. */
  137018. static MODEL_RIGHT_FILENAME: string;
  137019. /**
  137020. * Base Url for the Quest controller model.
  137021. */
  137022. static QUEST_MODEL_BASE_URL: string;
  137023. /**
  137024. * @hidden
  137025. * If the controllers are running on a device that needs the updated Quest controller models
  137026. */
  137027. static _IsQuest: boolean;
  137028. /**
  137029. * Fired when the secondary trigger on this controller is modified
  137030. */
  137031. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  137032. /**
  137033. * Fired when the thumb rest on this controller is modified
  137034. */
  137035. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  137036. /**
  137037. * Creates a new OculusTouchController from a gamepad
  137038. * @param vrGamepad the gamepad that the controller should be created from
  137039. */
  137040. constructor(vrGamepad: any);
  137041. /**
  137042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137043. * @param scene scene in which to add meshes
  137044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137045. */
  137046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137047. /**
  137048. * Fired when the A button on this controller is modified
  137049. */
  137050. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137051. /**
  137052. * Fired when the B button on this controller is modified
  137053. */
  137054. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137055. /**
  137056. * Fired when the X button on this controller is modified
  137057. */
  137058. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137059. /**
  137060. * Fired when the Y button on this controller is modified
  137061. */
  137062. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137063. /**
  137064. * Called once for each button that changed state since the last frame
  137065. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  137066. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  137067. * 2) secondary trigger (same)
  137068. * 3) A (right) X (left), touch, pressed = value
  137069. * 4) B / Y
  137070. * 5) thumb rest
  137071. * @param buttonIdx Which button index changed
  137072. * @param state New state of the button
  137073. * @param changes Which properties on the state changed since last frame
  137074. */
  137075. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137076. }
  137077. }
  137078. declare module BABYLON {
  137079. /**
  137080. * Vive Controller
  137081. */
  137082. export class ViveController extends WebVRController {
  137083. /**
  137084. * Base Url for the controller model.
  137085. */
  137086. static MODEL_BASE_URL: string;
  137087. /**
  137088. * File name for the controller model.
  137089. */
  137090. static MODEL_FILENAME: string;
  137091. /**
  137092. * Creates a new ViveController from a gamepad
  137093. * @param vrGamepad the gamepad that the controller should be created from
  137094. */
  137095. constructor(vrGamepad: any);
  137096. /**
  137097. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137098. * @param scene scene in which to add meshes
  137099. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137100. */
  137101. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137102. /**
  137103. * Fired when the left button on this controller is modified
  137104. */
  137105. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137106. /**
  137107. * Fired when the right button on this controller is modified
  137108. */
  137109. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137110. /**
  137111. * Fired when the menu button on this controller is modified
  137112. */
  137113. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137114. /**
  137115. * Called once for each button that changed state since the last frame
  137116. * Vive mapping:
  137117. * 0: touchpad
  137118. * 1: trigger
  137119. * 2: left AND right buttons
  137120. * 3: menu button
  137121. * @param buttonIdx Which button index changed
  137122. * @param state New state of the button
  137123. * @param changes Which properties on the state changed since last frame
  137124. */
  137125. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137126. }
  137127. }
  137128. declare module BABYLON {
  137129. /**
  137130. * Defines the WindowsMotionController object that the state of the windows motion controller
  137131. */
  137132. export class WindowsMotionController extends WebVRController {
  137133. /**
  137134. * The base url used to load the left and right controller models
  137135. */
  137136. static MODEL_BASE_URL: string;
  137137. /**
  137138. * The name of the left controller model file
  137139. */
  137140. static MODEL_LEFT_FILENAME: string;
  137141. /**
  137142. * The name of the right controller model file
  137143. */
  137144. static MODEL_RIGHT_FILENAME: string;
  137145. /**
  137146. * The controller name prefix for this controller type
  137147. */
  137148. static readonly GAMEPAD_ID_PREFIX: string;
  137149. /**
  137150. * The controller id pattern for this controller type
  137151. */
  137152. private static readonly GAMEPAD_ID_PATTERN;
  137153. private _loadedMeshInfo;
  137154. protected readonly _mapping: {
  137155. buttons: string[];
  137156. buttonMeshNames: {
  137157. trigger: string;
  137158. menu: string;
  137159. grip: string;
  137160. thumbstick: string;
  137161. trackpad: string;
  137162. };
  137163. buttonObservableNames: {
  137164. trigger: string;
  137165. menu: string;
  137166. grip: string;
  137167. thumbstick: string;
  137168. trackpad: string;
  137169. };
  137170. axisMeshNames: string[];
  137171. pointingPoseMeshName: string;
  137172. };
  137173. /**
  137174. * Fired when the trackpad on this controller is clicked
  137175. */
  137176. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137177. /**
  137178. * Fired when the trackpad on this controller is modified
  137179. */
  137180. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137181. /**
  137182. * The current x and y values of this controller's trackpad
  137183. */
  137184. trackpad: StickValues;
  137185. /**
  137186. * Creates a new WindowsMotionController from a gamepad
  137187. * @param vrGamepad the gamepad that the controller should be created from
  137188. */
  137189. constructor(vrGamepad: any);
  137190. /**
  137191. * Fired when the trigger on this controller is modified
  137192. */
  137193. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137194. /**
  137195. * Fired when the menu button on this controller is modified
  137196. */
  137197. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137198. /**
  137199. * Fired when the grip button on this controller is modified
  137200. */
  137201. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137202. /**
  137203. * Fired when the thumbstick button on this controller is modified
  137204. */
  137205. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137206. /**
  137207. * Fired when the touchpad button on this controller is modified
  137208. */
  137209. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137210. /**
  137211. * Fired when the touchpad values on this controller are modified
  137212. */
  137213. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137214. protected _updateTrackpad(): void;
  137215. /**
  137216. * Called once per frame by the engine.
  137217. */
  137218. update(): void;
  137219. /**
  137220. * Called once for each button that changed state since the last frame
  137221. * @param buttonIdx Which button index changed
  137222. * @param state New state of the button
  137223. * @param changes Which properties on the state changed since last frame
  137224. */
  137225. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137226. /**
  137227. * Moves the buttons on the controller mesh based on their current state
  137228. * @param buttonName the name of the button to move
  137229. * @param buttonValue the value of the button which determines the buttons new position
  137230. */
  137231. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137232. /**
  137233. * Moves the axis on the controller mesh based on its current state
  137234. * @param axis the index of the axis
  137235. * @param axisValue the value of the axis which determines the meshes new position
  137236. * @hidden
  137237. */
  137238. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137239. /**
  137240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137241. * @param scene scene in which to add meshes
  137242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137243. */
  137244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137245. /**
  137246. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137247. * can be transformed by button presses and axes values, based on this._mapping.
  137248. *
  137249. * @param scene scene in which the meshes exist
  137250. * @param meshes list of meshes that make up the controller model to process
  137251. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137252. */
  137253. private processModel;
  137254. private createMeshInfo;
  137255. /**
  137256. * Gets the ray of the controller in the direction the controller is pointing
  137257. * @param length the length the resulting ray should be
  137258. * @returns a ray in the direction the controller is pointing
  137259. */
  137260. getForwardRay(length?: number): Ray;
  137261. /**
  137262. * Disposes of the controller
  137263. */
  137264. dispose(): void;
  137265. }
  137266. /**
  137267. * This class represents a new windows motion controller in XR.
  137268. */
  137269. export class XRWindowsMotionController extends WindowsMotionController {
  137270. /**
  137271. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137272. */
  137273. protected readonly _mapping: {
  137274. buttons: string[];
  137275. buttonMeshNames: {
  137276. trigger: string;
  137277. menu: string;
  137278. grip: string;
  137279. thumbstick: string;
  137280. trackpad: string;
  137281. };
  137282. buttonObservableNames: {
  137283. trigger: string;
  137284. menu: string;
  137285. grip: string;
  137286. thumbstick: string;
  137287. trackpad: string;
  137288. };
  137289. axisMeshNames: string[];
  137290. pointingPoseMeshName: string;
  137291. };
  137292. /**
  137293. * Construct a new XR-Based windows motion controller
  137294. *
  137295. * @param gamepadInfo the gamepad object from the browser
  137296. */
  137297. constructor(gamepadInfo: any);
  137298. /**
  137299. * holds the thumbstick values (X,Y)
  137300. */
  137301. thumbstickValues: StickValues;
  137302. /**
  137303. * Fired when the thumbstick on this controller is clicked
  137304. */
  137305. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137306. /**
  137307. * Fired when the thumbstick on this controller is modified
  137308. */
  137309. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137310. /**
  137311. * Fired when the touchpad button on this controller is modified
  137312. */
  137313. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137314. /**
  137315. * Fired when the touchpad values on this controller are modified
  137316. */
  137317. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137318. /**
  137319. * Fired when the thumbstick button on this controller is modified
  137320. * here to prevent breaking changes
  137321. */
  137322. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137323. /**
  137324. * updating the thumbstick(!) and not the trackpad.
  137325. * This is named this way due to the difference between WebVR and XR and to avoid
  137326. * changing the parent class.
  137327. */
  137328. protected _updateTrackpad(): void;
  137329. /**
  137330. * Disposes the class with joy
  137331. */
  137332. dispose(): void;
  137333. }
  137334. }
  137335. declare module BABYLON {
  137336. /**
  137337. * Class containing static functions to help procedurally build meshes
  137338. */
  137339. export class PolyhedronBuilder {
  137340. /**
  137341. * Creates a polyhedron mesh
  137342. * * 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
  137343. * * The parameter `size` (positive float, default 1) sets the polygon size
  137344. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137345. * * 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`
  137346. * * 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
  137347. * * 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)`)
  137348. * * 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
  137349. * * 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
  137350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137353. * @param name defines the name of the mesh
  137354. * @param options defines the options used to create the mesh
  137355. * @param scene defines the hosting scene
  137356. * @returns the polyhedron mesh
  137357. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137358. */
  137359. static CreatePolyhedron(name: string, options: {
  137360. type?: number;
  137361. size?: number;
  137362. sizeX?: number;
  137363. sizeY?: number;
  137364. sizeZ?: number;
  137365. custom?: any;
  137366. faceUV?: Vector4[];
  137367. faceColors?: Color4[];
  137368. flat?: boolean;
  137369. updatable?: boolean;
  137370. sideOrientation?: number;
  137371. frontUVs?: Vector4;
  137372. backUVs?: Vector4;
  137373. }, scene?: Nullable<Scene>): Mesh;
  137374. }
  137375. }
  137376. declare module BABYLON {
  137377. /**
  137378. * Gizmo that enables scaling a mesh along 3 axis
  137379. */
  137380. export class ScaleGizmo extends Gizmo {
  137381. /**
  137382. * Internal gizmo used for interactions on the x axis
  137383. */
  137384. xGizmo: AxisScaleGizmo;
  137385. /**
  137386. * Internal gizmo used for interactions on the y axis
  137387. */
  137388. yGizmo: AxisScaleGizmo;
  137389. /**
  137390. * Internal gizmo used for interactions on the z axis
  137391. */
  137392. zGizmo: AxisScaleGizmo;
  137393. /**
  137394. * Internal gizmo used to scale all axis equally
  137395. */
  137396. uniformScaleGizmo: AxisScaleGizmo;
  137397. private _meshAttached;
  137398. private _nodeAttached;
  137399. private _snapDistance;
  137400. private _uniformScalingMesh;
  137401. private _octahedron;
  137402. private _sensitivity;
  137403. /** Fires an event when any of it's sub gizmos are dragged */
  137404. onDragStartObservable: Observable<unknown>;
  137405. /** Fires an event when any of it's sub gizmos are released from dragging */
  137406. onDragEndObservable: Observable<unknown>;
  137407. get attachedMesh(): Nullable<AbstractMesh>;
  137408. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137409. get attachedNode(): Nullable<Node>;
  137410. set attachedNode(node: Nullable<Node>);
  137411. /**
  137412. * True when the mouse pointer is hovering a gizmo mesh
  137413. */
  137414. get isHovered(): boolean;
  137415. /**
  137416. * Creates a ScaleGizmo
  137417. * @param gizmoLayer The utility layer the gizmo will be added to
  137418. * @param thickness display gizmo axis thickness
  137419. */
  137420. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137421. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137422. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137423. /**
  137424. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137425. */
  137426. set snapDistance(value: number);
  137427. get snapDistance(): number;
  137428. /**
  137429. * Ratio for the scale of the gizmo (Default: 1)
  137430. */
  137431. set scaleRatio(value: number);
  137432. get scaleRatio(): number;
  137433. /**
  137434. * Sensitivity factor for dragging (Default: 1)
  137435. */
  137436. set sensitivity(value: number);
  137437. get sensitivity(): number;
  137438. /**
  137439. * Disposes of the gizmo
  137440. */
  137441. dispose(): void;
  137442. }
  137443. }
  137444. declare module BABYLON {
  137445. /**
  137446. * Single axis scale gizmo
  137447. */
  137448. export class AxisScaleGizmo extends Gizmo {
  137449. /**
  137450. * Drag behavior responsible for the gizmos dragging interactions
  137451. */
  137452. dragBehavior: PointerDragBehavior;
  137453. private _pointerObserver;
  137454. /**
  137455. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137456. */
  137457. snapDistance: number;
  137458. /**
  137459. * Event that fires each time the gizmo snaps to a new location.
  137460. * * snapDistance is the the change in distance
  137461. */
  137462. onSnapObservable: Observable<{
  137463. snapDistance: number;
  137464. }>;
  137465. /**
  137466. * If the scaling operation should be done on all axis (default: false)
  137467. */
  137468. uniformScaling: boolean;
  137469. /**
  137470. * Custom sensitivity value for the drag strength
  137471. */
  137472. sensitivity: number;
  137473. private _isEnabled;
  137474. private _parent;
  137475. private _arrow;
  137476. private _coloredMaterial;
  137477. private _hoverMaterial;
  137478. /**
  137479. * Creates an AxisScaleGizmo
  137480. * @param gizmoLayer The utility layer the gizmo will be added to
  137481. * @param dragAxis The axis which the gizmo will be able to scale on
  137482. * @param color The color of the gizmo
  137483. * @param thickness display gizmo axis thickness
  137484. */
  137485. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137486. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137487. /**
  137488. * If the gizmo is enabled
  137489. */
  137490. set isEnabled(value: boolean);
  137491. get isEnabled(): boolean;
  137492. /**
  137493. * Disposes of the gizmo
  137494. */
  137495. dispose(): void;
  137496. /**
  137497. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137498. * @param mesh The mesh to replace the default mesh of the gizmo
  137499. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137500. */
  137501. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137502. }
  137503. }
  137504. declare module BABYLON {
  137505. /**
  137506. * Bounding box gizmo
  137507. */
  137508. export class BoundingBoxGizmo extends Gizmo {
  137509. private _lineBoundingBox;
  137510. private _rotateSpheresParent;
  137511. private _scaleBoxesParent;
  137512. private _boundingDimensions;
  137513. private _renderObserver;
  137514. private _pointerObserver;
  137515. private _scaleDragSpeed;
  137516. private _tmpQuaternion;
  137517. private _tmpVector;
  137518. private _tmpRotationMatrix;
  137519. /**
  137520. * 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)
  137521. */
  137522. ignoreChildren: boolean;
  137523. /**
  137524. * 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)
  137525. */
  137526. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137527. /**
  137528. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137529. */
  137530. rotationSphereSize: number;
  137531. /**
  137532. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137533. */
  137534. scaleBoxSize: number;
  137535. /**
  137536. * 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)
  137537. */
  137538. fixedDragMeshScreenSize: boolean;
  137539. /**
  137540. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137541. */
  137542. fixedDragMeshScreenSizeDistanceFactor: number;
  137543. /**
  137544. * Fired when a rotation sphere or scale box is dragged
  137545. */
  137546. onDragStartObservable: Observable<{}>;
  137547. /**
  137548. * Fired when a scale box is dragged
  137549. */
  137550. onScaleBoxDragObservable: Observable<{}>;
  137551. /**
  137552. * Fired when a scale box drag is ended
  137553. */
  137554. onScaleBoxDragEndObservable: Observable<{}>;
  137555. /**
  137556. * Fired when a rotation sphere is dragged
  137557. */
  137558. onRotationSphereDragObservable: Observable<{}>;
  137559. /**
  137560. * Fired when a rotation sphere drag is ended
  137561. */
  137562. onRotationSphereDragEndObservable: Observable<{}>;
  137563. /**
  137564. * 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)
  137565. */
  137566. scalePivot: Nullable<Vector3>;
  137567. /**
  137568. * Mesh used as a pivot to rotate the attached node
  137569. */
  137570. private _anchorMesh;
  137571. private _existingMeshScale;
  137572. private _dragMesh;
  137573. private pointerDragBehavior;
  137574. private coloredMaterial;
  137575. private hoverColoredMaterial;
  137576. /**
  137577. * Sets the color of the bounding box gizmo
  137578. * @param color the color to set
  137579. */
  137580. setColor(color: Color3): void;
  137581. /**
  137582. * Creates an BoundingBoxGizmo
  137583. * @param gizmoLayer The utility layer the gizmo will be added to
  137584. * @param color The color of the gizmo
  137585. */
  137586. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137587. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137588. private _selectNode;
  137589. /**
  137590. * Updates the bounding box information for the Gizmo
  137591. */
  137592. updateBoundingBox(): void;
  137593. private _updateRotationSpheres;
  137594. private _updateScaleBoxes;
  137595. /**
  137596. * Enables rotation on the specified axis and disables rotation on the others
  137597. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137598. */
  137599. setEnabledRotationAxis(axis: string): void;
  137600. /**
  137601. * Enables/disables scaling
  137602. * @param enable if scaling should be enabled
  137603. * @param homogeneousScaling defines if scaling should only be homogeneous
  137604. */
  137605. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137606. private _updateDummy;
  137607. /**
  137608. * Enables a pointer drag behavior on the bounding box of the gizmo
  137609. */
  137610. enableDragBehavior(): void;
  137611. /**
  137612. * Disposes of the gizmo
  137613. */
  137614. dispose(): void;
  137615. /**
  137616. * 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)
  137617. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137618. * @returns the bounding box mesh with the passed in mesh as a child
  137619. */
  137620. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137621. /**
  137622. * CustomMeshes are not supported by this gizmo
  137623. * @param mesh The mesh to replace the default mesh of the gizmo
  137624. */
  137625. setCustomMesh(mesh: Mesh): void;
  137626. }
  137627. }
  137628. declare module BABYLON {
  137629. /**
  137630. * Single plane rotation gizmo
  137631. */
  137632. export class PlaneRotationGizmo extends Gizmo {
  137633. /**
  137634. * Drag behavior responsible for the gizmos dragging interactions
  137635. */
  137636. dragBehavior: PointerDragBehavior;
  137637. private _pointerObserver;
  137638. /**
  137639. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137640. */
  137641. snapDistance: number;
  137642. /**
  137643. * Event that fires each time the gizmo snaps to a new location.
  137644. * * snapDistance is the the change in distance
  137645. */
  137646. onSnapObservable: Observable<{
  137647. snapDistance: number;
  137648. }>;
  137649. private _isEnabled;
  137650. private _parent;
  137651. /**
  137652. * Creates a PlaneRotationGizmo
  137653. * @param gizmoLayer The utility layer the gizmo will be added to
  137654. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137655. * @param color The color of the gizmo
  137656. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137657. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137658. * @param thickness display gizmo axis thickness
  137659. */
  137660. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137661. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137662. /**
  137663. * If the gizmo is enabled
  137664. */
  137665. set isEnabled(value: boolean);
  137666. get isEnabled(): boolean;
  137667. /**
  137668. * Disposes of the gizmo
  137669. */
  137670. dispose(): void;
  137671. }
  137672. }
  137673. declare module BABYLON {
  137674. /**
  137675. * Gizmo that enables rotating a mesh along 3 axis
  137676. */
  137677. export class RotationGizmo extends Gizmo {
  137678. /**
  137679. * Internal gizmo used for interactions on the x axis
  137680. */
  137681. xGizmo: PlaneRotationGizmo;
  137682. /**
  137683. * Internal gizmo used for interactions on the y axis
  137684. */
  137685. yGizmo: PlaneRotationGizmo;
  137686. /**
  137687. * Internal gizmo used for interactions on the z axis
  137688. */
  137689. zGizmo: PlaneRotationGizmo;
  137690. /** Fires an event when any of it's sub gizmos are dragged */
  137691. onDragStartObservable: Observable<unknown>;
  137692. /** Fires an event when any of it's sub gizmos are released from dragging */
  137693. onDragEndObservable: Observable<unknown>;
  137694. private _meshAttached;
  137695. private _nodeAttached;
  137696. get attachedMesh(): Nullable<AbstractMesh>;
  137697. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137698. get attachedNode(): Nullable<Node>;
  137699. set attachedNode(node: Nullable<Node>);
  137700. protected _checkBillboardTransform(): void;
  137701. /**
  137702. * True when the mouse pointer is hovering a gizmo mesh
  137703. */
  137704. get isHovered(): boolean;
  137705. /**
  137706. * Creates a RotationGizmo
  137707. * @param gizmoLayer The utility layer the gizmo will be added to
  137708. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137709. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137710. * @param thickness display gizmo axis thickness
  137711. */
  137712. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137713. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137714. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137715. /**
  137716. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137717. */
  137718. set snapDistance(value: number);
  137719. get snapDistance(): number;
  137720. /**
  137721. * Ratio for the scale of the gizmo (Default: 1)
  137722. */
  137723. set scaleRatio(value: number);
  137724. get scaleRatio(): number;
  137725. /**
  137726. * Disposes of the gizmo
  137727. */
  137728. dispose(): void;
  137729. /**
  137730. * CustomMeshes are not supported by this gizmo
  137731. * @param mesh The mesh to replace the default mesh of the gizmo
  137732. */
  137733. setCustomMesh(mesh: Mesh): void;
  137734. }
  137735. }
  137736. declare module BABYLON {
  137737. /**
  137738. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137739. */
  137740. export class GizmoManager implements IDisposable {
  137741. private scene;
  137742. /**
  137743. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137744. */
  137745. gizmos: {
  137746. positionGizmo: Nullable<PositionGizmo>;
  137747. rotationGizmo: Nullable<RotationGizmo>;
  137748. scaleGizmo: Nullable<ScaleGizmo>;
  137749. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137750. };
  137751. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137752. clearGizmoOnEmptyPointerEvent: boolean;
  137753. /** Fires an event when the manager is attached to a mesh */
  137754. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137755. /** Fires an event when the manager is attached to a node */
  137756. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137757. private _gizmosEnabled;
  137758. private _pointerObserver;
  137759. private _attachedMesh;
  137760. private _attachedNode;
  137761. private _boundingBoxColor;
  137762. private _defaultUtilityLayer;
  137763. private _defaultKeepDepthUtilityLayer;
  137764. private _thickness;
  137765. /**
  137766. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137767. */
  137768. boundingBoxDragBehavior: SixDofDragBehavior;
  137769. /**
  137770. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137771. */
  137772. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137773. /**
  137774. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137775. */
  137776. attachableNodes: Nullable<Array<Node>>;
  137777. /**
  137778. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137779. */
  137780. usePointerToAttachGizmos: boolean;
  137781. /**
  137782. * Utility layer that the bounding box gizmo belongs to
  137783. */
  137784. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137785. /**
  137786. * Utility layer that all gizmos besides bounding box belong to
  137787. */
  137788. get utilityLayer(): UtilityLayerRenderer;
  137789. /**
  137790. * True when the mouse pointer is hovering a gizmo mesh
  137791. */
  137792. get isHovered(): boolean;
  137793. /**
  137794. * Instatiates a gizmo manager
  137795. * @param scene the scene to overlay the gizmos on top of
  137796. * @param thickness display gizmo axis thickness
  137797. */
  137798. constructor(scene: Scene, thickness?: number);
  137799. /**
  137800. * Attaches a set of gizmos to the specified mesh
  137801. * @param mesh The mesh the gizmo's should be attached to
  137802. */
  137803. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137804. /**
  137805. * Attaches a set of gizmos to the specified node
  137806. * @param node The node the gizmo's should be attached to
  137807. */
  137808. attachToNode(node: Nullable<Node>): void;
  137809. /**
  137810. * If the position gizmo is enabled
  137811. */
  137812. set positionGizmoEnabled(value: boolean);
  137813. get positionGizmoEnabled(): boolean;
  137814. /**
  137815. * If the rotation gizmo is enabled
  137816. */
  137817. set rotationGizmoEnabled(value: boolean);
  137818. get rotationGizmoEnabled(): boolean;
  137819. /**
  137820. * If the scale gizmo is enabled
  137821. */
  137822. set scaleGizmoEnabled(value: boolean);
  137823. get scaleGizmoEnabled(): boolean;
  137824. /**
  137825. * If the boundingBox gizmo is enabled
  137826. */
  137827. set boundingBoxGizmoEnabled(value: boolean);
  137828. get boundingBoxGizmoEnabled(): boolean;
  137829. /**
  137830. * Disposes of the gizmo manager
  137831. */
  137832. dispose(): void;
  137833. }
  137834. }
  137835. declare module BABYLON {
  137836. /**
  137837. * A directional light is defined by a direction (what a surprise!).
  137838. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137839. * 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.
  137840. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137841. */
  137842. export class DirectionalLight extends ShadowLight {
  137843. private _shadowFrustumSize;
  137844. /**
  137845. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137846. */
  137847. get shadowFrustumSize(): number;
  137848. /**
  137849. * Specifies a fix frustum size for the shadow generation.
  137850. */
  137851. set shadowFrustumSize(value: number);
  137852. private _shadowOrthoScale;
  137853. /**
  137854. * Gets the shadow projection scale against the optimal computed one.
  137855. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137856. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137857. */
  137858. get shadowOrthoScale(): number;
  137859. /**
  137860. * Sets the shadow projection scale against the optimal computed one.
  137861. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137862. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137863. */
  137864. set shadowOrthoScale(value: number);
  137865. /**
  137866. * Automatically compute the projection matrix to best fit (including all the casters)
  137867. * on each frame.
  137868. */
  137869. autoUpdateExtends: boolean;
  137870. /**
  137871. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137872. * on each frame. autoUpdateExtends must be set to true for this to work
  137873. */
  137874. autoCalcShadowZBounds: boolean;
  137875. private _orthoLeft;
  137876. private _orthoRight;
  137877. private _orthoTop;
  137878. private _orthoBottom;
  137879. /**
  137880. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137881. * The directional light is emitted from everywhere in the given direction.
  137882. * It can cast shadows.
  137883. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137884. * @param name The friendly name of the light
  137885. * @param direction The direction of the light
  137886. * @param scene The scene the light belongs to
  137887. */
  137888. constructor(name: string, direction: Vector3, scene: Scene);
  137889. /**
  137890. * Returns the string "DirectionalLight".
  137891. * @return The class name
  137892. */
  137893. getClassName(): string;
  137894. /**
  137895. * Returns the integer 1.
  137896. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137897. */
  137898. getTypeID(): number;
  137899. /**
  137900. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137901. * Returns the DirectionalLight Shadow projection matrix.
  137902. */
  137903. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137904. /**
  137905. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137906. * Returns the DirectionalLight Shadow projection matrix.
  137907. */
  137908. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137909. /**
  137910. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137911. * Returns the DirectionalLight Shadow projection matrix.
  137912. */
  137913. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137914. protected _buildUniformLayout(): void;
  137915. /**
  137916. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137917. * @param effect The effect to update
  137918. * @param lightIndex The index of the light in the effect to update
  137919. * @returns The directional light
  137920. */
  137921. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137922. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137923. /**
  137924. * Gets the minZ used for shadow according to both the scene and the light.
  137925. *
  137926. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137927. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137928. * @param activeCamera The camera we are returning the min for
  137929. * @returns the depth min z
  137930. */
  137931. getDepthMinZ(activeCamera: Camera): number;
  137932. /**
  137933. * Gets the maxZ used for shadow according to both the scene and the light.
  137934. *
  137935. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137936. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137937. * @param activeCamera The camera we are returning the max for
  137938. * @returns the depth max z
  137939. */
  137940. getDepthMaxZ(activeCamera: Camera): number;
  137941. /**
  137942. * Prepares the list of defines specific to the light type.
  137943. * @param defines the list of defines
  137944. * @param lightIndex defines the index of the light for the effect
  137945. */
  137946. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137947. }
  137948. }
  137949. declare module BABYLON {
  137950. /**
  137951. * Class containing static functions to help procedurally build meshes
  137952. */
  137953. export class HemisphereBuilder {
  137954. /**
  137955. * Creates a hemisphere mesh
  137956. * @param name defines the name of the mesh
  137957. * @param options defines the options used to create the mesh
  137958. * @param scene defines the hosting scene
  137959. * @returns the hemisphere mesh
  137960. */
  137961. static CreateHemisphere(name: string, options: {
  137962. segments?: number;
  137963. diameter?: number;
  137964. sideOrientation?: number;
  137965. }, scene: any): Mesh;
  137966. }
  137967. }
  137968. declare module BABYLON {
  137969. /**
  137970. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137971. * These values define a cone of light starting from the position, emitting toward the direction.
  137972. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137973. * and the exponent defines the speed of the decay of the light with distance (reach).
  137974. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137975. */
  137976. export class SpotLight extends ShadowLight {
  137977. private _angle;
  137978. private _innerAngle;
  137979. private _cosHalfAngle;
  137980. private _lightAngleScale;
  137981. private _lightAngleOffset;
  137982. /**
  137983. * Gets the cone angle of the spot light in Radians.
  137984. */
  137985. get angle(): number;
  137986. /**
  137987. * Sets the cone angle of the spot light in Radians.
  137988. */
  137989. set angle(value: number);
  137990. /**
  137991. * Only used in gltf falloff mode, this defines the angle where
  137992. * the directional falloff will start before cutting at angle which could be seen
  137993. * as outer angle.
  137994. */
  137995. get innerAngle(): number;
  137996. /**
  137997. * Only used in gltf falloff mode, this defines the angle where
  137998. * the directional falloff will start before cutting at angle which could be seen
  137999. * as outer angle.
  138000. */
  138001. set innerAngle(value: number);
  138002. private _shadowAngleScale;
  138003. /**
  138004. * Allows scaling the angle of the light for shadow generation only.
  138005. */
  138006. get shadowAngleScale(): number;
  138007. /**
  138008. * Allows scaling the angle of the light for shadow generation only.
  138009. */
  138010. set shadowAngleScale(value: number);
  138011. /**
  138012. * The light decay speed with the distance from the emission spot.
  138013. */
  138014. exponent: number;
  138015. private _projectionTextureMatrix;
  138016. /**
  138017. * Allows reading the projecton texture
  138018. */
  138019. get projectionTextureMatrix(): Matrix;
  138020. protected _projectionTextureLightNear: number;
  138021. /**
  138022. * Gets the near clip of the Spotlight for texture projection.
  138023. */
  138024. get projectionTextureLightNear(): number;
  138025. /**
  138026. * Sets the near clip of the Spotlight for texture projection.
  138027. */
  138028. set projectionTextureLightNear(value: number);
  138029. protected _projectionTextureLightFar: number;
  138030. /**
  138031. * Gets the far clip of the Spotlight for texture projection.
  138032. */
  138033. get projectionTextureLightFar(): number;
  138034. /**
  138035. * Sets the far clip of the Spotlight for texture projection.
  138036. */
  138037. set projectionTextureLightFar(value: number);
  138038. protected _projectionTextureUpDirection: Vector3;
  138039. /**
  138040. * Gets the Up vector of the Spotlight for texture projection.
  138041. */
  138042. get projectionTextureUpDirection(): Vector3;
  138043. /**
  138044. * Sets the Up vector of the Spotlight for texture projection.
  138045. */
  138046. set projectionTextureUpDirection(value: Vector3);
  138047. private _projectionTexture;
  138048. /**
  138049. * Gets the projection texture of the light.
  138050. */
  138051. get projectionTexture(): Nullable<BaseTexture>;
  138052. /**
  138053. * Sets the projection texture of the light.
  138054. */
  138055. set projectionTexture(value: Nullable<BaseTexture>);
  138056. private _projectionTextureViewLightDirty;
  138057. private _projectionTextureProjectionLightDirty;
  138058. private _projectionTextureDirty;
  138059. private _projectionTextureViewTargetVector;
  138060. private _projectionTextureViewLightMatrix;
  138061. private _projectionTextureProjectionLightMatrix;
  138062. private _projectionTextureScalingMatrix;
  138063. /**
  138064. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  138065. * It can cast shadows.
  138066. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138067. * @param name The light friendly name
  138068. * @param position The position of the spot light in the scene
  138069. * @param direction The direction of the light in the scene
  138070. * @param angle The cone angle of the light in Radians
  138071. * @param exponent The light decay speed with the distance from the emission spot
  138072. * @param scene The scene the lights belongs to
  138073. */
  138074. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138075. /**
  138076. * Returns the string "SpotLight".
  138077. * @returns the class name
  138078. */
  138079. getClassName(): string;
  138080. /**
  138081. * Returns the integer 2.
  138082. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138083. */
  138084. getTypeID(): number;
  138085. /**
  138086. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138087. */
  138088. protected _setDirection(value: Vector3): void;
  138089. /**
  138090. * Overrides the position setter to recompute the projection texture view light Matrix.
  138091. */
  138092. protected _setPosition(value: Vector3): void;
  138093. /**
  138094. * 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.
  138095. * Returns the SpotLight.
  138096. */
  138097. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138098. protected _computeProjectionTextureViewLightMatrix(): void;
  138099. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138100. /**
  138101. * Main function for light texture projection matrix computing.
  138102. */
  138103. protected _computeProjectionTextureMatrix(): void;
  138104. protected _buildUniformLayout(): void;
  138105. private _computeAngleValues;
  138106. /**
  138107. * Sets the passed Effect "effect" with the Light textures.
  138108. * @param effect The effect to update
  138109. * @param lightIndex The index of the light in the effect to update
  138110. * @returns The light
  138111. */
  138112. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138113. /**
  138114. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138115. * @param effect The effect to update
  138116. * @param lightIndex The index of the light in the effect to update
  138117. * @returns The spot light
  138118. */
  138119. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138120. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138121. /**
  138122. * Disposes the light and the associated resources.
  138123. */
  138124. dispose(): void;
  138125. /**
  138126. * Prepares the list of defines specific to the light type.
  138127. * @param defines the list of defines
  138128. * @param lightIndex defines the index of the light for the effect
  138129. */
  138130. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138131. }
  138132. }
  138133. declare module BABYLON {
  138134. /**
  138135. * Gizmo that enables viewing a light
  138136. */
  138137. export class LightGizmo extends Gizmo {
  138138. private _lightMesh;
  138139. private _material;
  138140. private _cachedPosition;
  138141. private _cachedForward;
  138142. private _attachedMeshParent;
  138143. private _pointerObserver;
  138144. /**
  138145. * Event that fires each time the gizmo is clicked
  138146. */
  138147. onClickedObservable: Observable<Light>;
  138148. /**
  138149. * Creates a LightGizmo
  138150. * @param gizmoLayer The utility layer the gizmo will be added to
  138151. */
  138152. constructor(gizmoLayer?: UtilityLayerRenderer);
  138153. private _light;
  138154. /**
  138155. * The light that the gizmo is attached to
  138156. */
  138157. set light(light: Nullable<Light>);
  138158. get light(): Nullable<Light>;
  138159. /**
  138160. * Gets the material used to render the light gizmo
  138161. */
  138162. get material(): StandardMaterial;
  138163. /**
  138164. * @hidden
  138165. * Updates the gizmo to match the attached mesh's position/rotation
  138166. */
  138167. protected _update(): void;
  138168. private static _Scale;
  138169. /**
  138170. * Creates the lines for a light mesh
  138171. */
  138172. private static _CreateLightLines;
  138173. /**
  138174. * Disposes of the light gizmo
  138175. */
  138176. dispose(): void;
  138177. private static _CreateHemisphericLightMesh;
  138178. private static _CreatePointLightMesh;
  138179. private static _CreateSpotLightMesh;
  138180. private static _CreateDirectionalLightMesh;
  138181. }
  138182. }
  138183. declare module BABYLON {
  138184. /**
  138185. * Gizmo that enables viewing a camera
  138186. */
  138187. export class CameraGizmo extends Gizmo {
  138188. private _cameraMesh;
  138189. private _cameraLinesMesh;
  138190. private _material;
  138191. private _pointerObserver;
  138192. /**
  138193. * Event that fires each time the gizmo is clicked
  138194. */
  138195. onClickedObservable: Observable<Camera>;
  138196. /**
  138197. * Creates a CameraGizmo
  138198. * @param gizmoLayer The utility layer the gizmo will be added to
  138199. */
  138200. constructor(gizmoLayer?: UtilityLayerRenderer);
  138201. private _camera;
  138202. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138203. get displayFrustum(): boolean;
  138204. set displayFrustum(value: boolean);
  138205. /**
  138206. * The camera that the gizmo is attached to
  138207. */
  138208. set camera(camera: Nullable<Camera>);
  138209. get camera(): Nullable<Camera>;
  138210. /**
  138211. * Gets the material used to render the camera gizmo
  138212. */
  138213. get material(): StandardMaterial;
  138214. /**
  138215. * @hidden
  138216. * Updates the gizmo to match the attached mesh's position/rotation
  138217. */
  138218. protected _update(): void;
  138219. private static _Scale;
  138220. private _invProjection;
  138221. /**
  138222. * Disposes of the camera gizmo
  138223. */
  138224. dispose(): void;
  138225. private static _CreateCameraMesh;
  138226. private static _CreateCameraFrustum;
  138227. }
  138228. }
  138229. declare module BABYLON {
  138230. /** @hidden */
  138231. export var backgroundFragmentDeclaration: {
  138232. name: string;
  138233. shader: string;
  138234. };
  138235. }
  138236. declare module BABYLON {
  138237. /** @hidden */
  138238. export var backgroundUboDeclaration: {
  138239. name: string;
  138240. shader: string;
  138241. };
  138242. }
  138243. declare module BABYLON {
  138244. /** @hidden */
  138245. export var backgroundPixelShader: {
  138246. name: string;
  138247. shader: string;
  138248. };
  138249. }
  138250. declare module BABYLON {
  138251. /** @hidden */
  138252. export var backgroundVertexDeclaration: {
  138253. name: string;
  138254. shader: string;
  138255. };
  138256. }
  138257. declare module BABYLON {
  138258. /** @hidden */
  138259. export var backgroundVertexShader: {
  138260. name: string;
  138261. shader: string;
  138262. };
  138263. }
  138264. declare module BABYLON {
  138265. /**
  138266. * Background material used to create an efficient environement around your scene.
  138267. */
  138268. export class BackgroundMaterial extends PushMaterial {
  138269. /**
  138270. * Standard reflectance value at parallel view angle.
  138271. */
  138272. static StandardReflectance0: number;
  138273. /**
  138274. * Standard reflectance value at grazing angle.
  138275. */
  138276. static StandardReflectance90: number;
  138277. protected _primaryColor: Color3;
  138278. /**
  138279. * Key light Color (multiply against the environement texture)
  138280. */
  138281. primaryColor: Color3;
  138282. protected __perceptualColor: Nullable<Color3>;
  138283. /**
  138284. * Experimental Internal Use Only.
  138285. *
  138286. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138287. * This acts as a helper to set the primary color to a more "human friendly" value.
  138288. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138289. * output color as close as possible from the chosen value.
  138290. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138291. * part of lighting setup.)
  138292. */
  138293. get _perceptualColor(): Nullable<Color3>;
  138294. set _perceptualColor(value: Nullable<Color3>);
  138295. protected _primaryColorShadowLevel: float;
  138296. /**
  138297. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138298. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138299. */
  138300. get primaryColorShadowLevel(): float;
  138301. set primaryColorShadowLevel(value: float);
  138302. protected _primaryColorHighlightLevel: float;
  138303. /**
  138304. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138305. * The primary color is used at the level chosen to define what the white area would look.
  138306. */
  138307. get primaryColorHighlightLevel(): float;
  138308. set primaryColorHighlightLevel(value: float);
  138309. protected _reflectionTexture: Nullable<BaseTexture>;
  138310. /**
  138311. * Reflection Texture used in the material.
  138312. * Should be author in a specific way for the best result (refer to the documentation).
  138313. */
  138314. reflectionTexture: Nullable<BaseTexture>;
  138315. protected _reflectionBlur: float;
  138316. /**
  138317. * Reflection Texture level of blur.
  138318. *
  138319. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138320. * texture twice.
  138321. */
  138322. reflectionBlur: float;
  138323. protected _diffuseTexture: Nullable<BaseTexture>;
  138324. /**
  138325. * Diffuse Texture used in the material.
  138326. * Should be author in a specific way for the best result (refer to the documentation).
  138327. */
  138328. diffuseTexture: Nullable<BaseTexture>;
  138329. protected _shadowLights: Nullable<IShadowLight[]>;
  138330. /**
  138331. * Specify the list of lights casting shadow on the material.
  138332. * All scene shadow lights will be included if null.
  138333. */
  138334. shadowLights: Nullable<IShadowLight[]>;
  138335. protected _shadowLevel: float;
  138336. /**
  138337. * Helps adjusting the shadow to a softer level if required.
  138338. * 0 means black shadows and 1 means no shadows.
  138339. */
  138340. shadowLevel: float;
  138341. protected _sceneCenter: Vector3;
  138342. /**
  138343. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138344. * It is usually zero but might be interesting to modify according to your setup.
  138345. */
  138346. sceneCenter: Vector3;
  138347. protected _opacityFresnel: boolean;
  138348. /**
  138349. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138350. * This helps ensuring a nice transition when the camera goes under the ground.
  138351. */
  138352. opacityFresnel: boolean;
  138353. protected _reflectionFresnel: boolean;
  138354. /**
  138355. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138356. * This helps adding a mirror texture on the ground.
  138357. */
  138358. reflectionFresnel: boolean;
  138359. protected _reflectionFalloffDistance: number;
  138360. /**
  138361. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138362. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138363. */
  138364. reflectionFalloffDistance: number;
  138365. protected _reflectionAmount: number;
  138366. /**
  138367. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138368. */
  138369. reflectionAmount: number;
  138370. protected _reflectionReflectance0: number;
  138371. /**
  138372. * This specifies the weight of the reflection at grazing angle.
  138373. */
  138374. reflectionReflectance0: number;
  138375. protected _reflectionReflectance90: number;
  138376. /**
  138377. * This specifies the weight of the reflection at a perpendicular point of view.
  138378. */
  138379. reflectionReflectance90: number;
  138380. /**
  138381. * Sets the reflection reflectance fresnel values according to the default standard
  138382. * empirically know to work well :-)
  138383. */
  138384. set reflectionStandardFresnelWeight(value: number);
  138385. protected _useRGBColor: boolean;
  138386. /**
  138387. * Helps to directly use the maps channels instead of their level.
  138388. */
  138389. useRGBColor: boolean;
  138390. protected _enableNoise: boolean;
  138391. /**
  138392. * This helps reducing the banding effect that could occur on the background.
  138393. */
  138394. enableNoise: boolean;
  138395. /**
  138396. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138397. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138398. * Recommended to be keep at 1.0 except for special cases.
  138399. */
  138400. get fovMultiplier(): number;
  138401. set fovMultiplier(value: number);
  138402. private _fovMultiplier;
  138403. /**
  138404. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138405. */
  138406. useEquirectangularFOV: boolean;
  138407. private _maxSimultaneousLights;
  138408. /**
  138409. * Number of Simultaneous lights allowed on the material.
  138410. */
  138411. maxSimultaneousLights: int;
  138412. private _shadowOnly;
  138413. /**
  138414. * Make the material only render shadows
  138415. */
  138416. shadowOnly: boolean;
  138417. /**
  138418. * Default configuration related to image processing available in the Background Material.
  138419. */
  138420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138421. /**
  138422. * Keep track of the image processing observer to allow dispose and replace.
  138423. */
  138424. private _imageProcessingObserver;
  138425. /**
  138426. * Attaches a new image processing configuration to the PBR Material.
  138427. * @param configuration (if null the scene configuration will be use)
  138428. */
  138429. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138430. /**
  138431. * Gets the image processing configuration used either in this material.
  138432. */
  138433. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138434. /**
  138435. * Sets the Default image processing configuration used either in the this material.
  138436. *
  138437. * If sets to null, the scene one is in use.
  138438. */
  138439. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138440. /**
  138441. * Gets wether the color curves effect is enabled.
  138442. */
  138443. get cameraColorCurvesEnabled(): boolean;
  138444. /**
  138445. * Sets wether the color curves effect is enabled.
  138446. */
  138447. set cameraColorCurvesEnabled(value: boolean);
  138448. /**
  138449. * Gets wether the color grading effect is enabled.
  138450. */
  138451. get cameraColorGradingEnabled(): boolean;
  138452. /**
  138453. * Gets wether the color grading effect is enabled.
  138454. */
  138455. set cameraColorGradingEnabled(value: boolean);
  138456. /**
  138457. * Gets wether tonemapping is enabled or not.
  138458. */
  138459. get cameraToneMappingEnabled(): boolean;
  138460. /**
  138461. * Sets wether tonemapping is enabled or not
  138462. */
  138463. set cameraToneMappingEnabled(value: boolean);
  138464. /**
  138465. * The camera exposure used on this material.
  138466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138467. * This corresponds to a photographic exposure.
  138468. */
  138469. get cameraExposure(): float;
  138470. /**
  138471. * The camera exposure used on this material.
  138472. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138473. * This corresponds to a photographic exposure.
  138474. */
  138475. set cameraExposure(value: float);
  138476. /**
  138477. * Gets The camera contrast used on this material.
  138478. */
  138479. get cameraContrast(): float;
  138480. /**
  138481. * Sets The camera contrast used on this material.
  138482. */
  138483. set cameraContrast(value: float);
  138484. /**
  138485. * Gets the Color Grading 2D Lookup Texture.
  138486. */
  138487. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138488. /**
  138489. * Sets the Color Grading 2D Lookup Texture.
  138490. */
  138491. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138492. /**
  138493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138495. * 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;
  138496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138497. */
  138498. get cameraColorCurves(): Nullable<ColorCurves>;
  138499. /**
  138500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138502. * 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;
  138503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138504. */
  138505. set cameraColorCurves(value: Nullable<ColorCurves>);
  138506. /**
  138507. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138508. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138509. */
  138510. switchToBGR: boolean;
  138511. private _renderTargets;
  138512. private _reflectionControls;
  138513. private _white;
  138514. private _primaryShadowColor;
  138515. private _primaryHighlightColor;
  138516. /**
  138517. * Instantiates a Background Material in the given scene
  138518. * @param name The friendly name of the material
  138519. * @param scene The scene to add the material to
  138520. */
  138521. constructor(name: string, scene: Scene);
  138522. /**
  138523. * Gets a boolean indicating that current material needs to register RTT
  138524. */
  138525. get hasRenderTargetTextures(): boolean;
  138526. /**
  138527. * The entire material has been created in order to prevent overdraw.
  138528. * @returns false
  138529. */
  138530. needAlphaTesting(): boolean;
  138531. /**
  138532. * The entire material has been created in order to prevent overdraw.
  138533. * @returns true if blending is enable
  138534. */
  138535. needAlphaBlending(): boolean;
  138536. /**
  138537. * Checks wether the material is ready to be rendered for a given mesh.
  138538. * @param mesh The mesh to render
  138539. * @param subMesh The submesh to check against
  138540. * @param useInstances Specify wether or not the material is used with instances
  138541. * @returns true if all the dependencies are ready (Textures, Effects...)
  138542. */
  138543. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138544. /**
  138545. * Compute the primary color according to the chosen perceptual color.
  138546. */
  138547. private _computePrimaryColorFromPerceptualColor;
  138548. /**
  138549. * Compute the highlights and shadow colors according to their chosen levels.
  138550. */
  138551. private _computePrimaryColors;
  138552. /**
  138553. * Build the uniform buffer used in the material.
  138554. */
  138555. buildUniformLayout(): void;
  138556. /**
  138557. * Unbind the material.
  138558. */
  138559. unbind(): void;
  138560. /**
  138561. * Bind only the world matrix to the material.
  138562. * @param world The world matrix to bind.
  138563. */
  138564. bindOnlyWorldMatrix(world: Matrix): void;
  138565. /**
  138566. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138567. * @param world The world matrix to bind.
  138568. * @param subMesh The submesh to bind for.
  138569. */
  138570. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138571. /**
  138572. * Checks to see if a texture is used in the material.
  138573. * @param texture - Base texture to use.
  138574. * @returns - Boolean specifying if a texture is used in the material.
  138575. */
  138576. hasTexture(texture: BaseTexture): boolean;
  138577. /**
  138578. * Dispose the material.
  138579. * @param forceDisposeEffect Force disposal of the associated effect.
  138580. * @param forceDisposeTextures Force disposal of the associated textures.
  138581. */
  138582. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138583. /**
  138584. * Clones the material.
  138585. * @param name The cloned name.
  138586. * @returns The cloned material.
  138587. */
  138588. clone(name: string): BackgroundMaterial;
  138589. /**
  138590. * Serializes the current material to its JSON representation.
  138591. * @returns The JSON representation.
  138592. */
  138593. serialize(): any;
  138594. /**
  138595. * Gets the class name of the material
  138596. * @returns "BackgroundMaterial"
  138597. */
  138598. getClassName(): string;
  138599. /**
  138600. * Parse a JSON input to create back a background material.
  138601. * @param source The JSON data to parse
  138602. * @param scene The scene to create the parsed material in
  138603. * @param rootUrl The root url of the assets the material depends upon
  138604. * @returns the instantiated BackgroundMaterial.
  138605. */
  138606. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138607. }
  138608. }
  138609. declare module BABYLON {
  138610. /**
  138611. * Represents the different options available during the creation of
  138612. * a Environment helper.
  138613. *
  138614. * This can control the default ground, skybox and image processing setup of your scene.
  138615. */
  138616. export interface IEnvironmentHelperOptions {
  138617. /**
  138618. * Specifies whether or not to create a ground.
  138619. * True by default.
  138620. */
  138621. createGround: boolean;
  138622. /**
  138623. * Specifies the ground size.
  138624. * 15 by default.
  138625. */
  138626. groundSize: number;
  138627. /**
  138628. * The texture used on the ground for the main color.
  138629. * Comes from the BabylonJS CDN by default.
  138630. *
  138631. * Remarks: Can be either a texture or a url.
  138632. */
  138633. groundTexture: string | BaseTexture;
  138634. /**
  138635. * The color mixed in the ground texture by default.
  138636. * BabylonJS clearColor by default.
  138637. */
  138638. groundColor: Color3;
  138639. /**
  138640. * Specifies the ground opacity.
  138641. * 1 by default.
  138642. */
  138643. groundOpacity: number;
  138644. /**
  138645. * Enables the ground to receive shadows.
  138646. * True by default.
  138647. */
  138648. enableGroundShadow: boolean;
  138649. /**
  138650. * Helps preventing the shadow to be fully black on the ground.
  138651. * 0.5 by default.
  138652. */
  138653. groundShadowLevel: number;
  138654. /**
  138655. * Creates a mirror texture attach to the ground.
  138656. * false by default.
  138657. */
  138658. enableGroundMirror: boolean;
  138659. /**
  138660. * Specifies the ground mirror size ratio.
  138661. * 0.3 by default as the default kernel is 64.
  138662. */
  138663. groundMirrorSizeRatio: number;
  138664. /**
  138665. * Specifies the ground mirror blur kernel size.
  138666. * 64 by default.
  138667. */
  138668. groundMirrorBlurKernel: number;
  138669. /**
  138670. * Specifies the ground mirror visibility amount.
  138671. * 1 by default
  138672. */
  138673. groundMirrorAmount: number;
  138674. /**
  138675. * Specifies the ground mirror reflectance weight.
  138676. * This uses the standard weight of the background material to setup the fresnel effect
  138677. * of the mirror.
  138678. * 1 by default.
  138679. */
  138680. groundMirrorFresnelWeight: number;
  138681. /**
  138682. * Specifies the ground mirror Falloff distance.
  138683. * This can helps reducing the size of the reflection.
  138684. * 0 by Default.
  138685. */
  138686. groundMirrorFallOffDistance: number;
  138687. /**
  138688. * Specifies the ground mirror texture type.
  138689. * Unsigned Int by Default.
  138690. */
  138691. groundMirrorTextureType: number;
  138692. /**
  138693. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138694. * the shown objects.
  138695. */
  138696. groundYBias: number;
  138697. /**
  138698. * Specifies whether or not to create a skybox.
  138699. * True by default.
  138700. */
  138701. createSkybox: boolean;
  138702. /**
  138703. * Specifies the skybox size.
  138704. * 20 by default.
  138705. */
  138706. skyboxSize: number;
  138707. /**
  138708. * The texture used on the skybox for the main color.
  138709. * Comes from the BabylonJS CDN by default.
  138710. *
  138711. * Remarks: Can be either a texture or a url.
  138712. */
  138713. skyboxTexture: string | BaseTexture;
  138714. /**
  138715. * The color mixed in the skybox texture by default.
  138716. * BabylonJS clearColor by default.
  138717. */
  138718. skyboxColor: Color3;
  138719. /**
  138720. * The background rotation around the Y axis of the scene.
  138721. * This helps aligning the key lights of your scene with the background.
  138722. * 0 by default.
  138723. */
  138724. backgroundYRotation: number;
  138725. /**
  138726. * Compute automatically the size of the elements to best fit with the scene.
  138727. */
  138728. sizeAuto: boolean;
  138729. /**
  138730. * Default position of the rootMesh if autoSize is not true.
  138731. */
  138732. rootPosition: Vector3;
  138733. /**
  138734. * Sets up the image processing in the scene.
  138735. * true by default.
  138736. */
  138737. setupImageProcessing: boolean;
  138738. /**
  138739. * The texture used as your environment texture in the scene.
  138740. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138741. *
  138742. * Remarks: Can be either a texture or a url.
  138743. */
  138744. environmentTexture: string | BaseTexture;
  138745. /**
  138746. * The value of the exposure to apply to the scene.
  138747. * 0.6 by default if setupImageProcessing is true.
  138748. */
  138749. cameraExposure: number;
  138750. /**
  138751. * The value of the contrast to apply to the scene.
  138752. * 1.6 by default if setupImageProcessing is true.
  138753. */
  138754. cameraContrast: number;
  138755. /**
  138756. * Specifies whether or not tonemapping should be enabled in the scene.
  138757. * true by default if setupImageProcessing is true.
  138758. */
  138759. toneMappingEnabled: boolean;
  138760. }
  138761. /**
  138762. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138763. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138764. * It also helps with the default setup of your imageProcessing configuration.
  138765. */
  138766. export class EnvironmentHelper {
  138767. /**
  138768. * Default ground texture URL.
  138769. */
  138770. private static _groundTextureCDNUrl;
  138771. /**
  138772. * Default skybox texture URL.
  138773. */
  138774. private static _skyboxTextureCDNUrl;
  138775. /**
  138776. * Default environment texture URL.
  138777. */
  138778. private static _environmentTextureCDNUrl;
  138779. /**
  138780. * Creates the default options for the helper.
  138781. */
  138782. private static _getDefaultOptions;
  138783. private _rootMesh;
  138784. /**
  138785. * Gets the root mesh created by the helper.
  138786. */
  138787. get rootMesh(): Mesh;
  138788. private _skybox;
  138789. /**
  138790. * Gets the skybox created by the helper.
  138791. */
  138792. get skybox(): Nullable<Mesh>;
  138793. private _skyboxTexture;
  138794. /**
  138795. * Gets the skybox texture created by the helper.
  138796. */
  138797. get skyboxTexture(): Nullable<BaseTexture>;
  138798. private _skyboxMaterial;
  138799. /**
  138800. * Gets the skybox material created by the helper.
  138801. */
  138802. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138803. private _ground;
  138804. /**
  138805. * Gets the ground mesh created by the helper.
  138806. */
  138807. get ground(): Nullable<Mesh>;
  138808. private _groundTexture;
  138809. /**
  138810. * Gets the ground texture created by the helper.
  138811. */
  138812. get groundTexture(): Nullable<BaseTexture>;
  138813. private _groundMirror;
  138814. /**
  138815. * Gets the ground mirror created by the helper.
  138816. */
  138817. get groundMirror(): Nullable<MirrorTexture>;
  138818. /**
  138819. * Gets the ground mirror render list to helps pushing the meshes
  138820. * you wish in the ground reflection.
  138821. */
  138822. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138823. private _groundMaterial;
  138824. /**
  138825. * Gets the ground material created by the helper.
  138826. */
  138827. get groundMaterial(): Nullable<BackgroundMaterial>;
  138828. /**
  138829. * Stores the creation options.
  138830. */
  138831. private readonly _scene;
  138832. private _options;
  138833. /**
  138834. * This observable will be notified with any error during the creation of the environment,
  138835. * mainly texture creation errors.
  138836. */
  138837. onErrorObservable: Observable<{
  138838. message?: string;
  138839. exception?: any;
  138840. }>;
  138841. /**
  138842. * constructor
  138843. * @param options Defines the options we want to customize the helper
  138844. * @param scene The scene to add the material to
  138845. */
  138846. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138847. /**
  138848. * Updates the background according to the new options
  138849. * @param options
  138850. */
  138851. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138852. /**
  138853. * Sets the primary color of all the available elements.
  138854. * @param color the main color to affect to the ground and the background
  138855. */
  138856. setMainColor(color: Color3): void;
  138857. /**
  138858. * Setup the image processing according to the specified options.
  138859. */
  138860. private _setupImageProcessing;
  138861. /**
  138862. * Setup the environment texture according to the specified options.
  138863. */
  138864. private _setupEnvironmentTexture;
  138865. /**
  138866. * Setup the background according to the specified options.
  138867. */
  138868. private _setupBackground;
  138869. /**
  138870. * Get the scene sizes according to the setup.
  138871. */
  138872. private _getSceneSize;
  138873. /**
  138874. * Setup the ground according to the specified options.
  138875. */
  138876. private _setupGround;
  138877. /**
  138878. * Setup the ground material according to the specified options.
  138879. */
  138880. private _setupGroundMaterial;
  138881. /**
  138882. * Setup the ground diffuse texture according to the specified options.
  138883. */
  138884. private _setupGroundDiffuseTexture;
  138885. /**
  138886. * Setup the ground mirror texture according to the specified options.
  138887. */
  138888. private _setupGroundMirrorTexture;
  138889. /**
  138890. * Setup the ground to receive the mirror texture.
  138891. */
  138892. private _setupMirrorInGroundMaterial;
  138893. /**
  138894. * Setup the skybox according to the specified options.
  138895. */
  138896. private _setupSkybox;
  138897. /**
  138898. * Setup the skybox material according to the specified options.
  138899. */
  138900. private _setupSkyboxMaterial;
  138901. /**
  138902. * Setup the skybox reflection texture according to the specified options.
  138903. */
  138904. private _setupSkyboxReflectionTexture;
  138905. private _errorHandler;
  138906. /**
  138907. * Dispose all the elements created by the Helper.
  138908. */
  138909. dispose(): void;
  138910. }
  138911. }
  138912. declare module BABYLON {
  138913. /**
  138914. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138915. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138916. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138917. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138918. */
  138919. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138920. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138921. /**
  138922. * Define the source as a Monoscopic panoramic 360/180.
  138923. */
  138924. static readonly MODE_MONOSCOPIC: number;
  138925. /**
  138926. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138927. */
  138928. static readonly MODE_TOPBOTTOM: number;
  138929. /**
  138930. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138931. */
  138932. static readonly MODE_SIDEBYSIDE: number;
  138933. private _halfDome;
  138934. private _crossEye;
  138935. protected _useDirectMapping: boolean;
  138936. /**
  138937. * The texture being displayed on the sphere
  138938. */
  138939. protected _texture: T;
  138940. /**
  138941. * Gets the texture being displayed on the sphere
  138942. */
  138943. get texture(): T;
  138944. /**
  138945. * Sets the texture being displayed on the sphere
  138946. */
  138947. set texture(newTexture: T);
  138948. /**
  138949. * The skybox material
  138950. */
  138951. protected _material: BackgroundMaterial;
  138952. /**
  138953. * The surface used for the dome
  138954. */
  138955. protected _mesh: Mesh;
  138956. /**
  138957. * Gets the mesh used for the dome.
  138958. */
  138959. get mesh(): Mesh;
  138960. /**
  138961. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138962. */
  138963. private _halfDomeMask;
  138964. /**
  138965. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138966. * Also see the options.resolution property.
  138967. */
  138968. get fovMultiplier(): number;
  138969. set fovMultiplier(value: number);
  138970. protected _textureMode: number;
  138971. /**
  138972. * Gets or set the current texture mode for the texture. It can be:
  138973. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138974. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138975. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138976. */
  138977. get textureMode(): number;
  138978. /**
  138979. * Sets the current texture mode for the texture. It can be:
  138980. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138981. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138982. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138983. */
  138984. set textureMode(value: number);
  138985. /**
  138986. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138987. */
  138988. get halfDome(): boolean;
  138989. /**
  138990. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138991. */
  138992. set halfDome(enabled: boolean);
  138993. /**
  138994. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  138995. */
  138996. set crossEye(enabled: boolean);
  138997. /**
  138998. * Is it a cross-eye texture?
  138999. */
  139000. get crossEye(): boolean;
  139001. /**
  139002. * The background material of this dome.
  139003. */
  139004. get material(): BackgroundMaterial;
  139005. /**
  139006. * Oberserver used in Stereoscopic VR Mode.
  139007. */
  139008. private _onBeforeCameraRenderObserver;
  139009. /**
  139010. * Observable raised when an error occured while loading the 360 image
  139011. */
  139012. onLoadErrorObservable: Observable<string>;
  139013. /**
  139014. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  139015. * @param name Element's name, child elements will append suffixes for their own names.
  139016. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  139017. * @param options An object containing optional or exposed sub element properties
  139018. */
  139019. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  139020. resolution?: number;
  139021. clickToPlay?: boolean;
  139022. autoPlay?: boolean;
  139023. loop?: boolean;
  139024. size?: number;
  139025. poster?: string;
  139026. faceForward?: boolean;
  139027. useDirectMapping?: boolean;
  139028. halfDomeMode?: boolean;
  139029. crossEyeMode?: boolean;
  139030. generateMipMaps?: boolean;
  139031. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  139032. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  139033. protected _changeTextureMode(value: number): void;
  139034. /**
  139035. * Releases resources associated with this node.
  139036. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  139037. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  139038. */
  139039. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  139040. }
  139041. }
  139042. declare module BABYLON {
  139043. /**
  139044. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  139045. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  139046. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139047. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139048. */
  139049. export class PhotoDome extends TextureDome<Texture> {
  139050. /**
  139051. * Define the image as a Monoscopic panoramic 360 image.
  139052. */
  139053. static readonly MODE_MONOSCOPIC: number;
  139054. /**
  139055. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  139056. */
  139057. static readonly MODE_TOPBOTTOM: number;
  139058. /**
  139059. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  139060. */
  139061. static readonly MODE_SIDEBYSIDE: number;
  139062. /**
  139063. * Gets or sets the texture being displayed on the sphere
  139064. */
  139065. get photoTexture(): Texture;
  139066. /**
  139067. * sets the texture being displayed on the sphere
  139068. */
  139069. set photoTexture(value: Texture);
  139070. /**
  139071. * Gets the current video mode for the video. It can be:
  139072. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139073. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139074. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139075. */
  139076. get imageMode(): number;
  139077. /**
  139078. * Sets the current video mode for the video. It can be:
  139079. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139080. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139081. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139082. */
  139083. set imageMode(value: number);
  139084. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139085. }
  139086. }
  139087. declare module BABYLON {
  139088. /**
  139089. * Direct draw surface info
  139090. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139091. */
  139092. export interface DDSInfo {
  139093. /**
  139094. * Width of the texture
  139095. */
  139096. width: number;
  139097. /**
  139098. * Width of the texture
  139099. */
  139100. height: number;
  139101. /**
  139102. * Number of Mipmaps for the texture
  139103. * @see https://en.wikipedia.org/wiki/Mipmap
  139104. */
  139105. mipmapCount: number;
  139106. /**
  139107. * If the textures format is a known fourCC format
  139108. * @see https://www.fourcc.org/
  139109. */
  139110. isFourCC: boolean;
  139111. /**
  139112. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139113. */
  139114. isRGB: boolean;
  139115. /**
  139116. * If the texture is a lumincance format
  139117. */
  139118. isLuminance: boolean;
  139119. /**
  139120. * If this is a cube texture
  139121. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139122. */
  139123. isCube: boolean;
  139124. /**
  139125. * If the texture is a compressed format eg. FOURCC_DXT1
  139126. */
  139127. isCompressed: boolean;
  139128. /**
  139129. * The dxgiFormat of the texture
  139130. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139131. */
  139132. dxgiFormat: number;
  139133. /**
  139134. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139135. */
  139136. textureType: number;
  139137. /**
  139138. * Sphericle polynomial created for the dds texture
  139139. */
  139140. sphericalPolynomial?: SphericalPolynomial;
  139141. }
  139142. /**
  139143. * Class used to provide DDS decompression tools
  139144. */
  139145. export class DDSTools {
  139146. /**
  139147. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139148. */
  139149. static StoreLODInAlphaChannel: boolean;
  139150. /**
  139151. * Gets DDS information from an array buffer
  139152. * @param data defines the array buffer view to read data from
  139153. * @returns the DDS information
  139154. */
  139155. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139156. private static _FloatView;
  139157. private static _Int32View;
  139158. private static _ToHalfFloat;
  139159. private static _FromHalfFloat;
  139160. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139161. private static _GetHalfFloatRGBAArrayBuffer;
  139162. private static _GetFloatRGBAArrayBuffer;
  139163. private static _GetFloatAsUIntRGBAArrayBuffer;
  139164. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139165. private static _GetRGBAArrayBuffer;
  139166. private static _ExtractLongWordOrder;
  139167. private static _GetRGBArrayBuffer;
  139168. private static _GetLuminanceArrayBuffer;
  139169. /**
  139170. * Uploads DDS Levels to a Babylon Texture
  139171. * @hidden
  139172. */
  139173. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139174. }
  139175. interface ThinEngine {
  139176. /**
  139177. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139178. * @param rootUrl defines the url where the file to load is located
  139179. * @param scene defines the current scene
  139180. * @param lodScale defines scale to apply to the mip map selection
  139181. * @param lodOffset defines offset to apply to the mip map selection
  139182. * @param onLoad defines an optional callback raised when the texture is loaded
  139183. * @param onError defines an optional callback raised if there is an issue to load the texture
  139184. * @param format defines the format of the data
  139185. * @param forcedExtension defines the extension to use to pick the right loader
  139186. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139187. * @returns the cube texture as an InternalTexture
  139188. */
  139189. 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;
  139190. }
  139191. }
  139192. declare module BABYLON {
  139193. /**
  139194. * Implementation of the DDS Texture Loader.
  139195. * @hidden
  139196. */
  139197. export class _DDSTextureLoader implements IInternalTextureLoader {
  139198. /**
  139199. * Defines wether the loader supports cascade loading the different faces.
  139200. */
  139201. readonly supportCascades: boolean;
  139202. /**
  139203. * This returns if the loader support the current file information.
  139204. * @param extension defines the file extension of the file being loaded
  139205. * @returns true if the loader can load the specified file
  139206. */
  139207. canLoad(extension: string): boolean;
  139208. /**
  139209. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139210. * @param data contains the texture data
  139211. * @param texture defines the BabylonJS internal texture
  139212. * @param createPolynomials will be true if polynomials have been requested
  139213. * @param onLoad defines the callback to trigger once the texture is ready
  139214. * @param onError defines the callback to trigger in case of error
  139215. */
  139216. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139217. /**
  139218. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139219. * @param data contains the texture data
  139220. * @param texture defines the BabylonJS internal texture
  139221. * @param callback defines the method to call once ready to upload
  139222. */
  139223. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139224. }
  139225. }
  139226. declare module BABYLON {
  139227. /**
  139228. * Implementation of the ENV Texture Loader.
  139229. * @hidden
  139230. */
  139231. export class _ENVTextureLoader implements IInternalTextureLoader {
  139232. /**
  139233. * Defines wether the loader supports cascade loading the different faces.
  139234. */
  139235. readonly supportCascades: boolean;
  139236. /**
  139237. * This returns if the loader support the current file information.
  139238. * @param extension defines the file extension of the file being loaded
  139239. * @returns true if the loader can load the specified file
  139240. */
  139241. canLoad(extension: string): boolean;
  139242. /**
  139243. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139244. * @param data contains the texture data
  139245. * @param texture defines the BabylonJS internal texture
  139246. * @param createPolynomials will be true if polynomials have been requested
  139247. * @param onLoad defines the callback to trigger once the texture is ready
  139248. * @param onError defines the callback to trigger in case of error
  139249. */
  139250. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139251. /**
  139252. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139253. * @param data contains the texture data
  139254. * @param texture defines the BabylonJS internal texture
  139255. * @param callback defines the method to call once ready to upload
  139256. */
  139257. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139258. }
  139259. }
  139260. declare module BABYLON {
  139261. /**
  139262. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139263. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139264. */
  139265. export class KhronosTextureContainer {
  139266. /** contents of the KTX container file */
  139267. data: ArrayBufferView;
  139268. private static HEADER_LEN;
  139269. private static COMPRESSED_2D;
  139270. private static COMPRESSED_3D;
  139271. private static TEX_2D;
  139272. private static TEX_3D;
  139273. /**
  139274. * Gets the openGL type
  139275. */
  139276. glType: number;
  139277. /**
  139278. * Gets the openGL type size
  139279. */
  139280. glTypeSize: number;
  139281. /**
  139282. * Gets the openGL format
  139283. */
  139284. glFormat: number;
  139285. /**
  139286. * Gets the openGL internal format
  139287. */
  139288. glInternalFormat: number;
  139289. /**
  139290. * Gets the base internal format
  139291. */
  139292. glBaseInternalFormat: number;
  139293. /**
  139294. * Gets image width in pixel
  139295. */
  139296. pixelWidth: number;
  139297. /**
  139298. * Gets image height in pixel
  139299. */
  139300. pixelHeight: number;
  139301. /**
  139302. * Gets image depth in pixels
  139303. */
  139304. pixelDepth: number;
  139305. /**
  139306. * Gets the number of array elements
  139307. */
  139308. numberOfArrayElements: number;
  139309. /**
  139310. * Gets the number of faces
  139311. */
  139312. numberOfFaces: number;
  139313. /**
  139314. * Gets the number of mipmap levels
  139315. */
  139316. numberOfMipmapLevels: number;
  139317. /**
  139318. * Gets the bytes of key value data
  139319. */
  139320. bytesOfKeyValueData: number;
  139321. /**
  139322. * Gets the load type
  139323. */
  139324. loadType: number;
  139325. /**
  139326. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139327. */
  139328. isInvalid: boolean;
  139329. /**
  139330. * Creates a new KhronosTextureContainer
  139331. * @param data contents of the KTX container file
  139332. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139333. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139334. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139335. */
  139336. constructor(
  139337. /** contents of the KTX container file */
  139338. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139339. /**
  139340. * Uploads KTX content to a Babylon Texture.
  139341. * It is assumed that the texture has already been created & is currently bound
  139342. * @hidden
  139343. */
  139344. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139345. private _upload2DCompressedLevels;
  139346. /**
  139347. * Checks if the given data starts with a KTX file identifier.
  139348. * @param data the data to check
  139349. * @returns true if the data is a KTX file or false otherwise
  139350. */
  139351. static IsValid(data: ArrayBufferView): boolean;
  139352. }
  139353. }
  139354. declare module BABYLON {
  139355. /**
  139356. * Helper class to push actions to a pool of workers.
  139357. */
  139358. export class WorkerPool implements IDisposable {
  139359. private _workerInfos;
  139360. private _pendingActions;
  139361. /**
  139362. * Constructor
  139363. * @param workers Array of workers to use for actions
  139364. */
  139365. constructor(workers: Array<Worker>);
  139366. /**
  139367. * Terminates all workers and clears any pending actions.
  139368. */
  139369. dispose(): void;
  139370. /**
  139371. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139372. * pended until a worker has completed its action.
  139373. * @param action The action to perform. Call onComplete when the action is complete.
  139374. */
  139375. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139376. private _execute;
  139377. }
  139378. }
  139379. declare module BABYLON {
  139380. /**
  139381. * Class for loading KTX2 files
  139382. */
  139383. export class KhronosTextureContainer2 {
  139384. private static _WorkerPoolPromise?;
  139385. private static _Initialized;
  139386. private static _Ktx2Decoder;
  139387. /**
  139388. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139389. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139390. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139391. * Urls you can change:
  139392. * URLConfig.jsDecoderModule
  139393. * URLConfig.wasmUASTCToASTC
  139394. * URLConfig.wasmUASTCToBC7
  139395. * URLConfig.jsMSCTranscoder
  139396. * URLConfig.wasmMSCTranscoder
  139397. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139398. */
  139399. static URLConfig: {
  139400. jsDecoderModule: string;
  139401. wasmUASTCToASTC: null;
  139402. wasmUASTCToBC7: null;
  139403. jsMSCTranscoder: null;
  139404. wasmMSCTranscoder: null;
  139405. };
  139406. /**
  139407. * Default number of workers used to handle data decoding
  139408. */
  139409. static DefaultNumWorkers: number;
  139410. private static GetDefaultNumWorkers;
  139411. private _engine;
  139412. private static _CreateWorkerPool;
  139413. /**
  139414. * Constructor
  139415. * @param engine The engine to use
  139416. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139417. */
  139418. constructor(engine: ThinEngine, numWorkers?: number);
  139419. /** @hidden */
  139420. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  139421. /**
  139422. * Stop all async operations and release resources.
  139423. */
  139424. dispose(): void;
  139425. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139426. /**
  139427. * Checks if the given data starts with a KTX2 file identifier.
  139428. * @param data the data to check
  139429. * @returns true if the data is a KTX2 file or false otherwise
  139430. */
  139431. static IsValid(data: ArrayBufferView): boolean;
  139432. }
  139433. }
  139434. declare module BABYLON {
  139435. /**
  139436. * Implementation of the KTX Texture Loader.
  139437. * @hidden
  139438. */
  139439. export class _KTXTextureLoader implements IInternalTextureLoader {
  139440. /**
  139441. * Defines wether the loader supports cascade loading the different faces.
  139442. */
  139443. readonly supportCascades: boolean;
  139444. /**
  139445. * This returns if the loader support the current file information.
  139446. * @param extension defines the file extension of the file being loaded
  139447. * @param mimeType defines the optional mime type of the file being loaded
  139448. * @returns true if the loader can load the specified file
  139449. */
  139450. canLoad(extension: string, mimeType?: string): boolean;
  139451. /**
  139452. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139453. * @param data contains the texture data
  139454. * @param texture defines the BabylonJS internal texture
  139455. * @param createPolynomials will be true if polynomials have been requested
  139456. * @param onLoad defines the callback to trigger once the texture is ready
  139457. * @param onError defines the callback to trigger in case of error
  139458. */
  139459. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139460. /**
  139461. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139462. * @param data contains the texture data
  139463. * @param texture defines the BabylonJS internal texture
  139464. * @param callback defines the method to call once ready to upload
  139465. */
  139466. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  139467. }
  139468. }
  139469. declare module BABYLON {
  139470. /** @hidden */
  139471. export var _forceSceneHelpersToBundle: boolean;
  139472. interface Scene {
  139473. /**
  139474. * Creates a default light for the scene.
  139475. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139476. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139477. */
  139478. createDefaultLight(replace?: boolean): void;
  139479. /**
  139480. * Creates a default camera for the scene.
  139481. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139482. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139483. * @param replace has default false, when true replaces the active camera in the scene
  139484. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139485. */
  139486. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139487. /**
  139488. * Creates a default camera and a default light.
  139489. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139490. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139491. * @param replace has the default false, when true replaces the active camera/light in the scene
  139492. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139493. */
  139494. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139495. /**
  139496. * Creates a new sky box
  139497. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139498. * @param environmentTexture defines the texture to use as environment texture
  139499. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139500. * @param scale defines the overall scale of the skybox
  139501. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139502. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139503. * @returns a new mesh holding the sky box
  139504. */
  139505. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139506. /**
  139507. * Creates a new environment
  139508. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139509. * @param options defines the options you can use to configure the environment
  139510. * @returns the new EnvironmentHelper
  139511. */
  139512. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139513. /**
  139514. * Creates a new VREXperienceHelper
  139515. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139516. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139517. * @returns a new VREXperienceHelper
  139518. */
  139519. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139520. /**
  139521. * Creates a new WebXRDefaultExperience
  139522. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139523. * @param options experience options
  139524. * @returns a promise for a new WebXRDefaultExperience
  139525. */
  139526. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139527. }
  139528. }
  139529. declare module BABYLON {
  139530. /**
  139531. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139532. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139533. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139534. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139535. */
  139536. export class VideoDome extends TextureDome<VideoTexture> {
  139537. /**
  139538. * Define the video source as a Monoscopic panoramic 360 video.
  139539. */
  139540. static readonly MODE_MONOSCOPIC: number;
  139541. /**
  139542. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139543. */
  139544. static readonly MODE_TOPBOTTOM: number;
  139545. /**
  139546. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139547. */
  139548. static readonly MODE_SIDEBYSIDE: number;
  139549. /**
  139550. * Get the video texture associated with this video dome
  139551. */
  139552. get videoTexture(): VideoTexture;
  139553. /**
  139554. * Get the video mode of this dome
  139555. */
  139556. get videoMode(): number;
  139557. /**
  139558. * Set the video mode of this dome.
  139559. * @see textureMode
  139560. */
  139561. set videoMode(value: number);
  139562. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139563. }
  139564. }
  139565. declare module BABYLON {
  139566. /**
  139567. * This class can be used to get instrumentation data from a Babylon engine
  139568. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139569. */
  139570. export class EngineInstrumentation implements IDisposable {
  139571. /**
  139572. * Define the instrumented engine.
  139573. */
  139574. engine: Engine;
  139575. private _captureGPUFrameTime;
  139576. private _gpuFrameTimeToken;
  139577. private _gpuFrameTime;
  139578. private _captureShaderCompilationTime;
  139579. private _shaderCompilationTime;
  139580. private _onBeginFrameObserver;
  139581. private _onEndFrameObserver;
  139582. private _onBeforeShaderCompilationObserver;
  139583. private _onAfterShaderCompilationObserver;
  139584. /**
  139585. * Gets the perf counter used for GPU frame time
  139586. */
  139587. get gpuFrameTimeCounter(): PerfCounter;
  139588. /**
  139589. * Gets the GPU frame time capture status
  139590. */
  139591. get captureGPUFrameTime(): boolean;
  139592. /**
  139593. * Enable or disable the GPU frame time capture
  139594. */
  139595. set captureGPUFrameTime(value: boolean);
  139596. /**
  139597. * Gets the perf counter used for shader compilation time
  139598. */
  139599. get shaderCompilationTimeCounter(): PerfCounter;
  139600. /**
  139601. * Gets the shader compilation time capture status
  139602. */
  139603. get captureShaderCompilationTime(): boolean;
  139604. /**
  139605. * Enable or disable the shader compilation time capture
  139606. */
  139607. set captureShaderCompilationTime(value: boolean);
  139608. /**
  139609. * Instantiates a new engine instrumentation.
  139610. * This class can be used to get instrumentation data from a Babylon engine
  139611. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139612. * @param engine Defines the engine to instrument
  139613. */
  139614. constructor(
  139615. /**
  139616. * Define the instrumented engine.
  139617. */
  139618. engine: Engine);
  139619. /**
  139620. * Dispose and release associated resources.
  139621. */
  139622. dispose(): void;
  139623. }
  139624. }
  139625. declare module BABYLON {
  139626. /**
  139627. * This class can be used to get instrumentation data from a Babylon engine
  139628. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139629. */
  139630. export class SceneInstrumentation implements IDisposable {
  139631. /**
  139632. * Defines the scene to instrument
  139633. */
  139634. scene: Scene;
  139635. private _captureActiveMeshesEvaluationTime;
  139636. private _activeMeshesEvaluationTime;
  139637. private _captureRenderTargetsRenderTime;
  139638. private _renderTargetsRenderTime;
  139639. private _captureFrameTime;
  139640. private _frameTime;
  139641. private _captureRenderTime;
  139642. private _renderTime;
  139643. private _captureInterFrameTime;
  139644. private _interFrameTime;
  139645. private _captureParticlesRenderTime;
  139646. private _particlesRenderTime;
  139647. private _captureSpritesRenderTime;
  139648. private _spritesRenderTime;
  139649. private _capturePhysicsTime;
  139650. private _physicsTime;
  139651. private _captureAnimationsTime;
  139652. private _animationsTime;
  139653. private _captureCameraRenderTime;
  139654. private _cameraRenderTime;
  139655. private _onBeforeActiveMeshesEvaluationObserver;
  139656. private _onAfterActiveMeshesEvaluationObserver;
  139657. private _onBeforeRenderTargetsRenderObserver;
  139658. private _onAfterRenderTargetsRenderObserver;
  139659. private _onAfterRenderObserver;
  139660. private _onBeforeDrawPhaseObserver;
  139661. private _onAfterDrawPhaseObserver;
  139662. private _onBeforeAnimationsObserver;
  139663. private _onBeforeParticlesRenderingObserver;
  139664. private _onAfterParticlesRenderingObserver;
  139665. private _onBeforeSpritesRenderingObserver;
  139666. private _onAfterSpritesRenderingObserver;
  139667. private _onBeforePhysicsObserver;
  139668. private _onAfterPhysicsObserver;
  139669. private _onAfterAnimationsObserver;
  139670. private _onBeforeCameraRenderObserver;
  139671. private _onAfterCameraRenderObserver;
  139672. /**
  139673. * Gets the perf counter used for active meshes evaluation time
  139674. */
  139675. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139676. /**
  139677. * Gets the active meshes evaluation time capture status
  139678. */
  139679. get captureActiveMeshesEvaluationTime(): boolean;
  139680. /**
  139681. * Enable or disable the active meshes evaluation time capture
  139682. */
  139683. set captureActiveMeshesEvaluationTime(value: boolean);
  139684. /**
  139685. * Gets the perf counter used for render targets render time
  139686. */
  139687. get renderTargetsRenderTimeCounter(): PerfCounter;
  139688. /**
  139689. * Gets the render targets render time capture status
  139690. */
  139691. get captureRenderTargetsRenderTime(): boolean;
  139692. /**
  139693. * Enable or disable the render targets render time capture
  139694. */
  139695. set captureRenderTargetsRenderTime(value: boolean);
  139696. /**
  139697. * Gets the perf counter used for particles render time
  139698. */
  139699. get particlesRenderTimeCounter(): PerfCounter;
  139700. /**
  139701. * Gets the particles render time capture status
  139702. */
  139703. get captureParticlesRenderTime(): boolean;
  139704. /**
  139705. * Enable or disable the particles render time capture
  139706. */
  139707. set captureParticlesRenderTime(value: boolean);
  139708. /**
  139709. * Gets the perf counter used for sprites render time
  139710. */
  139711. get spritesRenderTimeCounter(): PerfCounter;
  139712. /**
  139713. * Gets the sprites render time capture status
  139714. */
  139715. get captureSpritesRenderTime(): boolean;
  139716. /**
  139717. * Enable or disable the sprites render time capture
  139718. */
  139719. set captureSpritesRenderTime(value: boolean);
  139720. /**
  139721. * Gets the perf counter used for physics time
  139722. */
  139723. get physicsTimeCounter(): PerfCounter;
  139724. /**
  139725. * Gets the physics time capture status
  139726. */
  139727. get capturePhysicsTime(): boolean;
  139728. /**
  139729. * Enable or disable the physics time capture
  139730. */
  139731. set capturePhysicsTime(value: boolean);
  139732. /**
  139733. * Gets the perf counter used for animations time
  139734. */
  139735. get animationsTimeCounter(): PerfCounter;
  139736. /**
  139737. * Gets the animations time capture status
  139738. */
  139739. get captureAnimationsTime(): boolean;
  139740. /**
  139741. * Enable or disable the animations time capture
  139742. */
  139743. set captureAnimationsTime(value: boolean);
  139744. /**
  139745. * Gets the perf counter used for frame time capture
  139746. */
  139747. get frameTimeCounter(): PerfCounter;
  139748. /**
  139749. * Gets the frame time capture status
  139750. */
  139751. get captureFrameTime(): boolean;
  139752. /**
  139753. * Enable or disable the frame time capture
  139754. */
  139755. set captureFrameTime(value: boolean);
  139756. /**
  139757. * Gets the perf counter used for inter-frames time capture
  139758. */
  139759. get interFrameTimeCounter(): PerfCounter;
  139760. /**
  139761. * Gets the inter-frames time capture status
  139762. */
  139763. get captureInterFrameTime(): boolean;
  139764. /**
  139765. * Enable or disable the inter-frames time capture
  139766. */
  139767. set captureInterFrameTime(value: boolean);
  139768. /**
  139769. * Gets the perf counter used for render time capture
  139770. */
  139771. get renderTimeCounter(): PerfCounter;
  139772. /**
  139773. * Gets the render time capture status
  139774. */
  139775. get captureRenderTime(): boolean;
  139776. /**
  139777. * Enable or disable the render time capture
  139778. */
  139779. set captureRenderTime(value: boolean);
  139780. /**
  139781. * Gets the perf counter used for camera render time capture
  139782. */
  139783. get cameraRenderTimeCounter(): PerfCounter;
  139784. /**
  139785. * Gets the camera render time capture status
  139786. */
  139787. get captureCameraRenderTime(): boolean;
  139788. /**
  139789. * Enable or disable the camera render time capture
  139790. */
  139791. set captureCameraRenderTime(value: boolean);
  139792. /**
  139793. * Gets the perf counter used for draw calls
  139794. */
  139795. get drawCallsCounter(): PerfCounter;
  139796. /**
  139797. * Instantiates a new scene instrumentation.
  139798. * This class can be used to get instrumentation data from a Babylon engine
  139799. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139800. * @param scene Defines the scene to instrument
  139801. */
  139802. constructor(
  139803. /**
  139804. * Defines the scene to instrument
  139805. */
  139806. scene: Scene);
  139807. /**
  139808. * Dispose and release associated resources.
  139809. */
  139810. dispose(): void;
  139811. }
  139812. }
  139813. declare module BABYLON {
  139814. /** @hidden */
  139815. export var glowMapGenerationPixelShader: {
  139816. name: string;
  139817. shader: string;
  139818. };
  139819. }
  139820. declare module BABYLON {
  139821. /** @hidden */
  139822. export var glowMapGenerationVertexShader: {
  139823. name: string;
  139824. shader: string;
  139825. };
  139826. }
  139827. declare module BABYLON {
  139828. /**
  139829. * Effect layer options. This helps customizing the behaviour
  139830. * of the effect layer.
  139831. */
  139832. export interface IEffectLayerOptions {
  139833. /**
  139834. * Multiplication factor apply to the canvas size to compute the render target size
  139835. * used to generated the objects (the smaller the faster).
  139836. */
  139837. mainTextureRatio: number;
  139838. /**
  139839. * Enforces a fixed size texture to ensure effect stability across devices.
  139840. */
  139841. mainTextureFixedSize?: number;
  139842. /**
  139843. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139844. */
  139845. alphaBlendingMode: number;
  139846. /**
  139847. * The camera attached to the layer.
  139848. */
  139849. camera: Nullable<Camera>;
  139850. /**
  139851. * The rendering group to draw the layer in.
  139852. */
  139853. renderingGroupId: number;
  139854. }
  139855. /**
  139856. * The effect layer Helps adding post process effect blended with the main pass.
  139857. *
  139858. * This can be for instance use to generate glow or higlight effects on the scene.
  139859. *
  139860. * The effect layer class can not be used directly and is intented to inherited from to be
  139861. * customized per effects.
  139862. */
  139863. export abstract class EffectLayer {
  139864. private _vertexBuffers;
  139865. private _indexBuffer;
  139866. private _cachedDefines;
  139867. private _effectLayerMapGenerationEffect;
  139868. private _effectLayerOptions;
  139869. private _mergeEffect;
  139870. protected _scene: Scene;
  139871. protected _engine: Engine;
  139872. protected _maxSize: number;
  139873. protected _mainTextureDesiredSize: ISize;
  139874. protected _mainTexture: RenderTargetTexture;
  139875. protected _shouldRender: boolean;
  139876. protected _postProcesses: PostProcess[];
  139877. protected _textures: BaseTexture[];
  139878. protected _emissiveTextureAndColor: {
  139879. texture: Nullable<BaseTexture>;
  139880. color: Color4;
  139881. };
  139882. /**
  139883. * The name of the layer
  139884. */
  139885. name: string;
  139886. /**
  139887. * The clear color of the texture used to generate the glow map.
  139888. */
  139889. neutralColor: Color4;
  139890. /**
  139891. * Specifies whether the highlight layer is enabled or not.
  139892. */
  139893. isEnabled: boolean;
  139894. /**
  139895. * Gets the camera attached to the layer.
  139896. */
  139897. get camera(): Nullable<Camera>;
  139898. /**
  139899. * Gets the rendering group id the layer should render in.
  139900. */
  139901. get renderingGroupId(): number;
  139902. set renderingGroupId(renderingGroupId: number);
  139903. /**
  139904. * An event triggered when the effect layer has been disposed.
  139905. */
  139906. onDisposeObservable: Observable<EffectLayer>;
  139907. /**
  139908. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139909. */
  139910. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139911. /**
  139912. * An event triggered when the generated texture is being merged in the scene.
  139913. */
  139914. onBeforeComposeObservable: Observable<EffectLayer>;
  139915. /**
  139916. * An event triggered when the mesh is rendered into the effect render target.
  139917. */
  139918. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139919. /**
  139920. * An event triggered after the mesh has been rendered into the effect render target.
  139921. */
  139922. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139923. /**
  139924. * An event triggered when the generated texture has been merged in the scene.
  139925. */
  139926. onAfterComposeObservable: Observable<EffectLayer>;
  139927. /**
  139928. * An event triggered when the efffect layer changes its size.
  139929. */
  139930. onSizeChangedObservable: Observable<EffectLayer>;
  139931. /** @hidden */
  139932. static _SceneComponentInitialization: (scene: Scene) => void;
  139933. /**
  139934. * Instantiates a new effect Layer and references it in the scene.
  139935. * @param name The name of the layer
  139936. * @param scene The scene to use the layer in
  139937. */
  139938. constructor(
  139939. /** The Friendly of the effect in the scene */
  139940. name: string, scene: Scene);
  139941. /**
  139942. * Get the effect name of the layer.
  139943. * @return The effect name
  139944. */
  139945. abstract getEffectName(): string;
  139946. /**
  139947. * Checks for the readiness of the element composing the layer.
  139948. * @param subMesh the mesh to check for
  139949. * @param useInstances specify whether or not to use instances to render the mesh
  139950. * @return true if ready otherwise, false
  139951. */
  139952. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139953. /**
  139954. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139955. * @returns true if the effect requires stencil during the main canvas render pass.
  139956. */
  139957. abstract needStencil(): boolean;
  139958. /**
  139959. * Create the merge effect. This is the shader use to blit the information back
  139960. * to the main canvas at the end of the scene rendering.
  139961. * @returns The effect containing the shader used to merge the effect on the main canvas
  139962. */
  139963. protected abstract _createMergeEffect(): Effect;
  139964. /**
  139965. * Creates the render target textures and post processes used in the effect layer.
  139966. */
  139967. protected abstract _createTextureAndPostProcesses(): void;
  139968. /**
  139969. * Implementation specific of rendering the generating effect on the main canvas.
  139970. * @param effect The effect used to render through
  139971. */
  139972. protected abstract _internalRender(effect: Effect): void;
  139973. /**
  139974. * Sets the required values for both the emissive texture and and the main color.
  139975. */
  139976. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139977. /**
  139978. * Free any resources and references associated to a mesh.
  139979. * Internal use
  139980. * @param mesh The mesh to free.
  139981. */
  139982. abstract _disposeMesh(mesh: Mesh): void;
  139983. /**
  139984. * Serializes this layer (Glow or Highlight for example)
  139985. * @returns a serialized layer object
  139986. */
  139987. abstract serialize?(): any;
  139988. /**
  139989. * Initializes the effect layer with the required options.
  139990. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139991. */
  139992. protected _init(options: Partial<IEffectLayerOptions>): void;
  139993. /**
  139994. * Generates the index buffer of the full screen quad blending to the main canvas.
  139995. */
  139996. private _generateIndexBuffer;
  139997. /**
  139998. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139999. */
  140000. private _generateVertexBuffer;
  140001. /**
  140002. * Sets the main texture desired size which is the closest power of two
  140003. * of the engine canvas size.
  140004. */
  140005. private _setMainTextureSize;
  140006. /**
  140007. * Creates the main texture for the effect layer.
  140008. */
  140009. protected _createMainTexture(): void;
  140010. /**
  140011. * Adds specific effects defines.
  140012. * @param defines The defines to add specifics to.
  140013. */
  140014. protected _addCustomEffectDefines(defines: string[]): void;
  140015. /**
  140016. * Checks for the readiness of the element composing the layer.
  140017. * @param subMesh the mesh to check for
  140018. * @param useInstances specify whether or not to use instances to render the mesh
  140019. * @param emissiveTexture the associated emissive texture used to generate the glow
  140020. * @return true if ready otherwise, false
  140021. */
  140022. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  140023. /**
  140024. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  140025. */
  140026. render(): void;
  140027. /**
  140028. * Determine if a given mesh will be used in the current effect.
  140029. * @param mesh mesh to test
  140030. * @returns true if the mesh will be used
  140031. */
  140032. hasMesh(mesh: AbstractMesh): boolean;
  140033. /**
  140034. * Returns true if the layer contains information to display, otherwise false.
  140035. * @returns true if the glow layer should be rendered
  140036. */
  140037. shouldRender(): boolean;
  140038. /**
  140039. * Returns true if the mesh should render, otherwise false.
  140040. * @param mesh The mesh to render
  140041. * @returns true if it should render otherwise false
  140042. */
  140043. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  140044. /**
  140045. * Returns true if the mesh can be rendered, otherwise false.
  140046. * @param mesh The mesh to render
  140047. * @param material The material used on the mesh
  140048. * @returns true if it can be rendered otherwise false
  140049. */
  140050. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140051. /**
  140052. * Returns true if the mesh should render, otherwise false.
  140053. * @param mesh The mesh to render
  140054. * @returns true if it should render otherwise false
  140055. */
  140056. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  140057. /**
  140058. * Renders the submesh passed in parameter to the generation map.
  140059. */
  140060. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  140061. /**
  140062. * Defines whether the current material of the mesh should be use to render the effect.
  140063. * @param mesh defines the current mesh to render
  140064. */
  140065. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140066. /**
  140067. * Rebuild the required buffers.
  140068. * @hidden Internal use only.
  140069. */
  140070. _rebuild(): void;
  140071. /**
  140072. * Dispose only the render target textures and post process.
  140073. */
  140074. private _disposeTextureAndPostProcesses;
  140075. /**
  140076. * Dispose the highlight layer and free resources.
  140077. */
  140078. dispose(): void;
  140079. /**
  140080. * Gets the class name of the effect layer
  140081. * @returns the string with the class name of the effect layer
  140082. */
  140083. getClassName(): string;
  140084. /**
  140085. * Creates an effect layer from parsed effect layer data
  140086. * @param parsedEffectLayer defines effect layer data
  140087. * @param scene defines the current scene
  140088. * @param rootUrl defines the root URL containing the effect layer information
  140089. * @returns a parsed effect Layer
  140090. */
  140091. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140092. }
  140093. }
  140094. declare module BABYLON {
  140095. interface AbstractScene {
  140096. /**
  140097. * The list of effect layers (highlights/glow) added to the scene
  140098. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140099. * @see https://doc.babylonjs.com/how_to/glow_layer
  140100. */
  140101. effectLayers: Array<EffectLayer>;
  140102. /**
  140103. * Removes the given effect layer from this scene.
  140104. * @param toRemove defines the effect layer to remove
  140105. * @returns the index of the removed effect layer
  140106. */
  140107. removeEffectLayer(toRemove: EffectLayer): number;
  140108. /**
  140109. * Adds the given effect layer to this scene
  140110. * @param newEffectLayer defines the effect layer to add
  140111. */
  140112. addEffectLayer(newEffectLayer: EffectLayer): void;
  140113. }
  140114. /**
  140115. * Defines the layer scene component responsible to manage any effect layers
  140116. * in a given scene.
  140117. */
  140118. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140119. /**
  140120. * The component name helpfull to identify the component in the list of scene components.
  140121. */
  140122. readonly name: string;
  140123. /**
  140124. * The scene the component belongs to.
  140125. */
  140126. scene: Scene;
  140127. private _engine;
  140128. private _renderEffects;
  140129. private _needStencil;
  140130. private _previousStencilState;
  140131. /**
  140132. * Creates a new instance of the component for the given scene
  140133. * @param scene Defines the scene to register the component in
  140134. */
  140135. constructor(scene: Scene);
  140136. /**
  140137. * Registers the component in a given scene
  140138. */
  140139. register(): void;
  140140. /**
  140141. * Rebuilds the elements related to this component in case of
  140142. * context lost for instance.
  140143. */
  140144. rebuild(): void;
  140145. /**
  140146. * Serializes the component data to the specified json object
  140147. * @param serializationObject The object to serialize to
  140148. */
  140149. serialize(serializationObject: any): void;
  140150. /**
  140151. * Adds all the elements from the container to the scene
  140152. * @param container the container holding the elements
  140153. */
  140154. addFromContainer(container: AbstractScene): void;
  140155. /**
  140156. * Removes all the elements in the container from the scene
  140157. * @param container contains the elements to remove
  140158. * @param dispose if the removed element should be disposed (default: false)
  140159. */
  140160. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140161. /**
  140162. * Disposes the component and the associated ressources.
  140163. */
  140164. dispose(): void;
  140165. private _isReadyForMesh;
  140166. private _renderMainTexture;
  140167. private _setStencil;
  140168. private _setStencilBack;
  140169. private _draw;
  140170. private _drawCamera;
  140171. private _drawRenderingGroup;
  140172. }
  140173. }
  140174. declare module BABYLON {
  140175. /** @hidden */
  140176. export var glowMapMergePixelShader: {
  140177. name: string;
  140178. shader: string;
  140179. };
  140180. }
  140181. declare module BABYLON {
  140182. /** @hidden */
  140183. export var glowMapMergeVertexShader: {
  140184. name: string;
  140185. shader: string;
  140186. };
  140187. }
  140188. declare module BABYLON {
  140189. interface AbstractScene {
  140190. /**
  140191. * Return a the first highlight layer of the scene with a given name.
  140192. * @param name The name of the highlight layer to look for.
  140193. * @return The highlight layer if found otherwise null.
  140194. */
  140195. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140196. }
  140197. /**
  140198. * Glow layer options. This helps customizing the behaviour
  140199. * of the glow layer.
  140200. */
  140201. export interface IGlowLayerOptions {
  140202. /**
  140203. * Multiplication factor apply to the canvas size to compute the render target size
  140204. * used to generated the glowing objects (the smaller the faster).
  140205. */
  140206. mainTextureRatio: number;
  140207. /**
  140208. * Enforces a fixed size texture to ensure resize independant blur.
  140209. */
  140210. mainTextureFixedSize?: number;
  140211. /**
  140212. * How big is the kernel of the blur texture.
  140213. */
  140214. blurKernelSize: number;
  140215. /**
  140216. * The camera attached to the layer.
  140217. */
  140218. camera: Nullable<Camera>;
  140219. /**
  140220. * Enable MSAA by chosing the number of samples.
  140221. */
  140222. mainTextureSamples?: number;
  140223. /**
  140224. * The rendering group to draw the layer in.
  140225. */
  140226. renderingGroupId: number;
  140227. }
  140228. /**
  140229. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140230. *
  140231. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140232. *
  140233. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140234. */
  140235. export class GlowLayer extends EffectLayer {
  140236. /**
  140237. * Effect Name of the layer.
  140238. */
  140239. static readonly EffectName: string;
  140240. /**
  140241. * The default blur kernel size used for the glow.
  140242. */
  140243. static DefaultBlurKernelSize: number;
  140244. /**
  140245. * The default texture size ratio used for the glow.
  140246. */
  140247. static DefaultTextureRatio: number;
  140248. /**
  140249. * Sets the kernel size of the blur.
  140250. */
  140251. set blurKernelSize(value: number);
  140252. /**
  140253. * Gets the kernel size of the blur.
  140254. */
  140255. get blurKernelSize(): number;
  140256. /**
  140257. * Sets the glow intensity.
  140258. */
  140259. set intensity(value: number);
  140260. /**
  140261. * Gets the glow intensity.
  140262. */
  140263. get intensity(): number;
  140264. private _options;
  140265. private _intensity;
  140266. private _horizontalBlurPostprocess1;
  140267. private _verticalBlurPostprocess1;
  140268. private _horizontalBlurPostprocess2;
  140269. private _verticalBlurPostprocess2;
  140270. private _blurTexture1;
  140271. private _blurTexture2;
  140272. private _postProcesses1;
  140273. private _postProcesses2;
  140274. private _includedOnlyMeshes;
  140275. private _excludedMeshes;
  140276. private _meshesUsingTheirOwnMaterials;
  140277. /**
  140278. * Callback used to let the user override the color selection on a per mesh basis
  140279. */
  140280. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140281. /**
  140282. * Callback used to let the user override the texture selection on a per mesh basis
  140283. */
  140284. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140285. /**
  140286. * Instantiates a new glow Layer and references it to the scene.
  140287. * @param name The name of the layer
  140288. * @param scene The scene to use the layer in
  140289. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140290. */
  140291. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140292. /**
  140293. * Get the effect name of the layer.
  140294. * @return The effect name
  140295. */
  140296. getEffectName(): string;
  140297. /**
  140298. * Create the merge effect. This is the shader use to blit the information back
  140299. * to the main canvas at the end of the scene rendering.
  140300. */
  140301. protected _createMergeEffect(): Effect;
  140302. /**
  140303. * Creates the render target textures and post processes used in the glow layer.
  140304. */
  140305. protected _createTextureAndPostProcesses(): void;
  140306. /**
  140307. * Checks for the readiness of the element composing the layer.
  140308. * @param subMesh the mesh to check for
  140309. * @param useInstances specify wether or not to use instances to render the mesh
  140310. * @param emissiveTexture the associated emissive texture used to generate the glow
  140311. * @return true if ready otherwise, false
  140312. */
  140313. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140314. /**
  140315. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140316. */
  140317. needStencil(): boolean;
  140318. /**
  140319. * Returns true if the mesh can be rendered, otherwise false.
  140320. * @param mesh The mesh to render
  140321. * @param material The material used on the mesh
  140322. * @returns true if it can be rendered otherwise false
  140323. */
  140324. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140325. /**
  140326. * Implementation specific of rendering the generating effect on the main canvas.
  140327. * @param effect The effect used to render through
  140328. */
  140329. protected _internalRender(effect: Effect): void;
  140330. /**
  140331. * Sets the required values for both the emissive texture and and the main color.
  140332. */
  140333. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140334. /**
  140335. * Returns true if the mesh should render, otherwise false.
  140336. * @param mesh The mesh to render
  140337. * @returns true if it should render otherwise false
  140338. */
  140339. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140340. /**
  140341. * Adds specific effects defines.
  140342. * @param defines The defines to add specifics to.
  140343. */
  140344. protected _addCustomEffectDefines(defines: string[]): void;
  140345. /**
  140346. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140347. * @param mesh The mesh to exclude from the glow layer
  140348. */
  140349. addExcludedMesh(mesh: Mesh): void;
  140350. /**
  140351. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140352. * @param mesh The mesh to remove
  140353. */
  140354. removeExcludedMesh(mesh: Mesh): void;
  140355. /**
  140356. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140357. * @param mesh The mesh to include in the glow layer
  140358. */
  140359. addIncludedOnlyMesh(mesh: Mesh): void;
  140360. /**
  140361. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140362. * @param mesh The mesh to remove
  140363. */
  140364. removeIncludedOnlyMesh(mesh: Mesh): void;
  140365. /**
  140366. * Determine if a given mesh will be used in the glow layer
  140367. * @param mesh The mesh to test
  140368. * @returns true if the mesh will be highlighted by the current glow layer
  140369. */
  140370. hasMesh(mesh: AbstractMesh): boolean;
  140371. /**
  140372. * Defines whether the current material of the mesh should be use to render the effect.
  140373. * @param mesh defines the current mesh to render
  140374. */
  140375. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140376. /**
  140377. * Add a mesh to be rendered through its own material and not with emissive only.
  140378. * @param mesh The mesh for which we need to use its material
  140379. */
  140380. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140381. /**
  140382. * Remove a mesh from being rendered through its own material and not with emissive only.
  140383. * @param mesh The mesh for which we need to not use its material
  140384. */
  140385. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140386. /**
  140387. * Free any resources and references associated to a mesh.
  140388. * Internal use
  140389. * @param mesh The mesh to free.
  140390. * @hidden
  140391. */
  140392. _disposeMesh(mesh: Mesh): void;
  140393. /**
  140394. * Gets the class name of the effect layer
  140395. * @returns the string with the class name of the effect layer
  140396. */
  140397. getClassName(): string;
  140398. /**
  140399. * Serializes this glow layer
  140400. * @returns a serialized glow layer object
  140401. */
  140402. serialize(): any;
  140403. /**
  140404. * Creates a Glow Layer from parsed glow layer data
  140405. * @param parsedGlowLayer defines glow layer data
  140406. * @param scene defines the current scene
  140407. * @param rootUrl defines the root URL containing the glow layer information
  140408. * @returns a parsed Glow Layer
  140409. */
  140410. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140411. }
  140412. }
  140413. declare module BABYLON {
  140414. /** @hidden */
  140415. export var glowBlurPostProcessPixelShader: {
  140416. name: string;
  140417. shader: string;
  140418. };
  140419. }
  140420. declare module BABYLON {
  140421. interface AbstractScene {
  140422. /**
  140423. * Return a the first highlight layer of the scene with a given name.
  140424. * @param name The name of the highlight layer to look for.
  140425. * @return The highlight layer if found otherwise null.
  140426. */
  140427. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140428. }
  140429. /**
  140430. * Highlight layer options. This helps customizing the behaviour
  140431. * of the highlight layer.
  140432. */
  140433. export interface IHighlightLayerOptions {
  140434. /**
  140435. * Multiplication factor apply to the canvas size to compute the render target size
  140436. * used to generated the glowing objects (the smaller the faster).
  140437. */
  140438. mainTextureRatio: number;
  140439. /**
  140440. * Enforces a fixed size texture to ensure resize independant blur.
  140441. */
  140442. mainTextureFixedSize?: number;
  140443. /**
  140444. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140445. * of the picture to blur (the smaller the faster).
  140446. */
  140447. blurTextureSizeRatio: number;
  140448. /**
  140449. * How big in texel of the blur texture is the vertical blur.
  140450. */
  140451. blurVerticalSize: number;
  140452. /**
  140453. * How big in texel of the blur texture is the horizontal blur.
  140454. */
  140455. blurHorizontalSize: number;
  140456. /**
  140457. * Alpha blending mode used to apply the blur. Default is combine.
  140458. */
  140459. alphaBlendingMode: number;
  140460. /**
  140461. * The camera attached to the layer.
  140462. */
  140463. camera: Nullable<Camera>;
  140464. /**
  140465. * Should we display highlight as a solid stroke?
  140466. */
  140467. isStroke?: boolean;
  140468. /**
  140469. * The rendering group to draw the layer in.
  140470. */
  140471. renderingGroupId: number;
  140472. }
  140473. /**
  140474. * The highlight layer Helps adding a glow effect around a mesh.
  140475. *
  140476. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140477. * glowy meshes to your scene.
  140478. *
  140479. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140480. */
  140481. export class HighlightLayer extends EffectLayer {
  140482. name: string;
  140483. /**
  140484. * Effect Name of the highlight layer.
  140485. */
  140486. static readonly EffectName: string;
  140487. /**
  140488. * The neutral color used during the preparation of the glow effect.
  140489. * This is black by default as the blend operation is a blend operation.
  140490. */
  140491. static NeutralColor: Color4;
  140492. /**
  140493. * Stencil value used for glowing meshes.
  140494. */
  140495. static GlowingMeshStencilReference: number;
  140496. /**
  140497. * Stencil value used for the other meshes in the scene.
  140498. */
  140499. static NormalMeshStencilReference: number;
  140500. /**
  140501. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140502. */
  140503. innerGlow: boolean;
  140504. /**
  140505. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140506. */
  140507. outerGlow: boolean;
  140508. /**
  140509. * Specifies the horizontal size of the blur.
  140510. */
  140511. set blurHorizontalSize(value: number);
  140512. /**
  140513. * Specifies the vertical size of the blur.
  140514. */
  140515. set blurVerticalSize(value: number);
  140516. /**
  140517. * Gets the horizontal size of the blur.
  140518. */
  140519. get blurHorizontalSize(): number;
  140520. /**
  140521. * Gets the vertical size of the blur.
  140522. */
  140523. get blurVerticalSize(): number;
  140524. /**
  140525. * An event triggered when the highlight layer is being blurred.
  140526. */
  140527. onBeforeBlurObservable: Observable<HighlightLayer>;
  140528. /**
  140529. * An event triggered when the highlight layer has been blurred.
  140530. */
  140531. onAfterBlurObservable: Observable<HighlightLayer>;
  140532. private _instanceGlowingMeshStencilReference;
  140533. private _options;
  140534. private _downSamplePostprocess;
  140535. private _horizontalBlurPostprocess;
  140536. private _verticalBlurPostprocess;
  140537. private _blurTexture;
  140538. private _meshes;
  140539. private _excludedMeshes;
  140540. /**
  140541. * Instantiates a new highlight Layer and references it to the scene..
  140542. * @param name The name of the layer
  140543. * @param scene The scene to use the layer in
  140544. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140545. */
  140546. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140547. /**
  140548. * Get the effect name of the layer.
  140549. * @return The effect name
  140550. */
  140551. getEffectName(): string;
  140552. /**
  140553. * Create the merge effect. This is the shader use to blit the information back
  140554. * to the main canvas at the end of the scene rendering.
  140555. */
  140556. protected _createMergeEffect(): Effect;
  140557. /**
  140558. * Creates the render target textures and post processes used in the highlight layer.
  140559. */
  140560. protected _createTextureAndPostProcesses(): void;
  140561. /**
  140562. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140563. */
  140564. needStencil(): boolean;
  140565. /**
  140566. * Checks for the readiness of the element composing the layer.
  140567. * @param subMesh the mesh to check for
  140568. * @param useInstances specify wether or not to use instances to render the mesh
  140569. * @param emissiveTexture the associated emissive texture used to generate the glow
  140570. * @return true if ready otherwise, false
  140571. */
  140572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140573. /**
  140574. * Implementation specific of rendering the generating effect on the main canvas.
  140575. * @param effect The effect used to render through
  140576. */
  140577. protected _internalRender(effect: Effect): void;
  140578. /**
  140579. * Returns true if the layer contains information to display, otherwise false.
  140580. */
  140581. shouldRender(): boolean;
  140582. /**
  140583. * Returns true if the mesh should render, otherwise false.
  140584. * @param mesh The mesh to render
  140585. * @returns true if it should render otherwise false
  140586. */
  140587. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140588. /**
  140589. * Returns true if the mesh can be rendered, otherwise false.
  140590. * @param mesh The mesh to render
  140591. * @param material The material used on the mesh
  140592. * @returns true if it can be rendered otherwise false
  140593. */
  140594. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140595. /**
  140596. * Adds specific effects defines.
  140597. * @param defines The defines to add specifics to.
  140598. */
  140599. protected _addCustomEffectDefines(defines: string[]): void;
  140600. /**
  140601. * Sets the required values for both the emissive texture and and the main color.
  140602. */
  140603. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140604. /**
  140605. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140606. * @param mesh The mesh to exclude from the highlight layer
  140607. */
  140608. addExcludedMesh(mesh: Mesh): void;
  140609. /**
  140610. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140611. * @param mesh The mesh to highlight
  140612. */
  140613. removeExcludedMesh(mesh: Mesh): void;
  140614. /**
  140615. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140616. * @param mesh mesh to test
  140617. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140618. */
  140619. hasMesh(mesh: AbstractMesh): boolean;
  140620. /**
  140621. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140622. * @param mesh The mesh to highlight
  140623. * @param color The color of the highlight
  140624. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140625. */
  140626. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140627. /**
  140628. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140629. * @param mesh The mesh to highlight
  140630. */
  140631. removeMesh(mesh: Mesh): void;
  140632. /**
  140633. * Remove all the meshes currently referenced in the highlight layer
  140634. */
  140635. removeAllMeshes(): void;
  140636. /**
  140637. * Force the stencil to the normal expected value for none glowing parts
  140638. */
  140639. private _defaultStencilReference;
  140640. /**
  140641. * Free any resources and references associated to a mesh.
  140642. * Internal use
  140643. * @param mesh The mesh to free.
  140644. * @hidden
  140645. */
  140646. _disposeMesh(mesh: Mesh): void;
  140647. /**
  140648. * Dispose the highlight layer and free resources.
  140649. */
  140650. dispose(): void;
  140651. /**
  140652. * Gets the class name of the effect layer
  140653. * @returns the string with the class name of the effect layer
  140654. */
  140655. getClassName(): string;
  140656. /**
  140657. * Serializes this Highlight layer
  140658. * @returns a serialized Highlight layer object
  140659. */
  140660. serialize(): any;
  140661. /**
  140662. * Creates a Highlight layer from parsed Highlight layer data
  140663. * @param parsedHightlightLayer defines the Highlight layer data
  140664. * @param scene defines the current scene
  140665. * @param rootUrl defines the root URL containing the Highlight layer information
  140666. * @returns a parsed Highlight layer
  140667. */
  140668. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140669. }
  140670. }
  140671. declare module BABYLON {
  140672. interface AbstractScene {
  140673. /**
  140674. * The list of layers (background and foreground) of the scene
  140675. */
  140676. layers: Array<Layer>;
  140677. }
  140678. /**
  140679. * Defines the layer scene component responsible to manage any layers
  140680. * in a given scene.
  140681. */
  140682. export class LayerSceneComponent implements ISceneComponent {
  140683. /**
  140684. * The component name helpfull to identify the component in the list of scene components.
  140685. */
  140686. readonly name: string;
  140687. /**
  140688. * The scene the component belongs to.
  140689. */
  140690. scene: Scene;
  140691. private _engine;
  140692. /**
  140693. * Creates a new instance of the component for the given scene
  140694. * @param scene Defines the scene to register the component in
  140695. */
  140696. constructor(scene: Scene);
  140697. /**
  140698. * Registers the component in a given scene
  140699. */
  140700. register(): void;
  140701. /**
  140702. * Rebuilds the elements related to this component in case of
  140703. * context lost for instance.
  140704. */
  140705. rebuild(): void;
  140706. /**
  140707. * Disposes the component and the associated ressources.
  140708. */
  140709. dispose(): void;
  140710. private _draw;
  140711. private _drawCameraPredicate;
  140712. private _drawCameraBackground;
  140713. private _drawCameraForeground;
  140714. private _drawRenderTargetPredicate;
  140715. private _drawRenderTargetBackground;
  140716. private _drawRenderTargetForeground;
  140717. /**
  140718. * Adds all the elements from the container to the scene
  140719. * @param container the container holding the elements
  140720. */
  140721. addFromContainer(container: AbstractScene): void;
  140722. /**
  140723. * Removes all the elements in the container from the scene
  140724. * @param container contains the elements to remove
  140725. * @param dispose if the removed element should be disposed (default: false)
  140726. */
  140727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140728. }
  140729. }
  140730. declare module BABYLON {
  140731. /** @hidden */
  140732. export var layerPixelShader: {
  140733. name: string;
  140734. shader: string;
  140735. };
  140736. }
  140737. declare module BABYLON {
  140738. /** @hidden */
  140739. export var layerVertexShader: {
  140740. name: string;
  140741. shader: string;
  140742. };
  140743. }
  140744. declare module BABYLON {
  140745. /**
  140746. * This represents a full screen 2d layer.
  140747. * This can be useful to display a picture in the background of your scene for instance.
  140748. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140749. */
  140750. export class Layer {
  140751. /**
  140752. * Define the name of the layer.
  140753. */
  140754. name: string;
  140755. /**
  140756. * Define the texture the layer should display.
  140757. */
  140758. texture: Nullable<Texture>;
  140759. /**
  140760. * Is the layer in background or foreground.
  140761. */
  140762. isBackground: boolean;
  140763. /**
  140764. * Define the color of the layer (instead of texture).
  140765. */
  140766. color: Color4;
  140767. /**
  140768. * Define the scale of the layer in order to zoom in out of the texture.
  140769. */
  140770. scale: Vector2;
  140771. /**
  140772. * Define an offset for the layer in order to shift the texture.
  140773. */
  140774. offset: Vector2;
  140775. /**
  140776. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140777. */
  140778. alphaBlendingMode: number;
  140779. /**
  140780. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140781. * Alpha test will not mix with the background color in case of transparency.
  140782. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140783. */
  140784. alphaTest: boolean;
  140785. /**
  140786. * Define a mask to restrict the layer to only some of the scene cameras.
  140787. */
  140788. layerMask: number;
  140789. /**
  140790. * Define the list of render target the layer is visible into.
  140791. */
  140792. renderTargetTextures: RenderTargetTexture[];
  140793. /**
  140794. * Define if the layer is only used in renderTarget or if it also
  140795. * renders in the main frame buffer of the canvas.
  140796. */
  140797. renderOnlyInRenderTargetTextures: boolean;
  140798. private _scene;
  140799. private _vertexBuffers;
  140800. private _indexBuffer;
  140801. private _effect;
  140802. private _previousDefines;
  140803. /**
  140804. * An event triggered when the layer is disposed.
  140805. */
  140806. onDisposeObservable: Observable<Layer>;
  140807. private _onDisposeObserver;
  140808. /**
  140809. * Back compatibility with callback before the onDisposeObservable existed.
  140810. * The set callback will be triggered when the layer has been disposed.
  140811. */
  140812. set onDispose(callback: () => void);
  140813. /**
  140814. * An event triggered before rendering the scene
  140815. */
  140816. onBeforeRenderObservable: Observable<Layer>;
  140817. private _onBeforeRenderObserver;
  140818. /**
  140819. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140820. * The set callback will be triggered just before rendering the layer.
  140821. */
  140822. set onBeforeRender(callback: () => void);
  140823. /**
  140824. * An event triggered after rendering the scene
  140825. */
  140826. onAfterRenderObservable: Observable<Layer>;
  140827. private _onAfterRenderObserver;
  140828. /**
  140829. * Back compatibility with callback before the onAfterRenderObservable existed.
  140830. * The set callback will be triggered just after rendering the layer.
  140831. */
  140832. set onAfterRender(callback: () => void);
  140833. /**
  140834. * Instantiates a new layer.
  140835. * This represents a full screen 2d layer.
  140836. * This can be useful to display a picture in the background of your scene for instance.
  140837. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140838. * @param name Define the name of the layer in the scene
  140839. * @param imgUrl Define the url of the texture to display in the layer
  140840. * @param scene Define the scene the layer belongs to
  140841. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140842. * @param color Defines a color for the layer
  140843. */
  140844. constructor(
  140845. /**
  140846. * Define the name of the layer.
  140847. */
  140848. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140849. private _createIndexBuffer;
  140850. /** @hidden */
  140851. _rebuild(): void;
  140852. /**
  140853. * Renders the layer in the scene.
  140854. */
  140855. render(): void;
  140856. /**
  140857. * Disposes and releases the associated ressources.
  140858. */
  140859. dispose(): void;
  140860. }
  140861. }
  140862. declare module BABYLON {
  140863. /** @hidden */
  140864. export var lensFlarePixelShader: {
  140865. name: string;
  140866. shader: string;
  140867. };
  140868. }
  140869. declare module BABYLON {
  140870. /** @hidden */
  140871. export var lensFlareVertexShader: {
  140872. name: string;
  140873. shader: string;
  140874. };
  140875. }
  140876. declare module BABYLON {
  140877. /**
  140878. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140879. * It is usually composed of several `lensFlare`.
  140880. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140881. */
  140882. export class LensFlareSystem {
  140883. /**
  140884. * Define the name of the lens flare system
  140885. */
  140886. name: string;
  140887. /**
  140888. * List of lens flares used in this system.
  140889. */
  140890. lensFlares: LensFlare[];
  140891. /**
  140892. * Define a limit from the border the lens flare can be visible.
  140893. */
  140894. borderLimit: number;
  140895. /**
  140896. * Define a viewport border we do not want to see the lens flare in.
  140897. */
  140898. viewportBorder: number;
  140899. /**
  140900. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140901. */
  140902. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140903. /**
  140904. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140905. */
  140906. layerMask: number;
  140907. /**
  140908. * Define the id of the lens flare system in the scene.
  140909. * (equal to name by default)
  140910. */
  140911. id: string;
  140912. private _scene;
  140913. private _emitter;
  140914. private _vertexBuffers;
  140915. private _indexBuffer;
  140916. private _effect;
  140917. private _positionX;
  140918. private _positionY;
  140919. private _isEnabled;
  140920. /** @hidden */
  140921. static _SceneComponentInitialization: (scene: Scene) => void;
  140922. /**
  140923. * Instantiates a lens flare system.
  140924. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140925. * It is usually composed of several `lensFlare`.
  140926. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140927. * @param name Define the name of the lens flare system in the scene
  140928. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140929. * @param scene Define the scene the lens flare system belongs to
  140930. */
  140931. constructor(
  140932. /**
  140933. * Define the name of the lens flare system
  140934. */
  140935. name: string, emitter: any, scene: Scene);
  140936. /**
  140937. * Define if the lens flare system is enabled.
  140938. */
  140939. get isEnabled(): boolean;
  140940. set isEnabled(value: boolean);
  140941. /**
  140942. * Get the scene the effects belongs to.
  140943. * @returns the scene holding the lens flare system
  140944. */
  140945. getScene(): Scene;
  140946. /**
  140947. * Get the emitter of the lens flare system.
  140948. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140949. * @returns the emitter of the lens flare system
  140950. */
  140951. getEmitter(): any;
  140952. /**
  140953. * Set the emitter of the lens flare system.
  140954. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140955. * @param newEmitter Define the new emitter of the system
  140956. */
  140957. setEmitter(newEmitter: any): void;
  140958. /**
  140959. * Get the lens flare system emitter position.
  140960. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140961. * @returns the position
  140962. */
  140963. getEmitterPosition(): Vector3;
  140964. /**
  140965. * @hidden
  140966. */
  140967. computeEffectivePosition(globalViewport: Viewport): boolean;
  140968. /** @hidden */
  140969. _isVisible(): boolean;
  140970. /**
  140971. * @hidden
  140972. */
  140973. render(): boolean;
  140974. /**
  140975. * Dispose and release the lens flare with its associated resources.
  140976. */
  140977. dispose(): void;
  140978. /**
  140979. * Parse a lens flare system from a JSON repressentation
  140980. * @param parsedLensFlareSystem Define the JSON to parse
  140981. * @param scene Define the scene the parsed system should be instantiated in
  140982. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140983. * @returns the parsed system
  140984. */
  140985. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140986. /**
  140987. * Serialize the current Lens Flare System into a JSON representation.
  140988. * @returns the serialized JSON
  140989. */
  140990. serialize(): any;
  140991. }
  140992. }
  140993. declare module BABYLON {
  140994. /**
  140995. * This represents one of the lens effect in a `lensFlareSystem`.
  140996. * It controls one of the indiviual texture used in the effect.
  140997. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140998. */
  140999. export class LensFlare {
  141000. /**
  141001. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141002. */
  141003. size: number;
  141004. /**
  141005. * 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.
  141006. */
  141007. position: number;
  141008. /**
  141009. * Define the lens color.
  141010. */
  141011. color: Color3;
  141012. /**
  141013. * Define the lens texture.
  141014. */
  141015. texture: Nullable<Texture>;
  141016. /**
  141017. * Define the alpha mode to render this particular lens.
  141018. */
  141019. alphaMode: number;
  141020. private _system;
  141021. /**
  141022. * Creates a new Lens Flare.
  141023. * This represents one of the lens effect in a `lensFlareSystem`.
  141024. * It controls one of the indiviual texture used in the effect.
  141025. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141026. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  141027. * @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.
  141028. * @param color Define the lens color
  141029. * @param imgUrl Define the lens texture url
  141030. * @param system Define the `lensFlareSystem` this flare is part of
  141031. * @returns The newly created Lens Flare
  141032. */
  141033. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  141034. /**
  141035. * Instantiates a new Lens Flare.
  141036. * This represents one of the lens effect in a `lensFlareSystem`.
  141037. * It controls one of the indiviual texture used in the effect.
  141038. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141039. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  141040. * @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.
  141041. * @param color Define the lens color
  141042. * @param imgUrl Define the lens texture url
  141043. * @param system Define the `lensFlareSystem` this flare is part of
  141044. */
  141045. constructor(
  141046. /**
  141047. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141048. */
  141049. size: number,
  141050. /**
  141051. * 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.
  141052. */
  141053. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  141054. /**
  141055. * Dispose and release the lens flare with its associated resources.
  141056. */
  141057. dispose(): void;
  141058. }
  141059. }
  141060. declare module BABYLON {
  141061. interface AbstractScene {
  141062. /**
  141063. * The list of lens flare system added to the scene
  141064. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141065. */
  141066. lensFlareSystems: Array<LensFlareSystem>;
  141067. /**
  141068. * Removes the given lens flare system from this scene.
  141069. * @param toRemove The lens flare system to remove
  141070. * @returns The index of the removed lens flare system
  141071. */
  141072. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141073. /**
  141074. * Adds the given lens flare system to this scene
  141075. * @param newLensFlareSystem The lens flare system to add
  141076. */
  141077. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141078. /**
  141079. * Gets a lens flare system using its name
  141080. * @param name defines the name to look for
  141081. * @returns the lens flare system or null if not found
  141082. */
  141083. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141084. /**
  141085. * Gets a lens flare system using its id
  141086. * @param id defines the id to look for
  141087. * @returns the lens flare system or null if not found
  141088. */
  141089. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141090. }
  141091. /**
  141092. * Defines the lens flare scene component responsible to manage any lens flares
  141093. * in a given scene.
  141094. */
  141095. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141096. /**
  141097. * The component name helpfull to identify the component in the list of scene components.
  141098. */
  141099. readonly name: string;
  141100. /**
  141101. * The scene the component belongs to.
  141102. */
  141103. scene: Scene;
  141104. /**
  141105. * Creates a new instance of the component for the given scene
  141106. * @param scene Defines the scene to register the component in
  141107. */
  141108. constructor(scene: Scene);
  141109. /**
  141110. * Registers the component in a given scene
  141111. */
  141112. register(): void;
  141113. /**
  141114. * Rebuilds the elements related to this component in case of
  141115. * context lost for instance.
  141116. */
  141117. rebuild(): void;
  141118. /**
  141119. * Adds all the elements from the container to the scene
  141120. * @param container the container holding the elements
  141121. */
  141122. addFromContainer(container: AbstractScene): void;
  141123. /**
  141124. * Removes all the elements in the container from the scene
  141125. * @param container contains the elements to remove
  141126. * @param dispose if the removed element should be disposed (default: false)
  141127. */
  141128. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141129. /**
  141130. * Serializes the component data to the specified json object
  141131. * @param serializationObject The object to serialize to
  141132. */
  141133. serialize(serializationObject: any): void;
  141134. /**
  141135. * Disposes the component and the associated ressources.
  141136. */
  141137. dispose(): void;
  141138. private _draw;
  141139. }
  141140. }
  141141. declare module BABYLON {
  141142. /** @hidden */
  141143. export var depthPixelShader: {
  141144. name: string;
  141145. shader: string;
  141146. };
  141147. }
  141148. declare module BABYLON {
  141149. /** @hidden */
  141150. export var depthVertexShader: {
  141151. name: string;
  141152. shader: string;
  141153. };
  141154. }
  141155. declare module BABYLON {
  141156. /**
  141157. * This represents a depth renderer in Babylon.
  141158. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141159. */
  141160. export class DepthRenderer {
  141161. private _scene;
  141162. private _depthMap;
  141163. private _effect;
  141164. private readonly _storeNonLinearDepth;
  141165. private readonly _clearColor;
  141166. /** Get if the depth renderer is using packed depth or not */
  141167. readonly isPacked: boolean;
  141168. private _cachedDefines;
  141169. private _camera;
  141170. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141171. enabled: boolean;
  141172. /**
  141173. * Specifiess that the depth renderer will only be used within
  141174. * the camera it is created for.
  141175. * This can help forcing its rendering during the camera processing.
  141176. */
  141177. useOnlyInActiveCamera: boolean;
  141178. /** @hidden */
  141179. static _SceneComponentInitialization: (scene: Scene) => void;
  141180. /**
  141181. * Instantiates a depth renderer
  141182. * @param scene The scene the renderer belongs to
  141183. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141184. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141185. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141186. */
  141187. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141188. /**
  141189. * Creates the depth rendering effect and checks if the effect is ready.
  141190. * @param subMesh The submesh to be used to render the depth map of
  141191. * @param useInstances If multiple world instances should be used
  141192. * @returns if the depth renderer is ready to render the depth map
  141193. */
  141194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141195. /**
  141196. * Gets the texture which the depth map will be written to.
  141197. * @returns The depth map texture
  141198. */
  141199. getDepthMap(): RenderTargetTexture;
  141200. /**
  141201. * Disposes of the depth renderer.
  141202. */
  141203. dispose(): void;
  141204. }
  141205. }
  141206. declare module BABYLON {
  141207. /** @hidden */
  141208. export var minmaxReduxPixelShader: {
  141209. name: string;
  141210. shader: string;
  141211. };
  141212. }
  141213. declare module BABYLON {
  141214. /**
  141215. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141216. * and maximum values from all values of the texture.
  141217. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141218. * The source values are read from the red channel of the texture.
  141219. */
  141220. export class MinMaxReducer {
  141221. /**
  141222. * Observable triggered when the computation has been performed
  141223. */
  141224. onAfterReductionPerformed: Observable<{
  141225. min: number;
  141226. max: number;
  141227. }>;
  141228. protected _camera: Camera;
  141229. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141230. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141231. protected _postProcessManager: PostProcessManager;
  141232. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141233. protected _forceFullscreenViewport: boolean;
  141234. /**
  141235. * Creates a min/max reducer
  141236. * @param camera The camera to use for the post processes
  141237. */
  141238. constructor(camera: Camera);
  141239. /**
  141240. * Gets the texture used to read the values from.
  141241. */
  141242. get sourceTexture(): Nullable<RenderTargetTexture>;
  141243. /**
  141244. * Sets the source texture to read the values from.
  141245. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141246. * because in such textures '1' value must not be taken into account to compute the maximum
  141247. * as this value is used to clear the texture.
  141248. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141249. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141250. * @param depthRedux Indicates if the texture is a depth texture or not
  141251. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141252. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141253. */
  141254. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141255. /**
  141256. * Defines the refresh rate of the computation.
  141257. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141258. */
  141259. get refreshRate(): number;
  141260. set refreshRate(value: number);
  141261. protected _activated: boolean;
  141262. /**
  141263. * Gets the activation status of the reducer
  141264. */
  141265. get activated(): boolean;
  141266. /**
  141267. * Activates the reduction computation.
  141268. * When activated, the observers registered in onAfterReductionPerformed are
  141269. * called after the compuation is performed
  141270. */
  141271. activate(): void;
  141272. /**
  141273. * Deactivates the reduction computation.
  141274. */
  141275. deactivate(): void;
  141276. /**
  141277. * Disposes the min/max reducer
  141278. * @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.
  141279. */
  141280. dispose(disposeAll?: boolean): void;
  141281. }
  141282. }
  141283. declare module BABYLON {
  141284. /**
  141285. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141286. */
  141287. export class DepthReducer extends MinMaxReducer {
  141288. private _depthRenderer;
  141289. private _depthRendererId;
  141290. /**
  141291. * Gets the depth renderer used for the computation.
  141292. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141293. */
  141294. get depthRenderer(): Nullable<DepthRenderer>;
  141295. /**
  141296. * Creates a depth reducer
  141297. * @param camera The camera used to render the depth texture
  141298. */
  141299. constructor(camera: Camera);
  141300. /**
  141301. * Sets the depth renderer to use to generate the depth map
  141302. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141303. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141304. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141305. */
  141306. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141307. /** @hidden */
  141308. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141309. /**
  141310. * Activates the reduction computation.
  141311. * When activated, the observers registered in onAfterReductionPerformed are
  141312. * called after the compuation is performed
  141313. */
  141314. activate(): void;
  141315. /**
  141316. * Deactivates the reduction computation.
  141317. */
  141318. deactivate(): void;
  141319. /**
  141320. * Disposes the depth reducer
  141321. * @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.
  141322. */
  141323. dispose(disposeAll?: boolean): void;
  141324. }
  141325. }
  141326. declare module BABYLON {
  141327. /**
  141328. * A CSM implementation allowing casting shadows on large scenes.
  141329. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141330. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141331. */
  141332. export class CascadedShadowGenerator extends ShadowGenerator {
  141333. private static readonly frustumCornersNDCSpace;
  141334. /**
  141335. * Name of the CSM class
  141336. */
  141337. static CLASSNAME: string;
  141338. /**
  141339. * Defines the default number of cascades used by the CSM.
  141340. */
  141341. static readonly DEFAULT_CASCADES_COUNT: number;
  141342. /**
  141343. * Defines the minimum number of cascades used by the CSM.
  141344. */
  141345. static readonly MIN_CASCADES_COUNT: number;
  141346. /**
  141347. * Defines the maximum number of cascades used by the CSM.
  141348. */
  141349. static readonly MAX_CASCADES_COUNT: number;
  141350. protected _validateFilter(filter: number): number;
  141351. /**
  141352. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141353. */
  141354. penumbraDarkness: number;
  141355. private _numCascades;
  141356. /**
  141357. * Gets or set the number of cascades used by the CSM.
  141358. */
  141359. get numCascades(): number;
  141360. set numCascades(value: number);
  141361. /**
  141362. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141363. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141364. */
  141365. stabilizeCascades: boolean;
  141366. private _freezeShadowCastersBoundingInfo;
  141367. private _freezeShadowCastersBoundingInfoObservable;
  141368. /**
  141369. * Enables or disables the shadow casters bounding info computation.
  141370. * If your shadow casters don't move, you can disable this feature.
  141371. * If it is enabled, the bounding box computation is done every frame.
  141372. */
  141373. get freezeShadowCastersBoundingInfo(): boolean;
  141374. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141375. private _scbiMin;
  141376. private _scbiMax;
  141377. protected _computeShadowCastersBoundingInfo(): void;
  141378. protected _shadowCastersBoundingInfo: BoundingInfo;
  141379. /**
  141380. * Gets or sets the shadow casters bounding info.
  141381. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141382. * so that the system won't overwrite the bounds you provide
  141383. */
  141384. get shadowCastersBoundingInfo(): BoundingInfo;
  141385. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141386. protected _breaksAreDirty: boolean;
  141387. protected _minDistance: number;
  141388. protected _maxDistance: number;
  141389. /**
  141390. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141391. *
  141392. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141393. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141394. * @param min minimal distance for the breaks (default to 0.)
  141395. * @param max maximal distance for the breaks (default to 1.)
  141396. */
  141397. setMinMaxDistance(min: number, max: number): void;
  141398. /** Gets the minimal distance used in the cascade break computation */
  141399. get minDistance(): number;
  141400. /** Gets the maximal distance used in the cascade break computation */
  141401. get maxDistance(): number;
  141402. /**
  141403. * Gets the class name of that object
  141404. * @returns "CascadedShadowGenerator"
  141405. */
  141406. getClassName(): string;
  141407. private _cascadeMinExtents;
  141408. private _cascadeMaxExtents;
  141409. /**
  141410. * Gets a cascade minimum extents
  141411. * @param cascadeIndex index of the cascade
  141412. * @returns the minimum cascade extents
  141413. */
  141414. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141415. /**
  141416. * Gets a cascade maximum extents
  141417. * @param cascadeIndex index of the cascade
  141418. * @returns the maximum cascade extents
  141419. */
  141420. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141421. private _cascades;
  141422. private _currentLayer;
  141423. private _viewSpaceFrustumsZ;
  141424. private _viewMatrices;
  141425. private _projectionMatrices;
  141426. private _transformMatrices;
  141427. private _transformMatricesAsArray;
  141428. private _frustumLengths;
  141429. private _lightSizeUVCorrection;
  141430. private _depthCorrection;
  141431. private _frustumCornersWorldSpace;
  141432. private _frustumCenter;
  141433. private _shadowCameraPos;
  141434. private _shadowMaxZ;
  141435. /**
  141436. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141437. * It defaults to camera.maxZ
  141438. */
  141439. get shadowMaxZ(): number;
  141440. /**
  141441. * Sets the shadow max z distance.
  141442. */
  141443. set shadowMaxZ(value: number);
  141444. protected _debug: boolean;
  141445. /**
  141446. * Gets or sets the debug flag.
  141447. * When enabled, the cascades are materialized by different colors on the screen.
  141448. */
  141449. get debug(): boolean;
  141450. set debug(dbg: boolean);
  141451. private _depthClamp;
  141452. /**
  141453. * Gets or sets the depth clamping value.
  141454. *
  141455. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141456. * to account for the shadow casters far away.
  141457. *
  141458. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141459. */
  141460. get depthClamp(): boolean;
  141461. set depthClamp(value: boolean);
  141462. private _cascadeBlendPercentage;
  141463. /**
  141464. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141465. * It defaults to 0.1 (10% blending).
  141466. */
  141467. get cascadeBlendPercentage(): number;
  141468. set cascadeBlendPercentage(value: number);
  141469. private _lambda;
  141470. /**
  141471. * Gets or set the lambda parameter.
  141472. * This parameter is used to split the camera frustum and create the cascades.
  141473. * 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.
  141474. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141475. */
  141476. get lambda(): number;
  141477. set lambda(value: number);
  141478. /**
  141479. * Gets the view matrix corresponding to a given cascade
  141480. * @param cascadeNum cascade to retrieve the view matrix from
  141481. * @returns the cascade view matrix
  141482. */
  141483. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141484. /**
  141485. * Gets the projection matrix corresponding to a given cascade
  141486. * @param cascadeNum cascade to retrieve the projection matrix from
  141487. * @returns the cascade projection matrix
  141488. */
  141489. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141490. /**
  141491. * Gets the transformation matrix corresponding to a given cascade
  141492. * @param cascadeNum cascade to retrieve the transformation matrix from
  141493. * @returns the cascade transformation matrix
  141494. */
  141495. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141496. private _depthRenderer;
  141497. /**
  141498. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141499. *
  141500. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141501. *
  141502. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141503. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141504. * @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
  141505. */
  141506. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141507. private _depthReducer;
  141508. private _autoCalcDepthBounds;
  141509. /**
  141510. * Gets or sets the autoCalcDepthBounds property.
  141511. *
  141512. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141513. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141514. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141515. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141516. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141517. */
  141518. get autoCalcDepthBounds(): boolean;
  141519. set autoCalcDepthBounds(value: boolean);
  141520. /**
  141521. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141522. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141523. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141524. * for setting the refresh rate on the renderer yourself!
  141525. */
  141526. get autoCalcDepthBoundsRefreshRate(): number;
  141527. set autoCalcDepthBoundsRefreshRate(value: number);
  141528. /**
  141529. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141530. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141531. * you change the camera near/far planes!
  141532. */
  141533. splitFrustum(): void;
  141534. private _splitFrustum;
  141535. private _computeMatrices;
  141536. private _computeFrustumInWorldSpace;
  141537. private _computeCascadeFrustum;
  141538. /**
  141539. * Support test.
  141540. */
  141541. static get IsSupported(): boolean;
  141542. /** @hidden */
  141543. static _SceneComponentInitialization: (scene: Scene) => void;
  141544. /**
  141545. * Creates a Cascaded Shadow Generator object.
  141546. * A ShadowGenerator is the required tool to use the shadows.
  141547. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141548. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141549. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141550. * @param light The directional light object generating the shadows.
  141551. * @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.
  141552. */
  141553. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141554. protected _initializeGenerator(): void;
  141555. protected _createTargetRenderTexture(): void;
  141556. protected _initializeShadowMap(): void;
  141557. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141558. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141559. /**
  141560. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141561. * @param defines Defines of the material we want to update
  141562. * @param lightIndex Index of the light in the enabled light list of the material
  141563. */
  141564. prepareDefines(defines: any, lightIndex: number): void;
  141565. /**
  141566. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141567. * defined in the generator but impacting the effect).
  141568. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141569. * @param effect The effect we are binfing the information for
  141570. */
  141571. bindShadowLight(lightIndex: string, effect: Effect): void;
  141572. /**
  141573. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141574. * (eq to view projection * shadow projection matrices)
  141575. * @returns The transform matrix used to create the shadow map
  141576. */
  141577. getTransformMatrix(): Matrix;
  141578. /**
  141579. * Disposes the ShadowGenerator.
  141580. * Returns nothing.
  141581. */
  141582. dispose(): void;
  141583. /**
  141584. * Serializes the shadow generator setup to a json object.
  141585. * @returns The serialized JSON object
  141586. */
  141587. serialize(): any;
  141588. /**
  141589. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141590. * @param parsedShadowGenerator The JSON object to parse
  141591. * @param scene The scene to create the shadow map for
  141592. * @returns The parsed shadow generator
  141593. */
  141594. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141595. }
  141596. }
  141597. declare module BABYLON {
  141598. /**
  141599. * Defines the shadow generator component responsible to manage any shadow generators
  141600. * in a given scene.
  141601. */
  141602. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141603. /**
  141604. * The component name helpfull to identify the component in the list of scene components.
  141605. */
  141606. readonly name: string;
  141607. /**
  141608. * The scene the component belongs to.
  141609. */
  141610. scene: Scene;
  141611. /**
  141612. * Creates a new instance of the component for the given scene
  141613. * @param scene Defines the scene to register the component in
  141614. */
  141615. constructor(scene: Scene);
  141616. /**
  141617. * Registers the component in a given scene
  141618. */
  141619. register(): void;
  141620. /**
  141621. * Rebuilds the elements related to this component in case of
  141622. * context lost for instance.
  141623. */
  141624. rebuild(): void;
  141625. /**
  141626. * Serializes the component data to the specified json object
  141627. * @param serializationObject The object to serialize to
  141628. */
  141629. serialize(serializationObject: any): void;
  141630. /**
  141631. * Adds all the elements from the container to the scene
  141632. * @param container the container holding the elements
  141633. */
  141634. addFromContainer(container: AbstractScene): void;
  141635. /**
  141636. * Removes all the elements in the container from the scene
  141637. * @param container contains the elements to remove
  141638. * @param dispose if the removed element should be disposed (default: false)
  141639. */
  141640. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141641. /**
  141642. * Rebuilds the elements related to this component in case of
  141643. * context lost for instance.
  141644. */
  141645. dispose(): void;
  141646. private _gatherRenderTargets;
  141647. }
  141648. }
  141649. declare module BABYLON {
  141650. /**
  141651. * A point light is a light defined by an unique point in world space.
  141652. * The light is emitted in every direction from this point.
  141653. * A good example of a point light is a standard light bulb.
  141654. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141655. */
  141656. export class PointLight extends ShadowLight {
  141657. private _shadowAngle;
  141658. /**
  141659. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141660. * This specifies what angle the shadow will use to be created.
  141661. *
  141662. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141663. */
  141664. get shadowAngle(): number;
  141665. /**
  141666. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141667. * This specifies what angle the shadow will use to be created.
  141668. *
  141669. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141670. */
  141671. set shadowAngle(value: number);
  141672. /**
  141673. * Gets the direction if it has been set.
  141674. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141675. */
  141676. get direction(): Vector3;
  141677. /**
  141678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141679. */
  141680. set direction(value: Vector3);
  141681. /**
  141682. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141683. * A PointLight emits the light in every direction.
  141684. * It can cast shadows.
  141685. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141686. * ```javascript
  141687. * var pointLight = new PointLight("pl", camera.position, scene);
  141688. * ```
  141689. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141690. * @param name The light friendly name
  141691. * @param position The position of the point light in the scene
  141692. * @param scene The scene the lights belongs to
  141693. */
  141694. constructor(name: string, position: Vector3, scene: Scene);
  141695. /**
  141696. * Returns the string "PointLight"
  141697. * @returns the class name
  141698. */
  141699. getClassName(): string;
  141700. /**
  141701. * Returns the integer 0.
  141702. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141703. */
  141704. getTypeID(): number;
  141705. /**
  141706. * Specifies wether or not the shadowmap should be a cube texture.
  141707. * @returns true if the shadowmap needs to be a cube texture.
  141708. */
  141709. needCube(): boolean;
  141710. /**
  141711. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141714. */
  141715. getShadowDirection(faceIndex?: number): Vector3;
  141716. /**
  141717. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141718. * - fov = PI / 2
  141719. * - aspect ratio : 1.0
  141720. * - z-near and far equal to the active camera minZ and maxZ.
  141721. * Returns the PointLight.
  141722. */
  141723. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141724. protected _buildUniformLayout(): void;
  141725. /**
  141726. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141727. * @param effect The effect to update
  141728. * @param lightIndex The index of the light in the effect to update
  141729. * @returns The point light
  141730. */
  141731. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141732. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141733. /**
  141734. * Prepares the list of defines specific to the light type.
  141735. * @param defines the list of defines
  141736. * @param lightIndex defines the index of the light for the effect
  141737. */
  141738. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141739. }
  141740. }
  141741. declare module BABYLON {
  141742. /**
  141743. * Header information of HDR texture files.
  141744. */
  141745. export interface HDRInfo {
  141746. /**
  141747. * The height of the texture in pixels.
  141748. */
  141749. height: number;
  141750. /**
  141751. * The width of the texture in pixels.
  141752. */
  141753. width: number;
  141754. /**
  141755. * The index of the beginning of the data in the binary file.
  141756. */
  141757. dataPosition: number;
  141758. }
  141759. /**
  141760. * This groups tools to convert HDR texture to native colors array.
  141761. */
  141762. export class HDRTools {
  141763. private static Ldexp;
  141764. private static Rgbe2float;
  141765. private static readStringLine;
  141766. /**
  141767. * Reads header information from an RGBE texture stored in a native array.
  141768. * More information on this format are available here:
  141769. * https://en.wikipedia.org/wiki/RGBE_image_format
  141770. *
  141771. * @param uint8array The binary file stored in native array.
  141772. * @return The header information.
  141773. */
  141774. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141775. /**
  141776. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141777. * This RGBE texture needs to store the information as a panorama.
  141778. *
  141779. * More information on this format are available here:
  141780. * https://en.wikipedia.org/wiki/RGBE_image_format
  141781. *
  141782. * @param buffer The binary file stored in an array buffer.
  141783. * @param size The expected size of the extracted cubemap.
  141784. * @return The Cube Map information.
  141785. */
  141786. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141787. /**
  141788. * Returns the pixels data extracted from an RGBE texture.
  141789. * This pixels will be stored left to right up to down in the R G B order in one array.
  141790. *
  141791. * More information on this format are available here:
  141792. * https://en.wikipedia.org/wiki/RGBE_image_format
  141793. *
  141794. * @param uint8array The binary file stored in an array buffer.
  141795. * @param hdrInfo The header information of the file.
  141796. * @return The pixels data in RGB right to left up to down order.
  141797. */
  141798. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141799. private static RGBE_ReadPixels_RLE;
  141800. private static RGBE_ReadPixels_NOT_RLE;
  141801. }
  141802. }
  141803. declare module BABYLON {
  141804. /**
  141805. * Effect Render Options
  141806. */
  141807. export interface IEffectRendererOptions {
  141808. /**
  141809. * Defines the vertices positions.
  141810. */
  141811. positions?: number[];
  141812. /**
  141813. * Defines the indices.
  141814. */
  141815. indices?: number[];
  141816. }
  141817. /**
  141818. * Helper class to render one or more effects.
  141819. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141820. */
  141821. export class EffectRenderer {
  141822. private engine;
  141823. private static _DefaultOptions;
  141824. private _vertexBuffers;
  141825. private _indexBuffer;
  141826. private _fullscreenViewport;
  141827. /**
  141828. * Creates an effect renderer
  141829. * @param engine the engine to use for rendering
  141830. * @param options defines the options of the effect renderer
  141831. */
  141832. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141833. /**
  141834. * Sets the current viewport in normalized coordinates 0-1
  141835. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141836. */
  141837. setViewport(viewport?: Viewport): void;
  141838. /**
  141839. * Binds the embedded attributes buffer to the effect.
  141840. * @param effect Defines the effect to bind the attributes for
  141841. */
  141842. bindBuffers(effect: Effect): void;
  141843. /**
  141844. * Sets the current effect wrapper to use during draw.
  141845. * The effect needs to be ready before calling this api.
  141846. * This also sets the default full screen position attribute.
  141847. * @param effectWrapper Defines the effect to draw with
  141848. */
  141849. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141850. /**
  141851. * Restores engine states
  141852. */
  141853. restoreStates(): void;
  141854. /**
  141855. * Draws a full screen quad.
  141856. */
  141857. draw(): void;
  141858. private isRenderTargetTexture;
  141859. /**
  141860. * renders one or more effects to a specified texture
  141861. * @param effectWrapper the effect to renderer
  141862. * @param outputTexture texture to draw to, if null it will render to the screen.
  141863. */
  141864. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141865. /**
  141866. * Disposes of the effect renderer
  141867. */
  141868. dispose(): void;
  141869. }
  141870. /**
  141871. * Options to create an EffectWrapper
  141872. */
  141873. interface EffectWrapperCreationOptions {
  141874. /**
  141875. * Engine to use to create the effect
  141876. */
  141877. engine: ThinEngine;
  141878. /**
  141879. * Fragment shader for the effect
  141880. */
  141881. fragmentShader: string;
  141882. /**
  141883. * Use the shader store instead of direct source code
  141884. */
  141885. useShaderStore?: boolean;
  141886. /**
  141887. * Vertex shader for the effect
  141888. */
  141889. vertexShader?: string;
  141890. /**
  141891. * Attributes to use in the shader
  141892. */
  141893. attributeNames?: Array<string>;
  141894. /**
  141895. * Uniforms to use in the shader
  141896. */
  141897. uniformNames?: Array<string>;
  141898. /**
  141899. * Texture sampler names to use in the shader
  141900. */
  141901. samplerNames?: Array<string>;
  141902. /**
  141903. * Defines to use in the shader
  141904. */
  141905. defines?: Array<string>;
  141906. /**
  141907. * Callback when effect is compiled
  141908. */
  141909. onCompiled?: Nullable<(effect: Effect) => void>;
  141910. /**
  141911. * The friendly name of the effect displayed in Spector.
  141912. */
  141913. name?: string;
  141914. }
  141915. /**
  141916. * Wraps an effect to be used for rendering
  141917. */
  141918. export class EffectWrapper {
  141919. /**
  141920. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141921. */
  141922. onApplyObservable: Observable<{}>;
  141923. /**
  141924. * The underlying effect
  141925. */
  141926. effect: Effect;
  141927. /**
  141928. * Creates an effect to be renderer
  141929. * @param creationOptions options to create the effect
  141930. */
  141931. constructor(creationOptions: EffectWrapperCreationOptions);
  141932. /**
  141933. * Disposes of the effect wrapper
  141934. */
  141935. dispose(): void;
  141936. }
  141937. }
  141938. declare module BABYLON {
  141939. /** @hidden */
  141940. export var hdrFilteringVertexShader: {
  141941. name: string;
  141942. shader: string;
  141943. };
  141944. }
  141945. declare module BABYLON {
  141946. /** @hidden */
  141947. export var hdrFilteringPixelShader: {
  141948. name: string;
  141949. shader: string;
  141950. };
  141951. }
  141952. declare module BABYLON {
  141953. /**
  141954. * Options for texture filtering
  141955. */
  141956. interface IHDRFilteringOptions {
  141957. /**
  141958. * Scales pixel intensity for the input HDR map.
  141959. */
  141960. hdrScale?: number;
  141961. /**
  141962. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141963. */
  141964. quality?: number;
  141965. }
  141966. /**
  141967. * Filters HDR maps to get correct renderings of PBR reflections
  141968. */
  141969. export class HDRFiltering {
  141970. private _engine;
  141971. private _effectRenderer;
  141972. private _effectWrapper;
  141973. private _lodGenerationOffset;
  141974. private _lodGenerationScale;
  141975. /**
  141976. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141977. * you care about baking speed.
  141978. */
  141979. quality: number;
  141980. /**
  141981. * Scales pixel intensity for the input HDR map.
  141982. */
  141983. hdrScale: number;
  141984. /**
  141985. * Instantiates HDR filter for reflection maps
  141986. *
  141987. * @param engine Thin engine
  141988. * @param options Options
  141989. */
  141990. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141991. private _createRenderTarget;
  141992. private _prefilterInternal;
  141993. private _createEffect;
  141994. /**
  141995. * Get a value indicating if the filter is ready to be used
  141996. * @param texture Texture to filter
  141997. * @returns true if the filter is ready
  141998. */
  141999. isReady(texture: BaseTexture): boolean;
  142000. /**
  142001. * Prefilters a cube texture to have mipmap levels representing roughness values.
  142002. * Prefiltering will be invoked at the end of next rendering pass.
  142003. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  142004. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  142005. * @param texture Texture to filter
  142006. * @param onFinished Callback when filtering is done
  142007. * @return Promise called when prefiltering is done
  142008. */
  142009. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  142010. }
  142011. }
  142012. declare module BABYLON {
  142013. /**
  142014. * This represents a texture coming from an HDR input.
  142015. *
  142016. * The only supported format is currently panorama picture stored in RGBE format.
  142017. * Example of such files can be found on HDRLib: http://hdrlib.com/
  142018. */
  142019. export class HDRCubeTexture extends BaseTexture {
  142020. private static _facesMapping;
  142021. private _generateHarmonics;
  142022. private _noMipmap;
  142023. private _prefilterOnLoad;
  142024. private _textureMatrix;
  142025. private _size;
  142026. private _onLoad;
  142027. private _onError;
  142028. /**
  142029. * The texture URL.
  142030. */
  142031. url: string;
  142032. protected _isBlocking: boolean;
  142033. /**
  142034. * Sets wether or not the texture is blocking during loading.
  142035. */
  142036. set isBlocking(value: boolean);
  142037. /**
  142038. * Gets wether or not the texture is blocking during loading.
  142039. */
  142040. get isBlocking(): boolean;
  142041. protected _rotationY: number;
  142042. /**
  142043. * Sets texture matrix rotation angle around Y axis in radians.
  142044. */
  142045. set rotationY(value: number);
  142046. /**
  142047. * Gets texture matrix rotation angle around Y axis radians.
  142048. */
  142049. get rotationY(): number;
  142050. /**
  142051. * Gets or sets the center of the bounding box associated with the cube texture
  142052. * It must define where the camera used to render the texture was set
  142053. */
  142054. boundingBoxPosition: Vector3;
  142055. private _boundingBoxSize;
  142056. /**
  142057. * Gets or sets the size of the bounding box associated with the cube texture
  142058. * When defined, the cubemap will switch to local mode
  142059. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  142060. * @example https://www.babylonjs-playground.com/#RNASML
  142061. */
  142062. set boundingBoxSize(value: Vector3);
  142063. get boundingBoxSize(): Vector3;
  142064. /**
  142065. * Instantiates an HDRTexture from the following parameters.
  142066. *
  142067. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  142068. * @param sceneOrEngine The scene or engine the texture will be used in
  142069. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142070. * @param noMipmap Forces to not generate the mipmap if true
  142071. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142072. * @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)
  142073. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142074. */
  142075. 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>);
  142076. /**
  142077. * Get the current class name of the texture useful for serialization or dynamic coding.
  142078. * @returns "HDRCubeTexture"
  142079. */
  142080. getClassName(): string;
  142081. /**
  142082. * Occurs when the file is raw .hdr file.
  142083. */
  142084. private loadTexture;
  142085. clone(): HDRCubeTexture;
  142086. delayLoad(): void;
  142087. /**
  142088. * Get the texture reflection matrix used to rotate/transform the reflection.
  142089. * @returns the reflection matrix
  142090. */
  142091. getReflectionTextureMatrix(): Matrix;
  142092. /**
  142093. * Set the texture reflection matrix used to rotate/transform the reflection.
  142094. * @param value Define the reflection matrix to set
  142095. */
  142096. setReflectionTextureMatrix(value: Matrix): void;
  142097. /**
  142098. * Parses a JSON representation of an HDR Texture in order to create the texture
  142099. * @param parsedTexture Define the JSON representation
  142100. * @param scene Define the scene the texture should be created in
  142101. * @param rootUrl Define the root url in case we need to load relative dependencies
  142102. * @returns the newly created texture after parsing
  142103. */
  142104. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142105. serialize(): any;
  142106. }
  142107. }
  142108. declare module BABYLON {
  142109. /**
  142110. * Class used to control physics engine
  142111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142112. */
  142113. export class PhysicsEngine implements IPhysicsEngine {
  142114. private _physicsPlugin;
  142115. /**
  142116. * Global value used to control the smallest number supported by the simulation
  142117. */
  142118. static Epsilon: number;
  142119. private _impostors;
  142120. private _joints;
  142121. private _subTimeStep;
  142122. /**
  142123. * Gets the gravity vector used by the simulation
  142124. */
  142125. gravity: Vector3;
  142126. /**
  142127. * Factory used to create the default physics plugin.
  142128. * @returns The default physics plugin
  142129. */
  142130. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142131. /**
  142132. * Creates a new Physics Engine
  142133. * @param gravity defines the gravity vector used by the simulation
  142134. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142135. */
  142136. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142137. /**
  142138. * Sets the gravity vector used by the simulation
  142139. * @param gravity defines the gravity vector to use
  142140. */
  142141. setGravity(gravity: Vector3): void;
  142142. /**
  142143. * Set the time step of the physics engine.
  142144. * Default is 1/60.
  142145. * To slow it down, enter 1/600 for example.
  142146. * To speed it up, 1/30
  142147. * @param newTimeStep defines the new timestep to apply to this world.
  142148. */
  142149. setTimeStep(newTimeStep?: number): void;
  142150. /**
  142151. * Get the time step of the physics engine.
  142152. * @returns the current time step
  142153. */
  142154. getTimeStep(): number;
  142155. /**
  142156. * Set the sub time step of the physics engine.
  142157. * Default is 0 meaning there is no sub steps
  142158. * To increase physics resolution precision, set a small value (like 1 ms)
  142159. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142160. */
  142161. setSubTimeStep(subTimeStep?: number): void;
  142162. /**
  142163. * Get the sub time step of the physics engine.
  142164. * @returns the current sub time step
  142165. */
  142166. getSubTimeStep(): number;
  142167. /**
  142168. * Release all resources
  142169. */
  142170. dispose(): void;
  142171. /**
  142172. * Gets the name of the current physics plugin
  142173. * @returns the name of the plugin
  142174. */
  142175. getPhysicsPluginName(): string;
  142176. /**
  142177. * Adding a new impostor for the impostor tracking.
  142178. * This will be done by the impostor itself.
  142179. * @param impostor the impostor to add
  142180. */
  142181. addImpostor(impostor: PhysicsImpostor): void;
  142182. /**
  142183. * Remove an impostor from the engine.
  142184. * This impostor and its mesh will not longer be updated by the physics engine.
  142185. * @param impostor the impostor to remove
  142186. */
  142187. removeImpostor(impostor: PhysicsImpostor): void;
  142188. /**
  142189. * Add a joint to the physics engine
  142190. * @param mainImpostor defines the main impostor to which the joint is added.
  142191. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142192. * @param joint defines the joint that will connect both impostors.
  142193. */
  142194. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142195. /**
  142196. * Removes a joint from the simulation
  142197. * @param mainImpostor defines the impostor used with the joint
  142198. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142199. * @param joint defines the joint to remove
  142200. */
  142201. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142202. /**
  142203. * Called by the scene. No need to call it.
  142204. * @param delta defines the timespam between frames
  142205. */
  142206. _step(delta: number): void;
  142207. /**
  142208. * Gets the current plugin used to run the simulation
  142209. * @returns current plugin
  142210. */
  142211. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142212. /**
  142213. * Gets the list of physic impostors
  142214. * @returns an array of PhysicsImpostor
  142215. */
  142216. getImpostors(): Array<PhysicsImpostor>;
  142217. /**
  142218. * Gets the impostor for a physics enabled object
  142219. * @param object defines the object impersonated by the impostor
  142220. * @returns the PhysicsImpostor or null if not found
  142221. */
  142222. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142223. /**
  142224. * Gets the impostor for a physics body object
  142225. * @param body defines physics body used by the impostor
  142226. * @returns the PhysicsImpostor or null if not found
  142227. */
  142228. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142229. /**
  142230. * Does a raycast in the physics world
  142231. * @param from when should the ray start?
  142232. * @param to when should the ray end?
  142233. * @returns PhysicsRaycastResult
  142234. */
  142235. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142236. }
  142237. }
  142238. declare module BABYLON {
  142239. /** @hidden */
  142240. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142241. private _useDeltaForWorldStep;
  142242. world: any;
  142243. name: string;
  142244. private _physicsMaterials;
  142245. private _fixedTimeStep;
  142246. private _cannonRaycastResult;
  142247. private _raycastResult;
  142248. private _physicsBodysToRemoveAfterStep;
  142249. private _firstFrame;
  142250. BJSCANNON: any;
  142251. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142252. setGravity(gravity: Vector3): void;
  142253. setTimeStep(timeStep: number): void;
  142254. getTimeStep(): number;
  142255. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142256. private _removeMarkedPhysicsBodiesFromWorld;
  142257. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142258. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142259. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142260. private _processChildMeshes;
  142261. removePhysicsBody(impostor: PhysicsImpostor): void;
  142262. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142263. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142264. private _addMaterial;
  142265. private _checkWithEpsilon;
  142266. private _createShape;
  142267. private _createHeightmap;
  142268. private _minus90X;
  142269. private _plus90X;
  142270. private _tmpPosition;
  142271. private _tmpDeltaPosition;
  142272. private _tmpUnityRotation;
  142273. private _updatePhysicsBodyTransformation;
  142274. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142275. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142276. isSupported(): boolean;
  142277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142282. getBodyMass(impostor: PhysicsImpostor): number;
  142283. getBodyFriction(impostor: PhysicsImpostor): number;
  142284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142285. getBodyRestitution(impostor: PhysicsImpostor): number;
  142286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142287. sleepBody(impostor: PhysicsImpostor): void;
  142288. wakeUpBody(impostor: PhysicsImpostor): void;
  142289. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142290. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142291. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142292. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142293. getRadius(impostor: PhysicsImpostor): number;
  142294. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142295. dispose(): void;
  142296. private _extendNamespace;
  142297. /**
  142298. * Does a raycast in the physics world
  142299. * @param from when should the ray start?
  142300. * @param to when should the ray end?
  142301. * @returns PhysicsRaycastResult
  142302. */
  142303. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142304. }
  142305. }
  142306. declare module BABYLON {
  142307. /** @hidden */
  142308. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142309. private _useDeltaForWorldStep;
  142310. world: any;
  142311. name: string;
  142312. BJSOIMO: any;
  142313. private _raycastResult;
  142314. private _fixedTimeStep;
  142315. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142316. setGravity(gravity: Vector3): void;
  142317. setTimeStep(timeStep: number): void;
  142318. getTimeStep(): number;
  142319. private _tmpImpostorsArray;
  142320. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142321. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142322. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142323. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142324. private _tmpPositionVector;
  142325. removePhysicsBody(impostor: PhysicsImpostor): void;
  142326. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142327. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142328. isSupported(): boolean;
  142329. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142330. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142331. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142332. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142333. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142334. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142335. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142336. getBodyMass(impostor: PhysicsImpostor): number;
  142337. getBodyFriction(impostor: PhysicsImpostor): number;
  142338. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142339. getBodyRestitution(impostor: PhysicsImpostor): number;
  142340. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142341. sleepBody(impostor: PhysicsImpostor): void;
  142342. wakeUpBody(impostor: PhysicsImpostor): void;
  142343. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142344. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142345. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142346. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142347. getRadius(impostor: PhysicsImpostor): number;
  142348. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142349. dispose(): void;
  142350. /**
  142351. * Does a raycast in the physics world
  142352. * @param from when should the ray start?
  142353. * @param to when should the ray end?
  142354. * @returns PhysicsRaycastResult
  142355. */
  142356. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142357. }
  142358. }
  142359. declare module BABYLON {
  142360. /**
  142361. * AmmoJS Physics plugin
  142362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142363. * @see https://github.com/kripken/ammo.js/
  142364. */
  142365. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142366. private _useDeltaForWorldStep;
  142367. /**
  142368. * Reference to the Ammo library
  142369. */
  142370. bjsAMMO: any;
  142371. /**
  142372. * Created ammoJS world which physics bodies are added to
  142373. */
  142374. world: any;
  142375. /**
  142376. * Name of the plugin
  142377. */
  142378. name: string;
  142379. private _timeStep;
  142380. private _fixedTimeStep;
  142381. private _maxSteps;
  142382. private _tmpQuaternion;
  142383. private _tmpAmmoTransform;
  142384. private _tmpAmmoQuaternion;
  142385. private _tmpAmmoConcreteContactResultCallback;
  142386. private _collisionConfiguration;
  142387. private _dispatcher;
  142388. private _overlappingPairCache;
  142389. private _solver;
  142390. private _softBodySolver;
  142391. private _tmpAmmoVectorA;
  142392. private _tmpAmmoVectorB;
  142393. private _tmpAmmoVectorC;
  142394. private _tmpAmmoVectorD;
  142395. private _tmpContactCallbackResult;
  142396. private _tmpAmmoVectorRCA;
  142397. private _tmpAmmoVectorRCB;
  142398. private _raycastResult;
  142399. private _tmpContactPoint;
  142400. private static readonly DISABLE_COLLISION_FLAG;
  142401. private static readonly KINEMATIC_FLAG;
  142402. private static readonly DISABLE_DEACTIVATION_FLAG;
  142403. /**
  142404. * Initializes the ammoJS plugin
  142405. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142406. * @param ammoInjection can be used to inject your own ammo reference
  142407. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142408. */
  142409. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142410. /**
  142411. * Sets the gravity of the physics world (m/(s^2))
  142412. * @param gravity Gravity to set
  142413. */
  142414. setGravity(gravity: Vector3): void;
  142415. /**
  142416. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142417. * @param timeStep timestep to use in seconds
  142418. */
  142419. setTimeStep(timeStep: number): void;
  142420. /**
  142421. * 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)
  142422. * @param fixedTimeStep fixedTimeStep to use in seconds
  142423. */
  142424. setFixedTimeStep(fixedTimeStep: number): void;
  142425. /**
  142426. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142427. * @param maxSteps the maximum number of steps by the physics engine per frame
  142428. */
  142429. setMaxSteps(maxSteps: number): void;
  142430. /**
  142431. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142432. * @returns the current timestep in seconds
  142433. */
  142434. getTimeStep(): number;
  142435. /**
  142436. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142437. */
  142438. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142439. private _isImpostorInContact;
  142440. private _isImpostorPairInContact;
  142441. private _stepSimulation;
  142442. /**
  142443. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142444. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142445. * After the step the babylon meshes are set to the position of the physics imposters
  142446. * @param delta amount of time to step forward
  142447. * @param impostors array of imposters to update before/after the step
  142448. */
  142449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142450. /**
  142451. * Update babylon mesh to match physics world object
  142452. * @param impostor imposter to match
  142453. */
  142454. private _afterSoftStep;
  142455. /**
  142456. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142457. * @param impostor imposter to match
  142458. */
  142459. private _ropeStep;
  142460. /**
  142461. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142462. * @param impostor imposter to match
  142463. */
  142464. private _softbodyOrClothStep;
  142465. private _tmpMatrix;
  142466. /**
  142467. * Applies an impulse on the imposter
  142468. * @param impostor imposter to apply impulse to
  142469. * @param force amount of force to be applied to the imposter
  142470. * @param contactPoint the location to apply the impulse on the imposter
  142471. */
  142472. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142473. /**
  142474. * Applies a force on the imposter
  142475. * @param impostor imposter to apply force
  142476. * @param force amount of force to be applied to the imposter
  142477. * @param contactPoint the location to apply the force on the imposter
  142478. */
  142479. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142480. /**
  142481. * Creates a physics body using the plugin
  142482. * @param impostor the imposter to create the physics body on
  142483. */
  142484. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142485. /**
  142486. * Removes the physics body from the imposter and disposes of the body's memory
  142487. * @param impostor imposter to remove the physics body from
  142488. */
  142489. removePhysicsBody(impostor: PhysicsImpostor): void;
  142490. /**
  142491. * Generates a joint
  142492. * @param impostorJoint the imposter joint to create the joint with
  142493. */
  142494. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142495. /**
  142496. * Removes a joint
  142497. * @param impostorJoint the imposter joint to remove the joint from
  142498. */
  142499. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142500. private _addMeshVerts;
  142501. /**
  142502. * Initialise the soft body vertices to match its object's (mesh) vertices
  142503. * Softbody vertices (nodes) are in world space and to match this
  142504. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142505. * @param impostor to create the softbody for
  142506. */
  142507. private _softVertexData;
  142508. /**
  142509. * Create an impostor's soft body
  142510. * @param impostor to create the softbody for
  142511. */
  142512. private _createSoftbody;
  142513. /**
  142514. * Create cloth for an impostor
  142515. * @param impostor to create the softbody for
  142516. */
  142517. private _createCloth;
  142518. /**
  142519. * Create rope for an impostor
  142520. * @param impostor to create the softbody for
  142521. */
  142522. private _createRope;
  142523. /**
  142524. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142525. * @param impostor to create the custom physics shape for
  142526. */
  142527. private _createCustom;
  142528. private _addHullVerts;
  142529. private _createShape;
  142530. /**
  142531. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142532. * @param impostor imposter containing the physics body and babylon object
  142533. */
  142534. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142535. /**
  142536. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142537. * @param impostor imposter containing the physics body and babylon object
  142538. * @param newPosition new position
  142539. * @param newRotation new rotation
  142540. */
  142541. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142542. /**
  142543. * If this plugin is supported
  142544. * @returns true if its supported
  142545. */
  142546. isSupported(): boolean;
  142547. /**
  142548. * Sets the linear velocity of the physics body
  142549. * @param impostor imposter to set the velocity on
  142550. * @param velocity velocity to set
  142551. */
  142552. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142553. /**
  142554. * Sets the angular velocity of the physics body
  142555. * @param impostor imposter to set the velocity on
  142556. * @param velocity velocity to set
  142557. */
  142558. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142559. /**
  142560. * gets the linear velocity
  142561. * @param impostor imposter to get linear velocity from
  142562. * @returns linear velocity
  142563. */
  142564. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142565. /**
  142566. * gets the angular velocity
  142567. * @param impostor imposter to get angular velocity from
  142568. * @returns angular velocity
  142569. */
  142570. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142571. /**
  142572. * Sets the mass of physics body
  142573. * @param impostor imposter to set the mass on
  142574. * @param mass mass to set
  142575. */
  142576. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142577. /**
  142578. * Gets the mass of the physics body
  142579. * @param impostor imposter to get the mass from
  142580. * @returns mass
  142581. */
  142582. getBodyMass(impostor: PhysicsImpostor): number;
  142583. /**
  142584. * Gets friction of the impostor
  142585. * @param impostor impostor to get friction from
  142586. * @returns friction value
  142587. */
  142588. getBodyFriction(impostor: PhysicsImpostor): number;
  142589. /**
  142590. * Sets friction of the impostor
  142591. * @param impostor impostor to set friction on
  142592. * @param friction friction value
  142593. */
  142594. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142595. /**
  142596. * Gets restitution of the impostor
  142597. * @param impostor impostor to get restitution from
  142598. * @returns restitution value
  142599. */
  142600. getBodyRestitution(impostor: PhysicsImpostor): number;
  142601. /**
  142602. * Sets resitution of the impostor
  142603. * @param impostor impostor to set resitution on
  142604. * @param restitution resitution value
  142605. */
  142606. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142607. /**
  142608. * Gets pressure inside the impostor
  142609. * @param impostor impostor to get pressure from
  142610. * @returns pressure value
  142611. */
  142612. getBodyPressure(impostor: PhysicsImpostor): number;
  142613. /**
  142614. * Sets pressure inside a soft body impostor
  142615. * Cloth and rope must remain 0 pressure
  142616. * @param impostor impostor to set pressure on
  142617. * @param pressure pressure value
  142618. */
  142619. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142620. /**
  142621. * Gets stiffness of the impostor
  142622. * @param impostor impostor to get stiffness from
  142623. * @returns pressure value
  142624. */
  142625. getBodyStiffness(impostor: PhysicsImpostor): number;
  142626. /**
  142627. * Sets stiffness of the impostor
  142628. * @param impostor impostor to set stiffness on
  142629. * @param stiffness stiffness value from 0 to 1
  142630. */
  142631. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142632. /**
  142633. * Gets velocityIterations of the impostor
  142634. * @param impostor impostor to get velocity iterations from
  142635. * @returns velocityIterations value
  142636. */
  142637. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142638. /**
  142639. * Sets velocityIterations of the impostor
  142640. * @param impostor impostor to set velocity iterations on
  142641. * @param velocityIterations velocityIterations value
  142642. */
  142643. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142644. /**
  142645. * Gets positionIterations of the impostor
  142646. * @param impostor impostor to get position iterations from
  142647. * @returns positionIterations value
  142648. */
  142649. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142650. /**
  142651. * Sets positionIterations of the impostor
  142652. * @param impostor impostor to set position on
  142653. * @param positionIterations positionIterations value
  142654. */
  142655. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142656. /**
  142657. * Append an anchor to a cloth object
  142658. * @param impostor is the cloth impostor to add anchor to
  142659. * @param otherImpostor is the rigid impostor to anchor to
  142660. * @param width ratio across width from 0 to 1
  142661. * @param height ratio up height from 0 to 1
  142662. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142663. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142664. */
  142665. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142666. /**
  142667. * Append an hook to a rope object
  142668. * @param impostor is the rope impostor to add hook to
  142669. * @param otherImpostor is the rigid impostor to hook to
  142670. * @param length ratio along the rope from 0 to 1
  142671. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142672. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142673. */
  142674. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142675. /**
  142676. * Sleeps the physics body and stops it from being active
  142677. * @param impostor impostor to sleep
  142678. */
  142679. sleepBody(impostor: PhysicsImpostor): void;
  142680. /**
  142681. * Activates the physics body
  142682. * @param impostor impostor to activate
  142683. */
  142684. wakeUpBody(impostor: PhysicsImpostor): void;
  142685. /**
  142686. * Updates the distance parameters of the joint
  142687. * @param joint joint to update
  142688. * @param maxDistance maximum distance of the joint
  142689. * @param minDistance minimum distance of the joint
  142690. */
  142691. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142692. /**
  142693. * Sets a motor on the joint
  142694. * @param joint joint to set motor on
  142695. * @param speed speed of the motor
  142696. * @param maxForce maximum force of the motor
  142697. * @param motorIndex index of the motor
  142698. */
  142699. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142700. /**
  142701. * Sets the motors limit
  142702. * @param joint joint to set limit on
  142703. * @param upperLimit upper limit
  142704. * @param lowerLimit lower limit
  142705. */
  142706. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142707. /**
  142708. * Syncs the position and rotation of a mesh with the impostor
  142709. * @param mesh mesh to sync
  142710. * @param impostor impostor to update the mesh with
  142711. */
  142712. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142713. /**
  142714. * Gets the radius of the impostor
  142715. * @param impostor impostor to get radius from
  142716. * @returns the radius
  142717. */
  142718. getRadius(impostor: PhysicsImpostor): number;
  142719. /**
  142720. * Gets the box size of the impostor
  142721. * @param impostor impostor to get box size from
  142722. * @param result the resulting box size
  142723. */
  142724. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142725. /**
  142726. * Disposes of the impostor
  142727. */
  142728. dispose(): void;
  142729. /**
  142730. * Does a raycast in the physics world
  142731. * @param from when should the ray start?
  142732. * @param to when should the ray end?
  142733. * @returns PhysicsRaycastResult
  142734. */
  142735. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142736. }
  142737. }
  142738. declare module BABYLON {
  142739. interface AbstractScene {
  142740. /**
  142741. * The list of reflection probes added to the scene
  142742. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142743. */
  142744. reflectionProbes: Array<ReflectionProbe>;
  142745. /**
  142746. * Removes the given reflection probe from this scene.
  142747. * @param toRemove The reflection probe to remove
  142748. * @returns The index of the removed reflection probe
  142749. */
  142750. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142751. /**
  142752. * Adds the given reflection probe to this scene.
  142753. * @param newReflectionProbe The reflection probe to add
  142754. */
  142755. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142756. }
  142757. /**
  142758. * Class used to generate realtime reflection / refraction cube textures
  142759. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142760. */
  142761. export class ReflectionProbe {
  142762. /** defines the name of the probe */
  142763. name: string;
  142764. private _scene;
  142765. private _renderTargetTexture;
  142766. private _projectionMatrix;
  142767. private _viewMatrix;
  142768. private _target;
  142769. private _add;
  142770. private _attachedMesh;
  142771. private _invertYAxis;
  142772. /** Gets or sets probe position (center of the cube map) */
  142773. position: Vector3;
  142774. /**
  142775. * Creates a new reflection probe
  142776. * @param name defines the name of the probe
  142777. * @param size defines the texture resolution (for each face)
  142778. * @param scene defines the hosting scene
  142779. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142780. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142781. */
  142782. constructor(
  142783. /** defines the name of the probe */
  142784. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142785. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142786. get samples(): number;
  142787. set samples(value: number);
  142788. /** Gets or sets the refresh rate to use (on every frame by default) */
  142789. get refreshRate(): number;
  142790. set refreshRate(value: number);
  142791. /**
  142792. * Gets the hosting scene
  142793. * @returns a Scene
  142794. */
  142795. getScene(): Scene;
  142796. /** Gets the internal CubeTexture used to render to */
  142797. get cubeTexture(): RenderTargetTexture;
  142798. /** Gets the list of meshes to render */
  142799. get renderList(): Nullable<AbstractMesh[]>;
  142800. /**
  142801. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142802. * @param mesh defines the mesh to attach to
  142803. */
  142804. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142805. /**
  142806. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142807. * @param renderingGroupId The rendering group id corresponding to its index
  142808. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142809. */
  142810. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142811. /**
  142812. * Clean all associated resources
  142813. */
  142814. dispose(): void;
  142815. /**
  142816. * Converts the reflection probe information to a readable string for debug purpose.
  142817. * @param fullDetails Supports for multiple levels of logging within scene loading
  142818. * @returns the human readable reflection probe info
  142819. */
  142820. toString(fullDetails?: boolean): string;
  142821. /**
  142822. * Get the class name of the relfection probe.
  142823. * @returns "ReflectionProbe"
  142824. */
  142825. getClassName(): string;
  142826. /**
  142827. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142828. * @returns The JSON representation of the texture
  142829. */
  142830. serialize(): any;
  142831. /**
  142832. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142833. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142834. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142835. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142836. * @returns The parsed reflection probe if successful
  142837. */
  142838. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142839. }
  142840. }
  142841. declare module BABYLON {
  142842. /** @hidden */
  142843. export var _BabylonLoaderRegistered: boolean;
  142844. /**
  142845. * Helps setting up some configuration for the babylon file loader.
  142846. */
  142847. export class BabylonFileLoaderConfiguration {
  142848. /**
  142849. * The loader does not allow injecting custom physix engine into the plugins.
  142850. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142851. * So you could set this variable to your engine import to make it work.
  142852. */
  142853. static LoaderInjectedPhysicsEngine: any;
  142854. }
  142855. }
  142856. declare module BABYLON {
  142857. /**
  142858. * The Physically based simple base material of BJS.
  142859. *
  142860. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142861. * It is used as the base class for both the specGloss and metalRough conventions.
  142862. */
  142863. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142864. /**
  142865. * Number of Simultaneous lights allowed on the material.
  142866. */
  142867. maxSimultaneousLights: number;
  142868. /**
  142869. * If sets to true, disables all the lights affecting the material.
  142870. */
  142871. disableLighting: boolean;
  142872. /**
  142873. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142874. */
  142875. environmentTexture: BaseTexture;
  142876. /**
  142877. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142878. */
  142879. invertNormalMapX: boolean;
  142880. /**
  142881. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142882. */
  142883. invertNormalMapY: boolean;
  142884. /**
  142885. * Normal map used in the model.
  142886. */
  142887. normalTexture: BaseTexture;
  142888. /**
  142889. * Emissivie color used to self-illuminate the model.
  142890. */
  142891. emissiveColor: Color3;
  142892. /**
  142893. * Emissivie texture used to self-illuminate the model.
  142894. */
  142895. emissiveTexture: BaseTexture;
  142896. /**
  142897. * Occlusion Channel Strenght.
  142898. */
  142899. occlusionStrength: number;
  142900. /**
  142901. * Occlusion Texture of the material (adding extra occlusion effects).
  142902. */
  142903. occlusionTexture: BaseTexture;
  142904. /**
  142905. * Defines the alpha limits in alpha test mode.
  142906. */
  142907. alphaCutOff: number;
  142908. /**
  142909. * Gets the current double sided mode.
  142910. */
  142911. get doubleSided(): boolean;
  142912. /**
  142913. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142914. */
  142915. set doubleSided(value: boolean);
  142916. /**
  142917. * Stores the pre-calculated light information of a mesh in a texture.
  142918. */
  142919. lightmapTexture: BaseTexture;
  142920. /**
  142921. * If true, the light map contains occlusion information instead of lighting info.
  142922. */
  142923. useLightmapAsShadowmap: boolean;
  142924. /**
  142925. * Instantiates a new PBRMaterial instance.
  142926. *
  142927. * @param name The material name
  142928. * @param scene The scene the material will be use in.
  142929. */
  142930. constructor(name: string, scene: Scene);
  142931. getClassName(): string;
  142932. }
  142933. }
  142934. declare module BABYLON {
  142935. /**
  142936. * The PBR material of BJS following the metal roughness convention.
  142937. *
  142938. * This fits to the PBR convention in the GLTF definition:
  142939. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142940. */
  142941. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142942. /**
  142943. * The base color has two different interpretations depending on the value of metalness.
  142944. * When the material is a metal, the base color is the specific measured reflectance value
  142945. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142946. * of the material.
  142947. */
  142948. baseColor: Color3;
  142949. /**
  142950. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142951. * well as opacity information in the alpha channel.
  142952. */
  142953. baseTexture: BaseTexture;
  142954. /**
  142955. * Specifies the metallic scalar value of the material.
  142956. * Can also be used to scale the metalness values of the metallic texture.
  142957. */
  142958. metallic: number;
  142959. /**
  142960. * Specifies the roughness scalar value of the material.
  142961. * Can also be used to scale the roughness values of the metallic texture.
  142962. */
  142963. roughness: number;
  142964. /**
  142965. * Texture containing both the metallic value in the B channel and the
  142966. * roughness value in the G channel to keep better precision.
  142967. */
  142968. metallicRoughnessTexture: BaseTexture;
  142969. /**
  142970. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142971. *
  142972. * @param name The material name
  142973. * @param scene The scene the material will be use in.
  142974. */
  142975. constructor(name: string, scene: Scene);
  142976. /**
  142977. * Return the currrent class name of the material.
  142978. */
  142979. getClassName(): string;
  142980. /**
  142981. * Makes a duplicate of the current material.
  142982. * @param name - name to use for the new material.
  142983. */
  142984. clone(name: string): PBRMetallicRoughnessMaterial;
  142985. /**
  142986. * Serialize the material to a parsable JSON object.
  142987. */
  142988. serialize(): any;
  142989. /**
  142990. * Parses a JSON object correponding to the serialize function.
  142991. */
  142992. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142993. }
  142994. }
  142995. declare module BABYLON {
  142996. /**
  142997. * The PBR material of BJS following the specular glossiness convention.
  142998. *
  142999. * This fits to the PBR convention in the GLTF definition:
  143000. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  143001. */
  143002. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  143003. /**
  143004. * Specifies the diffuse color of the material.
  143005. */
  143006. diffuseColor: Color3;
  143007. /**
  143008. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  143009. * channel.
  143010. */
  143011. diffuseTexture: BaseTexture;
  143012. /**
  143013. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  143014. */
  143015. specularColor: Color3;
  143016. /**
  143017. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  143018. */
  143019. glossiness: number;
  143020. /**
  143021. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  143022. */
  143023. specularGlossinessTexture: BaseTexture;
  143024. /**
  143025. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  143026. *
  143027. * @param name The material name
  143028. * @param scene The scene the material will be use in.
  143029. */
  143030. constructor(name: string, scene: Scene);
  143031. /**
  143032. * Return the currrent class name of the material.
  143033. */
  143034. getClassName(): string;
  143035. /**
  143036. * Makes a duplicate of the current material.
  143037. * @param name - name to use for the new material.
  143038. */
  143039. clone(name: string): PBRSpecularGlossinessMaterial;
  143040. /**
  143041. * Serialize the material to a parsable JSON object.
  143042. */
  143043. serialize(): any;
  143044. /**
  143045. * Parses a JSON object correponding to the serialize function.
  143046. */
  143047. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  143048. }
  143049. }
  143050. declare module BABYLON {
  143051. /**
  143052. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  143053. * It can help converting any input color in a desired output one. This can then be used to create effects
  143054. * from sepia, black and white to sixties or futuristic rendering...
  143055. *
  143056. * The only supported format is currently 3dl.
  143057. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  143058. */
  143059. export class ColorGradingTexture extends BaseTexture {
  143060. /**
  143061. * The texture URL.
  143062. */
  143063. url: string;
  143064. /**
  143065. * Empty line regex stored for GC.
  143066. */
  143067. private static _noneEmptyLineRegex;
  143068. private _textureMatrix;
  143069. private _onLoad;
  143070. /**
  143071. * Instantiates a ColorGradingTexture from the following parameters.
  143072. *
  143073. * @param url The location of the color gradind data (currently only supporting 3dl)
  143074. * @param sceneOrEngine The scene or engine the texture will be used in
  143075. * @param onLoad defines a callback triggered when the texture has been loaded
  143076. */
  143077. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143078. /**
  143079. * Fires the onload event from the constructor if requested.
  143080. */
  143081. private _triggerOnLoad;
  143082. /**
  143083. * Returns the texture matrix used in most of the material.
  143084. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143085. */
  143086. getTextureMatrix(): Matrix;
  143087. /**
  143088. * Occurs when the file being loaded is a .3dl LUT file.
  143089. */
  143090. private load3dlTexture;
  143091. /**
  143092. * Starts the loading process of the texture.
  143093. */
  143094. private loadTexture;
  143095. /**
  143096. * Clones the color gradind texture.
  143097. */
  143098. clone(): ColorGradingTexture;
  143099. /**
  143100. * Called during delayed load for textures.
  143101. */
  143102. delayLoad(): void;
  143103. /**
  143104. * Parses a color grading texture serialized by Babylon.
  143105. * @param parsedTexture The texture information being parsedTexture
  143106. * @param scene The scene to load the texture in
  143107. * @param rootUrl The root url of the data assets to load
  143108. * @return A color gradind texture
  143109. */
  143110. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143111. /**
  143112. * Serializes the LUT texture to json format.
  143113. */
  143114. serialize(): any;
  143115. }
  143116. }
  143117. declare module BABYLON {
  143118. /**
  143119. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143120. */
  143121. export class EquiRectangularCubeTexture extends BaseTexture {
  143122. /** The six faces of the cube. */
  143123. private static _FacesMapping;
  143124. private _noMipmap;
  143125. private _onLoad;
  143126. private _onError;
  143127. /** The size of the cubemap. */
  143128. private _size;
  143129. /** The buffer of the image. */
  143130. private _buffer;
  143131. /** The width of the input image. */
  143132. private _width;
  143133. /** The height of the input image. */
  143134. private _height;
  143135. /** The URL to the image. */
  143136. url: string;
  143137. /**
  143138. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143139. * @param url The location of the image
  143140. * @param scene The scene the texture will be used in
  143141. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143142. * @param noMipmap Forces to not generate the mipmap if true
  143143. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143144. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143145. * @param onLoad — defines a callback called when texture is loaded
  143146. * @param onError — defines a callback called if there is an error
  143147. */
  143148. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143149. /**
  143150. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143151. */
  143152. private loadImage;
  143153. /**
  143154. * Convert the image buffer into a cubemap and create a CubeTexture.
  143155. */
  143156. private loadTexture;
  143157. /**
  143158. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143159. * @param buffer The ArrayBuffer that should be converted.
  143160. * @returns The buffer as Float32Array.
  143161. */
  143162. private getFloat32ArrayFromArrayBuffer;
  143163. /**
  143164. * Get the current class name of the texture useful for serialization or dynamic coding.
  143165. * @returns "EquiRectangularCubeTexture"
  143166. */
  143167. getClassName(): string;
  143168. /**
  143169. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143170. * @returns A clone of the current EquiRectangularCubeTexture.
  143171. */
  143172. clone(): EquiRectangularCubeTexture;
  143173. }
  143174. }
  143175. declare module BABYLON {
  143176. /**
  143177. * Defines the options related to the creation of an HtmlElementTexture
  143178. */
  143179. export interface IHtmlElementTextureOptions {
  143180. /**
  143181. * Defines wether mip maps should be created or not.
  143182. */
  143183. generateMipMaps?: boolean;
  143184. /**
  143185. * Defines the sampling mode of the texture.
  143186. */
  143187. samplingMode?: number;
  143188. /**
  143189. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143190. */
  143191. engine: Nullable<ThinEngine>;
  143192. /**
  143193. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143194. */
  143195. scene: Nullable<Scene>;
  143196. }
  143197. /**
  143198. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143199. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143200. * is automatically managed.
  143201. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143202. * in your application.
  143203. *
  143204. * As the update is not automatic, you need to call them manually.
  143205. */
  143206. export class HtmlElementTexture extends BaseTexture {
  143207. /**
  143208. * The texture URL.
  143209. */
  143210. element: HTMLVideoElement | HTMLCanvasElement;
  143211. private static readonly DefaultOptions;
  143212. private _textureMatrix;
  143213. private _isVideo;
  143214. private _generateMipMaps;
  143215. private _samplingMode;
  143216. /**
  143217. * Instantiates a HtmlElementTexture from the following parameters.
  143218. *
  143219. * @param name Defines the name of the texture
  143220. * @param element Defines the video or canvas the texture is filled with
  143221. * @param options Defines the other none mandatory texture creation options
  143222. */
  143223. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143224. private _createInternalTexture;
  143225. /**
  143226. * Returns the texture matrix used in most of the material.
  143227. */
  143228. getTextureMatrix(): Matrix;
  143229. /**
  143230. * Updates the content of the texture.
  143231. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143232. */
  143233. update(invertY?: Nullable<boolean>): void;
  143234. }
  143235. }
  143236. declare module BABYLON {
  143237. /**
  143238. * Based on jsTGALoader - Javascript loader for TGA file
  143239. * By Vincent Thibault
  143240. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143241. */
  143242. export class TGATools {
  143243. private static _TYPE_INDEXED;
  143244. private static _TYPE_RGB;
  143245. private static _TYPE_GREY;
  143246. private static _TYPE_RLE_INDEXED;
  143247. private static _TYPE_RLE_RGB;
  143248. private static _TYPE_RLE_GREY;
  143249. private static _ORIGIN_MASK;
  143250. private static _ORIGIN_SHIFT;
  143251. private static _ORIGIN_BL;
  143252. private static _ORIGIN_BR;
  143253. private static _ORIGIN_UL;
  143254. private static _ORIGIN_UR;
  143255. /**
  143256. * Gets the header of a TGA file
  143257. * @param data defines the TGA data
  143258. * @returns the header
  143259. */
  143260. static GetTGAHeader(data: Uint8Array): any;
  143261. /**
  143262. * Uploads TGA content to a Babylon Texture
  143263. * @hidden
  143264. */
  143265. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143266. /** @hidden */
  143267. 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;
  143268. /** @hidden */
  143269. 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;
  143270. /** @hidden */
  143271. 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;
  143272. /** @hidden */
  143273. 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;
  143274. /** @hidden */
  143275. 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;
  143276. /** @hidden */
  143277. 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;
  143278. }
  143279. }
  143280. declare module BABYLON {
  143281. /**
  143282. * Implementation of the TGA Texture Loader.
  143283. * @hidden
  143284. */
  143285. export class _TGATextureLoader implements IInternalTextureLoader {
  143286. /**
  143287. * Defines wether the loader supports cascade loading the different faces.
  143288. */
  143289. readonly supportCascades: boolean;
  143290. /**
  143291. * This returns if the loader support the current file information.
  143292. * @param extension defines the file extension of the file being loaded
  143293. * @returns true if the loader can load the specified file
  143294. */
  143295. canLoad(extension: string): boolean;
  143296. /**
  143297. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143298. * @param data contains the texture data
  143299. * @param texture defines the BabylonJS internal texture
  143300. * @param createPolynomials will be true if polynomials have been requested
  143301. * @param onLoad defines the callback to trigger once the texture is ready
  143302. * @param onError defines the callback to trigger in case of error
  143303. */
  143304. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143305. /**
  143306. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143307. * @param data contains the texture data
  143308. * @param texture defines the BabylonJS internal texture
  143309. * @param callback defines the method to call once ready to upload
  143310. */
  143311. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143312. }
  143313. }
  143314. declare module BABYLON {
  143315. /**
  143316. * Info about the .basis files
  143317. */
  143318. class BasisFileInfo {
  143319. /**
  143320. * If the file has alpha
  143321. */
  143322. hasAlpha: boolean;
  143323. /**
  143324. * Info about each image of the basis file
  143325. */
  143326. images: Array<{
  143327. levels: Array<{
  143328. width: number;
  143329. height: number;
  143330. transcodedPixels: ArrayBufferView;
  143331. }>;
  143332. }>;
  143333. }
  143334. /**
  143335. * Result of transcoding a basis file
  143336. */
  143337. class TranscodeResult {
  143338. /**
  143339. * Info about the .basis file
  143340. */
  143341. fileInfo: BasisFileInfo;
  143342. /**
  143343. * Format to use when loading the file
  143344. */
  143345. format: number;
  143346. }
  143347. /**
  143348. * Configuration options for the Basis transcoder
  143349. */
  143350. export class BasisTranscodeConfiguration {
  143351. /**
  143352. * Supported compression formats used to determine the supported output format of the transcoder
  143353. */
  143354. supportedCompressionFormats?: {
  143355. /**
  143356. * etc1 compression format
  143357. */
  143358. etc1?: boolean;
  143359. /**
  143360. * s3tc compression format
  143361. */
  143362. s3tc?: boolean;
  143363. /**
  143364. * pvrtc compression format
  143365. */
  143366. pvrtc?: boolean;
  143367. /**
  143368. * etc2 compression format
  143369. */
  143370. etc2?: boolean;
  143371. };
  143372. /**
  143373. * If mipmap levels should be loaded for transcoded images (Default: true)
  143374. */
  143375. loadMipmapLevels?: boolean;
  143376. /**
  143377. * Index of a single image to load (Default: all images)
  143378. */
  143379. loadSingleImage?: number;
  143380. }
  143381. /**
  143382. * Used to load .Basis files
  143383. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143384. */
  143385. export class BasisTools {
  143386. private static _IgnoreSupportedFormats;
  143387. /**
  143388. * URL to use when loading the basis transcoder
  143389. */
  143390. static JSModuleURL: string;
  143391. /**
  143392. * URL to use when loading the wasm module for the transcoder
  143393. */
  143394. static WasmModuleURL: string;
  143395. /**
  143396. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143397. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143398. * @returns internal format corresponding to the Basis format
  143399. */
  143400. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143401. private static _WorkerPromise;
  143402. private static _Worker;
  143403. private static _actionId;
  143404. private static _CreateWorkerAsync;
  143405. /**
  143406. * Transcodes a loaded image file to compressed pixel data
  143407. * @param data image data to transcode
  143408. * @param config configuration options for the transcoding
  143409. * @returns a promise resulting in the transcoded image
  143410. */
  143411. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143412. /**
  143413. * Loads a texture from the transcode result
  143414. * @param texture texture load to
  143415. * @param transcodeResult the result of transcoding the basis file to load from
  143416. */
  143417. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143418. }
  143419. }
  143420. declare module BABYLON {
  143421. /**
  143422. * Loader for .basis file format
  143423. */
  143424. export class _BasisTextureLoader implements IInternalTextureLoader {
  143425. /**
  143426. * Defines whether the loader supports cascade loading the different faces.
  143427. */
  143428. readonly supportCascades: boolean;
  143429. /**
  143430. * This returns if the loader support the current file information.
  143431. * @param extension defines the file extension of the file being loaded
  143432. * @returns true if the loader can load the specified file
  143433. */
  143434. canLoad(extension: string): boolean;
  143435. /**
  143436. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143437. * @param data contains the texture data
  143438. * @param texture defines the BabylonJS internal texture
  143439. * @param createPolynomials will be true if polynomials have been requested
  143440. * @param onLoad defines the callback to trigger once the texture is ready
  143441. * @param onError defines the callback to trigger in case of error
  143442. */
  143443. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143444. /**
  143445. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143446. * @param data contains the texture data
  143447. * @param texture defines the BabylonJS internal texture
  143448. * @param callback defines the method to call once ready to upload
  143449. */
  143450. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143451. }
  143452. }
  143453. declare module BABYLON {
  143454. /**
  143455. * Defines the basic options interface of a TexturePacker Frame
  143456. */
  143457. export interface ITexturePackerFrame {
  143458. /**
  143459. * The frame ID
  143460. */
  143461. id: number;
  143462. /**
  143463. * The frames Scale
  143464. */
  143465. scale: Vector2;
  143466. /**
  143467. * The Frames offset
  143468. */
  143469. offset: Vector2;
  143470. }
  143471. /**
  143472. * This is a support class for frame Data on texture packer sets.
  143473. */
  143474. export class TexturePackerFrame implements ITexturePackerFrame {
  143475. /**
  143476. * The frame ID
  143477. */
  143478. id: number;
  143479. /**
  143480. * The frames Scale
  143481. */
  143482. scale: Vector2;
  143483. /**
  143484. * The Frames offset
  143485. */
  143486. offset: Vector2;
  143487. /**
  143488. * Initializes a texture package frame.
  143489. * @param id The numerical frame identifier
  143490. * @param scale Scalar Vector2 for UV frame
  143491. * @param offset Vector2 for the frame position in UV units.
  143492. * @returns TexturePackerFrame
  143493. */
  143494. constructor(id: number, scale: Vector2, offset: Vector2);
  143495. }
  143496. }
  143497. declare module BABYLON {
  143498. /**
  143499. * Defines the basic options interface of a TexturePacker
  143500. */
  143501. export interface ITexturePackerOptions {
  143502. /**
  143503. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143504. */
  143505. map?: string[];
  143506. /**
  143507. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143508. */
  143509. uvsIn?: string;
  143510. /**
  143511. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143512. */
  143513. uvsOut?: string;
  143514. /**
  143515. * number representing the layout style. Defaults to LAYOUT_STRIP
  143516. */
  143517. layout?: number;
  143518. /**
  143519. * number of columns if using custom column count layout(2). This defaults to 4.
  143520. */
  143521. colnum?: number;
  143522. /**
  143523. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143524. */
  143525. updateInputMeshes?: boolean;
  143526. /**
  143527. * boolean flag to dispose all the source textures. Defaults to true.
  143528. */
  143529. disposeSources?: boolean;
  143530. /**
  143531. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143532. */
  143533. fillBlanks?: boolean;
  143534. /**
  143535. * string value representing the context fill style color. Defaults to 'black'.
  143536. */
  143537. customFillColor?: string;
  143538. /**
  143539. * Width and Height Value of each Frame in the TexturePacker Sets
  143540. */
  143541. frameSize?: number;
  143542. /**
  143543. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143544. */
  143545. paddingRatio?: number;
  143546. /**
  143547. * Number that declares the fill method for the padding gutter.
  143548. */
  143549. paddingMode?: number;
  143550. /**
  143551. * If in SUBUV_COLOR padding mode what color to use.
  143552. */
  143553. paddingColor?: Color3 | Color4;
  143554. }
  143555. /**
  143556. * Defines the basic interface of a TexturePacker JSON File
  143557. */
  143558. export interface ITexturePackerJSON {
  143559. /**
  143560. * The frame ID
  143561. */
  143562. name: string;
  143563. /**
  143564. * The base64 channel data
  143565. */
  143566. sets: any;
  143567. /**
  143568. * The options of the Packer
  143569. */
  143570. options: ITexturePackerOptions;
  143571. /**
  143572. * The frame data of the Packer
  143573. */
  143574. frames: Array<number>;
  143575. }
  143576. /**
  143577. * This is a support class that generates a series of packed texture sets.
  143578. * @see https://doc.babylonjs.com/babylon101/materials
  143579. */
  143580. export class TexturePacker {
  143581. /** Packer Layout Constant 0 */
  143582. static readonly LAYOUT_STRIP: number;
  143583. /** Packer Layout Constant 1 */
  143584. static readonly LAYOUT_POWER2: number;
  143585. /** Packer Layout Constant 2 */
  143586. static readonly LAYOUT_COLNUM: number;
  143587. /** Packer Layout Constant 0 */
  143588. static readonly SUBUV_WRAP: number;
  143589. /** Packer Layout Constant 1 */
  143590. static readonly SUBUV_EXTEND: number;
  143591. /** Packer Layout Constant 2 */
  143592. static readonly SUBUV_COLOR: number;
  143593. /** The Name of the Texture Package */
  143594. name: string;
  143595. /** The scene scope of the TexturePacker */
  143596. scene: Scene;
  143597. /** The Meshes to target */
  143598. meshes: AbstractMesh[];
  143599. /** Arguments passed with the Constructor */
  143600. options: ITexturePackerOptions;
  143601. /** The promise that is started upon initialization */
  143602. promise: Nullable<Promise<TexturePacker | string>>;
  143603. /** The Container object for the channel sets that are generated */
  143604. sets: object;
  143605. /** The Container array for the frames that are generated */
  143606. frames: TexturePackerFrame[];
  143607. /** The expected number of textures the system is parsing. */
  143608. private _expecting;
  143609. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143610. private _paddingValue;
  143611. /**
  143612. * Initializes a texture package series from an array of meshes or a single mesh.
  143613. * @param name The name of the package
  143614. * @param meshes The target meshes to compose the package from
  143615. * @param options The arguments that texture packer should follow while building.
  143616. * @param scene The scene which the textures are scoped to.
  143617. * @returns TexturePacker
  143618. */
  143619. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143620. /**
  143621. * Starts the package process
  143622. * @param resolve The promises resolution function
  143623. * @returns TexturePacker
  143624. */
  143625. private _createFrames;
  143626. /**
  143627. * Calculates the Size of the Channel Sets
  143628. * @returns Vector2
  143629. */
  143630. private _calculateSize;
  143631. /**
  143632. * Calculates the UV data for the frames.
  143633. * @param baseSize the base frameSize
  143634. * @param padding the base frame padding
  143635. * @param dtSize size of the Dynamic Texture for that channel
  143636. * @param dtUnits is 1/dtSize
  143637. * @param update flag to update the input meshes
  143638. */
  143639. private _calculateMeshUVFrames;
  143640. /**
  143641. * Calculates the frames Offset.
  143642. * @param index of the frame
  143643. * @returns Vector2
  143644. */
  143645. private _getFrameOffset;
  143646. /**
  143647. * Updates a Mesh to the frame data
  143648. * @param mesh that is the target
  143649. * @param frameID or the frame index
  143650. */
  143651. private _updateMeshUV;
  143652. /**
  143653. * Updates a Meshes materials to use the texture packer channels
  143654. * @param m is the mesh to target
  143655. * @param force all channels on the packer to be set.
  143656. */
  143657. private _updateTextureReferences;
  143658. /**
  143659. * Public method to set a Mesh to a frame
  143660. * @param m that is the target
  143661. * @param frameID or the frame index
  143662. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143663. */
  143664. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143665. /**
  143666. * Starts the async promise to compile the texture packer.
  143667. * @returns Promise<void>
  143668. */
  143669. processAsync(): Promise<void>;
  143670. /**
  143671. * Disposes all textures associated with this packer
  143672. */
  143673. dispose(): void;
  143674. /**
  143675. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143676. * @param imageType is the image type to use.
  143677. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143678. */
  143679. download(imageType?: string, quality?: number): void;
  143680. /**
  143681. * Public method to load a texturePacker JSON file.
  143682. * @param data of the JSON file in string format.
  143683. */
  143684. updateFromJSON(data: string): void;
  143685. }
  143686. }
  143687. declare module BABYLON {
  143688. /**
  143689. * 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.
  143690. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143691. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143692. */
  143693. export class CustomProceduralTexture extends ProceduralTexture {
  143694. private _animate;
  143695. private _time;
  143696. private _config;
  143697. private _texturePath;
  143698. /**
  143699. * Instantiates a new Custom Procedural Texture.
  143700. * 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.
  143701. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143702. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143703. * @param name Define the name of the texture
  143704. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143705. * @param size Define the size of the texture to create
  143706. * @param scene Define the scene the texture belongs to
  143707. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143708. * @param generateMipMaps Define if the texture should creates mip maps or not
  143709. */
  143710. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143711. private _loadJson;
  143712. /**
  143713. * Is the texture ready to be used ? (rendered at least once)
  143714. * @returns true if ready, otherwise, false.
  143715. */
  143716. isReady(): boolean;
  143717. /**
  143718. * Render the texture to its associated render target.
  143719. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143720. */
  143721. render(useCameraPostProcess?: boolean): void;
  143722. /**
  143723. * Update the list of dependant textures samplers in the shader.
  143724. */
  143725. updateTextures(): void;
  143726. /**
  143727. * Update the uniform values of the procedural texture in the shader.
  143728. */
  143729. updateShaderUniforms(): void;
  143730. /**
  143731. * Define if the texture animates or not.
  143732. */
  143733. get animate(): boolean;
  143734. set animate(value: boolean);
  143735. }
  143736. }
  143737. declare module BABYLON {
  143738. /** @hidden */
  143739. export var noisePixelShader: {
  143740. name: string;
  143741. shader: string;
  143742. };
  143743. }
  143744. declare module BABYLON {
  143745. /**
  143746. * Class used to generate noise procedural textures
  143747. */
  143748. export class NoiseProceduralTexture extends ProceduralTexture {
  143749. /** Gets or sets the start time (default is 0) */
  143750. time: number;
  143751. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143752. brightness: number;
  143753. /** Defines the number of octaves to process */
  143754. octaves: number;
  143755. /** Defines the level of persistence (0.8 by default) */
  143756. persistence: number;
  143757. /** Gets or sets animation speed factor (default is 1) */
  143758. animationSpeedFactor: number;
  143759. /**
  143760. * Creates a new NoiseProceduralTexture
  143761. * @param name defines the name fo the texture
  143762. * @param size defines the size of the texture (default is 256)
  143763. * @param scene defines the hosting scene
  143764. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143765. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143766. */
  143767. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143768. private _updateShaderUniforms;
  143769. protected _getDefines(): string;
  143770. /** Generate the current state of the procedural texture */
  143771. render(useCameraPostProcess?: boolean): void;
  143772. /**
  143773. * Serializes this noise procedural texture
  143774. * @returns a serialized noise procedural texture object
  143775. */
  143776. serialize(): any;
  143777. /**
  143778. * Clone the texture.
  143779. * @returns the cloned texture
  143780. */
  143781. clone(): NoiseProceduralTexture;
  143782. /**
  143783. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143784. * @param parsedTexture defines parsed texture data
  143785. * @param scene defines the current scene
  143786. * @param rootUrl defines the root URL containing noise procedural texture information
  143787. * @returns a parsed NoiseProceduralTexture
  143788. */
  143789. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143790. }
  143791. }
  143792. declare module BABYLON {
  143793. /**
  143794. * Raw cube texture where the raw buffers are passed in
  143795. */
  143796. export class RawCubeTexture extends CubeTexture {
  143797. /**
  143798. * Creates a cube texture where the raw buffers are passed in.
  143799. * @param scene defines the scene the texture is attached to
  143800. * @param data defines the array of data to use to create each face
  143801. * @param size defines the size of the textures
  143802. * @param format defines the format of the data
  143803. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143804. * @param generateMipMaps defines if the engine should generate the mip levels
  143805. * @param invertY defines if data must be stored with Y axis inverted
  143806. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143807. * @param compression defines the compression used (null by default)
  143808. */
  143809. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143810. /**
  143811. * Updates the raw cube texture.
  143812. * @param data defines the data to store
  143813. * @param format defines the data format
  143814. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143815. * @param invertY defines if data must be stored with Y axis inverted
  143816. * @param compression defines the compression used (null by default)
  143817. * @param level defines which level of the texture to update
  143818. */
  143819. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143820. /**
  143821. * Updates a raw cube texture with RGBD encoded data.
  143822. * @param data defines the array of data [mipmap][face] to use to create each face
  143823. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143824. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143825. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143826. * @returns a promsie that resolves when the operation is complete
  143827. */
  143828. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143829. /**
  143830. * Clones the raw cube texture.
  143831. * @return a new cube texture
  143832. */
  143833. clone(): CubeTexture;
  143834. /** @hidden */
  143835. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143836. }
  143837. }
  143838. declare module BABYLON {
  143839. /**
  143840. * Class used to store 2D array textures containing user data
  143841. */
  143842. export class RawTexture2DArray extends Texture {
  143843. /** Gets or sets the texture format to use */
  143844. format: number;
  143845. /**
  143846. * Create a new RawTexture2DArray
  143847. * @param data defines the data of the texture
  143848. * @param width defines the width of the texture
  143849. * @param height defines the height of the texture
  143850. * @param depth defines the number of layers of the texture
  143851. * @param format defines the texture format to use
  143852. * @param scene defines the hosting scene
  143853. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143854. * @param invertY defines if texture must be stored with Y axis inverted
  143855. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143856. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143857. */
  143858. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143859. /** Gets or sets the texture format to use */
  143860. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143861. /**
  143862. * Update the texture with new data
  143863. * @param data defines the data to store in the texture
  143864. */
  143865. update(data: ArrayBufferView): void;
  143866. }
  143867. }
  143868. declare module BABYLON {
  143869. /**
  143870. * Class used to store 3D textures containing user data
  143871. */
  143872. export class RawTexture3D extends Texture {
  143873. /** Gets or sets the texture format to use */
  143874. format: number;
  143875. /**
  143876. * Create a new RawTexture3D
  143877. * @param data defines the data of the texture
  143878. * @param width defines the width of the texture
  143879. * @param height defines the height of the texture
  143880. * @param depth defines the depth of the texture
  143881. * @param format defines the texture format to use
  143882. * @param scene defines the hosting scene
  143883. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143884. * @param invertY defines if texture must be stored with Y axis inverted
  143885. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143886. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143887. */
  143888. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143889. /** Gets or sets the texture format to use */
  143890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143891. /**
  143892. * Update the texture with new data
  143893. * @param data defines the data to store in the texture
  143894. */
  143895. update(data: ArrayBufferView): void;
  143896. }
  143897. }
  143898. declare module BABYLON {
  143899. /**
  143900. * Creates a refraction texture used by refraction channel of the standard material.
  143901. * It is like a mirror but to see through a material.
  143902. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143903. */
  143904. export class RefractionTexture extends RenderTargetTexture {
  143905. /**
  143906. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143907. * 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.
  143908. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143909. */
  143910. refractionPlane: Plane;
  143911. /**
  143912. * Define how deep under the surface we should see.
  143913. */
  143914. depth: number;
  143915. /**
  143916. * Creates a refraction texture used by refraction channel of the standard material.
  143917. * It is like a mirror but to see through a material.
  143918. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143919. * @param name Define the texture name
  143920. * @param size Define the size of the underlying texture
  143921. * @param scene Define the scene the refraction belongs to
  143922. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143923. */
  143924. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143925. /**
  143926. * Clone the refraction texture.
  143927. * @returns the cloned texture
  143928. */
  143929. clone(): RefractionTexture;
  143930. /**
  143931. * Serialize the texture to a JSON representation you could use in Parse later on
  143932. * @returns the serialized JSON representation
  143933. */
  143934. serialize(): any;
  143935. }
  143936. }
  143937. declare module BABYLON {
  143938. /**
  143939. * Block used to add support for vertex skinning (bones)
  143940. */
  143941. export class BonesBlock extends NodeMaterialBlock {
  143942. /**
  143943. * Creates a new BonesBlock
  143944. * @param name defines the block name
  143945. */
  143946. constructor(name: string);
  143947. /**
  143948. * Initialize the block and prepare the context for build
  143949. * @param state defines the state that will be used for the build
  143950. */
  143951. initialize(state: NodeMaterialBuildState): void;
  143952. /**
  143953. * Gets the current class name
  143954. * @returns the class name
  143955. */
  143956. getClassName(): string;
  143957. /**
  143958. * Gets the matrix indices input component
  143959. */
  143960. get matricesIndices(): NodeMaterialConnectionPoint;
  143961. /**
  143962. * Gets the matrix weights input component
  143963. */
  143964. get matricesWeights(): NodeMaterialConnectionPoint;
  143965. /**
  143966. * Gets the extra matrix indices input component
  143967. */
  143968. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the extra matrix weights input component
  143971. */
  143972. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143973. /**
  143974. * Gets the world input component
  143975. */
  143976. get world(): NodeMaterialConnectionPoint;
  143977. /**
  143978. * Gets the output component
  143979. */
  143980. get output(): NodeMaterialConnectionPoint;
  143981. autoConfigure(material: NodeMaterial): void;
  143982. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143983. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143985. protected _buildBlock(state: NodeMaterialBuildState): this;
  143986. }
  143987. }
  143988. declare module BABYLON {
  143989. /**
  143990. * Block used to add support for instances
  143991. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143992. */
  143993. export class InstancesBlock extends NodeMaterialBlock {
  143994. /**
  143995. * Creates a new InstancesBlock
  143996. * @param name defines the block name
  143997. */
  143998. constructor(name: string);
  143999. /**
  144000. * Gets the current class name
  144001. * @returns the class name
  144002. */
  144003. getClassName(): string;
  144004. /**
  144005. * Gets the first world row input component
  144006. */
  144007. get world0(): NodeMaterialConnectionPoint;
  144008. /**
  144009. * Gets the second world row input component
  144010. */
  144011. get world1(): NodeMaterialConnectionPoint;
  144012. /**
  144013. * Gets the third world row input component
  144014. */
  144015. get world2(): NodeMaterialConnectionPoint;
  144016. /**
  144017. * Gets the forth world row input component
  144018. */
  144019. get world3(): NodeMaterialConnectionPoint;
  144020. /**
  144021. * Gets the world input component
  144022. */
  144023. get world(): NodeMaterialConnectionPoint;
  144024. /**
  144025. * Gets the output component
  144026. */
  144027. get output(): NodeMaterialConnectionPoint;
  144028. /**
  144029. * Gets the isntanceID component
  144030. */
  144031. get instanceID(): NodeMaterialConnectionPoint;
  144032. autoConfigure(material: NodeMaterial): void;
  144033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  144034. protected _buildBlock(state: NodeMaterialBuildState): this;
  144035. }
  144036. }
  144037. declare module BABYLON {
  144038. /**
  144039. * Block used to add morph targets support to vertex shader
  144040. */
  144041. export class MorphTargetsBlock extends NodeMaterialBlock {
  144042. private _repeatableContentAnchor;
  144043. /**
  144044. * Create a new MorphTargetsBlock
  144045. * @param name defines the block name
  144046. */
  144047. constructor(name: string);
  144048. /**
  144049. * Gets the current class name
  144050. * @returns the class name
  144051. */
  144052. getClassName(): string;
  144053. /**
  144054. * Gets the position input component
  144055. */
  144056. get position(): NodeMaterialConnectionPoint;
  144057. /**
  144058. * Gets the normal input component
  144059. */
  144060. get normal(): NodeMaterialConnectionPoint;
  144061. /**
  144062. * Gets the tangent input component
  144063. */
  144064. get tangent(): NodeMaterialConnectionPoint;
  144065. /**
  144066. * Gets the tangent input component
  144067. */
  144068. get uv(): NodeMaterialConnectionPoint;
  144069. /**
  144070. * Gets the position output component
  144071. */
  144072. get positionOutput(): NodeMaterialConnectionPoint;
  144073. /**
  144074. * Gets the normal output component
  144075. */
  144076. get normalOutput(): NodeMaterialConnectionPoint;
  144077. /**
  144078. * Gets the tangent output component
  144079. */
  144080. get tangentOutput(): NodeMaterialConnectionPoint;
  144081. /**
  144082. * Gets the tangent output component
  144083. */
  144084. get uvOutput(): NodeMaterialConnectionPoint;
  144085. initialize(state: NodeMaterialBuildState): void;
  144086. autoConfigure(material: NodeMaterial): void;
  144087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144089. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144090. protected _buildBlock(state: NodeMaterialBuildState): this;
  144091. }
  144092. }
  144093. declare module BABYLON {
  144094. /**
  144095. * Block used to get data information from a light
  144096. */
  144097. export class LightInformationBlock extends NodeMaterialBlock {
  144098. private _lightDataUniformName;
  144099. private _lightColorUniformName;
  144100. private _lightTypeDefineName;
  144101. /**
  144102. * Gets or sets the light associated with this block
  144103. */
  144104. light: Nullable<Light>;
  144105. /**
  144106. * Creates a new LightInformationBlock
  144107. * @param name defines the block name
  144108. */
  144109. constructor(name: string);
  144110. /**
  144111. * Gets the current class name
  144112. * @returns the class name
  144113. */
  144114. getClassName(): string;
  144115. /**
  144116. * Gets the world position input component
  144117. */
  144118. get worldPosition(): NodeMaterialConnectionPoint;
  144119. /**
  144120. * Gets the direction output component
  144121. */
  144122. get direction(): NodeMaterialConnectionPoint;
  144123. /**
  144124. * Gets the direction output component
  144125. */
  144126. get color(): NodeMaterialConnectionPoint;
  144127. /**
  144128. * Gets the direction output component
  144129. */
  144130. get intensity(): NodeMaterialConnectionPoint;
  144131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144132. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144133. protected _buildBlock(state: NodeMaterialBuildState): this;
  144134. serialize(): any;
  144135. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144136. }
  144137. }
  144138. declare module BABYLON {
  144139. /**
  144140. * Block used to add image processing support to fragment shader
  144141. */
  144142. export class ImageProcessingBlock extends NodeMaterialBlock {
  144143. /**
  144144. * Create a new ImageProcessingBlock
  144145. * @param name defines the block name
  144146. */
  144147. constructor(name: string);
  144148. /**
  144149. * Gets the current class name
  144150. * @returns the class name
  144151. */
  144152. getClassName(): string;
  144153. /**
  144154. * Gets the color input component
  144155. */
  144156. get color(): NodeMaterialConnectionPoint;
  144157. /**
  144158. * Gets the output component
  144159. */
  144160. get output(): NodeMaterialConnectionPoint;
  144161. /**
  144162. * Initialize the block and prepare the context for build
  144163. * @param state defines the state that will be used for the build
  144164. */
  144165. initialize(state: NodeMaterialBuildState): void;
  144166. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144169. protected _buildBlock(state: NodeMaterialBuildState): this;
  144170. }
  144171. }
  144172. declare module BABYLON {
  144173. /**
  144174. * Block used to pertub normals based on a normal map
  144175. */
  144176. export class PerturbNormalBlock extends NodeMaterialBlock {
  144177. private _tangentSpaceParameterName;
  144178. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144179. invertX: boolean;
  144180. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144181. invertY: boolean;
  144182. /**
  144183. * Create a new PerturbNormalBlock
  144184. * @param name defines the block name
  144185. */
  144186. constructor(name: string);
  144187. /**
  144188. * Gets the current class name
  144189. * @returns the class name
  144190. */
  144191. getClassName(): string;
  144192. /**
  144193. * Gets the world position input component
  144194. */
  144195. get worldPosition(): NodeMaterialConnectionPoint;
  144196. /**
  144197. * Gets the world normal input component
  144198. */
  144199. get worldNormal(): NodeMaterialConnectionPoint;
  144200. /**
  144201. * Gets the world tangent input component
  144202. */
  144203. get worldTangent(): NodeMaterialConnectionPoint;
  144204. /**
  144205. * Gets the uv input component
  144206. */
  144207. get uv(): NodeMaterialConnectionPoint;
  144208. /**
  144209. * Gets the normal map color input component
  144210. */
  144211. get normalMapColor(): NodeMaterialConnectionPoint;
  144212. /**
  144213. * Gets the strength input component
  144214. */
  144215. get strength(): NodeMaterialConnectionPoint;
  144216. /**
  144217. * Gets the output component
  144218. */
  144219. get output(): NodeMaterialConnectionPoint;
  144220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144222. autoConfigure(material: NodeMaterial): void;
  144223. protected _buildBlock(state: NodeMaterialBuildState): this;
  144224. protected _dumpPropertiesCode(): string;
  144225. serialize(): any;
  144226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144227. }
  144228. }
  144229. declare module BABYLON {
  144230. /**
  144231. * Block used to discard a pixel if a value is smaller than a cutoff
  144232. */
  144233. export class DiscardBlock extends NodeMaterialBlock {
  144234. /**
  144235. * Create a new DiscardBlock
  144236. * @param name defines the block name
  144237. */
  144238. constructor(name: string);
  144239. /**
  144240. * Gets the current class name
  144241. * @returns the class name
  144242. */
  144243. getClassName(): string;
  144244. /**
  144245. * Gets the color input component
  144246. */
  144247. get value(): NodeMaterialConnectionPoint;
  144248. /**
  144249. * Gets the cutoff input component
  144250. */
  144251. get cutoff(): NodeMaterialConnectionPoint;
  144252. protected _buildBlock(state: NodeMaterialBuildState): this;
  144253. }
  144254. }
  144255. declare module BABYLON {
  144256. /**
  144257. * Block used to test if the fragment shader is front facing
  144258. */
  144259. export class FrontFacingBlock extends NodeMaterialBlock {
  144260. /**
  144261. * Creates a new FrontFacingBlock
  144262. * @param name defines the block name
  144263. */
  144264. constructor(name: string);
  144265. /**
  144266. * Gets the current class name
  144267. * @returns the class name
  144268. */
  144269. getClassName(): string;
  144270. /**
  144271. * Gets the output component
  144272. */
  144273. get output(): NodeMaterialConnectionPoint;
  144274. protected _buildBlock(state: NodeMaterialBuildState): this;
  144275. }
  144276. }
  144277. declare module BABYLON {
  144278. /**
  144279. * Block used to get the derivative value on x and y of a given input
  144280. */
  144281. export class DerivativeBlock extends NodeMaterialBlock {
  144282. /**
  144283. * Create a new DerivativeBlock
  144284. * @param name defines the block name
  144285. */
  144286. constructor(name: string);
  144287. /**
  144288. * Gets the current class name
  144289. * @returns the class name
  144290. */
  144291. getClassName(): string;
  144292. /**
  144293. * Gets the input component
  144294. */
  144295. get input(): NodeMaterialConnectionPoint;
  144296. /**
  144297. * Gets the derivative output on x
  144298. */
  144299. get dx(): NodeMaterialConnectionPoint;
  144300. /**
  144301. * Gets the derivative output on y
  144302. */
  144303. get dy(): NodeMaterialConnectionPoint;
  144304. protected _buildBlock(state: NodeMaterialBuildState): this;
  144305. }
  144306. }
  144307. declare module BABYLON {
  144308. /**
  144309. * Block used to make gl_FragCoord available
  144310. */
  144311. export class FragCoordBlock extends NodeMaterialBlock {
  144312. /**
  144313. * Creates a new FragCoordBlock
  144314. * @param name defines the block name
  144315. */
  144316. constructor(name: string);
  144317. /**
  144318. * Gets the current class name
  144319. * @returns the class name
  144320. */
  144321. getClassName(): string;
  144322. /**
  144323. * Gets the xy component
  144324. */
  144325. get xy(): NodeMaterialConnectionPoint;
  144326. /**
  144327. * Gets the xyz component
  144328. */
  144329. get xyz(): NodeMaterialConnectionPoint;
  144330. /**
  144331. * Gets the xyzw component
  144332. */
  144333. get xyzw(): NodeMaterialConnectionPoint;
  144334. /**
  144335. * Gets the x component
  144336. */
  144337. get x(): NodeMaterialConnectionPoint;
  144338. /**
  144339. * Gets the y component
  144340. */
  144341. get y(): NodeMaterialConnectionPoint;
  144342. /**
  144343. * Gets the z component
  144344. */
  144345. get z(): NodeMaterialConnectionPoint;
  144346. /**
  144347. * Gets the w component
  144348. */
  144349. get output(): NodeMaterialConnectionPoint;
  144350. protected writeOutputs(state: NodeMaterialBuildState): string;
  144351. protected _buildBlock(state: NodeMaterialBuildState): this;
  144352. }
  144353. }
  144354. declare module BABYLON {
  144355. /**
  144356. * Block used to get the screen sizes
  144357. */
  144358. export class ScreenSizeBlock extends NodeMaterialBlock {
  144359. private _varName;
  144360. private _scene;
  144361. /**
  144362. * Creates a new ScreenSizeBlock
  144363. * @param name defines the block name
  144364. */
  144365. constructor(name: string);
  144366. /**
  144367. * Gets the current class name
  144368. * @returns the class name
  144369. */
  144370. getClassName(): string;
  144371. /**
  144372. * Gets the xy component
  144373. */
  144374. get xy(): NodeMaterialConnectionPoint;
  144375. /**
  144376. * Gets the x component
  144377. */
  144378. get x(): NodeMaterialConnectionPoint;
  144379. /**
  144380. * Gets the y component
  144381. */
  144382. get y(): NodeMaterialConnectionPoint;
  144383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144384. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144385. protected _buildBlock(state: NodeMaterialBuildState): this;
  144386. }
  144387. }
  144388. declare module BABYLON {
  144389. /**
  144390. * Block used to add support for scene fog
  144391. */
  144392. export class FogBlock extends NodeMaterialBlock {
  144393. private _fogDistanceName;
  144394. private _fogParameters;
  144395. /**
  144396. * Create a new FogBlock
  144397. * @param name defines the block name
  144398. */
  144399. constructor(name: string);
  144400. /**
  144401. * Gets the current class name
  144402. * @returns the class name
  144403. */
  144404. getClassName(): string;
  144405. /**
  144406. * Gets the world position input component
  144407. */
  144408. get worldPosition(): NodeMaterialConnectionPoint;
  144409. /**
  144410. * Gets the view input component
  144411. */
  144412. get view(): NodeMaterialConnectionPoint;
  144413. /**
  144414. * Gets the color input component
  144415. */
  144416. get input(): NodeMaterialConnectionPoint;
  144417. /**
  144418. * Gets the fog color input component
  144419. */
  144420. get fogColor(): NodeMaterialConnectionPoint;
  144421. /**
  144422. * Gets the output component
  144423. */
  144424. get output(): NodeMaterialConnectionPoint;
  144425. autoConfigure(material: NodeMaterial): void;
  144426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144427. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144428. protected _buildBlock(state: NodeMaterialBuildState): this;
  144429. }
  144430. }
  144431. declare module BABYLON {
  144432. /**
  144433. * Block used to add light in the fragment shader
  144434. */
  144435. export class LightBlock extends NodeMaterialBlock {
  144436. private _lightId;
  144437. /**
  144438. * Gets or sets the light associated with this block
  144439. */
  144440. light: Nullable<Light>;
  144441. /**
  144442. * Create a new LightBlock
  144443. * @param name defines the block name
  144444. */
  144445. constructor(name: string);
  144446. /**
  144447. * Gets the current class name
  144448. * @returns the class name
  144449. */
  144450. getClassName(): string;
  144451. /**
  144452. * Gets the world position input component
  144453. */
  144454. get worldPosition(): NodeMaterialConnectionPoint;
  144455. /**
  144456. * Gets the world normal input component
  144457. */
  144458. get worldNormal(): NodeMaterialConnectionPoint;
  144459. /**
  144460. * Gets the camera (or eye) position component
  144461. */
  144462. get cameraPosition(): NodeMaterialConnectionPoint;
  144463. /**
  144464. * Gets the glossiness component
  144465. */
  144466. get glossiness(): NodeMaterialConnectionPoint;
  144467. /**
  144468. * Gets the glossinness power component
  144469. */
  144470. get glossPower(): NodeMaterialConnectionPoint;
  144471. /**
  144472. * Gets the diffuse color component
  144473. */
  144474. get diffuseColor(): NodeMaterialConnectionPoint;
  144475. /**
  144476. * Gets the specular color component
  144477. */
  144478. get specularColor(): NodeMaterialConnectionPoint;
  144479. /**
  144480. * Gets the view matrix component
  144481. */
  144482. get view(): NodeMaterialConnectionPoint;
  144483. /**
  144484. * Gets the diffuse output component
  144485. */
  144486. get diffuseOutput(): NodeMaterialConnectionPoint;
  144487. /**
  144488. * Gets the specular output component
  144489. */
  144490. get specularOutput(): NodeMaterialConnectionPoint;
  144491. /**
  144492. * Gets the shadow output component
  144493. */
  144494. get shadow(): NodeMaterialConnectionPoint;
  144495. autoConfigure(material: NodeMaterial): void;
  144496. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144497. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144498. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144499. private _injectVertexCode;
  144500. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144501. serialize(): any;
  144502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144503. }
  144504. }
  144505. declare module BABYLON {
  144506. /**
  144507. * Block used to read a reflection texture from a sampler
  144508. */
  144509. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144510. /**
  144511. * Create a new ReflectionTextureBlock
  144512. * @param name defines the block name
  144513. */
  144514. constructor(name: string);
  144515. /**
  144516. * Gets the current class name
  144517. * @returns the class name
  144518. */
  144519. getClassName(): string;
  144520. /**
  144521. * Gets the world position input component
  144522. */
  144523. get position(): NodeMaterialConnectionPoint;
  144524. /**
  144525. * Gets the world position input component
  144526. */
  144527. get worldPosition(): NodeMaterialConnectionPoint;
  144528. /**
  144529. * Gets the world normal input component
  144530. */
  144531. get worldNormal(): NodeMaterialConnectionPoint;
  144532. /**
  144533. * Gets the world input component
  144534. */
  144535. get world(): NodeMaterialConnectionPoint;
  144536. /**
  144537. * Gets the camera (or eye) position component
  144538. */
  144539. get cameraPosition(): NodeMaterialConnectionPoint;
  144540. /**
  144541. * Gets the view input component
  144542. */
  144543. get view(): NodeMaterialConnectionPoint;
  144544. /**
  144545. * Gets the rgb output component
  144546. */
  144547. get rgb(): NodeMaterialConnectionPoint;
  144548. /**
  144549. * Gets the rgba output component
  144550. */
  144551. get rgba(): NodeMaterialConnectionPoint;
  144552. /**
  144553. * Gets the r output component
  144554. */
  144555. get r(): NodeMaterialConnectionPoint;
  144556. /**
  144557. * Gets the g output component
  144558. */
  144559. get g(): NodeMaterialConnectionPoint;
  144560. /**
  144561. * Gets the b output component
  144562. */
  144563. get b(): NodeMaterialConnectionPoint;
  144564. /**
  144565. * Gets the a output component
  144566. */
  144567. get a(): NodeMaterialConnectionPoint;
  144568. autoConfigure(material: NodeMaterial): void;
  144569. protected _buildBlock(state: NodeMaterialBuildState): this;
  144570. }
  144571. }
  144572. declare module BABYLON {
  144573. /**
  144574. * Block used to add 2 vectors
  144575. */
  144576. export class AddBlock extends NodeMaterialBlock {
  144577. /**
  144578. * Creates a new AddBlock
  144579. * @param name defines the block name
  144580. */
  144581. constructor(name: string);
  144582. /**
  144583. * Gets the current class name
  144584. * @returns the class name
  144585. */
  144586. getClassName(): string;
  144587. /**
  144588. * Gets the left operand input component
  144589. */
  144590. get left(): NodeMaterialConnectionPoint;
  144591. /**
  144592. * Gets the right operand input component
  144593. */
  144594. get right(): NodeMaterialConnectionPoint;
  144595. /**
  144596. * Gets the output component
  144597. */
  144598. get output(): NodeMaterialConnectionPoint;
  144599. protected _buildBlock(state: NodeMaterialBuildState): this;
  144600. }
  144601. }
  144602. declare module BABYLON {
  144603. /**
  144604. * Block used to scale a vector by a float
  144605. */
  144606. export class ScaleBlock extends NodeMaterialBlock {
  144607. /**
  144608. * Creates a new ScaleBlock
  144609. * @param name defines the block name
  144610. */
  144611. constructor(name: string);
  144612. /**
  144613. * Gets the current class name
  144614. * @returns the class name
  144615. */
  144616. getClassName(): string;
  144617. /**
  144618. * Gets the input component
  144619. */
  144620. get input(): NodeMaterialConnectionPoint;
  144621. /**
  144622. * Gets the factor input component
  144623. */
  144624. get factor(): NodeMaterialConnectionPoint;
  144625. /**
  144626. * Gets the output component
  144627. */
  144628. get output(): NodeMaterialConnectionPoint;
  144629. protected _buildBlock(state: NodeMaterialBuildState): this;
  144630. }
  144631. }
  144632. declare module BABYLON {
  144633. /**
  144634. * Block used to clamp a float
  144635. */
  144636. export class ClampBlock extends NodeMaterialBlock {
  144637. /** Gets or sets the minimum range */
  144638. minimum: number;
  144639. /** Gets or sets the maximum range */
  144640. maximum: number;
  144641. /**
  144642. * Creates a new ClampBlock
  144643. * @param name defines the block name
  144644. */
  144645. constructor(name: string);
  144646. /**
  144647. * Gets the current class name
  144648. * @returns the class name
  144649. */
  144650. getClassName(): string;
  144651. /**
  144652. * Gets the value input component
  144653. */
  144654. get value(): NodeMaterialConnectionPoint;
  144655. /**
  144656. * Gets the output component
  144657. */
  144658. get output(): NodeMaterialConnectionPoint;
  144659. protected _buildBlock(state: NodeMaterialBuildState): this;
  144660. protected _dumpPropertiesCode(): string;
  144661. serialize(): any;
  144662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144663. }
  144664. }
  144665. declare module BABYLON {
  144666. /**
  144667. * Block used to apply a cross product between 2 vectors
  144668. */
  144669. export class CrossBlock extends NodeMaterialBlock {
  144670. /**
  144671. * Creates a new CrossBlock
  144672. * @param name defines the block name
  144673. */
  144674. constructor(name: string);
  144675. /**
  144676. * Gets the current class name
  144677. * @returns the class name
  144678. */
  144679. getClassName(): string;
  144680. /**
  144681. * Gets the left operand input component
  144682. */
  144683. get left(): NodeMaterialConnectionPoint;
  144684. /**
  144685. * Gets the right operand input component
  144686. */
  144687. get right(): NodeMaterialConnectionPoint;
  144688. /**
  144689. * Gets the output component
  144690. */
  144691. get output(): NodeMaterialConnectionPoint;
  144692. protected _buildBlock(state: NodeMaterialBuildState): this;
  144693. }
  144694. }
  144695. declare module BABYLON {
  144696. /**
  144697. * Block used to apply a dot product between 2 vectors
  144698. */
  144699. export class DotBlock extends NodeMaterialBlock {
  144700. /**
  144701. * Creates a new DotBlock
  144702. * @param name defines the block name
  144703. */
  144704. constructor(name: string);
  144705. /**
  144706. * Gets the current class name
  144707. * @returns the class name
  144708. */
  144709. getClassName(): string;
  144710. /**
  144711. * Gets the left operand input component
  144712. */
  144713. get left(): NodeMaterialConnectionPoint;
  144714. /**
  144715. * Gets the right operand input component
  144716. */
  144717. get right(): NodeMaterialConnectionPoint;
  144718. /**
  144719. * Gets the output component
  144720. */
  144721. get output(): NodeMaterialConnectionPoint;
  144722. protected _buildBlock(state: NodeMaterialBuildState): this;
  144723. }
  144724. }
  144725. declare module BABYLON {
  144726. /**
  144727. * Block used to normalize a vector
  144728. */
  144729. export class NormalizeBlock extends NodeMaterialBlock {
  144730. /**
  144731. * Creates a new NormalizeBlock
  144732. * @param name defines the block name
  144733. */
  144734. constructor(name: string);
  144735. /**
  144736. * Gets the current class name
  144737. * @returns the class name
  144738. */
  144739. getClassName(): string;
  144740. /**
  144741. * Gets the input component
  144742. */
  144743. get input(): NodeMaterialConnectionPoint;
  144744. /**
  144745. * Gets the output component
  144746. */
  144747. get output(): NodeMaterialConnectionPoint;
  144748. protected _buildBlock(state: NodeMaterialBuildState): this;
  144749. }
  144750. }
  144751. declare module BABYLON {
  144752. /**
  144753. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144754. */
  144755. export class ColorMergerBlock extends NodeMaterialBlock {
  144756. /**
  144757. * Create a new ColorMergerBlock
  144758. * @param name defines the block name
  144759. */
  144760. constructor(name: string);
  144761. /**
  144762. * Gets the current class name
  144763. * @returns the class name
  144764. */
  144765. getClassName(): string;
  144766. /**
  144767. * Gets the rgb component (input)
  144768. */
  144769. get rgbIn(): NodeMaterialConnectionPoint;
  144770. /**
  144771. * Gets the r component (input)
  144772. */
  144773. get r(): NodeMaterialConnectionPoint;
  144774. /**
  144775. * Gets the g component (input)
  144776. */
  144777. get g(): NodeMaterialConnectionPoint;
  144778. /**
  144779. * Gets the b component (input)
  144780. */
  144781. get b(): NodeMaterialConnectionPoint;
  144782. /**
  144783. * Gets the a component (input)
  144784. */
  144785. get a(): NodeMaterialConnectionPoint;
  144786. /**
  144787. * Gets the rgba component (output)
  144788. */
  144789. get rgba(): NodeMaterialConnectionPoint;
  144790. /**
  144791. * Gets the rgb component (output)
  144792. */
  144793. get rgbOut(): NodeMaterialConnectionPoint;
  144794. /**
  144795. * Gets the rgb component (output)
  144796. * @deprecated Please use rgbOut instead.
  144797. */
  144798. get rgb(): NodeMaterialConnectionPoint;
  144799. protected _buildBlock(state: NodeMaterialBuildState): this;
  144800. }
  144801. }
  144802. declare module BABYLON {
  144803. /**
  144804. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144805. */
  144806. export class VectorSplitterBlock extends NodeMaterialBlock {
  144807. /**
  144808. * Create a new VectorSplitterBlock
  144809. * @param name defines the block name
  144810. */
  144811. constructor(name: string);
  144812. /**
  144813. * Gets the current class name
  144814. * @returns the class name
  144815. */
  144816. getClassName(): string;
  144817. /**
  144818. * Gets the xyzw component (input)
  144819. */
  144820. get xyzw(): NodeMaterialConnectionPoint;
  144821. /**
  144822. * Gets the xyz component (input)
  144823. */
  144824. get xyzIn(): NodeMaterialConnectionPoint;
  144825. /**
  144826. * Gets the xy component (input)
  144827. */
  144828. get xyIn(): NodeMaterialConnectionPoint;
  144829. /**
  144830. * Gets the xyz component (output)
  144831. */
  144832. get xyzOut(): NodeMaterialConnectionPoint;
  144833. /**
  144834. * Gets the xy component (output)
  144835. */
  144836. get xyOut(): NodeMaterialConnectionPoint;
  144837. /**
  144838. * Gets the x component (output)
  144839. */
  144840. get x(): NodeMaterialConnectionPoint;
  144841. /**
  144842. * Gets the y component (output)
  144843. */
  144844. get y(): NodeMaterialConnectionPoint;
  144845. /**
  144846. * Gets the z component (output)
  144847. */
  144848. get z(): NodeMaterialConnectionPoint;
  144849. /**
  144850. * Gets the w component (output)
  144851. */
  144852. get w(): NodeMaterialConnectionPoint;
  144853. protected _inputRename(name: string): string;
  144854. protected _outputRename(name: string): string;
  144855. protected _buildBlock(state: NodeMaterialBuildState): this;
  144856. }
  144857. }
  144858. declare module BABYLON {
  144859. /**
  144860. * Block used to lerp between 2 values
  144861. */
  144862. export class LerpBlock extends NodeMaterialBlock {
  144863. /**
  144864. * Creates a new LerpBlock
  144865. * @param name defines the block name
  144866. */
  144867. constructor(name: string);
  144868. /**
  144869. * Gets the current class name
  144870. * @returns the class name
  144871. */
  144872. getClassName(): string;
  144873. /**
  144874. * Gets the left operand input component
  144875. */
  144876. get left(): NodeMaterialConnectionPoint;
  144877. /**
  144878. * Gets the right operand input component
  144879. */
  144880. get right(): NodeMaterialConnectionPoint;
  144881. /**
  144882. * Gets the gradient operand input component
  144883. */
  144884. get gradient(): NodeMaterialConnectionPoint;
  144885. /**
  144886. * Gets the output component
  144887. */
  144888. get output(): NodeMaterialConnectionPoint;
  144889. protected _buildBlock(state: NodeMaterialBuildState): this;
  144890. }
  144891. }
  144892. declare module BABYLON {
  144893. /**
  144894. * Block used to divide 2 vectors
  144895. */
  144896. export class DivideBlock extends NodeMaterialBlock {
  144897. /**
  144898. * Creates a new DivideBlock
  144899. * @param name defines the block name
  144900. */
  144901. constructor(name: string);
  144902. /**
  144903. * Gets the current class name
  144904. * @returns the class name
  144905. */
  144906. getClassName(): string;
  144907. /**
  144908. * Gets the left operand input component
  144909. */
  144910. get left(): NodeMaterialConnectionPoint;
  144911. /**
  144912. * Gets the right operand input component
  144913. */
  144914. get right(): NodeMaterialConnectionPoint;
  144915. /**
  144916. * Gets the output component
  144917. */
  144918. get output(): NodeMaterialConnectionPoint;
  144919. protected _buildBlock(state: NodeMaterialBuildState): this;
  144920. }
  144921. }
  144922. declare module BABYLON {
  144923. /**
  144924. * Block used to subtract 2 vectors
  144925. */
  144926. export class SubtractBlock extends NodeMaterialBlock {
  144927. /**
  144928. * Creates a new SubtractBlock
  144929. * @param name defines the block name
  144930. */
  144931. constructor(name: string);
  144932. /**
  144933. * Gets the current class name
  144934. * @returns the class name
  144935. */
  144936. getClassName(): string;
  144937. /**
  144938. * Gets the left operand input component
  144939. */
  144940. get left(): NodeMaterialConnectionPoint;
  144941. /**
  144942. * Gets the right operand input component
  144943. */
  144944. get right(): NodeMaterialConnectionPoint;
  144945. /**
  144946. * Gets the output component
  144947. */
  144948. get output(): NodeMaterialConnectionPoint;
  144949. protected _buildBlock(state: NodeMaterialBuildState): this;
  144950. }
  144951. }
  144952. declare module BABYLON {
  144953. /**
  144954. * Block used to step a value
  144955. */
  144956. export class StepBlock extends NodeMaterialBlock {
  144957. /**
  144958. * Creates a new StepBlock
  144959. * @param name defines the block name
  144960. */
  144961. constructor(name: string);
  144962. /**
  144963. * Gets the current class name
  144964. * @returns the class name
  144965. */
  144966. getClassName(): string;
  144967. /**
  144968. * Gets the value operand input component
  144969. */
  144970. get value(): NodeMaterialConnectionPoint;
  144971. /**
  144972. * Gets the edge operand input component
  144973. */
  144974. get edge(): NodeMaterialConnectionPoint;
  144975. /**
  144976. * Gets the output component
  144977. */
  144978. get output(): NodeMaterialConnectionPoint;
  144979. protected _buildBlock(state: NodeMaterialBuildState): this;
  144980. }
  144981. }
  144982. declare module BABYLON {
  144983. /**
  144984. * Block used to get the opposite (1 - x) of a value
  144985. */
  144986. export class OneMinusBlock extends NodeMaterialBlock {
  144987. /**
  144988. * Creates a new OneMinusBlock
  144989. * @param name defines the block name
  144990. */
  144991. constructor(name: string);
  144992. /**
  144993. * Gets the current class name
  144994. * @returns the class name
  144995. */
  144996. getClassName(): string;
  144997. /**
  144998. * Gets the input component
  144999. */
  145000. get input(): NodeMaterialConnectionPoint;
  145001. /**
  145002. * Gets the output component
  145003. */
  145004. get output(): NodeMaterialConnectionPoint;
  145005. protected _buildBlock(state: NodeMaterialBuildState): this;
  145006. }
  145007. }
  145008. declare module BABYLON {
  145009. /**
  145010. * Block used to get the view direction
  145011. */
  145012. export class ViewDirectionBlock extends NodeMaterialBlock {
  145013. /**
  145014. * Creates a new ViewDirectionBlock
  145015. * @param name defines the block name
  145016. */
  145017. constructor(name: string);
  145018. /**
  145019. * Gets the current class name
  145020. * @returns the class name
  145021. */
  145022. getClassName(): string;
  145023. /**
  145024. * Gets the world position component
  145025. */
  145026. get worldPosition(): NodeMaterialConnectionPoint;
  145027. /**
  145028. * Gets the camera position component
  145029. */
  145030. get cameraPosition(): NodeMaterialConnectionPoint;
  145031. /**
  145032. * Gets the output component
  145033. */
  145034. get output(): NodeMaterialConnectionPoint;
  145035. autoConfigure(material: NodeMaterial): void;
  145036. protected _buildBlock(state: NodeMaterialBuildState): this;
  145037. }
  145038. }
  145039. declare module BABYLON {
  145040. /**
  145041. * Block used to compute fresnel value
  145042. */
  145043. export class FresnelBlock extends NodeMaterialBlock {
  145044. /**
  145045. * Create a new FresnelBlock
  145046. * @param name defines the block name
  145047. */
  145048. constructor(name: string);
  145049. /**
  145050. * Gets the current class name
  145051. * @returns the class name
  145052. */
  145053. getClassName(): string;
  145054. /**
  145055. * Gets the world normal input component
  145056. */
  145057. get worldNormal(): NodeMaterialConnectionPoint;
  145058. /**
  145059. * Gets the view direction input component
  145060. */
  145061. get viewDirection(): NodeMaterialConnectionPoint;
  145062. /**
  145063. * Gets the bias input component
  145064. */
  145065. get bias(): NodeMaterialConnectionPoint;
  145066. /**
  145067. * Gets the camera (or eye) position component
  145068. */
  145069. get power(): NodeMaterialConnectionPoint;
  145070. /**
  145071. * Gets the fresnel output component
  145072. */
  145073. get fresnel(): NodeMaterialConnectionPoint;
  145074. autoConfigure(material: NodeMaterial): void;
  145075. protected _buildBlock(state: NodeMaterialBuildState): this;
  145076. }
  145077. }
  145078. declare module BABYLON {
  145079. /**
  145080. * Block used to get the max of 2 values
  145081. */
  145082. export class MaxBlock extends NodeMaterialBlock {
  145083. /**
  145084. * Creates a new MaxBlock
  145085. * @param name defines the block name
  145086. */
  145087. constructor(name: string);
  145088. /**
  145089. * Gets the current class name
  145090. * @returns the class name
  145091. */
  145092. getClassName(): string;
  145093. /**
  145094. * Gets the left operand input component
  145095. */
  145096. get left(): NodeMaterialConnectionPoint;
  145097. /**
  145098. * Gets the right operand input component
  145099. */
  145100. get right(): NodeMaterialConnectionPoint;
  145101. /**
  145102. * Gets the output component
  145103. */
  145104. get output(): NodeMaterialConnectionPoint;
  145105. protected _buildBlock(state: NodeMaterialBuildState): this;
  145106. }
  145107. }
  145108. declare module BABYLON {
  145109. /**
  145110. * Block used to get the min of 2 values
  145111. */
  145112. export class MinBlock extends NodeMaterialBlock {
  145113. /**
  145114. * Creates a new MinBlock
  145115. * @param name defines the block name
  145116. */
  145117. constructor(name: string);
  145118. /**
  145119. * Gets the current class name
  145120. * @returns the class name
  145121. */
  145122. getClassName(): string;
  145123. /**
  145124. * Gets the left operand input component
  145125. */
  145126. get left(): NodeMaterialConnectionPoint;
  145127. /**
  145128. * Gets the right operand input component
  145129. */
  145130. get right(): NodeMaterialConnectionPoint;
  145131. /**
  145132. * Gets the output component
  145133. */
  145134. get output(): NodeMaterialConnectionPoint;
  145135. protected _buildBlock(state: NodeMaterialBuildState): this;
  145136. }
  145137. }
  145138. declare module BABYLON {
  145139. /**
  145140. * Block used to get the distance between 2 values
  145141. */
  145142. export class DistanceBlock extends NodeMaterialBlock {
  145143. /**
  145144. * Creates a new DistanceBlock
  145145. * @param name defines the block name
  145146. */
  145147. constructor(name: string);
  145148. /**
  145149. * Gets the current class name
  145150. * @returns the class name
  145151. */
  145152. getClassName(): string;
  145153. /**
  145154. * Gets the left operand input component
  145155. */
  145156. get left(): NodeMaterialConnectionPoint;
  145157. /**
  145158. * Gets the right operand input component
  145159. */
  145160. get right(): NodeMaterialConnectionPoint;
  145161. /**
  145162. * Gets the output component
  145163. */
  145164. get output(): NodeMaterialConnectionPoint;
  145165. protected _buildBlock(state: NodeMaterialBuildState): this;
  145166. }
  145167. }
  145168. declare module BABYLON {
  145169. /**
  145170. * Block used to get the length of a vector
  145171. */
  145172. export class LengthBlock extends NodeMaterialBlock {
  145173. /**
  145174. * Creates a new LengthBlock
  145175. * @param name defines the block name
  145176. */
  145177. constructor(name: string);
  145178. /**
  145179. * Gets the current class name
  145180. * @returns the class name
  145181. */
  145182. getClassName(): string;
  145183. /**
  145184. * Gets the value input component
  145185. */
  145186. get value(): NodeMaterialConnectionPoint;
  145187. /**
  145188. * Gets the output component
  145189. */
  145190. get output(): NodeMaterialConnectionPoint;
  145191. protected _buildBlock(state: NodeMaterialBuildState): this;
  145192. }
  145193. }
  145194. declare module BABYLON {
  145195. /**
  145196. * Block used to get negative version of a value (i.e. x * -1)
  145197. */
  145198. export class NegateBlock extends NodeMaterialBlock {
  145199. /**
  145200. * Creates a new NegateBlock
  145201. * @param name defines the block name
  145202. */
  145203. constructor(name: string);
  145204. /**
  145205. * Gets the current class name
  145206. * @returns the class name
  145207. */
  145208. getClassName(): string;
  145209. /**
  145210. * Gets the value input component
  145211. */
  145212. get value(): NodeMaterialConnectionPoint;
  145213. /**
  145214. * Gets the output component
  145215. */
  145216. get output(): NodeMaterialConnectionPoint;
  145217. protected _buildBlock(state: NodeMaterialBuildState): this;
  145218. }
  145219. }
  145220. declare module BABYLON {
  145221. /**
  145222. * Block used to get the value of the first parameter raised to the power of the second
  145223. */
  145224. export class PowBlock extends NodeMaterialBlock {
  145225. /**
  145226. * Creates a new PowBlock
  145227. * @param name defines the block name
  145228. */
  145229. constructor(name: string);
  145230. /**
  145231. * Gets the current class name
  145232. * @returns the class name
  145233. */
  145234. getClassName(): string;
  145235. /**
  145236. * Gets the value operand input component
  145237. */
  145238. get value(): NodeMaterialConnectionPoint;
  145239. /**
  145240. * Gets the power operand input component
  145241. */
  145242. get power(): NodeMaterialConnectionPoint;
  145243. /**
  145244. * Gets the output component
  145245. */
  145246. get output(): NodeMaterialConnectionPoint;
  145247. protected _buildBlock(state: NodeMaterialBuildState): this;
  145248. }
  145249. }
  145250. declare module BABYLON {
  145251. /**
  145252. * Block used to get a random number
  145253. */
  145254. export class RandomNumberBlock extends NodeMaterialBlock {
  145255. /**
  145256. * Creates a new RandomNumberBlock
  145257. * @param name defines the block name
  145258. */
  145259. constructor(name: string);
  145260. /**
  145261. * Gets the current class name
  145262. * @returns the class name
  145263. */
  145264. getClassName(): string;
  145265. /**
  145266. * Gets the seed input component
  145267. */
  145268. get seed(): NodeMaterialConnectionPoint;
  145269. /**
  145270. * Gets the output component
  145271. */
  145272. get output(): NodeMaterialConnectionPoint;
  145273. protected _buildBlock(state: NodeMaterialBuildState): this;
  145274. }
  145275. }
  145276. declare module BABYLON {
  145277. /**
  145278. * Block used to compute arc tangent of 2 values
  145279. */
  145280. export class ArcTan2Block extends NodeMaterialBlock {
  145281. /**
  145282. * Creates a new ArcTan2Block
  145283. * @param name defines the block name
  145284. */
  145285. constructor(name: string);
  145286. /**
  145287. * Gets the current class name
  145288. * @returns the class name
  145289. */
  145290. getClassName(): string;
  145291. /**
  145292. * Gets the x operand input component
  145293. */
  145294. get x(): NodeMaterialConnectionPoint;
  145295. /**
  145296. * Gets the y operand input component
  145297. */
  145298. get y(): NodeMaterialConnectionPoint;
  145299. /**
  145300. * Gets the output component
  145301. */
  145302. get output(): NodeMaterialConnectionPoint;
  145303. protected _buildBlock(state: NodeMaterialBuildState): this;
  145304. }
  145305. }
  145306. declare module BABYLON {
  145307. /**
  145308. * Block used to smooth step a value
  145309. */
  145310. export class SmoothStepBlock extends NodeMaterialBlock {
  145311. /**
  145312. * Creates a new SmoothStepBlock
  145313. * @param name defines the block name
  145314. */
  145315. constructor(name: string);
  145316. /**
  145317. * Gets the current class name
  145318. * @returns the class name
  145319. */
  145320. getClassName(): string;
  145321. /**
  145322. * Gets the value operand input component
  145323. */
  145324. get value(): NodeMaterialConnectionPoint;
  145325. /**
  145326. * Gets the first edge operand input component
  145327. */
  145328. get edge0(): NodeMaterialConnectionPoint;
  145329. /**
  145330. * Gets the second edge operand input component
  145331. */
  145332. get edge1(): NodeMaterialConnectionPoint;
  145333. /**
  145334. * Gets the output component
  145335. */
  145336. get output(): NodeMaterialConnectionPoint;
  145337. protected _buildBlock(state: NodeMaterialBuildState): this;
  145338. }
  145339. }
  145340. declare module BABYLON {
  145341. /**
  145342. * Block used to get the reciprocal (1 / x) of a value
  145343. */
  145344. export class ReciprocalBlock extends NodeMaterialBlock {
  145345. /**
  145346. * Creates a new ReciprocalBlock
  145347. * @param name defines the block name
  145348. */
  145349. constructor(name: string);
  145350. /**
  145351. * Gets the current class name
  145352. * @returns the class name
  145353. */
  145354. getClassName(): string;
  145355. /**
  145356. * Gets the input component
  145357. */
  145358. get input(): NodeMaterialConnectionPoint;
  145359. /**
  145360. * Gets the output component
  145361. */
  145362. get output(): NodeMaterialConnectionPoint;
  145363. protected _buildBlock(state: NodeMaterialBuildState): this;
  145364. }
  145365. }
  145366. declare module BABYLON {
  145367. /**
  145368. * Block used to replace a color by another one
  145369. */
  145370. export class ReplaceColorBlock extends NodeMaterialBlock {
  145371. /**
  145372. * Creates a new ReplaceColorBlock
  145373. * @param name defines the block name
  145374. */
  145375. constructor(name: string);
  145376. /**
  145377. * Gets the current class name
  145378. * @returns the class name
  145379. */
  145380. getClassName(): string;
  145381. /**
  145382. * Gets the value input component
  145383. */
  145384. get value(): NodeMaterialConnectionPoint;
  145385. /**
  145386. * Gets the reference input component
  145387. */
  145388. get reference(): NodeMaterialConnectionPoint;
  145389. /**
  145390. * Gets the distance input component
  145391. */
  145392. get distance(): NodeMaterialConnectionPoint;
  145393. /**
  145394. * Gets the replacement input component
  145395. */
  145396. get replacement(): NodeMaterialConnectionPoint;
  145397. /**
  145398. * Gets the output component
  145399. */
  145400. get output(): NodeMaterialConnectionPoint;
  145401. protected _buildBlock(state: NodeMaterialBuildState): this;
  145402. }
  145403. }
  145404. declare module BABYLON {
  145405. /**
  145406. * Block used to posterize a value
  145407. * @see https://en.wikipedia.org/wiki/Posterization
  145408. */
  145409. export class PosterizeBlock extends NodeMaterialBlock {
  145410. /**
  145411. * Creates a new PosterizeBlock
  145412. * @param name defines the block name
  145413. */
  145414. constructor(name: string);
  145415. /**
  145416. * Gets the current class name
  145417. * @returns the class name
  145418. */
  145419. getClassName(): string;
  145420. /**
  145421. * Gets the value input component
  145422. */
  145423. get value(): NodeMaterialConnectionPoint;
  145424. /**
  145425. * Gets the steps input component
  145426. */
  145427. get steps(): NodeMaterialConnectionPoint;
  145428. /**
  145429. * Gets the output component
  145430. */
  145431. get output(): NodeMaterialConnectionPoint;
  145432. protected _buildBlock(state: NodeMaterialBuildState): this;
  145433. }
  145434. }
  145435. declare module BABYLON {
  145436. /**
  145437. * Operations supported by the Wave block
  145438. */
  145439. export enum WaveBlockKind {
  145440. /** SawTooth */
  145441. SawTooth = 0,
  145442. /** Square */
  145443. Square = 1,
  145444. /** Triangle */
  145445. Triangle = 2
  145446. }
  145447. /**
  145448. * Block used to apply wave operation to floats
  145449. */
  145450. export class WaveBlock extends NodeMaterialBlock {
  145451. /**
  145452. * Gets or sets the kibnd of wave to be applied by the block
  145453. */
  145454. kind: WaveBlockKind;
  145455. /**
  145456. * Creates a new WaveBlock
  145457. * @param name defines the block name
  145458. */
  145459. constructor(name: string);
  145460. /**
  145461. * Gets the current class name
  145462. * @returns the class name
  145463. */
  145464. getClassName(): string;
  145465. /**
  145466. * Gets the input component
  145467. */
  145468. get input(): NodeMaterialConnectionPoint;
  145469. /**
  145470. * Gets the output component
  145471. */
  145472. get output(): NodeMaterialConnectionPoint;
  145473. protected _buildBlock(state: NodeMaterialBuildState): this;
  145474. serialize(): any;
  145475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145476. }
  145477. }
  145478. declare module BABYLON {
  145479. /**
  145480. * Class used to store a color step for the GradientBlock
  145481. */
  145482. export class GradientBlockColorStep {
  145483. private _step;
  145484. /**
  145485. * Gets value indicating which step this color is associated with (between 0 and 1)
  145486. */
  145487. get step(): number;
  145488. /**
  145489. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145490. */
  145491. set step(val: number);
  145492. private _color;
  145493. /**
  145494. * Gets the color associated with this step
  145495. */
  145496. get color(): Color3;
  145497. /**
  145498. * Sets the color associated with this step
  145499. */
  145500. set color(val: Color3);
  145501. /**
  145502. * Creates a new GradientBlockColorStep
  145503. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145504. * @param color defines the color associated with this step
  145505. */
  145506. constructor(step: number, color: Color3);
  145507. }
  145508. /**
  145509. * Block used to return a color from a gradient based on an input value between 0 and 1
  145510. */
  145511. export class GradientBlock extends NodeMaterialBlock {
  145512. /**
  145513. * Gets or sets the list of color steps
  145514. */
  145515. colorSteps: GradientBlockColorStep[];
  145516. /** Gets an observable raised when the value is changed */
  145517. onValueChangedObservable: Observable<GradientBlock>;
  145518. /** calls observable when the value is changed*/
  145519. colorStepsUpdated(): void;
  145520. /**
  145521. * Creates a new GradientBlock
  145522. * @param name defines the block name
  145523. */
  145524. constructor(name: string);
  145525. /**
  145526. * Gets the current class name
  145527. * @returns the class name
  145528. */
  145529. getClassName(): string;
  145530. /**
  145531. * Gets the gradient input component
  145532. */
  145533. get gradient(): NodeMaterialConnectionPoint;
  145534. /**
  145535. * Gets the output component
  145536. */
  145537. get output(): NodeMaterialConnectionPoint;
  145538. private _writeColorConstant;
  145539. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145540. serialize(): any;
  145541. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145542. protected _dumpPropertiesCode(): string;
  145543. }
  145544. }
  145545. declare module BABYLON {
  145546. /**
  145547. * Block used to normalize lerp between 2 values
  145548. */
  145549. export class NLerpBlock extends NodeMaterialBlock {
  145550. /**
  145551. * Creates a new NLerpBlock
  145552. * @param name defines the block name
  145553. */
  145554. constructor(name: string);
  145555. /**
  145556. * Gets the current class name
  145557. * @returns the class name
  145558. */
  145559. getClassName(): string;
  145560. /**
  145561. * Gets the left operand input component
  145562. */
  145563. get left(): NodeMaterialConnectionPoint;
  145564. /**
  145565. * Gets the right operand input component
  145566. */
  145567. get right(): NodeMaterialConnectionPoint;
  145568. /**
  145569. * Gets the gradient operand input component
  145570. */
  145571. get gradient(): NodeMaterialConnectionPoint;
  145572. /**
  145573. * Gets the output component
  145574. */
  145575. get output(): NodeMaterialConnectionPoint;
  145576. protected _buildBlock(state: NodeMaterialBuildState): this;
  145577. }
  145578. }
  145579. declare module BABYLON {
  145580. /**
  145581. * block used to Generate a Worley Noise 3D Noise Pattern
  145582. */
  145583. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145584. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145585. manhattanDistance: boolean;
  145586. /**
  145587. * Creates a new WorleyNoise3DBlock
  145588. * @param name defines the block name
  145589. */
  145590. constructor(name: string);
  145591. /**
  145592. * Gets the current class name
  145593. * @returns the class name
  145594. */
  145595. getClassName(): string;
  145596. /**
  145597. * Gets the seed input component
  145598. */
  145599. get seed(): NodeMaterialConnectionPoint;
  145600. /**
  145601. * Gets the jitter input component
  145602. */
  145603. get jitter(): NodeMaterialConnectionPoint;
  145604. /**
  145605. * Gets the output component
  145606. */
  145607. get output(): NodeMaterialConnectionPoint;
  145608. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145609. /**
  145610. * Exposes the properties to the UI?
  145611. */
  145612. protected _dumpPropertiesCode(): string;
  145613. /**
  145614. * Exposes the properties to the Seralize?
  145615. */
  145616. serialize(): any;
  145617. /**
  145618. * Exposes the properties to the deseralize?
  145619. */
  145620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145621. }
  145622. }
  145623. declare module BABYLON {
  145624. /**
  145625. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145626. */
  145627. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145628. /**
  145629. * Creates a new SimplexPerlin3DBlock
  145630. * @param name defines the block name
  145631. */
  145632. constructor(name: string);
  145633. /**
  145634. * Gets the current class name
  145635. * @returns the class name
  145636. */
  145637. getClassName(): string;
  145638. /**
  145639. * Gets the seed operand input component
  145640. */
  145641. get seed(): NodeMaterialConnectionPoint;
  145642. /**
  145643. * Gets the output component
  145644. */
  145645. get output(): NodeMaterialConnectionPoint;
  145646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145647. }
  145648. }
  145649. declare module BABYLON {
  145650. /**
  145651. * Block used to blend normals
  145652. */
  145653. export class NormalBlendBlock extends NodeMaterialBlock {
  145654. /**
  145655. * Creates a new NormalBlendBlock
  145656. * @param name defines the block name
  145657. */
  145658. constructor(name: string);
  145659. /**
  145660. * Gets the current class name
  145661. * @returns the class name
  145662. */
  145663. getClassName(): string;
  145664. /**
  145665. * Gets the first input component
  145666. */
  145667. get normalMap0(): NodeMaterialConnectionPoint;
  145668. /**
  145669. * Gets the second input component
  145670. */
  145671. get normalMap1(): NodeMaterialConnectionPoint;
  145672. /**
  145673. * Gets the output component
  145674. */
  145675. get output(): NodeMaterialConnectionPoint;
  145676. protected _buildBlock(state: NodeMaterialBuildState): this;
  145677. }
  145678. }
  145679. declare module BABYLON {
  145680. /**
  145681. * Block used to rotate a 2d vector by a given angle
  145682. */
  145683. export class Rotate2dBlock extends NodeMaterialBlock {
  145684. /**
  145685. * Creates a new Rotate2dBlock
  145686. * @param name defines the block name
  145687. */
  145688. constructor(name: string);
  145689. /**
  145690. * Gets the current class name
  145691. * @returns the class name
  145692. */
  145693. getClassName(): string;
  145694. /**
  145695. * Gets the input vector
  145696. */
  145697. get input(): NodeMaterialConnectionPoint;
  145698. /**
  145699. * Gets the input angle
  145700. */
  145701. get angle(): NodeMaterialConnectionPoint;
  145702. /**
  145703. * Gets the output component
  145704. */
  145705. get output(): NodeMaterialConnectionPoint;
  145706. autoConfigure(material: NodeMaterial): void;
  145707. protected _buildBlock(state: NodeMaterialBuildState): this;
  145708. }
  145709. }
  145710. declare module BABYLON {
  145711. /**
  145712. * Block used to get the reflected vector from a direction and a normal
  145713. */
  145714. export class ReflectBlock extends NodeMaterialBlock {
  145715. /**
  145716. * Creates a new ReflectBlock
  145717. * @param name defines the block name
  145718. */
  145719. constructor(name: string);
  145720. /**
  145721. * Gets the current class name
  145722. * @returns the class name
  145723. */
  145724. getClassName(): string;
  145725. /**
  145726. * Gets the incident component
  145727. */
  145728. get incident(): NodeMaterialConnectionPoint;
  145729. /**
  145730. * Gets the normal component
  145731. */
  145732. get normal(): NodeMaterialConnectionPoint;
  145733. /**
  145734. * Gets the output component
  145735. */
  145736. get output(): NodeMaterialConnectionPoint;
  145737. protected _buildBlock(state: NodeMaterialBuildState): this;
  145738. }
  145739. }
  145740. declare module BABYLON {
  145741. /**
  145742. * Block used to get the refracted vector from a direction and a normal
  145743. */
  145744. export class RefractBlock extends NodeMaterialBlock {
  145745. /**
  145746. * Creates a new RefractBlock
  145747. * @param name defines the block name
  145748. */
  145749. constructor(name: string);
  145750. /**
  145751. * Gets the current class name
  145752. * @returns the class name
  145753. */
  145754. getClassName(): string;
  145755. /**
  145756. * Gets the incident component
  145757. */
  145758. get incident(): NodeMaterialConnectionPoint;
  145759. /**
  145760. * Gets the normal component
  145761. */
  145762. get normal(): NodeMaterialConnectionPoint;
  145763. /**
  145764. * Gets the index of refraction component
  145765. */
  145766. get ior(): NodeMaterialConnectionPoint;
  145767. /**
  145768. * Gets the output component
  145769. */
  145770. get output(): NodeMaterialConnectionPoint;
  145771. protected _buildBlock(state: NodeMaterialBuildState): this;
  145772. }
  145773. }
  145774. declare module BABYLON {
  145775. /**
  145776. * Block used to desaturate a color
  145777. */
  145778. export class DesaturateBlock extends NodeMaterialBlock {
  145779. /**
  145780. * Creates a new DesaturateBlock
  145781. * @param name defines the block name
  145782. */
  145783. constructor(name: string);
  145784. /**
  145785. * Gets the current class name
  145786. * @returns the class name
  145787. */
  145788. getClassName(): string;
  145789. /**
  145790. * Gets the color operand input component
  145791. */
  145792. get color(): NodeMaterialConnectionPoint;
  145793. /**
  145794. * Gets the level operand input component
  145795. */
  145796. get level(): NodeMaterialConnectionPoint;
  145797. /**
  145798. * Gets the output component
  145799. */
  145800. get output(): NodeMaterialConnectionPoint;
  145801. protected _buildBlock(state: NodeMaterialBuildState): this;
  145802. }
  145803. }
  145804. declare module BABYLON {
  145805. /**
  145806. * Block used to implement the ambient occlusion module of the PBR material
  145807. */
  145808. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145809. /**
  145810. * Create a new AmbientOcclusionBlock
  145811. * @param name defines the block name
  145812. */
  145813. constructor(name: string);
  145814. /**
  145815. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145816. */
  145817. useAmbientInGrayScale: boolean;
  145818. /**
  145819. * Initialize the block and prepare the context for build
  145820. * @param state defines the state that will be used for the build
  145821. */
  145822. initialize(state: NodeMaterialBuildState): void;
  145823. /**
  145824. * Gets the current class name
  145825. * @returns the class name
  145826. */
  145827. getClassName(): string;
  145828. /**
  145829. * Gets the texture input component
  145830. */
  145831. get texture(): NodeMaterialConnectionPoint;
  145832. /**
  145833. * Gets the texture intensity component
  145834. */
  145835. get intensity(): NodeMaterialConnectionPoint;
  145836. /**
  145837. * Gets the direct light intensity input component
  145838. */
  145839. get directLightIntensity(): NodeMaterialConnectionPoint;
  145840. /**
  145841. * Gets the ambient occlusion object output component
  145842. */
  145843. get ambientOcc(): NodeMaterialConnectionPoint;
  145844. /**
  145845. * Gets the main code of the block (fragment side)
  145846. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145847. * @returns the shader code
  145848. */
  145849. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145851. protected _buildBlock(state: NodeMaterialBuildState): this;
  145852. protected _dumpPropertiesCode(): string;
  145853. serialize(): any;
  145854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145855. }
  145856. }
  145857. declare module BABYLON {
  145858. /**
  145859. * Block used to implement the reflection module of the PBR material
  145860. */
  145861. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145862. /** @hidden */
  145863. _defineLODReflectionAlpha: string;
  145864. /** @hidden */
  145865. _defineLinearSpecularReflection: string;
  145866. private _vEnvironmentIrradianceName;
  145867. /** @hidden */
  145868. _vReflectionMicrosurfaceInfosName: string;
  145869. /** @hidden */
  145870. _vReflectionInfosName: string;
  145871. /** @hidden */
  145872. _vReflectionFilteringInfoName: string;
  145873. private _scene;
  145874. /**
  145875. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145876. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145877. * It's less burden on the user side in the editor part.
  145878. */
  145879. /** @hidden */
  145880. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145881. /** @hidden */
  145882. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145883. /** @hidden */
  145884. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145885. /**
  145886. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145887. * diffuse part of the IBL.
  145888. */
  145889. useSphericalHarmonics: boolean;
  145890. /**
  145891. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145892. */
  145893. forceIrradianceInFragment: boolean;
  145894. /**
  145895. * Create a new ReflectionBlock
  145896. * @param name defines the block name
  145897. */
  145898. constructor(name: string);
  145899. /**
  145900. * Gets the current class name
  145901. * @returns the class name
  145902. */
  145903. getClassName(): string;
  145904. /**
  145905. * Gets the position input component
  145906. */
  145907. get position(): NodeMaterialConnectionPoint;
  145908. /**
  145909. * Gets the world position input component
  145910. */
  145911. get worldPosition(): NodeMaterialConnectionPoint;
  145912. /**
  145913. * Gets the world normal input component
  145914. */
  145915. get worldNormal(): NodeMaterialConnectionPoint;
  145916. /**
  145917. * Gets the world input component
  145918. */
  145919. get world(): NodeMaterialConnectionPoint;
  145920. /**
  145921. * Gets the camera (or eye) position component
  145922. */
  145923. get cameraPosition(): NodeMaterialConnectionPoint;
  145924. /**
  145925. * Gets the view input component
  145926. */
  145927. get view(): NodeMaterialConnectionPoint;
  145928. /**
  145929. * Gets the color input component
  145930. */
  145931. get color(): NodeMaterialConnectionPoint;
  145932. /**
  145933. * Gets the reflection object output component
  145934. */
  145935. get reflection(): NodeMaterialConnectionPoint;
  145936. /**
  145937. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145938. */
  145939. get hasTexture(): boolean;
  145940. /**
  145941. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145942. */
  145943. get reflectionColor(): string;
  145944. protected _getTexture(): Nullable<BaseTexture>;
  145945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145947. /**
  145948. * Gets the code to inject in the vertex shader
  145949. * @param state current state of the node material building
  145950. * @returns the shader code
  145951. */
  145952. handleVertexSide(state: NodeMaterialBuildState): string;
  145953. /**
  145954. * Gets the main code of the block (fragment side)
  145955. * @param state current state of the node material building
  145956. * @param normalVarName name of the existing variable corresponding to the normal
  145957. * @returns the shader code
  145958. */
  145959. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145960. protected _buildBlock(state: NodeMaterialBuildState): this;
  145961. protected _dumpPropertiesCode(): string;
  145962. serialize(): any;
  145963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145964. }
  145965. }
  145966. declare module BABYLON {
  145967. /**
  145968. * Block used to implement the sheen module of the PBR material
  145969. */
  145970. export class SheenBlock extends NodeMaterialBlock {
  145971. /**
  145972. * Create a new SheenBlock
  145973. * @param name defines the block name
  145974. */
  145975. constructor(name: string);
  145976. /**
  145977. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145978. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145979. * making it easier to setup and tweak the effect
  145980. */
  145981. albedoScaling: boolean;
  145982. /**
  145983. * Defines if the sheen is linked to the sheen color.
  145984. */
  145985. linkSheenWithAlbedo: boolean;
  145986. /**
  145987. * Initialize the block and prepare the context for build
  145988. * @param state defines the state that will be used for the build
  145989. */
  145990. initialize(state: NodeMaterialBuildState): void;
  145991. /**
  145992. * Gets the current class name
  145993. * @returns the class name
  145994. */
  145995. getClassName(): string;
  145996. /**
  145997. * Gets the intensity input component
  145998. */
  145999. get intensity(): NodeMaterialConnectionPoint;
  146000. /**
  146001. * Gets the color input component
  146002. */
  146003. get color(): NodeMaterialConnectionPoint;
  146004. /**
  146005. * Gets the roughness input component
  146006. */
  146007. get roughness(): NodeMaterialConnectionPoint;
  146008. /**
  146009. * Gets the sheen object output component
  146010. */
  146011. get sheen(): NodeMaterialConnectionPoint;
  146012. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146013. /**
  146014. * Gets the main code of the block (fragment side)
  146015. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146016. * @returns the shader code
  146017. */
  146018. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  146019. protected _buildBlock(state: NodeMaterialBuildState): this;
  146020. protected _dumpPropertiesCode(): string;
  146021. serialize(): any;
  146022. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146023. }
  146024. }
  146025. declare module BABYLON {
  146026. /**
  146027. * Block used to implement the reflectivity module of the PBR material
  146028. */
  146029. export class ReflectivityBlock extends NodeMaterialBlock {
  146030. private _metallicReflectanceColor;
  146031. private _metallicF0Factor;
  146032. /** @hidden */
  146033. _vMetallicReflectanceFactorsName: string;
  146034. /**
  146035. * The property below is set by the main PBR block prior to calling methods of this class.
  146036. */
  146037. /** @hidden */
  146038. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  146039. /**
  146040. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  146041. */
  146042. useAmbientOcclusionFromMetallicTextureRed: boolean;
  146043. /**
  146044. * Specifies if the metallic texture contains the metallness information in its blue channel.
  146045. */
  146046. useMetallnessFromMetallicTextureBlue: boolean;
  146047. /**
  146048. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  146049. */
  146050. useRoughnessFromMetallicTextureAlpha: boolean;
  146051. /**
  146052. * Specifies if the metallic texture contains the roughness information in its green channel.
  146053. */
  146054. useRoughnessFromMetallicTextureGreen: boolean;
  146055. /**
  146056. * Create a new ReflectivityBlock
  146057. * @param name defines the block name
  146058. */
  146059. constructor(name: string);
  146060. /**
  146061. * Initialize the block and prepare the context for build
  146062. * @param state defines the state that will be used for the build
  146063. */
  146064. initialize(state: NodeMaterialBuildState): void;
  146065. /**
  146066. * Gets the current class name
  146067. * @returns the class name
  146068. */
  146069. getClassName(): string;
  146070. /**
  146071. * Gets the metallic input component
  146072. */
  146073. get metallic(): NodeMaterialConnectionPoint;
  146074. /**
  146075. * Gets the roughness input component
  146076. */
  146077. get roughness(): NodeMaterialConnectionPoint;
  146078. /**
  146079. * Gets the texture input component
  146080. */
  146081. get texture(): NodeMaterialConnectionPoint;
  146082. /**
  146083. * Gets the reflectivity object output component
  146084. */
  146085. get reflectivity(): NodeMaterialConnectionPoint;
  146086. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146087. /**
  146088. * Gets the main code of the block (fragment side)
  146089. * @param state current state of the node material building
  146090. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146091. * @returns the shader code
  146092. */
  146093. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146095. protected _buildBlock(state: NodeMaterialBuildState): this;
  146096. protected _dumpPropertiesCode(): string;
  146097. serialize(): any;
  146098. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146099. }
  146100. }
  146101. declare module BABYLON {
  146102. /**
  146103. * Block used to implement the anisotropy module of the PBR material
  146104. */
  146105. export class AnisotropyBlock extends NodeMaterialBlock {
  146106. /**
  146107. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146108. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146109. * It's less burden on the user side in the editor part.
  146110. */
  146111. /** @hidden */
  146112. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146113. /** @hidden */
  146114. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146115. /**
  146116. * Create a new AnisotropyBlock
  146117. * @param name defines the block name
  146118. */
  146119. constructor(name: string);
  146120. /**
  146121. * Initialize the block and prepare the context for build
  146122. * @param state defines the state that will be used for the build
  146123. */
  146124. initialize(state: NodeMaterialBuildState): void;
  146125. /**
  146126. * Gets the current class name
  146127. * @returns the class name
  146128. */
  146129. getClassName(): string;
  146130. /**
  146131. * Gets the intensity input component
  146132. */
  146133. get intensity(): NodeMaterialConnectionPoint;
  146134. /**
  146135. * Gets the direction input component
  146136. */
  146137. get direction(): NodeMaterialConnectionPoint;
  146138. /**
  146139. * Gets the texture input component
  146140. */
  146141. get texture(): NodeMaterialConnectionPoint;
  146142. /**
  146143. * Gets the uv input component
  146144. */
  146145. get uv(): NodeMaterialConnectionPoint;
  146146. /**
  146147. * Gets the worldTangent input component
  146148. */
  146149. get worldTangent(): NodeMaterialConnectionPoint;
  146150. /**
  146151. * Gets the anisotropy object output component
  146152. */
  146153. get anisotropy(): NodeMaterialConnectionPoint;
  146154. private _generateTBNSpace;
  146155. /**
  146156. * Gets the main code of the block (fragment side)
  146157. * @param state current state of the node material building
  146158. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146159. * @returns the shader code
  146160. */
  146161. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146163. protected _buildBlock(state: NodeMaterialBuildState): this;
  146164. }
  146165. }
  146166. declare module BABYLON {
  146167. /**
  146168. * Block used to implement the clear coat module of the PBR material
  146169. */
  146170. export class ClearCoatBlock extends NodeMaterialBlock {
  146171. private _scene;
  146172. /**
  146173. * Create a new ClearCoatBlock
  146174. * @param name defines the block name
  146175. */
  146176. constructor(name: string);
  146177. /**
  146178. * Initialize the block and prepare the context for build
  146179. * @param state defines the state that will be used for the build
  146180. */
  146181. initialize(state: NodeMaterialBuildState): void;
  146182. /**
  146183. * Gets the current class name
  146184. * @returns the class name
  146185. */
  146186. getClassName(): string;
  146187. /**
  146188. * Gets the intensity input component
  146189. */
  146190. get intensity(): NodeMaterialConnectionPoint;
  146191. /**
  146192. * Gets the roughness input component
  146193. */
  146194. get roughness(): NodeMaterialConnectionPoint;
  146195. /**
  146196. * Gets the ior input component
  146197. */
  146198. get ior(): NodeMaterialConnectionPoint;
  146199. /**
  146200. * Gets the texture input component
  146201. */
  146202. get texture(): NodeMaterialConnectionPoint;
  146203. /**
  146204. * Gets the bump texture input component
  146205. */
  146206. get bumpTexture(): NodeMaterialConnectionPoint;
  146207. /**
  146208. * Gets the uv input component
  146209. */
  146210. get uv(): NodeMaterialConnectionPoint;
  146211. /**
  146212. * Gets the tint color input component
  146213. */
  146214. get tintColor(): NodeMaterialConnectionPoint;
  146215. /**
  146216. * Gets the tint "at distance" input component
  146217. */
  146218. get tintAtDistance(): NodeMaterialConnectionPoint;
  146219. /**
  146220. * Gets the tint thickness input component
  146221. */
  146222. get tintThickness(): NodeMaterialConnectionPoint;
  146223. /**
  146224. * Gets the world tangent input component
  146225. */
  146226. get worldTangent(): NodeMaterialConnectionPoint;
  146227. /**
  146228. * Gets the clear coat object output component
  146229. */
  146230. get clearcoat(): NodeMaterialConnectionPoint;
  146231. autoConfigure(material: NodeMaterial): void;
  146232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146233. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146234. private _generateTBNSpace;
  146235. /**
  146236. * Gets the main code of the block (fragment side)
  146237. * @param state current state of the node material building
  146238. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146239. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146240. * @param worldPosVarName name of the variable holding the world position
  146241. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146242. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146243. * @param worldNormalVarName name of the variable holding the world normal
  146244. * @returns the shader code
  146245. */
  146246. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146247. protected _buildBlock(state: NodeMaterialBuildState): this;
  146248. }
  146249. }
  146250. declare module BABYLON {
  146251. /**
  146252. * Block used to implement the sub surface module of the PBR material
  146253. */
  146254. export class SubSurfaceBlock extends NodeMaterialBlock {
  146255. /**
  146256. * Create a new SubSurfaceBlock
  146257. * @param name defines the block name
  146258. */
  146259. constructor(name: string);
  146260. /**
  146261. * Stores the intensity of the different subsurface effects in the thickness texture.
  146262. * * the green channel is the translucency intensity.
  146263. * * the blue channel is the scattering intensity.
  146264. * * the alpha channel is the refraction intensity.
  146265. */
  146266. useMaskFromThicknessTexture: boolean;
  146267. /**
  146268. * Initialize the block and prepare the context for build
  146269. * @param state defines the state that will be used for the build
  146270. */
  146271. initialize(state: NodeMaterialBuildState): void;
  146272. /**
  146273. * Gets the current class name
  146274. * @returns the class name
  146275. */
  146276. getClassName(): string;
  146277. /**
  146278. * Gets the min thickness input component
  146279. */
  146280. get minThickness(): NodeMaterialConnectionPoint;
  146281. /**
  146282. * Gets the max thickness input component
  146283. */
  146284. get maxThickness(): NodeMaterialConnectionPoint;
  146285. /**
  146286. * Gets the thickness texture component
  146287. */
  146288. get thicknessTexture(): NodeMaterialConnectionPoint;
  146289. /**
  146290. * Gets the tint color input component
  146291. */
  146292. get tintColor(): NodeMaterialConnectionPoint;
  146293. /**
  146294. * Gets the translucency intensity input component
  146295. */
  146296. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146297. /**
  146298. * Gets the translucency diffusion distance input component
  146299. */
  146300. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146301. /**
  146302. * Gets the refraction object parameters
  146303. */
  146304. get refraction(): NodeMaterialConnectionPoint;
  146305. /**
  146306. * Gets the sub surface object output component
  146307. */
  146308. get subsurface(): NodeMaterialConnectionPoint;
  146309. autoConfigure(material: NodeMaterial): void;
  146310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146311. /**
  146312. * Gets the main code of the block (fragment side)
  146313. * @param state current state of the node material building
  146314. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146315. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146316. * @param worldPosVarName name of the variable holding the world position
  146317. * @returns the shader code
  146318. */
  146319. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146320. protected _buildBlock(state: NodeMaterialBuildState): this;
  146321. }
  146322. }
  146323. declare module BABYLON {
  146324. /**
  146325. * Block used to implement the PBR metallic/roughness model
  146326. */
  146327. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146328. /**
  146329. * Gets or sets the light associated with this block
  146330. */
  146331. light: Nullable<Light>;
  146332. private _lightId;
  146333. private _scene;
  146334. private _environmentBRDFTexture;
  146335. private _environmentBrdfSamplerName;
  146336. private _vNormalWName;
  146337. private _invertNormalName;
  146338. /**
  146339. * Create a new ReflectionBlock
  146340. * @param name defines the block name
  146341. */
  146342. constructor(name: string);
  146343. /**
  146344. * Intensity of the direct lights e.g. the four lights available in your scene.
  146345. * This impacts both the direct diffuse and specular highlights.
  146346. */
  146347. directIntensity: number;
  146348. /**
  146349. * Intensity of the environment e.g. how much the environment will light the object
  146350. * either through harmonics for rough material or through the refelction for shiny ones.
  146351. */
  146352. environmentIntensity: number;
  146353. /**
  146354. * This is a special control allowing the reduction of the specular highlights coming from the
  146355. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146356. */
  146357. specularIntensity: number;
  146358. /**
  146359. * Defines the falloff type used in this material.
  146360. * It by default is Physical.
  146361. */
  146362. lightFalloff: number;
  146363. /**
  146364. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146365. */
  146366. useAlphaFromAlbedoTexture: boolean;
  146367. /**
  146368. * Specifies that alpha test should be used
  146369. */
  146370. useAlphaTest: boolean;
  146371. /**
  146372. * Defines the alpha limits in alpha test mode.
  146373. */
  146374. alphaTestCutoff: number;
  146375. /**
  146376. * Specifies that alpha blending should be used
  146377. */
  146378. useAlphaBlending: boolean;
  146379. /**
  146380. * Defines if the alpha value should be determined via the rgb values.
  146381. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146382. */
  146383. opacityRGB: boolean;
  146384. /**
  146385. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146386. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146387. */
  146388. useRadianceOverAlpha: boolean;
  146389. /**
  146390. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146391. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146392. */
  146393. useSpecularOverAlpha: boolean;
  146394. /**
  146395. * Enables specular anti aliasing in the PBR shader.
  146396. * It will both interacts on the Geometry for analytical and IBL lighting.
  146397. * It also prefilter the roughness map based on the bump values.
  146398. */
  146399. enableSpecularAntiAliasing: boolean;
  146400. /**
  146401. * Enables realtime filtering on the texture.
  146402. */
  146403. realTimeFiltering: boolean;
  146404. /**
  146405. * Quality switch for realtime filtering
  146406. */
  146407. realTimeFilteringQuality: number;
  146408. /**
  146409. * Defines if the material uses energy conservation.
  146410. */
  146411. useEnergyConservation: boolean;
  146412. /**
  146413. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146414. * too much the area relying on ambient texture to define their ambient occlusion.
  146415. */
  146416. useRadianceOcclusion: boolean;
  146417. /**
  146418. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146419. * makes the reflect vector face the model (under horizon).
  146420. */
  146421. useHorizonOcclusion: boolean;
  146422. /**
  146423. * If set to true, no lighting calculations will be applied.
  146424. */
  146425. unlit: boolean;
  146426. /**
  146427. * Force normal to face away from face.
  146428. */
  146429. forceNormalForward: boolean;
  146430. /**
  146431. * Defines the material debug mode.
  146432. * It helps seeing only some components of the material while troubleshooting.
  146433. */
  146434. debugMode: number;
  146435. /**
  146436. * Specify from where on screen the debug mode should start.
  146437. * The value goes from -1 (full screen) to 1 (not visible)
  146438. * It helps with side by side comparison against the final render
  146439. * This defaults to 0
  146440. */
  146441. debugLimit: number;
  146442. /**
  146443. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146444. * You can use the factor to better multiply the final value.
  146445. */
  146446. debugFactor: number;
  146447. /**
  146448. * Initialize the block and prepare the context for build
  146449. * @param state defines the state that will be used for the build
  146450. */
  146451. initialize(state: NodeMaterialBuildState): void;
  146452. /**
  146453. * Gets the current class name
  146454. * @returns the class name
  146455. */
  146456. getClassName(): string;
  146457. /**
  146458. * Gets the world position input component
  146459. */
  146460. get worldPosition(): NodeMaterialConnectionPoint;
  146461. /**
  146462. * Gets the world normal input component
  146463. */
  146464. get worldNormal(): NodeMaterialConnectionPoint;
  146465. /**
  146466. * Gets the perturbed normal input component
  146467. */
  146468. get perturbedNormal(): NodeMaterialConnectionPoint;
  146469. /**
  146470. * Gets the camera position input component
  146471. */
  146472. get cameraPosition(): NodeMaterialConnectionPoint;
  146473. /**
  146474. * Gets the base color input component
  146475. */
  146476. get baseColor(): NodeMaterialConnectionPoint;
  146477. /**
  146478. * Gets the opacity texture input component
  146479. */
  146480. get opacityTexture(): NodeMaterialConnectionPoint;
  146481. /**
  146482. * Gets the ambient color input component
  146483. */
  146484. get ambientColor(): NodeMaterialConnectionPoint;
  146485. /**
  146486. * Gets the reflectivity object parameters
  146487. */
  146488. get reflectivity(): NodeMaterialConnectionPoint;
  146489. /**
  146490. * Gets the ambient occlusion object parameters
  146491. */
  146492. get ambientOcc(): NodeMaterialConnectionPoint;
  146493. /**
  146494. * Gets the reflection object parameters
  146495. */
  146496. get reflection(): NodeMaterialConnectionPoint;
  146497. /**
  146498. * Gets the sheen object parameters
  146499. */
  146500. get sheen(): NodeMaterialConnectionPoint;
  146501. /**
  146502. * Gets the clear coat object parameters
  146503. */
  146504. get clearcoat(): NodeMaterialConnectionPoint;
  146505. /**
  146506. * Gets the sub surface object parameters
  146507. */
  146508. get subsurface(): NodeMaterialConnectionPoint;
  146509. /**
  146510. * Gets the anisotropy object parameters
  146511. */
  146512. get anisotropy(): NodeMaterialConnectionPoint;
  146513. /**
  146514. * Gets the view matrix parameter
  146515. */
  146516. get view(): NodeMaterialConnectionPoint;
  146517. /**
  146518. * Gets the ambient output component
  146519. */
  146520. get ambient(): NodeMaterialConnectionPoint;
  146521. /**
  146522. * Gets the diffuse output component
  146523. */
  146524. get diffuse(): NodeMaterialConnectionPoint;
  146525. /**
  146526. * Gets the specular output component
  146527. */
  146528. get specular(): NodeMaterialConnectionPoint;
  146529. /**
  146530. * Gets the sheen output component
  146531. */
  146532. get sheenDir(): NodeMaterialConnectionPoint;
  146533. /**
  146534. * Gets the clear coat output component
  146535. */
  146536. get clearcoatDir(): NodeMaterialConnectionPoint;
  146537. /**
  146538. * Gets the indirect diffuse output component
  146539. */
  146540. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146541. /**
  146542. * Gets the indirect specular output component
  146543. */
  146544. get specularIndirect(): NodeMaterialConnectionPoint;
  146545. /**
  146546. * Gets the indirect sheen output component
  146547. */
  146548. get sheenIndirect(): NodeMaterialConnectionPoint;
  146549. /**
  146550. * Gets the indirect clear coat output component
  146551. */
  146552. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146553. /**
  146554. * Gets the refraction output component
  146555. */
  146556. get refraction(): NodeMaterialConnectionPoint;
  146557. /**
  146558. * Gets the global lighting output component
  146559. */
  146560. get lighting(): NodeMaterialConnectionPoint;
  146561. /**
  146562. * Gets the shadow output component
  146563. */
  146564. get shadow(): NodeMaterialConnectionPoint;
  146565. /**
  146566. * Gets the alpha output component
  146567. */
  146568. get alpha(): NodeMaterialConnectionPoint;
  146569. autoConfigure(material: NodeMaterial): void;
  146570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146571. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146573. private _injectVertexCode;
  146574. /**
  146575. * Gets the code corresponding to the albedo/opacity module
  146576. * @returns the shader code
  146577. */
  146578. getAlbedoOpacityCode(): string;
  146579. protected _buildBlock(state: NodeMaterialBuildState): this;
  146580. protected _dumpPropertiesCode(): string;
  146581. serialize(): any;
  146582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146583. }
  146584. }
  146585. declare module BABYLON {
  146586. /**
  146587. * Block used to compute value of one parameter modulo another
  146588. */
  146589. export class ModBlock extends NodeMaterialBlock {
  146590. /**
  146591. * Creates a new ModBlock
  146592. * @param name defines the block name
  146593. */
  146594. constructor(name: string);
  146595. /**
  146596. * Gets the current class name
  146597. * @returns the class name
  146598. */
  146599. getClassName(): string;
  146600. /**
  146601. * Gets the left operand input component
  146602. */
  146603. get left(): NodeMaterialConnectionPoint;
  146604. /**
  146605. * Gets the right operand input component
  146606. */
  146607. get right(): NodeMaterialConnectionPoint;
  146608. /**
  146609. * Gets the output component
  146610. */
  146611. get output(): NodeMaterialConnectionPoint;
  146612. protected _buildBlock(state: NodeMaterialBuildState): this;
  146613. }
  146614. }
  146615. declare module BABYLON {
  146616. /**
  146617. * Configuration for Draco compression
  146618. */
  146619. export interface IDracoCompressionConfiguration {
  146620. /**
  146621. * Configuration for the decoder.
  146622. */
  146623. decoder: {
  146624. /**
  146625. * The url to the WebAssembly module.
  146626. */
  146627. wasmUrl?: string;
  146628. /**
  146629. * The url to the WebAssembly binary.
  146630. */
  146631. wasmBinaryUrl?: string;
  146632. /**
  146633. * The url to the fallback JavaScript module.
  146634. */
  146635. fallbackUrl?: string;
  146636. };
  146637. }
  146638. /**
  146639. * Draco compression (https://google.github.io/draco/)
  146640. *
  146641. * This class wraps the Draco module.
  146642. *
  146643. * **Encoder**
  146644. *
  146645. * The encoder is not currently implemented.
  146646. *
  146647. * **Decoder**
  146648. *
  146649. * 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.
  146650. *
  146651. * To update the configuration, use the following code:
  146652. * ```javascript
  146653. * DracoCompression.Configuration = {
  146654. * decoder: {
  146655. * wasmUrl: "<url to the WebAssembly library>",
  146656. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146657. * fallbackUrl: "<url to the fallback JavaScript library>",
  146658. * }
  146659. * };
  146660. * ```
  146661. *
  146662. * 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.
  146663. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146664. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146665. *
  146666. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146667. * ```javascript
  146668. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146669. * ```
  146670. *
  146671. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146672. */
  146673. export class DracoCompression implements IDisposable {
  146674. private _workerPoolPromise?;
  146675. private _decoderModulePromise?;
  146676. /**
  146677. * The configuration. Defaults to the following urls:
  146678. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146679. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146680. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146681. */
  146682. static Configuration: IDracoCompressionConfiguration;
  146683. /**
  146684. * Returns true if the decoder configuration is available.
  146685. */
  146686. static get DecoderAvailable(): boolean;
  146687. /**
  146688. * Default number of workers to create when creating the draco compression object.
  146689. */
  146690. static DefaultNumWorkers: number;
  146691. private static GetDefaultNumWorkers;
  146692. private static _Default;
  146693. /**
  146694. * Default instance for the draco compression object.
  146695. */
  146696. static get Default(): DracoCompression;
  146697. /**
  146698. * Constructor
  146699. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146700. */
  146701. constructor(numWorkers?: number);
  146702. /**
  146703. * Stop all async operations and release resources.
  146704. */
  146705. dispose(): void;
  146706. /**
  146707. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146708. * @returns a promise that resolves when ready
  146709. */
  146710. whenReadyAsync(): Promise<void>;
  146711. /**
  146712. * Decode Draco compressed mesh data to vertex data.
  146713. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146714. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146715. * @returns A promise that resolves with the decoded vertex data
  146716. */
  146717. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146718. [kind: string]: number;
  146719. }): Promise<VertexData>;
  146720. }
  146721. }
  146722. declare module BABYLON {
  146723. /**
  146724. * Class for building Constructive Solid Geometry
  146725. */
  146726. export class CSG {
  146727. private polygons;
  146728. /**
  146729. * The world matrix
  146730. */
  146731. matrix: Matrix;
  146732. /**
  146733. * Stores the position
  146734. */
  146735. position: Vector3;
  146736. /**
  146737. * Stores the rotation
  146738. */
  146739. rotation: Vector3;
  146740. /**
  146741. * Stores the rotation quaternion
  146742. */
  146743. rotationQuaternion: Nullable<Quaternion>;
  146744. /**
  146745. * Stores the scaling vector
  146746. */
  146747. scaling: Vector3;
  146748. /**
  146749. * Convert the Mesh to CSG
  146750. * @param mesh The Mesh to convert to CSG
  146751. * @returns A new CSG from the Mesh
  146752. */
  146753. static FromMesh(mesh: Mesh): CSG;
  146754. /**
  146755. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146756. * @param polygons Polygons used to construct a CSG solid
  146757. */
  146758. private static FromPolygons;
  146759. /**
  146760. * Clones, or makes a deep copy, of the CSG
  146761. * @returns A new CSG
  146762. */
  146763. clone(): CSG;
  146764. /**
  146765. * Unions this CSG with another CSG
  146766. * @param csg The CSG to union against this CSG
  146767. * @returns The unioned CSG
  146768. */
  146769. union(csg: CSG): CSG;
  146770. /**
  146771. * Unions this CSG with another CSG in place
  146772. * @param csg The CSG to union against this CSG
  146773. */
  146774. unionInPlace(csg: CSG): void;
  146775. /**
  146776. * Subtracts this CSG with another CSG
  146777. * @param csg The CSG to subtract against this CSG
  146778. * @returns A new CSG
  146779. */
  146780. subtract(csg: CSG): CSG;
  146781. /**
  146782. * Subtracts this CSG with another CSG in place
  146783. * @param csg The CSG to subtact against this CSG
  146784. */
  146785. subtractInPlace(csg: CSG): void;
  146786. /**
  146787. * Intersect this CSG with another CSG
  146788. * @param csg The CSG to intersect against this CSG
  146789. * @returns A new CSG
  146790. */
  146791. intersect(csg: CSG): CSG;
  146792. /**
  146793. * Intersects this CSG with another CSG in place
  146794. * @param csg The CSG to intersect against this CSG
  146795. */
  146796. intersectInPlace(csg: CSG): void;
  146797. /**
  146798. * Return a new CSG solid with solid and empty space switched. This solid is
  146799. * not modified.
  146800. * @returns A new CSG solid with solid and empty space switched
  146801. */
  146802. inverse(): CSG;
  146803. /**
  146804. * Inverses the CSG in place
  146805. */
  146806. inverseInPlace(): void;
  146807. /**
  146808. * This is used to keep meshes transformations so they can be restored
  146809. * when we build back a Babylon Mesh
  146810. * NB : All CSG operations are performed in world coordinates
  146811. * @param csg The CSG to copy the transform attributes from
  146812. * @returns This CSG
  146813. */
  146814. copyTransformAttributes(csg: CSG): CSG;
  146815. /**
  146816. * Build Raw mesh from CSG
  146817. * Coordinates here are in world space
  146818. * @param name The name of the mesh geometry
  146819. * @param scene The Scene
  146820. * @param keepSubMeshes Specifies if the submeshes should be kept
  146821. * @returns A new Mesh
  146822. */
  146823. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146824. /**
  146825. * Build Mesh from CSG taking material and transforms into account
  146826. * @param name The name of the Mesh
  146827. * @param material The material of the Mesh
  146828. * @param scene The Scene
  146829. * @param keepSubMeshes Specifies if submeshes should be kept
  146830. * @returns The new Mesh
  146831. */
  146832. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146833. }
  146834. }
  146835. declare module BABYLON {
  146836. /**
  146837. * Class used to create a trail following a mesh
  146838. */
  146839. export class TrailMesh extends Mesh {
  146840. private _generator;
  146841. private _autoStart;
  146842. private _running;
  146843. private _diameter;
  146844. private _length;
  146845. private _sectionPolygonPointsCount;
  146846. private _sectionVectors;
  146847. private _sectionNormalVectors;
  146848. private _beforeRenderObserver;
  146849. /**
  146850. * @constructor
  146851. * @param name The value used by scene.getMeshByName() to do a lookup.
  146852. * @param generator The mesh or transform node to generate a trail.
  146853. * @param scene The scene to add this mesh to.
  146854. * @param diameter Diameter of trailing mesh. Default is 1.
  146855. * @param length Length of trailing mesh. Default is 60.
  146856. * @param autoStart Automatically start trailing mesh. Default true.
  146857. */
  146858. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146859. /**
  146860. * "TrailMesh"
  146861. * @returns "TrailMesh"
  146862. */
  146863. getClassName(): string;
  146864. private _createMesh;
  146865. /**
  146866. * Start trailing mesh.
  146867. */
  146868. start(): void;
  146869. /**
  146870. * Stop trailing mesh.
  146871. */
  146872. stop(): void;
  146873. /**
  146874. * Update trailing mesh geometry.
  146875. */
  146876. update(): void;
  146877. /**
  146878. * Returns a new TrailMesh object.
  146879. * @param name is a string, the name given to the new mesh
  146880. * @param newGenerator use new generator object for cloned trail mesh
  146881. * @returns a new mesh
  146882. */
  146883. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146884. /**
  146885. * Serializes this trail mesh
  146886. * @param serializationObject object to write serialization to
  146887. */
  146888. serialize(serializationObject: any): void;
  146889. /**
  146890. * Parses a serialized trail mesh
  146891. * @param parsedMesh the serialized mesh
  146892. * @param scene the scene to create the trail mesh in
  146893. * @returns the created trail mesh
  146894. */
  146895. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146896. }
  146897. }
  146898. declare module BABYLON {
  146899. /**
  146900. * Class containing static functions to help procedurally build meshes
  146901. */
  146902. export class TiledBoxBuilder {
  146903. /**
  146904. * Creates a box mesh
  146905. * 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)
  146906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146910. * @param name defines the name of the mesh
  146911. * @param options defines the options used to create the mesh
  146912. * @param scene defines the hosting scene
  146913. * @returns the box mesh
  146914. */
  146915. static CreateTiledBox(name: string, options: {
  146916. pattern?: number;
  146917. width?: number;
  146918. height?: number;
  146919. depth?: number;
  146920. tileSize?: number;
  146921. tileWidth?: number;
  146922. tileHeight?: number;
  146923. alignHorizontal?: number;
  146924. alignVertical?: number;
  146925. faceUV?: Vector4[];
  146926. faceColors?: Color4[];
  146927. sideOrientation?: number;
  146928. updatable?: boolean;
  146929. }, scene?: Nullable<Scene>): Mesh;
  146930. }
  146931. }
  146932. declare module BABYLON {
  146933. /**
  146934. * Class containing static functions to help procedurally build meshes
  146935. */
  146936. export class TorusKnotBuilder {
  146937. /**
  146938. * Creates a torus knot mesh
  146939. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146940. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146941. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146942. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146946. * @param name defines the name of the mesh
  146947. * @param options defines the options used to create the mesh
  146948. * @param scene defines the hosting scene
  146949. * @returns the torus knot mesh
  146950. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146951. */
  146952. static CreateTorusKnot(name: string, options: {
  146953. radius?: number;
  146954. tube?: number;
  146955. radialSegments?: number;
  146956. tubularSegments?: number;
  146957. p?: number;
  146958. q?: number;
  146959. updatable?: boolean;
  146960. sideOrientation?: number;
  146961. frontUVs?: Vector4;
  146962. backUVs?: Vector4;
  146963. }, scene: any): Mesh;
  146964. }
  146965. }
  146966. declare module BABYLON {
  146967. /**
  146968. * Polygon
  146969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146970. */
  146971. export class Polygon {
  146972. /**
  146973. * Creates a rectangle
  146974. * @param xmin bottom X coord
  146975. * @param ymin bottom Y coord
  146976. * @param xmax top X coord
  146977. * @param ymax top Y coord
  146978. * @returns points that make the resulting rectation
  146979. */
  146980. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146981. /**
  146982. * Creates a circle
  146983. * @param radius radius of circle
  146984. * @param cx scale in x
  146985. * @param cy scale in y
  146986. * @param numberOfSides number of sides that make up the circle
  146987. * @returns points that make the resulting circle
  146988. */
  146989. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146990. /**
  146991. * Creates a polygon from input string
  146992. * @param input Input polygon data
  146993. * @returns the parsed points
  146994. */
  146995. static Parse(input: string): Vector2[];
  146996. /**
  146997. * Starts building a polygon from x and y coordinates
  146998. * @param x x coordinate
  146999. * @param y y coordinate
  147000. * @returns the started path2
  147001. */
  147002. static StartingAt(x: number, y: number): Path2;
  147003. }
  147004. /**
  147005. * Builds a polygon
  147006. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  147007. */
  147008. export class PolygonMeshBuilder {
  147009. private _points;
  147010. private _outlinepoints;
  147011. private _holes;
  147012. private _name;
  147013. private _scene;
  147014. private _epoints;
  147015. private _eholes;
  147016. private _addToepoint;
  147017. /**
  147018. * Babylon reference to the earcut plugin.
  147019. */
  147020. bjsEarcut: any;
  147021. /**
  147022. * Creates a PolygonMeshBuilder
  147023. * @param name name of the builder
  147024. * @param contours Path of the polygon
  147025. * @param scene scene to add to when creating the mesh
  147026. * @param earcutInjection can be used to inject your own earcut reference
  147027. */
  147028. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  147029. /**
  147030. * Adds a whole within the polygon
  147031. * @param hole Array of points defining the hole
  147032. * @returns this
  147033. */
  147034. addHole(hole: Vector2[]): PolygonMeshBuilder;
  147035. /**
  147036. * Creates the polygon
  147037. * @param updatable If the mesh should be updatable
  147038. * @param depth The depth of the mesh created
  147039. * @returns the created mesh
  147040. */
  147041. build(updatable?: boolean, depth?: number): Mesh;
  147042. /**
  147043. * Creates the polygon
  147044. * @param depth The depth of the mesh created
  147045. * @returns the created VertexData
  147046. */
  147047. buildVertexData(depth?: number): VertexData;
  147048. /**
  147049. * Adds a side to the polygon
  147050. * @param positions points that make the polygon
  147051. * @param normals normals of the polygon
  147052. * @param uvs uvs of the polygon
  147053. * @param indices indices of the polygon
  147054. * @param bounds bounds of the polygon
  147055. * @param points points of the polygon
  147056. * @param depth depth of the polygon
  147057. * @param flip flip of the polygon
  147058. */
  147059. private addSide;
  147060. }
  147061. }
  147062. declare module BABYLON {
  147063. /**
  147064. * Class containing static functions to help procedurally build meshes
  147065. */
  147066. export class PolygonBuilder {
  147067. /**
  147068. * Creates a polygon mesh
  147069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147070. * * 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
  147071. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147074. * * Remember you can only change the shape positions, not their number when updating a polygon
  147075. * @param name defines the name of the mesh
  147076. * @param options defines the options used to create the mesh
  147077. * @param scene defines the hosting scene
  147078. * @param earcutInjection can be used to inject your own earcut reference
  147079. * @returns the polygon mesh
  147080. */
  147081. static CreatePolygon(name: string, options: {
  147082. shape: Vector3[];
  147083. holes?: Vector3[][];
  147084. depth?: number;
  147085. faceUV?: Vector4[];
  147086. faceColors?: Color4[];
  147087. updatable?: boolean;
  147088. sideOrientation?: number;
  147089. frontUVs?: Vector4;
  147090. backUVs?: Vector4;
  147091. wrap?: boolean;
  147092. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147093. /**
  147094. * Creates an extruded polygon mesh, with depth in the Y direction.
  147095. * * 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)
  147096. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147097. * @param name defines the name of the mesh
  147098. * @param options defines the options used to create the mesh
  147099. * @param scene defines the hosting scene
  147100. * @param earcutInjection can be used to inject your own earcut reference
  147101. * @returns the polygon mesh
  147102. */
  147103. static ExtrudePolygon(name: string, options: {
  147104. shape: Vector3[];
  147105. holes?: Vector3[][];
  147106. depth?: number;
  147107. faceUV?: Vector4[];
  147108. faceColors?: Color4[];
  147109. updatable?: boolean;
  147110. sideOrientation?: number;
  147111. frontUVs?: Vector4;
  147112. backUVs?: Vector4;
  147113. wrap?: boolean;
  147114. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147115. }
  147116. }
  147117. declare module BABYLON {
  147118. /**
  147119. * Class containing static functions to help procedurally build meshes
  147120. */
  147121. export class LatheBuilder {
  147122. /**
  147123. * Creates lathe mesh.
  147124. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147125. * * 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
  147126. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147127. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147128. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147129. * * 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
  147130. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147131. * * 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
  147132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147136. * @param name defines the name of the mesh
  147137. * @param options defines the options used to create the mesh
  147138. * @param scene defines the hosting scene
  147139. * @returns the lathe mesh
  147140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147141. */
  147142. static CreateLathe(name: string, options: {
  147143. shape: Vector3[];
  147144. radius?: number;
  147145. tessellation?: number;
  147146. clip?: number;
  147147. arc?: number;
  147148. closed?: boolean;
  147149. updatable?: boolean;
  147150. sideOrientation?: number;
  147151. frontUVs?: Vector4;
  147152. backUVs?: Vector4;
  147153. cap?: number;
  147154. invertUV?: boolean;
  147155. }, scene?: Nullable<Scene>): Mesh;
  147156. }
  147157. }
  147158. declare module BABYLON {
  147159. /**
  147160. * Class containing static functions to help procedurally build meshes
  147161. */
  147162. export class TiledPlaneBuilder {
  147163. /**
  147164. * Creates a tiled plane mesh
  147165. * * The parameter `pattern` will, depending on value, do nothing or
  147166. * * * flip (reflect about central vertical) alternate tiles across and up
  147167. * * * flip every tile on alternate rows
  147168. * * * rotate (180 degs) alternate tiles across and up
  147169. * * * rotate every tile on alternate rows
  147170. * * * flip and rotate alternate tiles across and up
  147171. * * * flip and rotate every tile on alternate rows
  147172. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147173. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147176. * * 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)
  147177. * * 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)
  147178. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147179. * @param name defines the name of the mesh
  147180. * @param options defines the options used to create the mesh
  147181. * @param scene defines the hosting scene
  147182. * @returns the box mesh
  147183. */
  147184. static CreateTiledPlane(name: string, options: {
  147185. pattern?: number;
  147186. tileSize?: number;
  147187. tileWidth?: number;
  147188. tileHeight?: number;
  147189. size?: number;
  147190. width?: number;
  147191. height?: number;
  147192. alignHorizontal?: number;
  147193. alignVertical?: number;
  147194. sideOrientation?: number;
  147195. frontUVs?: Vector4;
  147196. backUVs?: Vector4;
  147197. updatable?: boolean;
  147198. }, scene?: Nullable<Scene>): Mesh;
  147199. }
  147200. }
  147201. declare module BABYLON {
  147202. /**
  147203. * Class containing static functions to help procedurally build meshes
  147204. */
  147205. export class TubeBuilder {
  147206. /**
  147207. * Creates a tube mesh.
  147208. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147209. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147210. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147211. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147212. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147213. * * 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)
  147214. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147215. * * 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
  147216. * * 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
  147217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147221. * @param name defines the name of the mesh
  147222. * @param options defines the options used to create the mesh
  147223. * @param scene defines the hosting scene
  147224. * @returns the tube mesh
  147225. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147226. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147227. */
  147228. static CreateTube(name: string, options: {
  147229. path: Vector3[];
  147230. radius?: number;
  147231. tessellation?: number;
  147232. radiusFunction?: {
  147233. (i: number, distance: number): number;
  147234. };
  147235. cap?: number;
  147236. arc?: number;
  147237. updatable?: boolean;
  147238. sideOrientation?: number;
  147239. frontUVs?: Vector4;
  147240. backUVs?: Vector4;
  147241. instance?: Mesh;
  147242. invertUV?: boolean;
  147243. }, scene?: Nullable<Scene>): Mesh;
  147244. }
  147245. }
  147246. declare module BABYLON {
  147247. /**
  147248. * Class containing static functions to help procedurally build meshes
  147249. */
  147250. export class IcoSphereBuilder {
  147251. /**
  147252. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147253. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147254. * * 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`)
  147255. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147256. * * 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
  147257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147260. * @param name defines the name of the mesh
  147261. * @param options defines the options used to create the mesh
  147262. * @param scene defines the hosting scene
  147263. * @returns the icosahedron mesh
  147264. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147265. */
  147266. static CreateIcoSphere(name: string, options: {
  147267. radius?: number;
  147268. radiusX?: number;
  147269. radiusY?: number;
  147270. radiusZ?: number;
  147271. flat?: boolean;
  147272. subdivisions?: number;
  147273. sideOrientation?: number;
  147274. frontUVs?: Vector4;
  147275. backUVs?: Vector4;
  147276. updatable?: boolean;
  147277. }, scene?: Nullable<Scene>): Mesh;
  147278. }
  147279. }
  147280. declare module BABYLON {
  147281. /**
  147282. * Class containing static functions to help procedurally build meshes
  147283. */
  147284. export class DecalBuilder {
  147285. /**
  147286. * Creates a decal mesh.
  147287. * 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
  147288. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147289. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147290. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147291. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147292. * @param name defines the name of the mesh
  147293. * @param sourceMesh defines the mesh where the decal must be applied
  147294. * @param options defines the options used to create the mesh
  147295. * @param scene defines the hosting scene
  147296. * @returns the decal mesh
  147297. * @see https://doc.babylonjs.com/how_to/decals
  147298. */
  147299. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147300. position?: Vector3;
  147301. normal?: Vector3;
  147302. size?: Vector3;
  147303. angle?: number;
  147304. }): Mesh;
  147305. }
  147306. }
  147307. declare module BABYLON {
  147308. /**
  147309. * Class containing static functions to help procedurally build meshes
  147310. */
  147311. export class MeshBuilder {
  147312. /**
  147313. * Creates a box mesh
  147314. * * The parameter `size` sets the size (float) of each box side (default 1)
  147315. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147316. * * 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)
  147317. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147321. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147322. * @param name defines the name of the mesh
  147323. * @param options defines the options used to create the mesh
  147324. * @param scene defines the hosting scene
  147325. * @returns the box mesh
  147326. */
  147327. static CreateBox(name: string, options: {
  147328. size?: number;
  147329. width?: number;
  147330. height?: number;
  147331. depth?: number;
  147332. faceUV?: Vector4[];
  147333. faceColors?: Color4[];
  147334. sideOrientation?: number;
  147335. frontUVs?: Vector4;
  147336. backUVs?: Vector4;
  147337. wrap?: boolean;
  147338. topBaseAt?: number;
  147339. bottomBaseAt?: number;
  147340. updatable?: boolean;
  147341. }, scene?: Nullable<Scene>): Mesh;
  147342. /**
  147343. * Creates a tiled box mesh
  147344. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147346. * @param name defines the name of the mesh
  147347. * @param options defines the options used to create the mesh
  147348. * @param scene defines the hosting scene
  147349. * @returns the tiled box mesh
  147350. */
  147351. static CreateTiledBox(name: string, options: {
  147352. pattern?: number;
  147353. size?: number;
  147354. width?: number;
  147355. height?: number;
  147356. depth: number;
  147357. tileSize?: number;
  147358. tileWidth?: number;
  147359. tileHeight?: number;
  147360. faceUV?: Vector4[];
  147361. faceColors?: Color4[];
  147362. alignHorizontal?: number;
  147363. alignVertical?: number;
  147364. sideOrientation?: number;
  147365. updatable?: boolean;
  147366. }, scene?: Nullable<Scene>): Mesh;
  147367. /**
  147368. * Creates a sphere mesh
  147369. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147370. * * 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`)
  147371. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147372. * * 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
  147373. * * 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)
  147374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147377. * @param name defines the name of the mesh
  147378. * @param options defines the options used to create the mesh
  147379. * @param scene defines the hosting scene
  147380. * @returns the sphere mesh
  147381. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147382. */
  147383. static CreateSphere(name: string, options: {
  147384. segments?: number;
  147385. diameter?: number;
  147386. diameterX?: number;
  147387. diameterY?: number;
  147388. diameterZ?: number;
  147389. arc?: number;
  147390. slice?: number;
  147391. sideOrientation?: number;
  147392. frontUVs?: Vector4;
  147393. backUVs?: Vector4;
  147394. updatable?: boolean;
  147395. }, scene?: Nullable<Scene>): Mesh;
  147396. /**
  147397. * Creates a plane polygonal mesh. By default, this is a disc
  147398. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147399. * * 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
  147400. * * 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
  147401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147404. * @param name defines the name of the mesh
  147405. * @param options defines the options used to create the mesh
  147406. * @param scene defines the hosting scene
  147407. * @returns the plane polygonal mesh
  147408. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147409. */
  147410. static CreateDisc(name: string, options: {
  147411. radius?: number;
  147412. tessellation?: number;
  147413. arc?: number;
  147414. updatable?: boolean;
  147415. sideOrientation?: number;
  147416. frontUVs?: Vector4;
  147417. backUVs?: Vector4;
  147418. }, scene?: Nullable<Scene>): Mesh;
  147419. /**
  147420. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147421. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147422. * * 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`)
  147423. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147424. * * 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
  147425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147428. * @param name defines the name of the mesh
  147429. * @param options defines the options used to create the mesh
  147430. * @param scene defines the hosting scene
  147431. * @returns the icosahedron mesh
  147432. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147433. */
  147434. static CreateIcoSphere(name: string, options: {
  147435. radius?: number;
  147436. radiusX?: number;
  147437. radiusY?: number;
  147438. radiusZ?: number;
  147439. flat?: boolean;
  147440. subdivisions?: number;
  147441. sideOrientation?: number;
  147442. frontUVs?: Vector4;
  147443. backUVs?: Vector4;
  147444. updatable?: boolean;
  147445. }, scene?: Nullable<Scene>): Mesh;
  147446. /**
  147447. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147448. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147449. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147450. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147451. * * 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
  147452. * * 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
  147453. * * 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
  147454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147457. * * 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
  147458. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147459. * * 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
  147460. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147462. * @param name defines the name of the mesh
  147463. * @param options defines the options used to create the mesh
  147464. * @param scene defines the hosting scene
  147465. * @returns the ribbon mesh
  147466. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147468. */
  147469. static CreateRibbon(name: string, options: {
  147470. pathArray: Vector3[][];
  147471. closeArray?: boolean;
  147472. closePath?: boolean;
  147473. offset?: number;
  147474. updatable?: boolean;
  147475. sideOrientation?: number;
  147476. frontUVs?: Vector4;
  147477. backUVs?: Vector4;
  147478. instance?: Mesh;
  147479. invertUV?: boolean;
  147480. uvs?: Vector2[];
  147481. colors?: Color4[];
  147482. }, scene?: Nullable<Scene>): Mesh;
  147483. /**
  147484. * Creates a cylinder or a cone mesh
  147485. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147486. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147487. * * 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.
  147488. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147489. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147490. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147491. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147492. * * 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).
  147493. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147494. * * 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).
  147495. * * 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
  147496. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147497. * * 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
  147498. * * 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.
  147499. * * If `enclose` is false, a ring surface is one element.
  147500. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147501. * * 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
  147502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147505. * @param name defines the name of the mesh
  147506. * @param options defines the options used to create the mesh
  147507. * @param scene defines the hosting scene
  147508. * @returns the cylinder mesh
  147509. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147510. */
  147511. static CreateCylinder(name: string, options: {
  147512. height?: number;
  147513. diameterTop?: number;
  147514. diameterBottom?: number;
  147515. diameter?: number;
  147516. tessellation?: number;
  147517. subdivisions?: number;
  147518. arc?: number;
  147519. faceColors?: Color4[];
  147520. faceUV?: Vector4[];
  147521. updatable?: boolean;
  147522. hasRings?: boolean;
  147523. enclose?: boolean;
  147524. cap?: number;
  147525. sideOrientation?: number;
  147526. frontUVs?: Vector4;
  147527. backUVs?: Vector4;
  147528. }, scene?: Nullable<Scene>): Mesh;
  147529. /**
  147530. * Creates a torus mesh
  147531. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147532. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147533. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147537. * @param name defines the name of the mesh
  147538. * @param options defines the options used to create the mesh
  147539. * @param scene defines the hosting scene
  147540. * @returns the torus mesh
  147541. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147542. */
  147543. static CreateTorus(name: string, options: {
  147544. diameter?: number;
  147545. thickness?: number;
  147546. tessellation?: number;
  147547. updatable?: boolean;
  147548. sideOrientation?: number;
  147549. frontUVs?: Vector4;
  147550. backUVs?: Vector4;
  147551. }, scene?: Nullable<Scene>): Mesh;
  147552. /**
  147553. * Creates a torus knot mesh
  147554. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147555. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147556. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147557. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147561. * @param name defines the name of the mesh
  147562. * @param options defines the options used to create the mesh
  147563. * @param scene defines the hosting scene
  147564. * @returns the torus knot mesh
  147565. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147566. */
  147567. static CreateTorusKnot(name: string, options: {
  147568. radius?: number;
  147569. tube?: number;
  147570. radialSegments?: number;
  147571. tubularSegments?: number;
  147572. p?: number;
  147573. q?: number;
  147574. updatable?: boolean;
  147575. sideOrientation?: number;
  147576. frontUVs?: Vector4;
  147577. backUVs?: Vector4;
  147578. }, scene?: Nullable<Scene>): Mesh;
  147579. /**
  147580. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147581. * * 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
  147582. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147583. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147584. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147585. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147586. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147587. * * 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
  147588. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147591. * @param name defines the name of the new line system
  147592. * @param options defines the options used to create the line system
  147593. * @param scene defines the hosting scene
  147594. * @returns a new line system mesh
  147595. */
  147596. static CreateLineSystem(name: string, options: {
  147597. lines: Vector3[][];
  147598. updatable?: boolean;
  147599. instance?: Nullable<LinesMesh>;
  147600. colors?: Nullable<Color4[][]>;
  147601. useVertexAlpha?: boolean;
  147602. }, scene: Nullable<Scene>): LinesMesh;
  147603. /**
  147604. * Creates a line mesh
  147605. * 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
  147606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147607. * * The parameter `points` is an array successive Vector3
  147608. * * 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
  147609. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147611. * * When updating an instance, remember that only point positions can change, not the number of points
  147612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147614. * @param name defines the name of the new line system
  147615. * @param options defines the options used to create the line system
  147616. * @param scene defines the hosting scene
  147617. * @returns a new line mesh
  147618. */
  147619. static CreateLines(name: string, options: {
  147620. points: Vector3[];
  147621. updatable?: boolean;
  147622. instance?: Nullable<LinesMesh>;
  147623. colors?: Color4[];
  147624. useVertexAlpha?: boolean;
  147625. }, scene?: Nullable<Scene>): LinesMesh;
  147626. /**
  147627. * Creates a dashed line mesh
  147628. * * 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
  147629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147630. * * The parameter `points` is an array successive Vector3
  147631. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147632. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147633. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147634. * * 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
  147635. * * When updating an instance, remember that only point positions can change, not the number of points
  147636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147637. * @param name defines the name of the mesh
  147638. * @param options defines the options used to create the mesh
  147639. * @param scene defines the hosting scene
  147640. * @returns the dashed line mesh
  147641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147642. */
  147643. static CreateDashedLines(name: string, options: {
  147644. points: Vector3[];
  147645. dashSize?: number;
  147646. gapSize?: number;
  147647. dashNb?: number;
  147648. updatable?: boolean;
  147649. instance?: LinesMesh;
  147650. }, scene?: Nullable<Scene>): LinesMesh;
  147651. /**
  147652. * 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.
  147653. * * 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.
  147654. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147655. * * 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.
  147656. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147657. * * 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
  147658. * * 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
  147659. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147664. * @param name defines the name of the mesh
  147665. * @param options defines the options used to create the mesh
  147666. * @param scene defines the hosting scene
  147667. * @returns the extruded shape mesh
  147668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147670. */
  147671. static ExtrudeShape(name: string, options: {
  147672. shape: Vector3[];
  147673. path: Vector3[];
  147674. scale?: number;
  147675. rotation?: number;
  147676. cap?: number;
  147677. updatable?: boolean;
  147678. sideOrientation?: number;
  147679. frontUVs?: Vector4;
  147680. backUVs?: Vector4;
  147681. instance?: Mesh;
  147682. invertUV?: boolean;
  147683. }, scene?: Nullable<Scene>): Mesh;
  147684. /**
  147685. * Creates an custom extruded shape mesh.
  147686. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147687. * * 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.
  147688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147689. * * 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
  147690. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147691. * * 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
  147692. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147693. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147694. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147695. * * 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
  147696. * * 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
  147697. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147702. * @param name defines the name of the mesh
  147703. * @param options defines the options used to create the mesh
  147704. * @param scene defines the hosting scene
  147705. * @returns the custom extruded shape mesh
  147706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147709. */
  147710. static ExtrudeShapeCustom(name: string, options: {
  147711. shape: Vector3[];
  147712. path: Vector3[];
  147713. scaleFunction?: any;
  147714. rotationFunction?: any;
  147715. ribbonCloseArray?: boolean;
  147716. ribbonClosePath?: boolean;
  147717. cap?: number;
  147718. updatable?: boolean;
  147719. sideOrientation?: number;
  147720. frontUVs?: Vector4;
  147721. backUVs?: Vector4;
  147722. instance?: Mesh;
  147723. invertUV?: boolean;
  147724. }, scene?: Nullable<Scene>): Mesh;
  147725. /**
  147726. * Creates lathe mesh.
  147727. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147728. * * 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
  147729. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147730. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147731. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147732. * * 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
  147733. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147734. * * 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
  147735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147739. * @param name defines the name of the mesh
  147740. * @param options defines the options used to create the mesh
  147741. * @param scene defines the hosting scene
  147742. * @returns the lathe mesh
  147743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147744. */
  147745. static CreateLathe(name: string, options: {
  147746. shape: Vector3[];
  147747. radius?: number;
  147748. tessellation?: number;
  147749. clip?: number;
  147750. arc?: number;
  147751. closed?: boolean;
  147752. updatable?: boolean;
  147753. sideOrientation?: number;
  147754. frontUVs?: Vector4;
  147755. backUVs?: Vector4;
  147756. cap?: number;
  147757. invertUV?: boolean;
  147758. }, scene?: Nullable<Scene>): Mesh;
  147759. /**
  147760. * Creates a tiled plane mesh
  147761. * * You can set a limited pattern arrangement with the tiles
  147762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147765. * @param name defines the name of the mesh
  147766. * @param options defines the options used to create the mesh
  147767. * @param scene defines the hosting scene
  147768. * @returns the plane mesh
  147769. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147770. */
  147771. static CreateTiledPlane(name: string, options: {
  147772. pattern?: number;
  147773. tileSize?: number;
  147774. tileWidth?: number;
  147775. tileHeight?: number;
  147776. size?: number;
  147777. width?: number;
  147778. height?: number;
  147779. alignHorizontal?: number;
  147780. alignVertical?: number;
  147781. sideOrientation?: number;
  147782. frontUVs?: Vector4;
  147783. backUVs?: Vector4;
  147784. updatable?: boolean;
  147785. }, scene?: Nullable<Scene>): Mesh;
  147786. /**
  147787. * Creates a plane mesh
  147788. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147789. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147790. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147794. * @param name defines the name of the mesh
  147795. * @param options defines the options used to create the mesh
  147796. * @param scene defines the hosting scene
  147797. * @returns the plane mesh
  147798. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147799. */
  147800. static CreatePlane(name: string, options: {
  147801. size?: number;
  147802. width?: number;
  147803. height?: number;
  147804. sideOrientation?: number;
  147805. frontUVs?: Vector4;
  147806. backUVs?: Vector4;
  147807. updatable?: boolean;
  147808. sourcePlane?: Plane;
  147809. }, scene?: Nullable<Scene>): Mesh;
  147810. /**
  147811. * Creates a ground mesh
  147812. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147813. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147815. * @param name defines the name of the mesh
  147816. * @param options defines the options used to create the mesh
  147817. * @param scene defines the hosting scene
  147818. * @returns the ground mesh
  147819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147820. */
  147821. static CreateGround(name: string, options: {
  147822. width?: number;
  147823. height?: number;
  147824. subdivisions?: number;
  147825. subdivisionsX?: number;
  147826. subdivisionsY?: number;
  147827. updatable?: boolean;
  147828. }, scene?: Nullable<Scene>): Mesh;
  147829. /**
  147830. * Creates a tiled ground mesh
  147831. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147832. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147833. * * 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
  147834. * * 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
  147835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147836. * @param name defines the name of the mesh
  147837. * @param options defines the options used to create the mesh
  147838. * @param scene defines the hosting scene
  147839. * @returns the tiled ground mesh
  147840. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147841. */
  147842. static CreateTiledGround(name: string, options: {
  147843. xmin: number;
  147844. zmin: number;
  147845. xmax: number;
  147846. zmax: number;
  147847. subdivisions?: {
  147848. w: number;
  147849. h: number;
  147850. };
  147851. precision?: {
  147852. w: number;
  147853. h: number;
  147854. };
  147855. updatable?: boolean;
  147856. }, scene?: Nullable<Scene>): Mesh;
  147857. /**
  147858. * Creates a ground mesh from a height map
  147859. * * The parameter `url` sets the URL of the height map image resource.
  147860. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147861. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147862. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147863. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147864. * * 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.
  147865. * * 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).
  147866. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147868. * @param name defines the name of the mesh
  147869. * @param url defines the url to the height map
  147870. * @param options defines the options used to create the mesh
  147871. * @param scene defines the hosting scene
  147872. * @returns the ground mesh
  147873. * @see https://doc.babylonjs.com/babylon101/height_map
  147874. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147875. */
  147876. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147877. width?: number;
  147878. height?: number;
  147879. subdivisions?: number;
  147880. minHeight?: number;
  147881. maxHeight?: number;
  147882. colorFilter?: Color3;
  147883. alphaFilter?: number;
  147884. updatable?: boolean;
  147885. onReady?: (mesh: GroundMesh) => void;
  147886. }, scene?: Nullable<Scene>): GroundMesh;
  147887. /**
  147888. * Creates a polygon mesh
  147889. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147890. * * 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
  147891. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147894. * * Remember you can only change the shape positions, not their number when updating a polygon
  147895. * @param name defines the name of the mesh
  147896. * @param options defines the options used to create the mesh
  147897. * @param scene defines the hosting scene
  147898. * @param earcutInjection can be used to inject your own earcut reference
  147899. * @returns the polygon mesh
  147900. */
  147901. static CreatePolygon(name: string, options: {
  147902. shape: Vector3[];
  147903. holes?: Vector3[][];
  147904. depth?: number;
  147905. faceUV?: Vector4[];
  147906. faceColors?: Color4[];
  147907. updatable?: boolean;
  147908. sideOrientation?: number;
  147909. frontUVs?: Vector4;
  147910. backUVs?: Vector4;
  147911. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147912. /**
  147913. * Creates an extruded polygon mesh, with depth in the Y direction.
  147914. * * 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)
  147915. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147916. * @param name defines the name of the mesh
  147917. * @param options defines the options used to create the mesh
  147918. * @param scene defines the hosting scene
  147919. * @param earcutInjection can be used to inject your own earcut reference
  147920. * @returns the polygon mesh
  147921. */
  147922. static ExtrudePolygon(name: string, options: {
  147923. shape: Vector3[];
  147924. holes?: Vector3[][];
  147925. depth?: number;
  147926. faceUV?: Vector4[];
  147927. faceColors?: Color4[];
  147928. updatable?: boolean;
  147929. sideOrientation?: number;
  147930. frontUVs?: Vector4;
  147931. backUVs?: Vector4;
  147932. wrap?: boolean;
  147933. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147934. /**
  147935. * Creates a tube mesh.
  147936. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147937. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147938. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147939. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147940. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147941. * * 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)
  147942. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147943. * * 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
  147944. * * 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
  147945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147949. * @param name defines the name of the mesh
  147950. * @param options defines the options used to create the mesh
  147951. * @param scene defines the hosting scene
  147952. * @returns the tube mesh
  147953. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147954. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147955. */
  147956. static CreateTube(name: string, options: {
  147957. path: Vector3[];
  147958. radius?: number;
  147959. tessellation?: number;
  147960. radiusFunction?: {
  147961. (i: number, distance: number): number;
  147962. };
  147963. cap?: number;
  147964. arc?: number;
  147965. updatable?: boolean;
  147966. sideOrientation?: number;
  147967. frontUVs?: Vector4;
  147968. backUVs?: Vector4;
  147969. instance?: Mesh;
  147970. invertUV?: boolean;
  147971. }, scene?: Nullable<Scene>): Mesh;
  147972. /**
  147973. * Creates a polyhedron mesh
  147974. * * 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
  147975. * * The parameter `size` (positive float, default 1) sets the polygon size
  147976. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147977. * * 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`
  147978. * * 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
  147979. * * 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)`)
  147980. * * 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
  147981. * * 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
  147982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147985. * @param name defines the name of the mesh
  147986. * @param options defines the options used to create the mesh
  147987. * @param scene defines the hosting scene
  147988. * @returns the polyhedron mesh
  147989. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147990. */
  147991. static CreatePolyhedron(name: string, options: {
  147992. type?: number;
  147993. size?: number;
  147994. sizeX?: number;
  147995. sizeY?: number;
  147996. sizeZ?: number;
  147997. custom?: any;
  147998. faceUV?: Vector4[];
  147999. faceColors?: Color4[];
  148000. flat?: boolean;
  148001. updatable?: boolean;
  148002. sideOrientation?: number;
  148003. frontUVs?: Vector4;
  148004. backUVs?: Vector4;
  148005. }, scene?: Nullable<Scene>): Mesh;
  148006. /**
  148007. * Creates a decal mesh.
  148008. * 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
  148009. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148010. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148011. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148012. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148013. * @param name defines the name of the mesh
  148014. * @param sourceMesh defines the mesh where the decal must be applied
  148015. * @param options defines the options used to create the mesh
  148016. * @param scene defines the hosting scene
  148017. * @returns the decal mesh
  148018. * @see https://doc.babylonjs.com/how_to/decals
  148019. */
  148020. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148021. position?: Vector3;
  148022. normal?: Vector3;
  148023. size?: Vector3;
  148024. angle?: number;
  148025. }): Mesh;
  148026. /**
  148027. * Creates a Capsule Mesh
  148028. * @param name defines the name of the mesh.
  148029. * @param options the constructors options used to shape the mesh.
  148030. * @param scene defines the scene the mesh is scoped to.
  148031. * @returns the capsule mesh
  148032. * @see https://doc.babylonjs.com/how_to/capsule_shape
  148033. */
  148034. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  148035. }
  148036. }
  148037. declare module BABYLON {
  148038. /**
  148039. * A simplifier interface for future simplification implementations
  148040. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148041. */
  148042. export interface ISimplifier {
  148043. /**
  148044. * Simplification of a given mesh according to the given settings.
  148045. * Since this requires computation, it is assumed that the function runs async.
  148046. * @param settings The settings of the simplification, including quality and distance
  148047. * @param successCallback A callback that will be called after the mesh was simplified.
  148048. * @param errorCallback in case of an error, this callback will be called. optional.
  148049. */
  148050. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  148051. }
  148052. /**
  148053. * Expected simplification settings.
  148054. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  148055. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148056. */
  148057. export interface ISimplificationSettings {
  148058. /**
  148059. * Gets or sets the expected quality
  148060. */
  148061. quality: number;
  148062. /**
  148063. * Gets or sets the distance when this optimized version should be used
  148064. */
  148065. distance: number;
  148066. /**
  148067. * Gets an already optimized mesh
  148068. */
  148069. optimizeMesh?: boolean;
  148070. }
  148071. /**
  148072. * Class used to specify simplification options
  148073. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148074. */
  148075. export class SimplificationSettings implements ISimplificationSettings {
  148076. /** expected quality */
  148077. quality: number;
  148078. /** distance when this optimized version should be used */
  148079. distance: number;
  148080. /** already optimized mesh */
  148081. optimizeMesh?: boolean | undefined;
  148082. /**
  148083. * Creates a SimplificationSettings
  148084. * @param quality expected quality
  148085. * @param distance distance when this optimized version should be used
  148086. * @param optimizeMesh already optimized mesh
  148087. */
  148088. constructor(
  148089. /** expected quality */
  148090. quality: number,
  148091. /** distance when this optimized version should be used */
  148092. distance: number,
  148093. /** already optimized mesh */
  148094. optimizeMesh?: boolean | undefined);
  148095. }
  148096. /**
  148097. * Interface used to define a simplification task
  148098. */
  148099. export interface ISimplificationTask {
  148100. /**
  148101. * Array of settings
  148102. */
  148103. settings: Array<ISimplificationSettings>;
  148104. /**
  148105. * Simplification type
  148106. */
  148107. simplificationType: SimplificationType;
  148108. /**
  148109. * Mesh to simplify
  148110. */
  148111. mesh: Mesh;
  148112. /**
  148113. * Callback called on success
  148114. */
  148115. successCallback?: () => void;
  148116. /**
  148117. * Defines if parallel processing can be used
  148118. */
  148119. parallelProcessing: boolean;
  148120. }
  148121. /**
  148122. * Queue used to order the simplification tasks
  148123. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148124. */
  148125. export class SimplificationQueue {
  148126. private _simplificationArray;
  148127. /**
  148128. * Gets a boolean indicating that the process is still running
  148129. */
  148130. running: boolean;
  148131. /**
  148132. * Creates a new queue
  148133. */
  148134. constructor();
  148135. /**
  148136. * Adds a new simplification task
  148137. * @param task defines a task to add
  148138. */
  148139. addTask(task: ISimplificationTask): void;
  148140. /**
  148141. * Execute next task
  148142. */
  148143. executeNext(): void;
  148144. /**
  148145. * Execute a simplification task
  148146. * @param task defines the task to run
  148147. */
  148148. runSimplification(task: ISimplificationTask): void;
  148149. private getSimplifier;
  148150. }
  148151. /**
  148152. * The implemented types of simplification
  148153. * At the moment only Quadratic Error Decimation is implemented
  148154. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148155. */
  148156. export enum SimplificationType {
  148157. /** Quadratic error decimation */
  148158. QUADRATIC = 0
  148159. }
  148160. /**
  148161. * An implementation of the Quadratic Error simplification algorithm.
  148162. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148163. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148164. * @author RaananW
  148165. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148166. */
  148167. export class QuadraticErrorSimplification implements ISimplifier {
  148168. private _mesh;
  148169. private triangles;
  148170. private vertices;
  148171. private references;
  148172. private _reconstructedMesh;
  148173. /** Gets or sets the number pf sync interations */
  148174. syncIterations: number;
  148175. /** Gets or sets the aggressiveness of the simplifier */
  148176. aggressiveness: number;
  148177. /** Gets or sets the number of allowed iterations for decimation */
  148178. decimationIterations: number;
  148179. /** Gets or sets the espilon to use for bounding box computation */
  148180. boundingBoxEpsilon: number;
  148181. /**
  148182. * Creates a new QuadraticErrorSimplification
  148183. * @param _mesh defines the target mesh
  148184. */
  148185. constructor(_mesh: Mesh);
  148186. /**
  148187. * Simplification of a given mesh according to the given settings.
  148188. * Since this requires computation, it is assumed that the function runs async.
  148189. * @param settings The settings of the simplification, including quality and distance
  148190. * @param successCallback A callback that will be called after the mesh was simplified.
  148191. */
  148192. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148193. private runDecimation;
  148194. private initWithMesh;
  148195. private init;
  148196. private reconstructMesh;
  148197. private initDecimatedMesh;
  148198. private isFlipped;
  148199. private updateTriangles;
  148200. private identifyBorder;
  148201. private updateMesh;
  148202. private vertexError;
  148203. private calculateError;
  148204. }
  148205. }
  148206. declare module BABYLON {
  148207. interface Scene {
  148208. /** @hidden (Backing field) */
  148209. _simplificationQueue: SimplificationQueue;
  148210. /**
  148211. * Gets or sets the simplification queue attached to the scene
  148212. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148213. */
  148214. simplificationQueue: SimplificationQueue;
  148215. }
  148216. interface Mesh {
  148217. /**
  148218. * Simplify the mesh according to the given array of settings.
  148219. * Function will return immediately and will simplify async
  148220. * @param settings a collection of simplification settings
  148221. * @param parallelProcessing should all levels calculate parallel or one after the other
  148222. * @param simplificationType the type of simplification to run
  148223. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148224. * @returns the current mesh
  148225. */
  148226. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148227. }
  148228. /**
  148229. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148230. * created in a scene
  148231. */
  148232. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148233. /**
  148234. * The component name helpfull to identify the component in the list of scene components.
  148235. */
  148236. readonly name: string;
  148237. /**
  148238. * The scene the component belongs to.
  148239. */
  148240. scene: Scene;
  148241. /**
  148242. * Creates a new instance of the component for the given scene
  148243. * @param scene Defines the scene to register the component in
  148244. */
  148245. constructor(scene: Scene);
  148246. /**
  148247. * Registers the component in a given scene
  148248. */
  148249. register(): void;
  148250. /**
  148251. * Rebuilds the elements related to this component in case of
  148252. * context lost for instance.
  148253. */
  148254. rebuild(): void;
  148255. /**
  148256. * Disposes the component and the associated ressources
  148257. */
  148258. dispose(): void;
  148259. private _beforeCameraUpdate;
  148260. }
  148261. }
  148262. declare module BABYLON {
  148263. interface Mesh {
  148264. /**
  148265. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148266. */
  148267. thinInstanceEnablePicking: boolean;
  148268. /**
  148269. * Creates a new thin instance
  148270. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148271. * @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
  148272. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148273. */
  148274. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148275. /**
  148276. * Adds the transformation (matrix) of the current mesh as a thin instance
  148277. * @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
  148278. * @returns the thin instance index number
  148279. */
  148280. thinInstanceAddSelf(refresh: boolean): number;
  148281. /**
  148282. * Registers a custom attribute to be used with thin instances
  148283. * @param kind name of the attribute
  148284. * @param stride size in floats of the attribute
  148285. */
  148286. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148287. /**
  148288. * Sets the matrix of a thin instance
  148289. * @param index index of the thin instance
  148290. * @param matrix matrix to set
  148291. * @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
  148292. */
  148293. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148294. /**
  148295. * Sets the value of a custom attribute for a thin instance
  148296. * @param kind name of the attribute
  148297. * @param index index of the thin instance
  148298. * @param value value to set
  148299. * @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
  148300. */
  148301. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148302. /**
  148303. * 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.
  148304. */
  148305. thinInstanceCount: number;
  148306. /**
  148307. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148308. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148309. * @param buffer buffer to set
  148310. * @param stride size in floats of each value of the buffer
  148311. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148312. */
  148313. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148314. /**
  148315. * Gets the list of world matrices
  148316. * @return an array containing all the world matrices from the thin instances
  148317. */
  148318. thinInstanceGetWorldMatrices(): Matrix[];
  148319. /**
  148320. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148321. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148322. */
  148323. thinInstanceBufferUpdated(kind: string): void;
  148324. /**
  148325. * Applies a partial update to a buffer directly on the GPU
  148326. * 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
  148327. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148328. * @param data the data to set in the GPU buffer
  148329. * @param offset the offset in the GPU buffer where to update the data
  148330. */
  148331. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148332. /**
  148333. * Refreshes the bounding info, taking into account all the thin instances defined
  148334. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148335. */
  148336. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148337. /** @hidden */
  148338. _thinInstanceInitializeUserStorage(): void;
  148339. /** @hidden */
  148340. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148341. /** @hidden */
  148342. _userThinInstanceBuffersStorage: {
  148343. data: {
  148344. [key: string]: Float32Array;
  148345. };
  148346. sizes: {
  148347. [key: string]: number;
  148348. };
  148349. vertexBuffers: {
  148350. [key: string]: Nullable<VertexBuffer>;
  148351. };
  148352. strides: {
  148353. [key: string]: number;
  148354. };
  148355. };
  148356. }
  148357. }
  148358. declare module BABYLON {
  148359. /**
  148360. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148361. */
  148362. export interface INavigationEnginePlugin {
  148363. /**
  148364. * plugin name
  148365. */
  148366. name: string;
  148367. /**
  148368. * Creates a navigation mesh
  148369. * @param meshes array of all the geometry used to compute the navigatio mesh
  148370. * @param parameters bunch of parameters used to filter geometry
  148371. */
  148372. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148373. /**
  148374. * Create a navigation mesh debug mesh
  148375. * @param scene is where the mesh will be added
  148376. * @returns debug display mesh
  148377. */
  148378. createDebugNavMesh(scene: Scene): Mesh;
  148379. /**
  148380. * Get a navigation mesh constrained position, closest to the parameter position
  148381. * @param position world position
  148382. * @returns the closest point to position constrained by the navigation mesh
  148383. */
  148384. getClosestPoint(position: Vector3): Vector3;
  148385. /**
  148386. * Get a navigation mesh constrained position, closest to the parameter position
  148387. * @param position world position
  148388. * @param result output the closest point to position constrained by the navigation mesh
  148389. */
  148390. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148391. /**
  148392. * Get a navigation mesh constrained position, within a particular radius
  148393. * @param position world position
  148394. * @param maxRadius the maximum distance to the constrained world position
  148395. * @returns the closest point to position constrained by the navigation mesh
  148396. */
  148397. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148398. /**
  148399. * Get a navigation mesh constrained position, within a particular radius
  148400. * @param position world position
  148401. * @param maxRadius the maximum distance to the constrained world position
  148402. * @param result output the closest point to position constrained by the navigation mesh
  148403. */
  148404. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148405. /**
  148406. * Compute the final position from a segment made of destination-position
  148407. * @param position world position
  148408. * @param destination world position
  148409. * @returns the resulting point along the navmesh
  148410. */
  148411. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148412. /**
  148413. * Compute the final position from a segment made of destination-position
  148414. * @param position world position
  148415. * @param destination world position
  148416. * @param result output the resulting point along the navmesh
  148417. */
  148418. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148419. /**
  148420. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148421. * @param start world position
  148422. * @param end world position
  148423. * @returns array containing world position composing the path
  148424. */
  148425. computePath(start: Vector3, end: Vector3): Vector3[];
  148426. /**
  148427. * If this plugin is supported
  148428. * @returns true if plugin is supported
  148429. */
  148430. isSupported(): boolean;
  148431. /**
  148432. * Create a new Crowd so you can add agents
  148433. * @param maxAgents the maximum agent count in the crowd
  148434. * @param maxAgentRadius the maximum radius an agent can have
  148435. * @param scene to attach the crowd to
  148436. * @returns the crowd you can add agents to
  148437. */
  148438. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148439. /**
  148440. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148441. * The queries will try to find a solution within those bounds
  148442. * default is (1,1,1)
  148443. * @param extent x,y,z value that define the extent around the queries point of reference
  148444. */
  148445. setDefaultQueryExtent(extent: Vector3): void;
  148446. /**
  148447. * Get the Bounding box extent specified by setDefaultQueryExtent
  148448. * @returns the box extent values
  148449. */
  148450. getDefaultQueryExtent(): Vector3;
  148451. /**
  148452. * build the navmesh from a previously saved state using getNavmeshData
  148453. * @param data the Uint8Array returned by getNavmeshData
  148454. */
  148455. buildFromNavmeshData(data: Uint8Array): void;
  148456. /**
  148457. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148458. * @returns data the Uint8Array that can be saved and reused
  148459. */
  148460. getNavmeshData(): Uint8Array;
  148461. /**
  148462. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148463. * @param result output the box extent values
  148464. */
  148465. getDefaultQueryExtentToRef(result: Vector3): void;
  148466. /**
  148467. * Release all resources
  148468. */
  148469. dispose(): void;
  148470. }
  148471. /**
  148472. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148473. */
  148474. export interface ICrowd {
  148475. /**
  148476. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148477. * You can attach anything to that node. The node position is updated in the scene update tick.
  148478. * @param pos world position that will be constrained by the navigation mesh
  148479. * @param parameters agent parameters
  148480. * @param transform hooked to the agent that will be update by the scene
  148481. * @returns agent index
  148482. */
  148483. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148484. /**
  148485. * Returns the agent position in world space
  148486. * @param index agent index returned by addAgent
  148487. * @returns world space position
  148488. */
  148489. getAgentPosition(index: number): Vector3;
  148490. /**
  148491. * Gets the agent position result in world space
  148492. * @param index agent index returned by addAgent
  148493. * @param result output world space position
  148494. */
  148495. getAgentPositionToRef(index: number, result: Vector3): void;
  148496. /**
  148497. * Gets the agent velocity in world space
  148498. * @param index agent index returned by addAgent
  148499. * @returns world space velocity
  148500. */
  148501. getAgentVelocity(index: number): Vector3;
  148502. /**
  148503. * Gets the agent velocity result in world space
  148504. * @param index agent index returned by addAgent
  148505. * @param result output world space velocity
  148506. */
  148507. getAgentVelocityToRef(index: number, result: Vector3): void;
  148508. /**
  148509. * remove a particular agent previously created
  148510. * @param index agent index returned by addAgent
  148511. */
  148512. removeAgent(index: number): void;
  148513. /**
  148514. * get the list of all agents attached to this crowd
  148515. * @returns list of agent indices
  148516. */
  148517. getAgents(): number[];
  148518. /**
  148519. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148520. * @param deltaTime in seconds
  148521. */
  148522. update(deltaTime: number): void;
  148523. /**
  148524. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148525. * @param index agent index returned by addAgent
  148526. * @param destination targeted world position
  148527. */
  148528. agentGoto(index: number, destination: Vector3): void;
  148529. /**
  148530. * Teleport the agent to a new position
  148531. * @param index agent index returned by addAgent
  148532. * @param destination targeted world position
  148533. */
  148534. agentTeleport(index: number, destination: Vector3): void;
  148535. /**
  148536. * Update agent parameters
  148537. * @param index agent index returned by addAgent
  148538. * @param parameters agent parameters
  148539. */
  148540. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148541. /**
  148542. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148543. * The queries will try to find a solution within those bounds
  148544. * default is (1,1,1)
  148545. * @param extent x,y,z value that define the extent around the queries point of reference
  148546. */
  148547. setDefaultQueryExtent(extent: Vector3): void;
  148548. /**
  148549. * Get the Bounding box extent specified by setDefaultQueryExtent
  148550. * @returns the box extent values
  148551. */
  148552. getDefaultQueryExtent(): Vector3;
  148553. /**
  148554. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148555. * @param result output the box extent values
  148556. */
  148557. getDefaultQueryExtentToRef(result: Vector3): void;
  148558. /**
  148559. * Release all resources
  148560. */
  148561. dispose(): void;
  148562. }
  148563. /**
  148564. * Configures an agent
  148565. */
  148566. export interface IAgentParameters {
  148567. /**
  148568. * Agent radius. [Limit: >= 0]
  148569. */
  148570. radius: number;
  148571. /**
  148572. * Agent height. [Limit: > 0]
  148573. */
  148574. height: number;
  148575. /**
  148576. * Maximum allowed acceleration. [Limit: >= 0]
  148577. */
  148578. maxAcceleration: number;
  148579. /**
  148580. * Maximum allowed speed. [Limit: >= 0]
  148581. */
  148582. maxSpeed: number;
  148583. /**
  148584. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148585. */
  148586. collisionQueryRange: number;
  148587. /**
  148588. * The path visibility optimization range. [Limit: > 0]
  148589. */
  148590. pathOptimizationRange: number;
  148591. /**
  148592. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148593. */
  148594. separationWeight: number;
  148595. }
  148596. /**
  148597. * Configures the navigation mesh creation
  148598. */
  148599. export interface INavMeshParameters {
  148600. /**
  148601. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148602. */
  148603. cs: number;
  148604. /**
  148605. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148606. */
  148607. ch: number;
  148608. /**
  148609. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148610. */
  148611. walkableSlopeAngle: number;
  148612. /**
  148613. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148614. * be considered walkable. [Limit: >= 3] [Units: vx]
  148615. */
  148616. walkableHeight: number;
  148617. /**
  148618. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148619. */
  148620. walkableClimb: number;
  148621. /**
  148622. * The distance to erode/shrink the walkable area of the heightfield away from
  148623. * obstructions. [Limit: >=0] [Units: vx]
  148624. */
  148625. walkableRadius: number;
  148626. /**
  148627. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148628. */
  148629. maxEdgeLen: number;
  148630. /**
  148631. * The maximum distance a simplfied contour's border edges should deviate
  148632. * the original raw contour. [Limit: >=0] [Units: vx]
  148633. */
  148634. maxSimplificationError: number;
  148635. /**
  148636. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148637. */
  148638. minRegionArea: number;
  148639. /**
  148640. * Any regions with a span count smaller than this value will, if possible,
  148641. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148642. */
  148643. mergeRegionArea: number;
  148644. /**
  148645. * The maximum number of vertices allowed for polygons generated during the
  148646. * contour to polygon conversion process. [Limit: >= 3]
  148647. */
  148648. maxVertsPerPoly: number;
  148649. /**
  148650. * Sets the sampling distance to use when generating the detail mesh.
  148651. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148652. */
  148653. detailSampleDist: number;
  148654. /**
  148655. * The maximum distance the detail mesh surface should deviate from heightfield
  148656. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148657. */
  148658. detailSampleMaxError: number;
  148659. }
  148660. }
  148661. declare module BABYLON {
  148662. /**
  148663. * RecastJS navigation plugin
  148664. */
  148665. export class RecastJSPlugin implements INavigationEnginePlugin {
  148666. /**
  148667. * Reference to the Recast library
  148668. */
  148669. bjsRECAST: any;
  148670. /**
  148671. * plugin name
  148672. */
  148673. name: string;
  148674. /**
  148675. * the first navmesh created. We might extend this to support multiple navmeshes
  148676. */
  148677. navMesh: any;
  148678. /**
  148679. * Initializes the recastJS plugin
  148680. * @param recastInjection can be used to inject your own recast reference
  148681. */
  148682. constructor(recastInjection?: any);
  148683. /**
  148684. * Creates a navigation mesh
  148685. * @param meshes array of all the geometry used to compute the navigatio mesh
  148686. * @param parameters bunch of parameters used to filter geometry
  148687. */
  148688. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148689. /**
  148690. * Create a navigation mesh debug mesh
  148691. * @param scene is where the mesh will be added
  148692. * @returns debug display mesh
  148693. */
  148694. createDebugNavMesh(scene: Scene): Mesh;
  148695. /**
  148696. * Get a navigation mesh constrained position, closest to the parameter position
  148697. * @param position world position
  148698. * @returns the closest point to position constrained by the navigation mesh
  148699. */
  148700. getClosestPoint(position: Vector3): Vector3;
  148701. /**
  148702. * Get a navigation mesh constrained position, closest to the parameter position
  148703. * @param position world position
  148704. * @param result output the closest point to position constrained by the navigation mesh
  148705. */
  148706. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148707. /**
  148708. * Get a navigation mesh constrained position, within a particular radius
  148709. * @param position world position
  148710. * @param maxRadius the maximum distance to the constrained world position
  148711. * @returns the closest point to position constrained by the navigation mesh
  148712. */
  148713. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148714. /**
  148715. * Get a navigation mesh constrained position, within a particular radius
  148716. * @param position world position
  148717. * @param maxRadius the maximum distance to the constrained world position
  148718. * @param result output the closest point to position constrained by the navigation mesh
  148719. */
  148720. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148721. /**
  148722. * Compute the final position from a segment made of destination-position
  148723. * @param position world position
  148724. * @param destination world position
  148725. * @returns the resulting point along the navmesh
  148726. */
  148727. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148728. /**
  148729. * Compute the final position from a segment made of destination-position
  148730. * @param position world position
  148731. * @param destination world position
  148732. * @param result output the resulting point along the navmesh
  148733. */
  148734. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148735. /**
  148736. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148737. * @param start world position
  148738. * @param end world position
  148739. * @returns array containing world position composing the path
  148740. */
  148741. computePath(start: Vector3, end: Vector3): Vector3[];
  148742. /**
  148743. * Create a new Crowd so you can add agents
  148744. * @param maxAgents the maximum agent count in the crowd
  148745. * @param maxAgentRadius the maximum radius an agent can have
  148746. * @param scene to attach the crowd to
  148747. * @returns the crowd you can add agents to
  148748. */
  148749. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148750. /**
  148751. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148752. * The queries will try to find a solution within those bounds
  148753. * default is (1,1,1)
  148754. * @param extent x,y,z value that define the extent around the queries point of reference
  148755. */
  148756. setDefaultQueryExtent(extent: Vector3): void;
  148757. /**
  148758. * Get the Bounding box extent specified by setDefaultQueryExtent
  148759. * @returns the box extent values
  148760. */
  148761. getDefaultQueryExtent(): Vector3;
  148762. /**
  148763. * build the navmesh from a previously saved state using getNavmeshData
  148764. * @param data the Uint8Array returned by getNavmeshData
  148765. */
  148766. buildFromNavmeshData(data: Uint8Array): void;
  148767. /**
  148768. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148769. * @returns data the Uint8Array that can be saved and reused
  148770. */
  148771. getNavmeshData(): Uint8Array;
  148772. /**
  148773. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148774. * @param result output the box extent values
  148775. */
  148776. getDefaultQueryExtentToRef(result: Vector3): void;
  148777. /**
  148778. * Disposes
  148779. */
  148780. dispose(): void;
  148781. /**
  148782. * If this plugin is supported
  148783. * @returns true if plugin is supported
  148784. */
  148785. isSupported(): boolean;
  148786. }
  148787. /**
  148788. * Recast detour crowd implementation
  148789. */
  148790. export class RecastJSCrowd implements ICrowd {
  148791. /**
  148792. * Recast/detour plugin
  148793. */
  148794. bjsRECASTPlugin: RecastJSPlugin;
  148795. /**
  148796. * Link to the detour crowd
  148797. */
  148798. recastCrowd: any;
  148799. /**
  148800. * One transform per agent
  148801. */
  148802. transforms: TransformNode[];
  148803. /**
  148804. * All agents created
  148805. */
  148806. agents: number[];
  148807. /**
  148808. * Link to the scene is kept to unregister the crowd from the scene
  148809. */
  148810. private _scene;
  148811. /**
  148812. * Observer for crowd updates
  148813. */
  148814. private _onBeforeAnimationsObserver;
  148815. /**
  148816. * Constructor
  148817. * @param plugin recastJS plugin
  148818. * @param maxAgents the maximum agent count in the crowd
  148819. * @param maxAgentRadius the maximum radius an agent can have
  148820. * @param scene to attach the crowd to
  148821. * @returns the crowd you can add agents to
  148822. */
  148823. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148824. /**
  148825. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148826. * You can attach anything to that node. The node position is updated in the scene update tick.
  148827. * @param pos world position that will be constrained by the navigation mesh
  148828. * @param parameters agent parameters
  148829. * @param transform hooked to the agent that will be update by the scene
  148830. * @returns agent index
  148831. */
  148832. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148833. /**
  148834. * Returns the agent position in world space
  148835. * @param index agent index returned by addAgent
  148836. * @returns world space position
  148837. */
  148838. getAgentPosition(index: number): Vector3;
  148839. /**
  148840. * Returns the agent position result in world space
  148841. * @param index agent index returned by addAgent
  148842. * @param result output world space position
  148843. */
  148844. getAgentPositionToRef(index: number, result: Vector3): void;
  148845. /**
  148846. * Returns the agent velocity in world space
  148847. * @param index agent index returned by addAgent
  148848. * @returns world space velocity
  148849. */
  148850. getAgentVelocity(index: number): Vector3;
  148851. /**
  148852. * Returns the agent velocity result in world space
  148853. * @param index agent index returned by addAgent
  148854. * @param result output world space velocity
  148855. */
  148856. getAgentVelocityToRef(index: number, result: Vector3): void;
  148857. /**
  148858. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148859. * @param index agent index returned by addAgent
  148860. * @param destination targeted world position
  148861. */
  148862. agentGoto(index: number, destination: Vector3): void;
  148863. /**
  148864. * Teleport the agent to a new position
  148865. * @param index agent index returned by addAgent
  148866. * @param destination targeted world position
  148867. */
  148868. agentTeleport(index: number, destination: Vector3): void;
  148869. /**
  148870. * Update agent parameters
  148871. * @param index agent index returned by addAgent
  148872. * @param parameters agent parameters
  148873. */
  148874. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148875. /**
  148876. * remove a particular agent previously created
  148877. * @param index agent index returned by addAgent
  148878. */
  148879. removeAgent(index: number): void;
  148880. /**
  148881. * get the list of all agents attached to this crowd
  148882. * @returns list of agent indices
  148883. */
  148884. getAgents(): number[];
  148885. /**
  148886. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148887. * @param deltaTime in seconds
  148888. */
  148889. update(deltaTime: number): void;
  148890. /**
  148891. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148892. * The queries will try to find a solution within those bounds
  148893. * default is (1,1,1)
  148894. * @param extent x,y,z value that define the extent around the queries point of reference
  148895. */
  148896. setDefaultQueryExtent(extent: Vector3): void;
  148897. /**
  148898. * Get the Bounding box extent specified by setDefaultQueryExtent
  148899. * @returns the box extent values
  148900. */
  148901. getDefaultQueryExtent(): Vector3;
  148902. /**
  148903. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148904. * @param result output the box extent values
  148905. */
  148906. getDefaultQueryExtentToRef(result: Vector3): void;
  148907. /**
  148908. * Release all resources
  148909. */
  148910. dispose(): void;
  148911. }
  148912. }
  148913. declare module BABYLON {
  148914. /**
  148915. * Class used to enable access to IndexedDB
  148916. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148917. */
  148918. export class Database implements IOfflineProvider {
  148919. private _callbackManifestChecked;
  148920. private _currentSceneUrl;
  148921. private _db;
  148922. private _enableSceneOffline;
  148923. private _enableTexturesOffline;
  148924. private _manifestVersionFound;
  148925. private _mustUpdateRessources;
  148926. private _hasReachedQuota;
  148927. private _isSupported;
  148928. private _idbFactory;
  148929. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148930. private static IsUASupportingBlobStorage;
  148931. /**
  148932. * Gets a boolean indicating if Database storate is enabled (off by default)
  148933. */
  148934. static IDBStorageEnabled: boolean;
  148935. /**
  148936. * Gets a boolean indicating if scene must be saved in the database
  148937. */
  148938. get enableSceneOffline(): boolean;
  148939. /**
  148940. * Gets a boolean indicating if textures must be saved in the database
  148941. */
  148942. get enableTexturesOffline(): boolean;
  148943. /**
  148944. * Creates a new Database
  148945. * @param urlToScene defines the url to load the scene
  148946. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148947. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148948. */
  148949. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148950. private static _ParseURL;
  148951. private static _ReturnFullUrlLocation;
  148952. private _checkManifestFile;
  148953. /**
  148954. * Open the database and make it available
  148955. * @param successCallback defines the callback to call on success
  148956. * @param errorCallback defines the callback to call on error
  148957. */
  148958. open(successCallback: () => void, errorCallback: () => void): void;
  148959. /**
  148960. * Loads an image from the database
  148961. * @param url defines the url to load from
  148962. * @param image defines the target DOM image
  148963. */
  148964. loadImage(url: string, image: HTMLImageElement): void;
  148965. private _loadImageFromDBAsync;
  148966. private _saveImageIntoDBAsync;
  148967. private _checkVersionFromDB;
  148968. private _loadVersionFromDBAsync;
  148969. private _saveVersionIntoDBAsync;
  148970. /**
  148971. * Loads a file from database
  148972. * @param url defines the URL to load from
  148973. * @param sceneLoaded defines a callback to call on success
  148974. * @param progressCallBack defines a callback to call when progress changed
  148975. * @param errorCallback defines a callback to call on error
  148976. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148977. */
  148978. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148979. private _loadFileAsync;
  148980. private _saveFileAsync;
  148981. /**
  148982. * Validates if xhr data is correct
  148983. * @param xhr defines the request to validate
  148984. * @param dataType defines the expected data type
  148985. * @returns true if data is correct
  148986. */
  148987. private static _ValidateXHRData;
  148988. }
  148989. }
  148990. declare module BABYLON {
  148991. /** @hidden */
  148992. export var gpuUpdateParticlesPixelShader: {
  148993. name: string;
  148994. shader: string;
  148995. };
  148996. }
  148997. declare module BABYLON {
  148998. /** @hidden */
  148999. export var gpuUpdateParticlesVertexShader: {
  149000. name: string;
  149001. shader: string;
  149002. };
  149003. }
  149004. declare module BABYLON {
  149005. /** @hidden */
  149006. export var clipPlaneFragmentDeclaration2: {
  149007. name: string;
  149008. shader: string;
  149009. };
  149010. }
  149011. declare module BABYLON {
  149012. /** @hidden */
  149013. export var gpuRenderParticlesPixelShader: {
  149014. name: string;
  149015. shader: string;
  149016. };
  149017. }
  149018. declare module BABYLON {
  149019. /** @hidden */
  149020. export var clipPlaneVertexDeclaration2: {
  149021. name: string;
  149022. shader: string;
  149023. };
  149024. }
  149025. declare module BABYLON {
  149026. /** @hidden */
  149027. export var gpuRenderParticlesVertexShader: {
  149028. name: string;
  149029. shader: string;
  149030. };
  149031. }
  149032. declare module BABYLON {
  149033. /**
  149034. * This represents a GPU particle system in Babylon
  149035. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  149036. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  149037. */
  149038. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  149039. /**
  149040. * The layer mask we are rendering the particles through.
  149041. */
  149042. layerMask: number;
  149043. private _capacity;
  149044. private _activeCount;
  149045. private _currentActiveCount;
  149046. private _accumulatedCount;
  149047. private _renderEffect;
  149048. private _updateEffect;
  149049. private _buffer0;
  149050. private _buffer1;
  149051. private _spriteBuffer;
  149052. private _updateVAO;
  149053. private _renderVAO;
  149054. private _targetIndex;
  149055. private _sourceBuffer;
  149056. private _targetBuffer;
  149057. private _currentRenderId;
  149058. private _started;
  149059. private _stopped;
  149060. private _timeDelta;
  149061. private _randomTexture;
  149062. private _randomTexture2;
  149063. private _attributesStrideSize;
  149064. private _updateEffectOptions;
  149065. private _randomTextureSize;
  149066. private _actualFrame;
  149067. private _customEffect;
  149068. private readonly _rawTextureWidth;
  149069. /**
  149070. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  149071. */
  149072. static get IsSupported(): boolean;
  149073. /**
  149074. * An event triggered when the system is disposed.
  149075. */
  149076. onDisposeObservable: Observable<IParticleSystem>;
  149077. /**
  149078. * An event triggered when the system is stopped
  149079. */
  149080. onStoppedObservable: Observable<IParticleSystem>;
  149081. /**
  149082. * Gets the maximum number of particles active at the same time.
  149083. * @returns The max number of active particles.
  149084. */
  149085. getCapacity(): number;
  149086. /**
  149087. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149088. * to override the particles.
  149089. */
  149090. forceDepthWrite: boolean;
  149091. /**
  149092. * Gets or set the number of active particles
  149093. */
  149094. get activeParticleCount(): number;
  149095. set activeParticleCount(value: number);
  149096. private _preWarmDone;
  149097. /**
  149098. * Specifies if the particles are updated in emitter local space or world space.
  149099. */
  149100. isLocal: boolean;
  149101. /** Gets or sets a matrix to use to compute projection */
  149102. defaultProjectionMatrix: Matrix;
  149103. /**
  149104. * Is this system ready to be used/rendered
  149105. * @return true if the system is ready
  149106. */
  149107. isReady(): boolean;
  149108. /**
  149109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149110. * @returns True if it has been started, otherwise false.
  149111. */
  149112. isStarted(): boolean;
  149113. /**
  149114. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149115. * @returns True if it has been stopped, otherwise false.
  149116. */
  149117. isStopped(): boolean;
  149118. /**
  149119. * Gets a boolean indicating that the system is stopping
  149120. * @returns true if the system is currently stopping
  149121. */
  149122. isStopping(): boolean;
  149123. /**
  149124. * Gets the number of particles active at the same time.
  149125. * @returns The number of active particles.
  149126. */
  149127. getActiveCount(): number;
  149128. /**
  149129. * Starts the particle system and begins to emit
  149130. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149131. */
  149132. start(delay?: number): void;
  149133. /**
  149134. * Stops the particle system.
  149135. */
  149136. stop(): void;
  149137. /**
  149138. * Remove all active particles
  149139. */
  149140. reset(): void;
  149141. /**
  149142. * Returns the string "GPUParticleSystem"
  149143. * @returns a string containing the class name
  149144. */
  149145. getClassName(): string;
  149146. /**
  149147. * Gets the custom effect used to render the particles
  149148. * @param blendMode Blend mode for which the effect should be retrieved
  149149. * @returns The effect
  149150. */
  149151. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149152. /**
  149153. * Sets the custom effect used to render the particles
  149154. * @param effect The effect to set
  149155. * @param blendMode Blend mode for which the effect should be set
  149156. */
  149157. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149158. /** @hidden */
  149159. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149160. /**
  149161. * Observable that will be called just before the particles are drawn
  149162. */
  149163. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149164. /**
  149165. * Gets the name of the particle vertex shader
  149166. */
  149167. get vertexShaderName(): string;
  149168. private _colorGradientsTexture;
  149169. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149170. /**
  149171. * Adds a new color gradient
  149172. * @param gradient defines the gradient to use (between 0 and 1)
  149173. * @param color1 defines the color to affect to the specified gradient
  149174. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149175. * @returns the current particle system
  149176. */
  149177. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149178. private _refreshColorGradient;
  149179. /** Force the system to rebuild all gradients that need to be resync */
  149180. forceRefreshGradients(): void;
  149181. /**
  149182. * Remove a specific color gradient
  149183. * @param gradient defines the gradient to remove
  149184. * @returns the current particle system
  149185. */
  149186. removeColorGradient(gradient: number): GPUParticleSystem;
  149187. private _angularSpeedGradientsTexture;
  149188. private _sizeGradientsTexture;
  149189. private _velocityGradientsTexture;
  149190. private _limitVelocityGradientsTexture;
  149191. private _dragGradientsTexture;
  149192. private _addFactorGradient;
  149193. /**
  149194. * Adds a new size gradient
  149195. * @param gradient defines the gradient to use (between 0 and 1)
  149196. * @param factor defines the size factor to affect to the specified gradient
  149197. * @returns the current particle system
  149198. */
  149199. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149200. /**
  149201. * Remove a specific size gradient
  149202. * @param gradient defines the gradient to remove
  149203. * @returns the current particle system
  149204. */
  149205. removeSizeGradient(gradient: number): GPUParticleSystem;
  149206. private _refreshFactorGradient;
  149207. /**
  149208. * Adds a new angular speed gradient
  149209. * @param gradient defines the gradient to use (between 0 and 1)
  149210. * @param factor defines the angular speed to affect to the specified gradient
  149211. * @returns the current particle system
  149212. */
  149213. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149214. /**
  149215. * Remove a specific angular speed gradient
  149216. * @param gradient defines the gradient to remove
  149217. * @returns the current particle system
  149218. */
  149219. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149220. /**
  149221. * Adds a new velocity gradient
  149222. * @param gradient defines the gradient to use (between 0 and 1)
  149223. * @param factor defines the velocity to affect to the specified gradient
  149224. * @returns the current particle system
  149225. */
  149226. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149227. /**
  149228. * Remove a specific velocity gradient
  149229. * @param gradient defines the gradient to remove
  149230. * @returns the current particle system
  149231. */
  149232. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149233. /**
  149234. * Adds a new limit velocity gradient
  149235. * @param gradient defines the gradient to use (between 0 and 1)
  149236. * @param factor defines the limit velocity value to affect to the specified gradient
  149237. * @returns the current particle system
  149238. */
  149239. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149240. /**
  149241. * Remove a specific limit velocity gradient
  149242. * @param gradient defines the gradient to remove
  149243. * @returns the current particle system
  149244. */
  149245. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149246. /**
  149247. * Adds a new drag gradient
  149248. * @param gradient defines the gradient to use (between 0 and 1)
  149249. * @param factor defines the drag value to affect to the specified gradient
  149250. * @returns the current particle system
  149251. */
  149252. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149253. /**
  149254. * Remove a specific drag gradient
  149255. * @param gradient defines the gradient to remove
  149256. * @returns the current particle system
  149257. */
  149258. removeDragGradient(gradient: number): GPUParticleSystem;
  149259. /**
  149260. * Not supported by GPUParticleSystem
  149261. * @param gradient defines the gradient to use (between 0 and 1)
  149262. * @param factor defines the emit rate value to affect to the specified gradient
  149263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149264. * @returns the current particle system
  149265. */
  149266. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149267. /**
  149268. * Not supported by GPUParticleSystem
  149269. * @param gradient defines the gradient to remove
  149270. * @returns the current particle system
  149271. */
  149272. removeEmitRateGradient(gradient: number): IParticleSystem;
  149273. /**
  149274. * Not supported by GPUParticleSystem
  149275. * @param gradient defines the gradient to use (between 0 and 1)
  149276. * @param factor defines the start size value to affect to the specified gradient
  149277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149278. * @returns the current particle system
  149279. */
  149280. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149281. /**
  149282. * Not supported by GPUParticleSystem
  149283. * @param gradient defines the gradient to remove
  149284. * @returns the current particle system
  149285. */
  149286. removeStartSizeGradient(gradient: number): IParticleSystem;
  149287. /**
  149288. * Not supported by GPUParticleSystem
  149289. * @param gradient defines the gradient to use (between 0 and 1)
  149290. * @param min defines the color remap minimal range
  149291. * @param max defines the color remap maximal range
  149292. * @returns the current particle system
  149293. */
  149294. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149295. /**
  149296. * Not supported by GPUParticleSystem
  149297. * @param gradient defines the gradient to remove
  149298. * @returns the current particle system
  149299. */
  149300. removeColorRemapGradient(): IParticleSystem;
  149301. /**
  149302. * Not supported by GPUParticleSystem
  149303. * @param gradient defines the gradient to use (between 0 and 1)
  149304. * @param min defines the alpha remap minimal range
  149305. * @param max defines the alpha remap maximal range
  149306. * @returns the current particle system
  149307. */
  149308. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149309. /**
  149310. * Not supported by GPUParticleSystem
  149311. * @param gradient defines the gradient to remove
  149312. * @returns the current particle system
  149313. */
  149314. removeAlphaRemapGradient(): IParticleSystem;
  149315. /**
  149316. * Not supported by GPUParticleSystem
  149317. * @param gradient defines the gradient to use (between 0 and 1)
  149318. * @param color defines the color to affect to the specified gradient
  149319. * @returns the current particle system
  149320. */
  149321. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149322. /**
  149323. * Not supported by GPUParticleSystem
  149324. * @param gradient defines the gradient to remove
  149325. * @returns the current particle system
  149326. */
  149327. removeRampGradient(): IParticleSystem;
  149328. /**
  149329. * Not supported by GPUParticleSystem
  149330. * @returns the list of ramp gradients
  149331. */
  149332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149333. /**
  149334. * Not supported by GPUParticleSystem
  149335. * Gets or sets a boolean indicating that ramp gradients must be used
  149336. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149337. */
  149338. get useRampGradients(): boolean;
  149339. set useRampGradients(value: boolean);
  149340. /**
  149341. * Not supported by GPUParticleSystem
  149342. * @param gradient defines the gradient to use (between 0 and 1)
  149343. * @param factor defines the life time factor to affect to the specified gradient
  149344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149345. * @returns the current particle system
  149346. */
  149347. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149348. /**
  149349. * Not supported by GPUParticleSystem
  149350. * @param gradient defines the gradient to remove
  149351. * @returns the current particle system
  149352. */
  149353. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149354. /**
  149355. * Instantiates a GPU particle system.
  149356. * 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.
  149357. * @param name The name of the particle system
  149358. * @param options The options used to create the system
  149359. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  149360. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  149361. * @param customEffect a custom effect used to change the way particles are rendered by default
  149362. */
  149363. constructor(name: string, options: Partial<{
  149364. capacity: number;
  149365. randomTextureSize: number;
  149366. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149367. protected _reset(): void;
  149368. private _createUpdateVAO;
  149369. private _createRenderVAO;
  149370. private _initialize;
  149371. /** @hidden */
  149372. _recreateUpdateEffect(): void;
  149373. private _getEffect;
  149374. /**
  149375. * Fill the defines array according to the current settings of the particle system
  149376. * @param defines Array to be updated
  149377. * @param blendMode blend mode to take into account when updating the array
  149378. */
  149379. fillDefines(defines: Array<string>, blendMode?: number): void;
  149380. /**
  149381. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149382. * @param uniforms Uniforms array to fill
  149383. * @param attributes Attributes array to fill
  149384. * @param samplers Samplers array to fill
  149385. */
  149386. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149387. /** @hidden */
  149388. _recreateRenderEffect(): Effect;
  149389. /**
  149390. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149391. * @param preWarm defines if we are in the pre-warmimg phase
  149392. */
  149393. animate(preWarm?: boolean): void;
  149394. private _createFactorGradientTexture;
  149395. private _createSizeGradientTexture;
  149396. private _createAngularSpeedGradientTexture;
  149397. private _createVelocityGradientTexture;
  149398. private _createLimitVelocityGradientTexture;
  149399. private _createDragGradientTexture;
  149400. private _createColorGradientTexture;
  149401. /**
  149402. * Renders the particle system in its current state
  149403. * @param preWarm defines if the system should only update the particles but not render them
  149404. * @returns the current number of particles
  149405. */
  149406. render(preWarm?: boolean): number;
  149407. /**
  149408. * Rebuilds the particle system
  149409. */
  149410. rebuild(): void;
  149411. private _releaseBuffers;
  149412. private _releaseVAOs;
  149413. /**
  149414. * Disposes the particle system and free the associated resources
  149415. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149416. */
  149417. dispose(disposeTexture?: boolean): void;
  149418. /**
  149419. * Clones the particle system.
  149420. * @param name The name of the cloned object
  149421. * @param newEmitter The new emitter to use
  149422. * @returns the cloned particle system
  149423. */
  149424. clone(name: string, newEmitter: any): GPUParticleSystem;
  149425. /**
  149426. * Serializes the particle system to a JSON object
  149427. * @param serializeTexture defines if the texture must be serialized as well
  149428. * @returns the JSON object
  149429. */
  149430. serialize(serializeTexture?: boolean): any;
  149431. /**
  149432. * Parses a JSON object to create a GPU particle system.
  149433. * @param parsedParticleSystem The JSON object to parse
  149434. * @param sceneOrEngine The scene or the engine to create the particle system in
  149435. * @param rootUrl The root url to use to load external dependencies like texture
  149436. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149437. * @returns the parsed GPU particle system
  149438. */
  149439. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149440. }
  149441. }
  149442. declare module BABYLON {
  149443. /**
  149444. * Represents a set of particle systems working together to create a specific effect
  149445. */
  149446. export class ParticleSystemSet implements IDisposable {
  149447. /**
  149448. * Gets or sets base Assets URL
  149449. */
  149450. static BaseAssetsUrl: string;
  149451. private _emitterCreationOptions;
  149452. private _emitterNode;
  149453. /**
  149454. * Gets the particle system list
  149455. */
  149456. systems: IParticleSystem[];
  149457. /**
  149458. * Gets the emitter node used with this set
  149459. */
  149460. get emitterNode(): Nullable<TransformNode>;
  149461. /**
  149462. * Creates a new emitter mesh as a sphere
  149463. * @param options defines the options used to create the sphere
  149464. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149465. * @param scene defines the hosting scene
  149466. */
  149467. setEmitterAsSphere(options: {
  149468. diameter: number;
  149469. segments: number;
  149470. color: Color3;
  149471. }, renderingGroupId: number, scene: Scene): void;
  149472. /**
  149473. * Starts all particle systems of the set
  149474. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149475. */
  149476. start(emitter?: AbstractMesh): void;
  149477. /**
  149478. * Release all associated resources
  149479. */
  149480. dispose(): void;
  149481. /**
  149482. * Serialize the set into a JSON compatible object
  149483. * @param serializeTexture defines if the texture must be serialized as well
  149484. * @returns a JSON compatible representation of the set
  149485. */
  149486. serialize(serializeTexture?: boolean): any;
  149487. /**
  149488. * Parse a new ParticleSystemSet from a serialized source
  149489. * @param data defines a JSON compatible representation of the set
  149490. * @param scene defines the hosting scene
  149491. * @param gpu defines if we want GPU particles or CPU particles
  149492. * @returns a new ParticleSystemSet
  149493. */
  149494. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149495. }
  149496. }
  149497. declare module BABYLON {
  149498. /**
  149499. * This class is made for on one-liner static method to help creating particle system set.
  149500. */
  149501. export class ParticleHelper {
  149502. /**
  149503. * Gets or sets base Assets URL
  149504. */
  149505. static BaseAssetsUrl: string;
  149506. /** Define the Url to load snippets */
  149507. static SnippetUrl: string;
  149508. /**
  149509. * Create a default particle system that you can tweak
  149510. * @param emitter defines the emitter to use
  149511. * @param capacity defines the system capacity (default is 500 particles)
  149512. * @param scene defines the hosting scene
  149513. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149514. * @returns the new Particle system
  149515. */
  149516. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149517. /**
  149518. * This is the main static method (one-liner) of this helper to create different particle systems
  149519. * @param type This string represents the type to the particle system to create
  149520. * @param scene The scene where the particle system should live
  149521. * @param gpu If the system will use gpu
  149522. * @returns the ParticleSystemSet created
  149523. */
  149524. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149525. /**
  149526. * Static function used to export a particle system to a ParticleSystemSet variable.
  149527. * Please note that the emitter shape is not exported
  149528. * @param systems defines the particle systems to export
  149529. * @returns the created particle system set
  149530. */
  149531. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149532. /**
  149533. * Creates a particle system from a snippet saved in a remote file
  149534. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149535. * @param url defines the url to load from
  149536. * @param scene defines the hosting scene
  149537. * @param gpu If the system will use gpu
  149538. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149539. * @returns a promise that will resolve to the new particle system
  149540. */
  149541. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149542. /**
  149543. * Creates a particle system from a snippet saved by the particle system editor
  149544. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149545. * @param scene defines the hosting scene
  149546. * @param gpu If the system will use gpu
  149547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149548. * @returns a promise that will resolve to the new particle system
  149549. */
  149550. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149551. }
  149552. }
  149553. declare module BABYLON {
  149554. interface Engine {
  149555. /**
  149556. * Create an effect to use with particle systems.
  149557. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149558. * the particle system for which you want to create a custom effect in the last parameter
  149559. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149560. * @param uniformsNames defines a list of attribute names
  149561. * @param samplers defines an array of string used to represent textures
  149562. * @param defines defines the string containing the defines to use to compile the shaders
  149563. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149564. * @param onCompiled defines a function to call when the effect creation is successful
  149565. * @param onError defines a function to call when the effect creation has failed
  149566. * @param particleSystem the particle system you want to create the effect for
  149567. * @returns the new Effect
  149568. */
  149569. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149570. }
  149571. interface Mesh {
  149572. /**
  149573. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149574. * @returns an array of IParticleSystem
  149575. */
  149576. getEmittedParticleSystems(): IParticleSystem[];
  149577. /**
  149578. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149579. * @returns an array of IParticleSystem
  149580. */
  149581. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149582. }
  149583. }
  149584. declare module BABYLON {
  149585. /** Defines the 4 color options */
  149586. export enum PointColor {
  149587. /** color value */
  149588. Color = 2,
  149589. /** uv value */
  149590. UV = 1,
  149591. /** random value */
  149592. Random = 0,
  149593. /** stated value */
  149594. Stated = 3
  149595. }
  149596. /**
  149597. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149598. * 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.
  149599. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149600. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149601. *
  149602. * Full documentation here : TO BE ENTERED
  149603. */
  149604. export class PointsCloudSystem implements IDisposable {
  149605. /**
  149606. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149607. * Example : var p = SPS.particles[i];
  149608. */
  149609. particles: CloudPoint[];
  149610. /**
  149611. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149612. */
  149613. nbParticles: number;
  149614. /**
  149615. * This a counter for your own usage. It's not set by any SPS functions.
  149616. */
  149617. counter: number;
  149618. /**
  149619. * The PCS name. This name is also given to the underlying mesh.
  149620. */
  149621. name: string;
  149622. /**
  149623. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149624. */
  149625. mesh: Mesh;
  149626. /**
  149627. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149628. * Please read :
  149629. */
  149630. vars: any;
  149631. /**
  149632. * @hidden
  149633. */
  149634. _size: number;
  149635. private _scene;
  149636. private _promises;
  149637. private _positions;
  149638. private _indices;
  149639. private _normals;
  149640. private _colors;
  149641. private _uvs;
  149642. private _indices32;
  149643. private _positions32;
  149644. private _colors32;
  149645. private _uvs32;
  149646. private _updatable;
  149647. private _isVisibilityBoxLocked;
  149648. private _alwaysVisible;
  149649. private _groups;
  149650. private _groupCounter;
  149651. private _computeParticleColor;
  149652. private _computeParticleTexture;
  149653. private _computeParticleRotation;
  149654. private _computeBoundingBox;
  149655. private _isReady;
  149656. /**
  149657. * Creates a PCS (Points Cloud System) object
  149658. * @param name (String) is the PCS name, this will be the underlying mesh name
  149659. * @param pointSize (number) is the size for each point
  149660. * @param scene (Scene) is the scene in which the PCS is added
  149661. * @param options defines the options of the PCS e.g.
  149662. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149663. */
  149664. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149665. updatable?: boolean;
  149666. });
  149667. /**
  149668. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149669. * If no points were added to the PCS, the returned mesh is just a single point.
  149670. * @returns a promise for the created mesh
  149671. */
  149672. buildMeshAsync(): Promise<Mesh>;
  149673. /**
  149674. * @hidden
  149675. */
  149676. private _buildMesh;
  149677. private _addParticle;
  149678. private _randomUnitVector;
  149679. private _getColorIndicesForCoord;
  149680. private _setPointsColorOrUV;
  149681. private _colorFromTexture;
  149682. private _calculateDensity;
  149683. /**
  149684. * Adds points to the PCS in random positions within a unit sphere
  149685. * @param nb (positive integer) the number of particles to be created from this model
  149686. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149687. * @returns the number of groups in the system
  149688. */
  149689. addPoints(nb: number, pointFunction?: any): number;
  149690. /**
  149691. * Adds points to the PCS from the surface of the model shape
  149692. * @param mesh is any Mesh object that will be used as a surface model for the points
  149693. * @param nb (positive integer) the number of particles to be created from this model
  149694. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149695. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149696. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149697. * @returns the number of groups in the system
  149698. */
  149699. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149700. /**
  149701. * Adds points to the PCS inside the model shape
  149702. * @param mesh is any Mesh object that will be used as a surface model for the points
  149703. * @param nb (positive integer) the number of particles to be created from this model
  149704. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149705. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149706. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149707. * @returns the number of groups in the system
  149708. */
  149709. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149710. /**
  149711. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149712. * This method calls `updateParticle()` for each particle of the SPS.
  149713. * For an animated SPS, it is usually called within the render loop.
  149714. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149715. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149716. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149717. * @returns the PCS.
  149718. */
  149719. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149720. /**
  149721. * Disposes the PCS.
  149722. */
  149723. dispose(): void;
  149724. /**
  149725. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149726. * doc :
  149727. * @returns the PCS.
  149728. */
  149729. refreshVisibleSize(): PointsCloudSystem;
  149730. /**
  149731. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149732. * @param size the size (float) of the visibility box
  149733. * note : this doesn't lock the PCS mesh bounding box.
  149734. * doc :
  149735. */
  149736. setVisibilityBox(size: number): void;
  149737. /**
  149738. * Gets whether the PCS is always visible or not
  149739. * doc :
  149740. */
  149741. get isAlwaysVisible(): boolean;
  149742. /**
  149743. * Sets the PCS as always visible or not
  149744. * doc :
  149745. */
  149746. set isAlwaysVisible(val: boolean);
  149747. /**
  149748. * Tells to `setParticles()` to compute the particle rotations or not
  149749. * Default value : false. The PCS is faster when it's set to false
  149750. * Note : particle rotations are only applied to parent particles
  149751. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149752. */
  149753. set computeParticleRotation(val: boolean);
  149754. /**
  149755. * Tells to `setParticles()` to compute the particle colors or not.
  149756. * Default value : true. The PCS is faster when it's set to false.
  149757. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149758. */
  149759. set computeParticleColor(val: boolean);
  149760. set computeParticleTexture(val: boolean);
  149761. /**
  149762. * Gets if `setParticles()` computes the particle colors or not.
  149763. * Default value : false. The PCS is faster when it's set to false.
  149764. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149765. */
  149766. get computeParticleColor(): boolean;
  149767. /**
  149768. * Gets if `setParticles()` computes the particle textures or not.
  149769. * Default value : false. The PCS is faster when it's set to false.
  149770. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149771. */
  149772. get computeParticleTexture(): boolean;
  149773. /**
  149774. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149775. */
  149776. set computeBoundingBox(val: boolean);
  149777. /**
  149778. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149779. */
  149780. get computeBoundingBox(): boolean;
  149781. /**
  149782. * This function does nothing. It may be overwritten to set all the particle first values.
  149783. * The PCS doesn't call this function, you may have to call it by your own.
  149784. * doc :
  149785. */
  149786. initParticles(): void;
  149787. /**
  149788. * This function does nothing. It may be overwritten to recycle a particle
  149789. * The PCS doesn't call this function, you can to call it
  149790. * doc :
  149791. * @param particle The particle to recycle
  149792. * @returns the recycled particle
  149793. */
  149794. recycleParticle(particle: CloudPoint): CloudPoint;
  149795. /**
  149796. * Updates a particle : this function should be overwritten by the user.
  149797. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149798. * doc :
  149799. * @example : just set a particle position or velocity and recycle conditions
  149800. * @param particle The particle to update
  149801. * @returns the updated particle
  149802. */
  149803. updateParticle(particle: CloudPoint): CloudPoint;
  149804. /**
  149805. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149806. * This does nothing and may be overwritten by the user.
  149807. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149808. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149809. * @param update the boolean update value actually passed to setParticles()
  149810. */
  149811. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149812. /**
  149813. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149814. * This will be passed three parameters.
  149815. * This does nothing and may be overwritten by the user.
  149816. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149817. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149818. * @param update the boolean update value actually passed to setParticles()
  149819. */
  149820. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149821. }
  149822. }
  149823. declare module BABYLON {
  149824. /**
  149825. * Represents one particle of a points cloud system.
  149826. */
  149827. export class CloudPoint {
  149828. /**
  149829. * particle global index
  149830. */
  149831. idx: number;
  149832. /**
  149833. * The color of the particle
  149834. */
  149835. color: Nullable<Color4>;
  149836. /**
  149837. * The world space position of the particle.
  149838. */
  149839. position: Vector3;
  149840. /**
  149841. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149842. */
  149843. rotation: Vector3;
  149844. /**
  149845. * The world space rotation quaternion of the particle.
  149846. */
  149847. rotationQuaternion: Nullable<Quaternion>;
  149848. /**
  149849. * The uv of the particle.
  149850. */
  149851. uv: Nullable<Vector2>;
  149852. /**
  149853. * The current speed of the particle.
  149854. */
  149855. velocity: Vector3;
  149856. /**
  149857. * The pivot point in the particle local space.
  149858. */
  149859. pivot: Vector3;
  149860. /**
  149861. * Must the particle be translated from its pivot point in its local space ?
  149862. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149863. * Default : false
  149864. */
  149865. translateFromPivot: boolean;
  149866. /**
  149867. * Index of this particle in the global "positions" array (Internal use)
  149868. * @hidden
  149869. */
  149870. _pos: number;
  149871. /**
  149872. * @hidden Index of this particle in the global "indices" array (Internal use)
  149873. */
  149874. _ind: number;
  149875. /**
  149876. * Group this particle belongs to
  149877. */
  149878. _group: PointsGroup;
  149879. /**
  149880. * Group id of this particle
  149881. */
  149882. groupId: number;
  149883. /**
  149884. * Index of the particle in its group id (Internal use)
  149885. */
  149886. idxInGroup: number;
  149887. /**
  149888. * @hidden Particle BoundingInfo object (Internal use)
  149889. */
  149890. _boundingInfo: BoundingInfo;
  149891. /**
  149892. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149893. */
  149894. _pcs: PointsCloudSystem;
  149895. /**
  149896. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149897. */
  149898. _stillInvisible: boolean;
  149899. /**
  149900. * @hidden Last computed particle rotation matrix
  149901. */
  149902. _rotationMatrix: number[];
  149903. /**
  149904. * Parent particle Id, if any.
  149905. * Default null.
  149906. */
  149907. parentId: Nullable<number>;
  149908. /**
  149909. * @hidden Internal global position in the PCS.
  149910. */
  149911. _globalPosition: Vector3;
  149912. /**
  149913. * Creates a Point Cloud object.
  149914. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149915. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149916. * @param group (PointsGroup) is the group the particle belongs to
  149917. * @param groupId (integer) is the group identifier in the PCS.
  149918. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149919. * @param pcs defines the PCS it is associated to
  149920. */
  149921. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149922. /**
  149923. * get point size
  149924. */
  149925. get size(): Vector3;
  149926. /**
  149927. * Set point size
  149928. */
  149929. set size(scale: Vector3);
  149930. /**
  149931. * Legacy support, changed quaternion to rotationQuaternion
  149932. */
  149933. get quaternion(): Nullable<Quaternion>;
  149934. /**
  149935. * Legacy support, changed quaternion to rotationQuaternion
  149936. */
  149937. set quaternion(q: Nullable<Quaternion>);
  149938. /**
  149939. * Returns a boolean. True if the particle intersects a mesh, else false
  149940. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149941. * @param target is the object (point or mesh) what the intersection is computed against
  149942. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149943. * @returns true if it intersects
  149944. */
  149945. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149946. /**
  149947. * get the rotation matrix of the particle
  149948. * @hidden
  149949. */
  149950. getRotationMatrix(m: Matrix): void;
  149951. }
  149952. /**
  149953. * Represents a group of points in a points cloud system
  149954. * * PCS internal tool, don't use it manually.
  149955. */
  149956. export class PointsGroup {
  149957. /**
  149958. * The group id
  149959. * @hidden
  149960. */
  149961. groupID: number;
  149962. /**
  149963. * image data for group (internal use)
  149964. * @hidden
  149965. */
  149966. _groupImageData: Nullable<ArrayBufferView>;
  149967. /**
  149968. * Image Width (internal use)
  149969. * @hidden
  149970. */
  149971. _groupImgWidth: number;
  149972. /**
  149973. * Image Height (internal use)
  149974. * @hidden
  149975. */
  149976. _groupImgHeight: number;
  149977. /**
  149978. * Custom position function (internal use)
  149979. * @hidden
  149980. */
  149981. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149982. /**
  149983. * density per facet for surface points
  149984. * @hidden
  149985. */
  149986. _groupDensity: number[];
  149987. /**
  149988. * Only when points are colored by texture carries pointer to texture list array
  149989. * @hidden
  149990. */
  149991. _textureNb: number;
  149992. /**
  149993. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149994. * PCS internal tool, don't use it manually.
  149995. * @hidden
  149996. */
  149997. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149998. }
  149999. }
  150000. declare module BABYLON {
  150001. interface Scene {
  150002. /** @hidden (Backing field) */
  150003. _physicsEngine: Nullable<IPhysicsEngine>;
  150004. /** @hidden */
  150005. _physicsTimeAccumulator: number;
  150006. /**
  150007. * Gets the current physics engine
  150008. * @returns a IPhysicsEngine or null if none attached
  150009. */
  150010. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  150011. /**
  150012. * Enables physics to the current scene
  150013. * @param gravity defines the scene's gravity for the physics engine
  150014. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  150015. * @return a boolean indicating if the physics engine was initialized
  150016. */
  150017. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  150018. /**
  150019. * Disables and disposes the physics engine associated with the scene
  150020. */
  150021. disablePhysicsEngine(): void;
  150022. /**
  150023. * Gets a boolean indicating if there is an active physics engine
  150024. * @returns a boolean indicating if there is an active physics engine
  150025. */
  150026. isPhysicsEnabled(): boolean;
  150027. /**
  150028. * Deletes a physics compound impostor
  150029. * @param compound defines the compound to delete
  150030. */
  150031. deleteCompoundImpostor(compound: any): void;
  150032. /**
  150033. * An event triggered when physic simulation is about to be run
  150034. */
  150035. onBeforePhysicsObservable: Observable<Scene>;
  150036. /**
  150037. * An event triggered when physic simulation has been done
  150038. */
  150039. onAfterPhysicsObservable: Observable<Scene>;
  150040. }
  150041. interface AbstractMesh {
  150042. /** @hidden */
  150043. _physicsImpostor: Nullable<PhysicsImpostor>;
  150044. /**
  150045. * Gets or sets impostor used for physic simulation
  150046. * @see https://doc.babylonjs.com/features/physics_engine
  150047. */
  150048. physicsImpostor: Nullable<PhysicsImpostor>;
  150049. /**
  150050. * Gets the current physics impostor
  150051. * @see https://doc.babylonjs.com/features/physics_engine
  150052. * @returns a physics impostor or null
  150053. */
  150054. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  150055. /** Apply a physic impulse to the mesh
  150056. * @param force defines the force to apply
  150057. * @param contactPoint defines where to apply the force
  150058. * @returns the current mesh
  150059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150060. */
  150061. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  150062. /**
  150063. * Creates a physic joint between two meshes
  150064. * @param otherMesh defines the other mesh to use
  150065. * @param pivot1 defines the pivot to use on this mesh
  150066. * @param pivot2 defines the pivot to use on the other mesh
  150067. * @param options defines additional options (can be plugin dependent)
  150068. * @returns the current mesh
  150069. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  150070. */
  150071. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  150072. /** @hidden */
  150073. _disposePhysicsObserver: Nullable<Observer<Node>>;
  150074. }
  150075. /**
  150076. * Defines the physics engine scene component responsible to manage a physics engine
  150077. */
  150078. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150079. /**
  150080. * The component name helpful to identify the component in the list of scene components.
  150081. */
  150082. readonly name: string;
  150083. /**
  150084. * The scene the component belongs to.
  150085. */
  150086. scene: Scene;
  150087. /**
  150088. * Creates a new instance of the component for the given scene
  150089. * @param scene Defines the scene to register the component in
  150090. */
  150091. constructor(scene: Scene);
  150092. /**
  150093. * Registers the component in a given scene
  150094. */
  150095. register(): void;
  150096. /**
  150097. * Rebuilds the elements related to this component in case of
  150098. * context lost for instance.
  150099. */
  150100. rebuild(): void;
  150101. /**
  150102. * Disposes the component and the associated ressources
  150103. */
  150104. dispose(): void;
  150105. }
  150106. }
  150107. declare module BABYLON {
  150108. /**
  150109. * A helper for physics simulations
  150110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150111. */
  150112. export class PhysicsHelper {
  150113. private _scene;
  150114. private _physicsEngine;
  150115. /**
  150116. * Initializes the Physics helper
  150117. * @param scene Babylon.js scene
  150118. */
  150119. constructor(scene: Scene);
  150120. /**
  150121. * Applies a radial explosion impulse
  150122. * @param origin the origin of the explosion
  150123. * @param radiusOrEventOptions the radius or the options of radial explosion
  150124. * @param strength the explosion strength
  150125. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150126. * @returns A physics radial explosion event, or null
  150127. */
  150128. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150129. /**
  150130. * Applies a radial explosion force
  150131. * @param origin the origin of the explosion
  150132. * @param radiusOrEventOptions the radius or the options of radial explosion
  150133. * @param strength the explosion strength
  150134. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150135. * @returns A physics radial explosion event, or null
  150136. */
  150137. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150138. /**
  150139. * Creates a gravitational field
  150140. * @param origin the origin of the explosion
  150141. * @param radiusOrEventOptions the radius or the options of radial explosion
  150142. * @param strength the explosion strength
  150143. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150144. * @returns A physics gravitational field event, or null
  150145. */
  150146. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150147. /**
  150148. * Creates a physics updraft event
  150149. * @param origin the origin of the updraft
  150150. * @param radiusOrEventOptions the radius or the options of the updraft
  150151. * @param strength the strength of the updraft
  150152. * @param height the height of the updraft
  150153. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150154. * @returns A physics updraft event, or null
  150155. */
  150156. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150157. /**
  150158. * Creates a physics vortex event
  150159. * @param origin the of the vortex
  150160. * @param radiusOrEventOptions the radius or the options of the vortex
  150161. * @param strength the strength of the vortex
  150162. * @param height the height of the vortex
  150163. * @returns a Physics vortex event, or null
  150164. * A physics vortex event or null
  150165. */
  150166. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150167. }
  150168. /**
  150169. * Represents a physics radial explosion event
  150170. */
  150171. class PhysicsRadialExplosionEvent {
  150172. private _scene;
  150173. private _options;
  150174. private _sphere;
  150175. private _dataFetched;
  150176. /**
  150177. * Initializes a radial explosioin event
  150178. * @param _scene BabylonJS scene
  150179. * @param _options The options for the vortex event
  150180. */
  150181. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150182. /**
  150183. * Returns the data related to the radial explosion event (sphere).
  150184. * @returns The radial explosion event data
  150185. */
  150186. getData(): PhysicsRadialExplosionEventData;
  150187. /**
  150188. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150189. * @param impostor A physics imposter
  150190. * @param origin the origin of the explosion
  150191. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150192. */
  150193. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150194. /**
  150195. * Triggers affecterd impostors callbacks
  150196. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150197. */
  150198. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150199. /**
  150200. * Disposes the sphere.
  150201. * @param force Specifies if the sphere should be disposed by force
  150202. */
  150203. dispose(force?: boolean): void;
  150204. /*** Helpers ***/
  150205. private _prepareSphere;
  150206. private _intersectsWithSphere;
  150207. }
  150208. /**
  150209. * Represents a gravitational field event
  150210. */
  150211. class PhysicsGravitationalFieldEvent {
  150212. private _physicsHelper;
  150213. private _scene;
  150214. private _origin;
  150215. private _options;
  150216. private _tickCallback;
  150217. private _sphere;
  150218. private _dataFetched;
  150219. /**
  150220. * Initializes the physics gravitational field event
  150221. * @param _physicsHelper A physics helper
  150222. * @param _scene BabylonJS scene
  150223. * @param _origin The origin position of the gravitational field event
  150224. * @param _options The options for the vortex event
  150225. */
  150226. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150227. /**
  150228. * Returns the data related to the gravitational field event (sphere).
  150229. * @returns A gravitational field event
  150230. */
  150231. getData(): PhysicsGravitationalFieldEventData;
  150232. /**
  150233. * Enables the gravitational field.
  150234. */
  150235. enable(): void;
  150236. /**
  150237. * Disables the gravitational field.
  150238. */
  150239. disable(): void;
  150240. /**
  150241. * Disposes the sphere.
  150242. * @param force The force to dispose from the gravitational field event
  150243. */
  150244. dispose(force?: boolean): void;
  150245. private _tick;
  150246. }
  150247. /**
  150248. * Represents a physics updraft event
  150249. */
  150250. class PhysicsUpdraftEvent {
  150251. private _scene;
  150252. private _origin;
  150253. private _options;
  150254. private _physicsEngine;
  150255. private _originTop;
  150256. private _originDirection;
  150257. private _tickCallback;
  150258. private _cylinder;
  150259. private _cylinderPosition;
  150260. private _dataFetched;
  150261. /**
  150262. * Initializes the physics updraft event
  150263. * @param _scene BabylonJS scene
  150264. * @param _origin The origin position of the updraft
  150265. * @param _options The options for the updraft event
  150266. */
  150267. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150268. /**
  150269. * Returns the data related to the updraft event (cylinder).
  150270. * @returns A physics updraft event
  150271. */
  150272. getData(): PhysicsUpdraftEventData;
  150273. /**
  150274. * Enables the updraft.
  150275. */
  150276. enable(): void;
  150277. /**
  150278. * Disables the updraft.
  150279. */
  150280. disable(): void;
  150281. /**
  150282. * Disposes the cylinder.
  150283. * @param force Specifies if the updraft should be disposed by force
  150284. */
  150285. dispose(force?: boolean): void;
  150286. private getImpostorHitData;
  150287. private _tick;
  150288. /*** Helpers ***/
  150289. private _prepareCylinder;
  150290. private _intersectsWithCylinder;
  150291. }
  150292. /**
  150293. * Represents a physics vortex event
  150294. */
  150295. class PhysicsVortexEvent {
  150296. private _scene;
  150297. private _origin;
  150298. private _options;
  150299. private _physicsEngine;
  150300. private _originTop;
  150301. private _tickCallback;
  150302. private _cylinder;
  150303. private _cylinderPosition;
  150304. private _dataFetched;
  150305. /**
  150306. * Initializes the physics vortex event
  150307. * @param _scene The BabylonJS scene
  150308. * @param _origin The origin position of the vortex
  150309. * @param _options The options for the vortex event
  150310. */
  150311. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150312. /**
  150313. * Returns the data related to the vortex event (cylinder).
  150314. * @returns The physics vortex event data
  150315. */
  150316. getData(): PhysicsVortexEventData;
  150317. /**
  150318. * Enables the vortex.
  150319. */
  150320. enable(): void;
  150321. /**
  150322. * Disables the cortex.
  150323. */
  150324. disable(): void;
  150325. /**
  150326. * Disposes the sphere.
  150327. * @param force
  150328. */
  150329. dispose(force?: boolean): void;
  150330. private getImpostorHitData;
  150331. private _tick;
  150332. /*** Helpers ***/
  150333. private _prepareCylinder;
  150334. private _intersectsWithCylinder;
  150335. }
  150336. /**
  150337. * Options fot the radial explosion event
  150338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150339. */
  150340. export class PhysicsRadialExplosionEventOptions {
  150341. /**
  150342. * The radius of the sphere for the radial explosion.
  150343. */
  150344. radius: number;
  150345. /**
  150346. * The strenth of the explosion.
  150347. */
  150348. strength: number;
  150349. /**
  150350. * The strenght of the force in correspondence to the distance of the affected object
  150351. */
  150352. falloff: PhysicsRadialImpulseFalloff;
  150353. /**
  150354. * Sphere options for the radial explosion.
  150355. */
  150356. sphere: {
  150357. segments: number;
  150358. diameter: number;
  150359. };
  150360. /**
  150361. * Sphere options for the radial explosion.
  150362. */
  150363. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150364. }
  150365. /**
  150366. * Options fot the updraft event
  150367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150368. */
  150369. export class PhysicsUpdraftEventOptions {
  150370. /**
  150371. * The radius of the cylinder for the vortex
  150372. */
  150373. radius: number;
  150374. /**
  150375. * The strenth of the updraft.
  150376. */
  150377. strength: number;
  150378. /**
  150379. * The height of the cylinder for the updraft.
  150380. */
  150381. height: number;
  150382. /**
  150383. * The mode for the the updraft.
  150384. */
  150385. updraftMode: PhysicsUpdraftMode;
  150386. }
  150387. /**
  150388. * Options fot the vortex event
  150389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150390. */
  150391. export class PhysicsVortexEventOptions {
  150392. /**
  150393. * The radius of the cylinder for the vortex
  150394. */
  150395. radius: number;
  150396. /**
  150397. * The strenth of the vortex.
  150398. */
  150399. strength: number;
  150400. /**
  150401. * The height of the cylinder for the vortex.
  150402. */
  150403. height: number;
  150404. /**
  150405. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150406. */
  150407. centripetalForceThreshold: number;
  150408. /**
  150409. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150410. */
  150411. centripetalForceMultiplier: number;
  150412. /**
  150413. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150414. */
  150415. centrifugalForceMultiplier: number;
  150416. /**
  150417. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150418. */
  150419. updraftForceMultiplier: number;
  150420. }
  150421. /**
  150422. * The strenght of the force in correspondence to the distance of the affected object
  150423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150424. */
  150425. export enum PhysicsRadialImpulseFalloff {
  150426. /** Defines that impulse is constant in strength across it's whole radius */
  150427. Constant = 0,
  150428. /** Defines that impulse gets weaker if it's further from the origin */
  150429. Linear = 1
  150430. }
  150431. /**
  150432. * The strength of the force in correspondence to the distance of the affected object
  150433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150434. */
  150435. export enum PhysicsUpdraftMode {
  150436. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150437. Center = 0,
  150438. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150439. Perpendicular = 1
  150440. }
  150441. /**
  150442. * Interface for a physics hit data
  150443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150444. */
  150445. export interface PhysicsHitData {
  150446. /**
  150447. * The force applied at the contact point
  150448. */
  150449. force: Vector3;
  150450. /**
  150451. * The contact point
  150452. */
  150453. contactPoint: Vector3;
  150454. /**
  150455. * The distance from the origin to the contact point
  150456. */
  150457. distanceFromOrigin: number;
  150458. }
  150459. /**
  150460. * Interface for radial explosion event data
  150461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150462. */
  150463. export interface PhysicsRadialExplosionEventData {
  150464. /**
  150465. * A sphere used for the radial explosion event
  150466. */
  150467. sphere: Mesh;
  150468. }
  150469. /**
  150470. * Interface for gravitational field event data
  150471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150472. */
  150473. export interface PhysicsGravitationalFieldEventData {
  150474. /**
  150475. * A sphere mesh used for the gravitational field event
  150476. */
  150477. sphere: Mesh;
  150478. }
  150479. /**
  150480. * Interface for updraft event data
  150481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150482. */
  150483. export interface PhysicsUpdraftEventData {
  150484. /**
  150485. * A cylinder used for the updraft event
  150486. */
  150487. cylinder: Mesh;
  150488. }
  150489. /**
  150490. * Interface for vortex event data
  150491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150492. */
  150493. export interface PhysicsVortexEventData {
  150494. /**
  150495. * A cylinder used for the vortex event
  150496. */
  150497. cylinder: Mesh;
  150498. }
  150499. /**
  150500. * Interface for an affected physics impostor
  150501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150502. */
  150503. export interface PhysicsAffectedImpostorWithData {
  150504. /**
  150505. * The impostor affected by the effect
  150506. */
  150507. impostor: PhysicsImpostor;
  150508. /**
  150509. * The data about the hit/horce from the explosion
  150510. */
  150511. hitData: PhysicsHitData;
  150512. }
  150513. }
  150514. declare module BABYLON {
  150515. /** @hidden */
  150516. export var blackAndWhitePixelShader: {
  150517. name: string;
  150518. shader: string;
  150519. };
  150520. }
  150521. declare module BABYLON {
  150522. /**
  150523. * Post process used to render in black and white
  150524. */
  150525. export class BlackAndWhitePostProcess extends PostProcess {
  150526. /**
  150527. * Linear about to convert he result to black and white (default: 1)
  150528. */
  150529. degree: number;
  150530. /**
  150531. * Gets a string identifying the name of the class
  150532. * @returns "BlackAndWhitePostProcess" string
  150533. */
  150534. getClassName(): string;
  150535. /**
  150536. * Creates a black and white post process
  150537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150538. * @param name The name of the effect.
  150539. * @param options The required width/height ratio to downsize to before computing the render pass.
  150540. * @param camera The camera to apply the render pass to.
  150541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150542. * @param engine The engine which the post process will be applied. (default: current engine)
  150543. * @param reusable If the post process can be reused on the same frame. (default: false)
  150544. */
  150545. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150546. /** @hidden */
  150547. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150548. }
  150549. }
  150550. declare module BABYLON {
  150551. /**
  150552. * This represents a set of one or more post processes in Babylon.
  150553. * A post process can be used to apply a shader to a texture after it is rendered.
  150554. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150555. */
  150556. export class PostProcessRenderEffect {
  150557. private _postProcesses;
  150558. private _getPostProcesses;
  150559. private _singleInstance;
  150560. private _cameras;
  150561. private _indicesForCamera;
  150562. /**
  150563. * Name of the effect
  150564. * @hidden
  150565. */
  150566. _name: string;
  150567. /**
  150568. * Instantiates a post process render effect.
  150569. * A post process can be used to apply a shader to a texture after it is rendered.
  150570. * @param engine The engine the effect is tied to
  150571. * @param name The name of the effect
  150572. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150573. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150574. */
  150575. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150576. /**
  150577. * Checks if all the post processes in the effect are supported.
  150578. */
  150579. get isSupported(): boolean;
  150580. /**
  150581. * Updates the current state of the effect
  150582. * @hidden
  150583. */
  150584. _update(): void;
  150585. /**
  150586. * Attaches the effect on cameras
  150587. * @param cameras The camera to attach to.
  150588. * @hidden
  150589. */
  150590. _attachCameras(cameras: Camera): void;
  150591. /**
  150592. * Attaches the effect on cameras
  150593. * @param cameras The camera to attach to.
  150594. * @hidden
  150595. */
  150596. _attachCameras(cameras: Camera[]): void;
  150597. /**
  150598. * Detaches the effect on cameras
  150599. * @param cameras The camera to detatch from.
  150600. * @hidden
  150601. */
  150602. _detachCameras(cameras: Camera): void;
  150603. /**
  150604. * Detatches the effect on cameras
  150605. * @param cameras The camera to detatch from.
  150606. * @hidden
  150607. */
  150608. _detachCameras(cameras: Camera[]): void;
  150609. /**
  150610. * Enables the effect on given cameras
  150611. * @param cameras The camera to enable.
  150612. * @hidden
  150613. */
  150614. _enable(cameras: Camera): void;
  150615. /**
  150616. * Enables the effect on given cameras
  150617. * @param cameras The camera to enable.
  150618. * @hidden
  150619. */
  150620. _enable(cameras: Nullable<Camera[]>): void;
  150621. /**
  150622. * Disables the effect on the given cameras
  150623. * @param cameras The camera to disable.
  150624. * @hidden
  150625. */
  150626. _disable(cameras: Camera): void;
  150627. /**
  150628. * Disables the effect on the given cameras
  150629. * @param cameras The camera to disable.
  150630. * @hidden
  150631. */
  150632. _disable(cameras: Nullable<Camera[]>): void;
  150633. /**
  150634. * Gets a list of the post processes contained in the effect.
  150635. * @param camera The camera to get the post processes on.
  150636. * @returns The list of the post processes in the effect.
  150637. */
  150638. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150639. }
  150640. }
  150641. declare module BABYLON {
  150642. /** @hidden */
  150643. export var extractHighlightsPixelShader: {
  150644. name: string;
  150645. shader: string;
  150646. };
  150647. }
  150648. declare module BABYLON {
  150649. /**
  150650. * 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.
  150651. */
  150652. export class ExtractHighlightsPostProcess extends PostProcess {
  150653. /**
  150654. * The luminance threshold, pixels below this value will be set to black.
  150655. */
  150656. threshold: number;
  150657. /** @hidden */
  150658. _exposure: number;
  150659. /**
  150660. * Post process which has the input texture to be used when performing highlight extraction
  150661. * @hidden
  150662. */
  150663. _inputPostProcess: Nullable<PostProcess>;
  150664. /**
  150665. * Gets a string identifying the name of the class
  150666. * @returns "ExtractHighlightsPostProcess" string
  150667. */
  150668. getClassName(): string;
  150669. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150670. }
  150671. }
  150672. declare module BABYLON {
  150673. /** @hidden */
  150674. export var bloomMergePixelShader: {
  150675. name: string;
  150676. shader: string;
  150677. };
  150678. }
  150679. declare module BABYLON {
  150680. /**
  150681. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150682. */
  150683. export class BloomMergePostProcess extends PostProcess {
  150684. /** Weight of the bloom to be added to the original input. */
  150685. weight: number;
  150686. /**
  150687. * Gets a string identifying the name of the class
  150688. * @returns "BloomMergePostProcess" string
  150689. */
  150690. getClassName(): string;
  150691. /**
  150692. * Creates a new instance of @see BloomMergePostProcess
  150693. * @param name The name of the effect.
  150694. * @param originalFromInput Post process which's input will be used for the merge.
  150695. * @param blurred Blurred highlights post process which's output will be used.
  150696. * @param weight Weight of the bloom to be added to the original input.
  150697. * @param options The required width/height ratio to downsize to before computing the render pass.
  150698. * @param camera The camera to apply the render pass to.
  150699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150700. * @param engine The engine which the post process will be applied. (default: current engine)
  150701. * @param reusable If the post process can be reused on the same frame. (default: false)
  150702. * @param textureType Type of textures used when performing the post process. (default: 0)
  150703. * @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)
  150704. */
  150705. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150706. /** Weight of the bloom to be added to the original input. */
  150707. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150708. }
  150709. }
  150710. declare module BABYLON {
  150711. /**
  150712. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150713. */
  150714. export class BloomEffect extends PostProcessRenderEffect {
  150715. private bloomScale;
  150716. /**
  150717. * @hidden Internal
  150718. */
  150719. _effects: Array<PostProcess>;
  150720. /**
  150721. * @hidden Internal
  150722. */
  150723. _downscale: ExtractHighlightsPostProcess;
  150724. private _blurX;
  150725. private _blurY;
  150726. private _merge;
  150727. /**
  150728. * The luminance threshold to find bright areas of the image to bloom.
  150729. */
  150730. get threshold(): number;
  150731. set threshold(value: number);
  150732. /**
  150733. * The strength of the bloom.
  150734. */
  150735. get weight(): number;
  150736. set weight(value: number);
  150737. /**
  150738. * Specifies the size of the bloom blur kernel, relative to the final output size
  150739. */
  150740. get kernel(): number;
  150741. set kernel(value: number);
  150742. /**
  150743. * Creates a new instance of @see BloomEffect
  150744. * @param scene The scene the effect belongs to.
  150745. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150746. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150747. * @param bloomWeight The the strength of bloom.
  150748. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150749. * @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)
  150750. */
  150751. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150752. /**
  150753. * Disposes each of the internal effects for a given camera.
  150754. * @param camera The camera to dispose the effect on.
  150755. */
  150756. disposeEffects(camera: Camera): void;
  150757. /**
  150758. * @hidden Internal
  150759. */
  150760. _updateEffects(): void;
  150761. /**
  150762. * Internal
  150763. * @returns if all the contained post processes are ready.
  150764. * @hidden
  150765. */
  150766. _isReady(): boolean;
  150767. }
  150768. }
  150769. declare module BABYLON {
  150770. /** @hidden */
  150771. export var chromaticAberrationPixelShader: {
  150772. name: string;
  150773. shader: string;
  150774. };
  150775. }
  150776. declare module BABYLON {
  150777. /**
  150778. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150779. */
  150780. export class ChromaticAberrationPostProcess extends PostProcess {
  150781. /**
  150782. * The amount of seperation of rgb channels (default: 30)
  150783. */
  150784. aberrationAmount: number;
  150785. /**
  150786. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150787. */
  150788. radialIntensity: number;
  150789. /**
  150790. * 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))
  150791. */
  150792. direction: Vector2;
  150793. /**
  150794. * 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))
  150795. */
  150796. centerPosition: Vector2;
  150797. /** The width of the screen to apply the effect on */
  150798. screenWidth: number;
  150799. /** The height of the screen to apply the effect on */
  150800. screenHeight: number;
  150801. /**
  150802. * Gets a string identifying the name of the class
  150803. * @returns "ChromaticAberrationPostProcess" string
  150804. */
  150805. getClassName(): string;
  150806. /**
  150807. * Creates a new instance ChromaticAberrationPostProcess
  150808. * @param name The name of the effect.
  150809. * @param screenWidth The width of the screen to apply the effect on.
  150810. * @param screenHeight The height of the screen to apply the effect on.
  150811. * @param options The required width/height ratio to downsize to before computing the render pass.
  150812. * @param camera The camera to apply the render pass to.
  150813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150814. * @param engine The engine which the post process will be applied. (default: current engine)
  150815. * @param reusable If the post process can be reused on the same frame. (default: false)
  150816. * @param textureType Type of textures used when performing the post process. (default: 0)
  150817. * @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)
  150818. */
  150819. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150820. /** @hidden */
  150821. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150822. }
  150823. }
  150824. declare module BABYLON {
  150825. /** @hidden */
  150826. export var circleOfConfusionPixelShader: {
  150827. name: string;
  150828. shader: string;
  150829. };
  150830. }
  150831. declare module BABYLON {
  150832. /**
  150833. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150834. */
  150835. export class CircleOfConfusionPostProcess extends PostProcess {
  150836. /**
  150837. * 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.
  150838. */
  150839. lensSize: number;
  150840. /**
  150841. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150842. */
  150843. fStop: number;
  150844. /**
  150845. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150846. */
  150847. focusDistance: number;
  150848. /**
  150849. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150850. */
  150851. focalLength: number;
  150852. /**
  150853. * Gets a string identifying the name of the class
  150854. * @returns "CircleOfConfusionPostProcess" string
  150855. */
  150856. getClassName(): string;
  150857. private _depthTexture;
  150858. /**
  150859. * Creates a new instance CircleOfConfusionPostProcess
  150860. * @param name The name of the effect.
  150861. * @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.
  150862. * @param options The required width/height ratio to downsize to before computing the render pass.
  150863. * @param camera The camera to apply the render pass to.
  150864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150865. * @param engine The engine which the post process will be applied. (default: current engine)
  150866. * @param reusable If the post process can be reused on the same frame. (default: false)
  150867. * @param textureType Type of textures used when performing the post process. (default: 0)
  150868. * @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)
  150869. */
  150870. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150871. /**
  150872. * 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.
  150873. */
  150874. set depthTexture(value: RenderTargetTexture);
  150875. }
  150876. }
  150877. declare module BABYLON {
  150878. /** @hidden */
  150879. export var colorCorrectionPixelShader: {
  150880. name: string;
  150881. shader: string;
  150882. };
  150883. }
  150884. declare module BABYLON {
  150885. /**
  150886. *
  150887. * This post-process allows the modification of rendered colors by using
  150888. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150889. *
  150890. * The object needs to be provided an url to a texture containing the color
  150891. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150892. * Use an image editing software to tweak the LUT to match your needs.
  150893. *
  150894. * For an example of a color LUT, see here:
  150895. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150896. * For explanations on color grading, see here:
  150897. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150898. *
  150899. */
  150900. export class ColorCorrectionPostProcess extends PostProcess {
  150901. private _colorTableTexture;
  150902. /**
  150903. * Gets the color table url used to create the LUT texture
  150904. */
  150905. colorTableUrl: string;
  150906. /**
  150907. * Gets a string identifying the name of the class
  150908. * @returns "ColorCorrectionPostProcess" string
  150909. */
  150910. getClassName(): string;
  150911. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150912. /** @hidden */
  150913. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150914. }
  150915. }
  150916. declare module BABYLON {
  150917. /** @hidden */
  150918. export var convolutionPixelShader: {
  150919. name: string;
  150920. shader: string;
  150921. };
  150922. }
  150923. declare module BABYLON {
  150924. /**
  150925. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150926. * input texture to perform effects such as edge detection or sharpening
  150927. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150928. */
  150929. export class ConvolutionPostProcess extends PostProcess {
  150930. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150931. kernel: number[];
  150932. /**
  150933. * Gets a string identifying the name of the class
  150934. * @returns "ConvolutionPostProcess" string
  150935. */
  150936. getClassName(): string;
  150937. /**
  150938. * Creates a new instance ConvolutionPostProcess
  150939. * @param name The name of the effect.
  150940. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150941. * @param options The required width/height ratio to downsize to before computing the render pass.
  150942. * @param camera The camera to apply the render pass to.
  150943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150944. * @param engine The engine which the post process will be applied. (default: current engine)
  150945. * @param reusable If the post process can be reused on the same frame. (default: false)
  150946. * @param textureType Type of textures used when performing the post process. (default: 0)
  150947. */
  150948. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150949. /** @hidden */
  150950. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150951. /**
  150952. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150953. */
  150954. static EdgeDetect0Kernel: number[];
  150955. /**
  150956. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150957. */
  150958. static EdgeDetect1Kernel: number[];
  150959. /**
  150960. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150961. */
  150962. static EdgeDetect2Kernel: number[];
  150963. /**
  150964. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150965. */
  150966. static SharpenKernel: number[];
  150967. /**
  150968. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150969. */
  150970. static EmbossKernel: number[];
  150971. /**
  150972. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150973. */
  150974. static GaussianKernel: number[];
  150975. }
  150976. }
  150977. declare module BABYLON {
  150978. /**
  150979. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150980. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150981. * based on samples that have a large difference in distance than the center pixel.
  150982. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150983. */
  150984. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150985. /**
  150986. * The direction the blur should be applied
  150987. */
  150988. direction: Vector2;
  150989. /**
  150990. * Gets a string identifying the name of the class
  150991. * @returns "DepthOfFieldBlurPostProcess" string
  150992. */
  150993. getClassName(): string;
  150994. /**
  150995. * Creates a new instance CircleOfConfusionPostProcess
  150996. * @param name The name of the effect.
  150997. * @param scene The scene the effect belongs to.
  150998. * @param direction The direction the blur should be applied.
  150999. * @param kernel The size of the kernel used to blur.
  151000. * @param options The required width/height ratio to downsize to before computing the render pass.
  151001. * @param camera The camera to apply the render pass to.
  151002. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  151003. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  151004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151005. * @param engine The engine which the post process will be applied. (default: current engine)
  151006. * @param reusable If the post process can be reused on the same frame. (default: false)
  151007. * @param textureType Type of textures used when performing the post process. (default: 0)
  151008. * @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)
  151009. */
  151010. 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);
  151011. }
  151012. }
  151013. declare module BABYLON {
  151014. /** @hidden */
  151015. export var depthOfFieldMergePixelShader: {
  151016. name: string;
  151017. shader: string;
  151018. };
  151019. }
  151020. declare module BABYLON {
  151021. /**
  151022. * Options to be set when merging outputs from the default pipeline.
  151023. */
  151024. export class DepthOfFieldMergePostProcessOptions {
  151025. /**
  151026. * The original image to merge on top of
  151027. */
  151028. originalFromInput: PostProcess;
  151029. /**
  151030. * Parameters to perform the merge of the depth of field effect
  151031. */
  151032. depthOfField?: {
  151033. circleOfConfusion: PostProcess;
  151034. blurSteps: Array<PostProcess>;
  151035. };
  151036. /**
  151037. * Parameters to perform the merge of bloom effect
  151038. */
  151039. bloom?: {
  151040. blurred: PostProcess;
  151041. weight: number;
  151042. };
  151043. }
  151044. /**
  151045. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151046. */
  151047. export class DepthOfFieldMergePostProcess extends PostProcess {
  151048. private blurSteps;
  151049. /**
  151050. * Gets a string identifying the name of the class
  151051. * @returns "DepthOfFieldMergePostProcess" string
  151052. */
  151053. getClassName(): string;
  151054. /**
  151055. * Creates a new instance of DepthOfFieldMergePostProcess
  151056. * @param name The name of the effect.
  151057. * @param originalFromInput Post process which's input will be used for the merge.
  151058. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  151059. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  151060. * @param options The required width/height ratio to downsize to before computing the render pass.
  151061. * @param camera The camera to apply the render pass to.
  151062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151063. * @param engine The engine which the post process will be applied. (default: current engine)
  151064. * @param reusable If the post process can be reused on the same frame. (default: false)
  151065. * @param textureType Type of textures used when performing the post process. (default: 0)
  151066. * @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)
  151067. */
  151068. 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);
  151069. /**
  151070. * Updates the effect with the current post process compile time values and recompiles the shader.
  151071. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  151072. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  151073. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  151074. * @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
  151075. * @param onCompiled Called when the shader has been compiled.
  151076. * @param onError Called if there is an error when compiling a shader.
  151077. */
  151078. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151079. }
  151080. }
  151081. declare module BABYLON {
  151082. /**
  151083. * Specifies the level of max blur that should be applied when using the depth of field effect
  151084. */
  151085. export enum DepthOfFieldEffectBlurLevel {
  151086. /**
  151087. * Subtle blur
  151088. */
  151089. Low = 0,
  151090. /**
  151091. * Medium blur
  151092. */
  151093. Medium = 1,
  151094. /**
  151095. * Large blur
  151096. */
  151097. High = 2
  151098. }
  151099. /**
  151100. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151101. */
  151102. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151103. private _circleOfConfusion;
  151104. /**
  151105. * @hidden Internal, blurs from high to low
  151106. */
  151107. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151108. private _depthOfFieldBlurY;
  151109. private _dofMerge;
  151110. /**
  151111. * @hidden Internal post processes in depth of field effect
  151112. */
  151113. _effects: Array<PostProcess>;
  151114. /**
  151115. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151116. */
  151117. set focalLength(value: number);
  151118. get focalLength(): number;
  151119. /**
  151120. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151121. */
  151122. set fStop(value: number);
  151123. get fStop(): number;
  151124. /**
  151125. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151126. */
  151127. set focusDistance(value: number);
  151128. get focusDistance(): number;
  151129. /**
  151130. * 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.
  151131. */
  151132. set lensSize(value: number);
  151133. get lensSize(): number;
  151134. /**
  151135. * Creates a new instance DepthOfFieldEffect
  151136. * @param scene The scene the effect belongs to.
  151137. * @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.
  151138. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151139. * @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)
  151140. */
  151141. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151142. /**
  151143. * Get the current class name of the current effet
  151144. * @returns "DepthOfFieldEffect"
  151145. */
  151146. getClassName(): string;
  151147. /**
  151148. * 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.
  151149. */
  151150. set depthTexture(value: RenderTargetTexture);
  151151. /**
  151152. * Disposes each of the internal effects for a given camera.
  151153. * @param camera The camera to dispose the effect on.
  151154. */
  151155. disposeEffects(camera: Camera): void;
  151156. /**
  151157. * @hidden Internal
  151158. */
  151159. _updateEffects(): void;
  151160. /**
  151161. * Internal
  151162. * @returns if all the contained post processes are ready.
  151163. * @hidden
  151164. */
  151165. _isReady(): boolean;
  151166. }
  151167. }
  151168. declare module BABYLON {
  151169. /** @hidden */
  151170. export var displayPassPixelShader: {
  151171. name: string;
  151172. shader: string;
  151173. };
  151174. }
  151175. declare module BABYLON {
  151176. /**
  151177. * DisplayPassPostProcess which produces an output the same as it's input
  151178. */
  151179. export class DisplayPassPostProcess extends PostProcess {
  151180. /**
  151181. * Gets a string identifying the name of the class
  151182. * @returns "DisplayPassPostProcess" string
  151183. */
  151184. getClassName(): string;
  151185. /**
  151186. * Creates the DisplayPassPostProcess
  151187. * @param name The name of the effect.
  151188. * @param options The required width/height ratio to downsize to before computing the render pass.
  151189. * @param camera The camera to apply the render pass to.
  151190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151191. * @param engine The engine which the post process will be applied. (default: current engine)
  151192. * @param reusable If the post process can be reused on the same frame. (default: false)
  151193. */
  151194. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151195. /** @hidden */
  151196. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151197. }
  151198. }
  151199. declare module BABYLON {
  151200. /** @hidden */
  151201. export var filterPixelShader: {
  151202. name: string;
  151203. shader: string;
  151204. };
  151205. }
  151206. declare module BABYLON {
  151207. /**
  151208. * Applies a kernel filter to the image
  151209. */
  151210. export class FilterPostProcess extends PostProcess {
  151211. /** The matrix to be applied to the image */
  151212. kernelMatrix: Matrix;
  151213. /**
  151214. * Gets a string identifying the name of the class
  151215. * @returns "FilterPostProcess" string
  151216. */
  151217. getClassName(): string;
  151218. /**
  151219. *
  151220. * @param name The name of the effect.
  151221. * @param kernelMatrix The matrix to be applied to the image
  151222. * @param options The required width/height ratio to downsize to before computing the render pass.
  151223. * @param camera The camera to apply the render pass to.
  151224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151225. * @param engine The engine which the post process will be applied. (default: current engine)
  151226. * @param reusable If the post process can be reused on the same frame. (default: false)
  151227. */
  151228. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151229. /** @hidden */
  151230. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151231. }
  151232. }
  151233. declare module BABYLON {
  151234. /** @hidden */
  151235. export var fxaaPixelShader: {
  151236. name: string;
  151237. shader: string;
  151238. };
  151239. }
  151240. declare module BABYLON {
  151241. /** @hidden */
  151242. export var fxaaVertexShader: {
  151243. name: string;
  151244. shader: string;
  151245. };
  151246. }
  151247. declare module BABYLON {
  151248. /**
  151249. * Fxaa post process
  151250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151251. */
  151252. export class FxaaPostProcess extends PostProcess {
  151253. /**
  151254. * Gets a string identifying the name of the class
  151255. * @returns "FxaaPostProcess" string
  151256. */
  151257. getClassName(): string;
  151258. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151259. private _getDefines;
  151260. /** @hidden */
  151261. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151262. }
  151263. }
  151264. declare module BABYLON {
  151265. /** @hidden */
  151266. export var grainPixelShader: {
  151267. name: string;
  151268. shader: string;
  151269. };
  151270. }
  151271. declare module BABYLON {
  151272. /**
  151273. * The GrainPostProcess adds noise to the image at mid luminance levels
  151274. */
  151275. export class GrainPostProcess extends PostProcess {
  151276. /**
  151277. * The intensity of the grain added (default: 30)
  151278. */
  151279. intensity: number;
  151280. /**
  151281. * If the grain should be randomized on every frame
  151282. */
  151283. animated: boolean;
  151284. /**
  151285. * Gets a string identifying the name of the class
  151286. * @returns "GrainPostProcess" string
  151287. */
  151288. getClassName(): string;
  151289. /**
  151290. * Creates a new instance of @see GrainPostProcess
  151291. * @param name The name of the effect.
  151292. * @param options The required width/height ratio to downsize to before computing the render pass.
  151293. * @param camera The camera to apply the render pass to.
  151294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151295. * @param engine The engine which the post process will be applied. (default: current engine)
  151296. * @param reusable If the post process can be reused on the same frame. (default: false)
  151297. * @param textureType Type of textures used when performing the post process. (default: 0)
  151298. * @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)
  151299. */
  151300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151301. /** @hidden */
  151302. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151303. }
  151304. }
  151305. declare module BABYLON {
  151306. /** @hidden */
  151307. export var highlightsPixelShader: {
  151308. name: string;
  151309. shader: string;
  151310. };
  151311. }
  151312. declare module BABYLON {
  151313. /**
  151314. * Extracts highlights from the image
  151315. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151316. */
  151317. export class HighlightsPostProcess extends PostProcess {
  151318. /**
  151319. * Gets a string identifying the name of the class
  151320. * @returns "HighlightsPostProcess" string
  151321. */
  151322. getClassName(): string;
  151323. /**
  151324. * Extracts highlights from the image
  151325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151326. * @param name The name of the effect.
  151327. * @param options The required width/height ratio to downsize to before computing the render pass.
  151328. * @param camera The camera to apply the render pass to.
  151329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151330. * @param engine The engine which the post process will be applied. (default: current engine)
  151331. * @param reusable If the post process can be reused on the same frame. (default: false)
  151332. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151333. */
  151334. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151335. }
  151336. }
  151337. declare module BABYLON {
  151338. /**
  151339. * Contains all parameters needed for the prepass to perform
  151340. * motion blur
  151341. */
  151342. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151343. /**
  151344. * Is motion blur enabled
  151345. */
  151346. enabled: boolean;
  151347. /**
  151348. * Name of the configuration
  151349. */
  151350. name: string;
  151351. /**
  151352. * Textures that should be present in the MRT for this effect to work
  151353. */
  151354. readonly texturesRequired: number[];
  151355. }
  151356. }
  151357. declare module BABYLON {
  151358. interface Scene {
  151359. /** @hidden (Backing field) */
  151360. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151361. /**
  151362. * Gets or Sets the current geometry buffer associated to the scene.
  151363. */
  151364. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151365. /**
  151366. * Enables a GeometryBufferRender and associates it with the scene
  151367. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151368. * @returns the GeometryBufferRenderer
  151369. */
  151370. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151371. /**
  151372. * Disables the GeometryBufferRender associated with the scene
  151373. */
  151374. disableGeometryBufferRenderer(): void;
  151375. }
  151376. /**
  151377. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151378. * in several rendering techniques.
  151379. */
  151380. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151381. /**
  151382. * The component name helpful to identify the component in the list of scene components.
  151383. */
  151384. readonly name: string;
  151385. /**
  151386. * The scene the component belongs to.
  151387. */
  151388. scene: Scene;
  151389. /**
  151390. * Creates a new instance of the component for the given scene
  151391. * @param scene Defines the scene to register the component in
  151392. */
  151393. constructor(scene: Scene);
  151394. /**
  151395. * Registers the component in a given scene
  151396. */
  151397. register(): void;
  151398. /**
  151399. * Rebuilds the elements related to this component in case of
  151400. * context lost for instance.
  151401. */
  151402. rebuild(): void;
  151403. /**
  151404. * Disposes the component and the associated ressources
  151405. */
  151406. dispose(): void;
  151407. private _gatherRenderTargets;
  151408. }
  151409. }
  151410. declare module BABYLON {
  151411. /** @hidden */
  151412. export var motionBlurPixelShader: {
  151413. name: string;
  151414. shader: string;
  151415. };
  151416. }
  151417. declare module BABYLON {
  151418. /**
  151419. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151420. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151421. * As an example, all you have to do is to create the post-process:
  151422. * var mb = new BABYLON.MotionBlurPostProcess(
  151423. * 'mb', // The name of the effect.
  151424. * scene, // The scene containing the objects to blur according to their velocity.
  151425. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151426. * camera // The camera to apply the render pass to.
  151427. * );
  151428. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151429. */
  151430. export class MotionBlurPostProcess extends PostProcess {
  151431. /**
  151432. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151433. */
  151434. motionStrength: number;
  151435. /**
  151436. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151437. */
  151438. get motionBlurSamples(): number;
  151439. /**
  151440. * Sets the number of iterations to be used for motion blur quality
  151441. */
  151442. set motionBlurSamples(samples: number);
  151443. private _motionBlurSamples;
  151444. private _forceGeometryBuffer;
  151445. private _geometryBufferRenderer;
  151446. private _prePassRenderer;
  151447. /**
  151448. * Gets a string identifying the name of the class
  151449. * @returns "MotionBlurPostProcess" string
  151450. */
  151451. getClassName(): string;
  151452. /**
  151453. * Creates a new instance MotionBlurPostProcess
  151454. * @param name The name of the effect.
  151455. * @param scene The scene containing the objects to blur according to their velocity.
  151456. * @param options The required width/height ratio to downsize to before computing the render pass.
  151457. * @param camera The camera to apply the render pass to.
  151458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151459. * @param engine The engine which the post process will be applied. (default: current engine)
  151460. * @param reusable If the post process can be reused on the same frame. (default: false)
  151461. * @param textureType Type of textures used when performing the post process. (default: 0)
  151462. * @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)
  151463. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151464. */
  151465. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151466. /**
  151467. * Excludes the given skinned mesh from computing bones velocities.
  151468. * 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.
  151469. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151470. */
  151471. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151472. /**
  151473. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151474. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151475. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151476. */
  151477. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151478. /**
  151479. * Disposes the post process.
  151480. * @param camera The camera to dispose the post process on.
  151481. */
  151482. dispose(camera?: Camera): void;
  151483. /** @hidden */
  151484. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151485. }
  151486. }
  151487. declare module BABYLON {
  151488. /** @hidden */
  151489. export var refractionPixelShader: {
  151490. name: string;
  151491. shader: string;
  151492. };
  151493. }
  151494. declare module BABYLON {
  151495. /**
  151496. * Post process which applies a refractin texture
  151497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151498. */
  151499. export class RefractionPostProcess extends PostProcess {
  151500. private _refTexture;
  151501. private _ownRefractionTexture;
  151502. /** the base color of the refraction (used to taint the rendering) */
  151503. color: Color3;
  151504. /** simulated refraction depth */
  151505. depth: number;
  151506. /** the coefficient of the base color (0 to remove base color tainting) */
  151507. colorLevel: number;
  151508. /** Gets the url used to load the refraction texture */
  151509. refractionTextureUrl: string;
  151510. /**
  151511. * Gets or sets the refraction texture
  151512. * Please note that you are responsible for disposing the texture if you set it manually
  151513. */
  151514. get refractionTexture(): Texture;
  151515. set refractionTexture(value: Texture);
  151516. /**
  151517. * Gets a string identifying the name of the class
  151518. * @returns "RefractionPostProcess" string
  151519. */
  151520. getClassName(): string;
  151521. /**
  151522. * Initializes the RefractionPostProcess
  151523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151524. * @param name The name of the effect.
  151525. * @param refractionTextureUrl Url of the refraction texture to use
  151526. * @param color the base color of the refraction (used to taint the rendering)
  151527. * @param depth simulated refraction depth
  151528. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151529. * @param camera The camera to apply the render pass to.
  151530. * @param options The required width/height ratio to downsize to before computing the render pass.
  151531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151532. * @param engine The engine which the post process will be applied. (default: current engine)
  151533. * @param reusable If the post process can be reused on the same frame. (default: false)
  151534. */
  151535. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151536. /**
  151537. * Disposes of the post process
  151538. * @param camera Camera to dispose post process on
  151539. */
  151540. dispose(camera: Camera): void;
  151541. /** @hidden */
  151542. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151543. }
  151544. }
  151545. declare module BABYLON {
  151546. /** @hidden */
  151547. export var sharpenPixelShader: {
  151548. name: string;
  151549. shader: string;
  151550. };
  151551. }
  151552. declare module BABYLON {
  151553. /**
  151554. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151555. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151556. */
  151557. export class SharpenPostProcess extends PostProcess {
  151558. /**
  151559. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151560. */
  151561. colorAmount: number;
  151562. /**
  151563. * How much sharpness should be applied (default: 0.3)
  151564. */
  151565. edgeAmount: number;
  151566. /**
  151567. * Gets a string identifying the name of the class
  151568. * @returns "SharpenPostProcess" string
  151569. */
  151570. getClassName(): string;
  151571. /**
  151572. * Creates a new instance ConvolutionPostProcess
  151573. * @param name The name of the effect.
  151574. * @param options The required width/height ratio to downsize to before computing the render pass.
  151575. * @param camera The camera to apply the render pass to.
  151576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151577. * @param engine The engine which the post process will be applied. (default: current engine)
  151578. * @param reusable If the post process can be reused on the same frame. (default: false)
  151579. * @param textureType Type of textures used when performing the post process. (default: 0)
  151580. * @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)
  151581. */
  151582. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151583. /** @hidden */
  151584. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151585. }
  151586. }
  151587. declare module BABYLON {
  151588. /**
  151589. * PostProcessRenderPipeline
  151590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151591. */
  151592. export class PostProcessRenderPipeline {
  151593. private engine;
  151594. private _renderEffects;
  151595. private _renderEffectsForIsolatedPass;
  151596. /**
  151597. * List of inspectable custom properties (used by the Inspector)
  151598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151599. */
  151600. inspectableCustomProperties: IInspectable[];
  151601. /**
  151602. * @hidden
  151603. */
  151604. protected _cameras: Camera[];
  151605. /** @hidden */
  151606. _name: string;
  151607. /**
  151608. * Gets pipeline name
  151609. */
  151610. get name(): string;
  151611. /** Gets the list of attached cameras */
  151612. get cameras(): Camera[];
  151613. /**
  151614. * Initializes a PostProcessRenderPipeline
  151615. * @param engine engine to add the pipeline to
  151616. * @param name name of the pipeline
  151617. */
  151618. constructor(engine: Engine, name: string);
  151619. /**
  151620. * Gets the class name
  151621. * @returns "PostProcessRenderPipeline"
  151622. */
  151623. getClassName(): string;
  151624. /**
  151625. * If all the render effects in the pipeline are supported
  151626. */
  151627. get isSupported(): boolean;
  151628. /**
  151629. * Adds an effect to the pipeline
  151630. * @param renderEffect the effect to add
  151631. */
  151632. addEffect(renderEffect: PostProcessRenderEffect): void;
  151633. /** @hidden */
  151634. _rebuild(): void;
  151635. /** @hidden */
  151636. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151637. /** @hidden */
  151638. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151639. /** @hidden */
  151640. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151641. /** @hidden */
  151642. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151643. /** @hidden */
  151644. _attachCameras(cameras: Camera, unique: boolean): void;
  151645. /** @hidden */
  151646. _attachCameras(cameras: Camera[], unique: boolean): void;
  151647. /** @hidden */
  151648. _detachCameras(cameras: Camera): void;
  151649. /** @hidden */
  151650. _detachCameras(cameras: Nullable<Camera[]>): void;
  151651. /** @hidden */
  151652. _update(): void;
  151653. /** @hidden */
  151654. _reset(): void;
  151655. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151656. /**
  151657. * Sets the required values to the prepass renderer.
  151658. * @param prePassRenderer defines the prepass renderer to setup.
  151659. * @returns true if the pre pass is needed.
  151660. */
  151661. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151662. /**
  151663. * Disposes of the pipeline
  151664. */
  151665. dispose(): void;
  151666. }
  151667. }
  151668. declare module BABYLON {
  151669. /**
  151670. * PostProcessRenderPipelineManager class
  151671. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151672. */
  151673. export class PostProcessRenderPipelineManager {
  151674. private _renderPipelines;
  151675. /**
  151676. * Initializes a PostProcessRenderPipelineManager
  151677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151678. */
  151679. constructor();
  151680. /**
  151681. * Gets the list of supported render pipelines
  151682. */
  151683. get supportedPipelines(): PostProcessRenderPipeline[];
  151684. /**
  151685. * Adds a pipeline to the manager
  151686. * @param renderPipeline The pipeline to add
  151687. */
  151688. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151689. /**
  151690. * Attaches a camera to the pipeline
  151691. * @param renderPipelineName The name of the pipeline to attach to
  151692. * @param cameras the camera to attach
  151693. * @param unique if the camera can be attached multiple times to the pipeline
  151694. */
  151695. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151696. /**
  151697. * Detaches a camera from the pipeline
  151698. * @param renderPipelineName The name of the pipeline to detach from
  151699. * @param cameras the camera to detach
  151700. */
  151701. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151702. /**
  151703. * Enables an effect by name on a pipeline
  151704. * @param renderPipelineName the name of the pipeline to enable the effect in
  151705. * @param renderEffectName the name of the effect to enable
  151706. * @param cameras the cameras that the effect should be enabled on
  151707. */
  151708. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151709. /**
  151710. * Disables an effect by name on a pipeline
  151711. * @param renderPipelineName the name of the pipeline to disable the effect in
  151712. * @param renderEffectName the name of the effect to disable
  151713. * @param cameras the cameras that the effect should be disabled on
  151714. */
  151715. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151716. /**
  151717. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151718. */
  151719. update(): void;
  151720. /** @hidden */
  151721. _rebuild(): void;
  151722. /**
  151723. * Disposes of the manager and pipelines
  151724. */
  151725. dispose(): void;
  151726. }
  151727. }
  151728. declare module BABYLON {
  151729. interface Scene {
  151730. /** @hidden (Backing field) */
  151731. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151732. /**
  151733. * Gets the postprocess render pipeline manager
  151734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151735. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151736. */
  151737. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151738. }
  151739. /**
  151740. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151741. */
  151742. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151743. /**
  151744. * The component name helpfull to identify the component in the list of scene components.
  151745. */
  151746. readonly name: string;
  151747. /**
  151748. * The scene the component belongs to.
  151749. */
  151750. scene: Scene;
  151751. /**
  151752. * Creates a new instance of the component for the given scene
  151753. * @param scene Defines the scene to register the component in
  151754. */
  151755. constructor(scene: Scene);
  151756. /**
  151757. * Registers the component in a given scene
  151758. */
  151759. register(): void;
  151760. /**
  151761. * Rebuilds the elements related to this component in case of
  151762. * context lost for instance.
  151763. */
  151764. rebuild(): void;
  151765. /**
  151766. * Disposes the component and the associated ressources
  151767. */
  151768. dispose(): void;
  151769. private _gatherRenderTargets;
  151770. }
  151771. }
  151772. declare module BABYLON {
  151773. /**
  151774. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151775. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151776. */
  151777. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151778. private _scene;
  151779. private _camerasToBeAttached;
  151780. /**
  151781. * ID of the sharpen post process,
  151782. */
  151783. private readonly SharpenPostProcessId;
  151784. /**
  151785. * @ignore
  151786. * ID of the image processing post process;
  151787. */
  151788. readonly ImageProcessingPostProcessId: string;
  151789. /**
  151790. * @ignore
  151791. * ID of the Fast Approximate Anti-Aliasing post process;
  151792. */
  151793. readonly FxaaPostProcessId: string;
  151794. /**
  151795. * ID of the chromatic aberration post process,
  151796. */
  151797. private readonly ChromaticAberrationPostProcessId;
  151798. /**
  151799. * ID of the grain post process
  151800. */
  151801. private readonly GrainPostProcessId;
  151802. /**
  151803. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151804. */
  151805. sharpen: SharpenPostProcess;
  151806. private _sharpenEffect;
  151807. private bloom;
  151808. /**
  151809. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151810. */
  151811. depthOfField: DepthOfFieldEffect;
  151812. /**
  151813. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151814. */
  151815. fxaa: FxaaPostProcess;
  151816. /**
  151817. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151818. */
  151819. imageProcessing: ImageProcessingPostProcess;
  151820. /**
  151821. * Chromatic aberration post process which will shift rgb colors in the image
  151822. */
  151823. chromaticAberration: ChromaticAberrationPostProcess;
  151824. private _chromaticAberrationEffect;
  151825. /**
  151826. * Grain post process which add noise to the image
  151827. */
  151828. grain: GrainPostProcess;
  151829. private _grainEffect;
  151830. /**
  151831. * Glow post process which adds a glow to emissive areas of the image
  151832. */
  151833. private _glowLayer;
  151834. /**
  151835. * Animations which can be used to tweak settings over a period of time
  151836. */
  151837. animations: Animation[];
  151838. private _imageProcessingConfigurationObserver;
  151839. private _sharpenEnabled;
  151840. private _bloomEnabled;
  151841. private _depthOfFieldEnabled;
  151842. private _depthOfFieldBlurLevel;
  151843. private _fxaaEnabled;
  151844. private _imageProcessingEnabled;
  151845. private _defaultPipelineTextureType;
  151846. private _bloomScale;
  151847. private _chromaticAberrationEnabled;
  151848. private _grainEnabled;
  151849. private _buildAllowed;
  151850. /**
  151851. * Gets active scene
  151852. */
  151853. get scene(): Scene;
  151854. /**
  151855. * Enable or disable the sharpen process from the pipeline
  151856. */
  151857. set sharpenEnabled(enabled: boolean);
  151858. get sharpenEnabled(): boolean;
  151859. private _resizeObserver;
  151860. private _hardwareScaleLevel;
  151861. private _bloomKernel;
  151862. /**
  151863. * Specifies the size of the bloom blur kernel, relative to the final output size
  151864. */
  151865. get bloomKernel(): number;
  151866. set bloomKernel(value: number);
  151867. /**
  151868. * Specifies the weight of the bloom in the final rendering
  151869. */
  151870. private _bloomWeight;
  151871. /**
  151872. * Specifies the luma threshold for the area that will be blurred by the bloom
  151873. */
  151874. private _bloomThreshold;
  151875. private _hdr;
  151876. /**
  151877. * The strength of the bloom.
  151878. */
  151879. set bloomWeight(value: number);
  151880. get bloomWeight(): number;
  151881. /**
  151882. * The strength of the bloom.
  151883. */
  151884. set bloomThreshold(value: number);
  151885. get bloomThreshold(): number;
  151886. /**
  151887. * The scale of the bloom, lower value will provide better performance.
  151888. */
  151889. set bloomScale(value: number);
  151890. get bloomScale(): number;
  151891. /**
  151892. * Enable or disable the bloom from the pipeline
  151893. */
  151894. set bloomEnabled(enabled: boolean);
  151895. get bloomEnabled(): boolean;
  151896. private _rebuildBloom;
  151897. /**
  151898. * If the depth of field is enabled.
  151899. */
  151900. get depthOfFieldEnabled(): boolean;
  151901. set depthOfFieldEnabled(enabled: boolean);
  151902. /**
  151903. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151904. */
  151905. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151906. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151907. /**
  151908. * If the anti aliasing is enabled.
  151909. */
  151910. set fxaaEnabled(enabled: boolean);
  151911. get fxaaEnabled(): boolean;
  151912. private _samples;
  151913. /**
  151914. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151915. */
  151916. set samples(sampleCount: number);
  151917. get samples(): number;
  151918. /**
  151919. * If image processing is enabled.
  151920. */
  151921. set imageProcessingEnabled(enabled: boolean);
  151922. get imageProcessingEnabled(): boolean;
  151923. /**
  151924. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151925. */
  151926. set glowLayerEnabled(enabled: boolean);
  151927. get glowLayerEnabled(): boolean;
  151928. /**
  151929. * Gets the glow layer (or null if not defined)
  151930. */
  151931. get glowLayer(): Nullable<GlowLayer>;
  151932. /**
  151933. * Enable or disable the chromaticAberration process from the pipeline
  151934. */
  151935. set chromaticAberrationEnabled(enabled: boolean);
  151936. get chromaticAberrationEnabled(): boolean;
  151937. /**
  151938. * Enable or disable the grain process from the pipeline
  151939. */
  151940. set grainEnabled(enabled: boolean);
  151941. get grainEnabled(): boolean;
  151942. /**
  151943. * @constructor
  151944. * @param name - The rendering pipeline name (default: "")
  151945. * @param hdr - If high dynamic range textures should be used (default: true)
  151946. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151947. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151948. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151949. */
  151950. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151951. /**
  151952. * Get the class name
  151953. * @returns "DefaultRenderingPipeline"
  151954. */
  151955. getClassName(): string;
  151956. /**
  151957. * Force the compilation of the entire pipeline.
  151958. */
  151959. prepare(): void;
  151960. private _hasCleared;
  151961. private _prevPostProcess;
  151962. private _prevPrevPostProcess;
  151963. private _setAutoClearAndTextureSharing;
  151964. private _depthOfFieldSceneObserver;
  151965. private _buildPipeline;
  151966. private _disposePostProcesses;
  151967. /**
  151968. * Adds a camera to the pipeline
  151969. * @param camera the camera to be added
  151970. */
  151971. addCamera(camera: Camera): void;
  151972. /**
  151973. * Removes a camera from the pipeline
  151974. * @param camera the camera to remove
  151975. */
  151976. removeCamera(camera: Camera): void;
  151977. /**
  151978. * Dispose of the pipeline and stop all post processes
  151979. */
  151980. dispose(): void;
  151981. /**
  151982. * Serialize the rendering pipeline (Used when exporting)
  151983. * @returns the serialized object
  151984. */
  151985. serialize(): any;
  151986. /**
  151987. * Parse the serialized pipeline
  151988. * @param source Source pipeline.
  151989. * @param scene The scene to load the pipeline to.
  151990. * @param rootUrl The URL of the serialized pipeline.
  151991. * @returns An instantiated pipeline from the serialized object.
  151992. */
  151993. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151994. }
  151995. }
  151996. declare module BABYLON {
  151997. /** @hidden */
  151998. export var lensHighlightsPixelShader: {
  151999. name: string;
  152000. shader: string;
  152001. };
  152002. }
  152003. declare module BABYLON {
  152004. /** @hidden */
  152005. export var depthOfFieldPixelShader: {
  152006. name: string;
  152007. shader: string;
  152008. };
  152009. }
  152010. declare module BABYLON {
  152011. /**
  152012. * BABYLON.JS Chromatic Aberration GLSL Shader
  152013. * Author: Olivier Guyot
  152014. * Separates very slightly R, G and B colors on the edges of the screen
  152015. * Inspired by Francois Tarlier & Martins Upitis
  152016. */
  152017. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  152018. /**
  152019. * @ignore
  152020. * The chromatic aberration PostProcess id in the pipeline
  152021. */
  152022. LensChromaticAberrationEffect: string;
  152023. /**
  152024. * @ignore
  152025. * The highlights enhancing PostProcess id in the pipeline
  152026. */
  152027. HighlightsEnhancingEffect: string;
  152028. /**
  152029. * @ignore
  152030. * The depth-of-field PostProcess id in the pipeline
  152031. */
  152032. LensDepthOfFieldEffect: string;
  152033. private _scene;
  152034. private _depthTexture;
  152035. private _grainTexture;
  152036. private _chromaticAberrationPostProcess;
  152037. private _highlightsPostProcess;
  152038. private _depthOfFieldPostProcess;
  152039. private _edgeBlur;
  152040. private _grainAmount;
  152041. private _chromaticAberration;
  152042. private _distortion;
  152043. private _highlightsGain;
  152044. private _highlightsThreshold;
  152045. private _dofDistance;
  152046. private _dofAperture;
  152047. private _dofDarken;
  152048. private _dofPentagon;
  152049. private _blurNoise;
  152050. /**
  152051. * @constructor
  152052. *
  152053. * Effect parameters are as follow:
  152054. * {
  152055. * chromatic_aberration: number; // from 0 to x (1 for realism)
  152056. * edge_blur: number; // from 0 to x (1 for realism)
  152057. * distortion: number; // from 0 to x (1 for realism)
  152058. * grain_amount: number; // from 0 to 1
  152059. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  152060. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  152061. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  152062. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  152063. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  152064. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  152065. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  152066. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  152067. * }
  152068. * Note: if an effect parameter is unset, effect is disabled
  152069. *
  152070. * @param name The rendering pipeline name
  152071. * @param parameters - An object containing all parameters (see above)
  152072. * @param scene The scene linked to this pipeline
  152073. * @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)
  152074. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152075. */
  152076. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  152077. /**
  152078. * Get the class name
  152079. * @returns "LensRenderingPipeline"
  152080. */
  152081. getClassName(): string;
  152082. /**
  152083. * Gets associated scene
  152084. */
  152085. get scene(): Scene;
  152086. /**
  152087. * Gets or sets the edge blur
  152088. */
  152089. get edgeBlur(): number;
  152090. set edgeBlur(value: number);
  152091. /**
  152092. * Gets or sets the grain amount
  152093. */
  152094. get grainAmount(): number;
  152095. set grainAmount(value: number);
  152096. /**
  152097. * Gets or sets the chromatic aberration amount
  152098. */
  152099. get chromaticAberration(): number;
  152100. set chromaticAberration(value: number);
  152101. /**
  152102. * Gets or sets the depth of field aperture
  152103. */
  152104. get dofAperture(): number;
  152105. set dofAperture(value: number);
  152106. /**
  152107. * Gets or sets the edge distortion
  152108. */
  152109. get edgeDistortion(): number;
  152110. set edgeDistortion(value: number);
  152111. /**
  152112. * Gets or sets the depth of field distortion
  152113. */
  152114. get dofDistortion(): number;
  152115. set dofDistortion(value: number);
  152116. /**
  152117. * Gets or sets the darken out of focus amount
  152118. */
  152119. get darkenOutOfFocus(): number;
  152120. set darkenOutOfFocus(value: number);
  152121. /**
  152122. * Gets or sets a boolean indicating if blur noise is enabled
  152123. */
  152124. get blurNoise(): boolean;
  152125. set blurNoise(value: boolean);
  152126. /**
  152127. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152128. */
  152129. get pentagonBokeh(): boolean;
  152130. set pentagonBokeh(value: boolean);
  152131. /**
  152132. * Gets or sets the highlight grain amount
  152133. */
  152134. get highlightsGain(): number;
  152135. set highlightsGain(value: number);
  152136. /**
  152137. * Gets or sets the highlight threshold
  152138. */
  152139. get highlightsThreshold(): number;
  152140. set highlightsThreshold(value: number);
  152141. /**
  152142. * Sets the amount of blur at the edges
  152143. * @param amount blur amount
  152144. */
  152145. setEdgeBlur(amount: number): void;
  152146. /**
  152147. * Sets edge blur to 0
  152148. */
  152149. disableEdgeBlur(): void;
  152150. /**
  152151. * Sets the amout of grain
  152152. * @param amount Amount of grain
  152153. */
  152154. setGrainAmount(amount: number): void;
  152155. /**
  152156. * Set grain amount to 0
  152157. */
  152158. disableGrain(): void;
  152159. /**
  152160. * Sets the chromatic aberration amount
  152161. * @param amount amount of chromatic aberration
  152162. */
  152163. setChromaticAberration(amount: number): void;
  152164. /**
  152165. * Sets chromatic aberration amount to 0
  152166. */
  152167. disableChromaticAberration(): void;
  152168. /**
  152169. * Sets the EdgeDistortion amount
  152170. * @param amount amount of EdgeDistortion
  152171. */
  152172. setEdgeDistortion(amount: number): void;
  152173. /**
  152174. * Sets edge distortion to 0
  152175. */
  152176. disableEdgeDistortion(): void;
  152177. /**
  152178. * Sets the FocusDistance amount
  152179. * @param amount amount of FocusDistance
  152180. */
  152181. setFocusDistance(amount: number): void;
  152182. /**
  152183. * Disables depth of field
  152184. */
  152185. disableDepthOfField(): void;
  152186. /**
  152187. * Sets the Aperture amount
  152188. * @param amount amount of Aperture
  152189. */
  152190. setAperture(amount: number): void;
  152191. /**
  152192. * Sets the DarkenOutOfFocus amount
  152193. * @param amount amount of DarkenOutOfFocus
  152194. */
  152195. setDarkenOutOfFocus(amount: number): void;
  152196. private _pentagonBokehIsEnabled;
  152197. /**
  152198. * Creates a pentagon bokeh effect
  152199. */
  152200. enablePentagonBokeh(): void;
  152201. /**
  152202. * Disables the pentagon bokeh effect
  152203. */
  152204. disablePentagonBokeh(): void;
  152205. /**
  152206. * Enables noise blur
  152207. */
  152208. enableNoiseBlur(): void;
  152209. /**
  152210. * Disables noise blur
  152211. */
  152212. disableNoiseBlur(): void;
  152213. /**
  152214. * Sets the HighlightsGain amount
  152215. * @param amount amount of HighlightsGain
  152216. */
  152217. setHighlightsGain(amount: number): void;
  152218. /**
  152219. * Sets the HighlightsThreshold amount
  152220. * @param amount amount of HighlightsThreshold
  152221. */
  152222. setHighlightsThreshold(amount: number): void;
  152223. /**
  152224. * Disables highlights
  152225. */
  152226. disableHighlights(): void;
  152227. /**
  152228. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152229. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152230. */
  152231. dispose(disableDepthRender?: boolean): void;
  152232. private _createChromaticAberrationPostProcess;
  152233. private _createHighlightsPostProcess;
  152234. private _createDepthOfFieldPostProcess;
  152235. private _createGrainTexture;
  152236. }
  152237. }
  152238. declare module BABYLON {
  152239. /**
  152240. * Contains all parameters needed for the prepass to perform
  152241. * screen space subsurface scattering
  152242. */
  152243. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152244. /**
  152245. * Is subsurface enabled
  152246. */
  152247. enabled: boolean;
  152248. /**
  152249. * Name of the configuration
  152250. */
  152251. name: string;
  152252. /**
  152253. * Textures that should be present in the MRT for this effect to work
  152254. */
  152255. readonly texturesRequired: number[];
  152256. }
  152257. }
  152258. declare module BABYLON {
  152259. /** @hidden */
  152260. export var ssao2PixelShader: {
  152261. name: string;
  152262. shader: string;
  152263. };
  152264. }
  152265. declare module BABYLON {
  152266. /** @hidden */
  152267. export var ssaoCombinePixelShader: {
  152268. name: string;
  152269. shader: string;
  152270. };
  152271. }
  152272. declare module BABYLON {
  152273. /**
  152274. * Render pipeline to produce ssao effect
  152275. */
  152276. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152277. /**
  152278. * @ignore
  152279. * The PassPostProcess id in the pipeline that contains the original scene color
  152280. */
  152281. SSAOOriginalSceneColorEffect: string;
  152282. /**
  152283. * @ignore
  152284. * The SSAO PostProcess id in the pipeline
  152285. */
  152286. SSAORenderEffect: string;
  152287. /**
  152288. * @ignore
  152289. * The horizontal blur PostProcess id in the pipeline
  152290. */
  152291. SSAOBlurHRenderEffect: string;
  152292. /**
  152293. * @ignore
  152294. * The vertical blur PostProcess id in the pipeline
  152295. */
  152296. SSAOBlurVRenderEffect: string;
  152297. /**
  152298. * @ignore
  152299. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152300. */
  152301. SSAOCombineRenderEffect: string;
  152302. /**
  152303. * The output strength of the SSAO post-process. Default value is 1.0.
  152304. */
  152305. totalStrength: number;
  152306. /**
  152307. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152308. */
  152309. maxZ: number;
  152310. /**
  152311. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152312. */
  152313. minZAspect: number;
  152314. private _samples;
  152315. /**
  152316. * Number of samples used for the SSAO calculations. Default value is 8
  152317. */
  152318. set samples(n: number);
  152319. get samples(): number;
  152320. private _textureSamples;
  152321. /**
  152322. * Number of samples to use for antialiasing
  152323. */
  152324. set textureSamples(n: number);
  152325. get textureSamples(): number;
  152326. /**
  152327. * Force rendering the geometry through geometry buffer
  152328. */
  152329. private _forceGeometryBuffer;
  152330. /**
  152331. * Ratio object used for SSAO ratio and blur ratio
  152332. */
  152333. private _ratio;
  152334. /**
  152335. * Dynamically generated sphere sampler.
  152336. */
  152337. private _sampleSphere;
  152338. /**
  152339. * Blur filter offsets
  152340. */
  152341. private _samplerOffsets;
  152342. private _expensiveBlur;
  152343. /**
  152344. * If bilateral blur should be used
  152345. */
  152346. set expensiveBlur(b: boolean);
  152347. get expensiveBlur(): boolean;
  152348. /**
  152349. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152350. */
  152351. radius: number;
  152352. /**
  152353. * The base color of the SSAO post-process
  152354. * The final result is "base + ssao" between [0, 1]
  152355. */
  152356. base: number;
  152357. /**
  152358. * Support test.
  152359. */
  152360. static get IsSupported(): boolean;
  152361. private _scene;
  152362. private _randomTexture;
  152363. private _originalColorPostProcess;
  152364. private _ssaoPostProcess;
  152365. private _blurHPostProcess;
  152366. private _blurVPostProcess;
  152367. private _ssaoCombinePostProcess;
  152368. private _prePassRenderer;
  152369. /**
  152370. * Gets active scene
  152371. */
  152372. get scene(): Scene;
  152373. /**
  152374. * @constructor
  152375. * @param name The rendering pipeline name
  152376. * @param scene The scene linked to this pipeline
  152377. * @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 }
  152378. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152379. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152380. */
  152381. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152382. /**
  152383. * Get the class name
  152384. * @returns "SSAO2RenderingPipeline"
  152385. */
  152386. getClassName(): string;
  152387. /**
  152388. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152389. */
  152390. dispose(disableGeometryBufferRenderer?: boolean): void;
  152391. private _createBlurPostProcess;
  152392. /** @hidden */
  152393. _rebuild(): void;
  152394. private _bits;
  152395. private _radicalInverse_VdC;
  152396. private _hammersley;
  152397. private _hemisphereSample_uniform;
  152398. private _generateHemisphere;
  152399. private _getDefinesForSSAO;
  152400. private _createSSAOPostProcess;
  152401. private _createSSAOCombinePostProcess;
  152402. private _createRandomTexture;
  152403. /**
  152404. * Serialize the rendering pipeline (Used when exporting)
  152405. * @returns the serialized object
  152406. */
  152407. serialize(): any;
  152408. /**
  152409. * Parse the serialized pipeline
  152410. * @param source Source pipeline.
  152411. * @param scene The scene to load the pipeline to.
  152412. * @param rootUrl The URL of the serialized pipeline.
  152413. * @returns An instantiated pipeline from the serialized object.
  152414. */
  152415. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152416. }
  152417. }
  152418. declare module BABYLON {
  152419. /** @hidden */
  152420. export var ssaoPixelShader: {
  152421. name: string;
  152422. shader: string;
  152423. };
  152424. }
  152425. declare module BABYLON {
  152426. /**
  152427. * Render pipeline to produce ssao effect
  152428. */
  152429. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152430. /**
  152431. * @ignore
  152432. * The PassPostProcess id in the pipeline that contains the original scene color
  152433. */
  152434. SSAOOriginalSceneColorEffect: string;
  152435. /**
  152436. * @ignore
  152437. * The SSAO PostProcess id in the pipeline
  152438. */
  152439. SSAORenderEffect: string;
  152440. /**
  152441. * @ignore
  152442. * The horizontal blur PostProcess id in the pipeline
  152443. */
  152444. SSAOBlurHRenderEffect: string;
  152445. /**
  152446. * @ignore
  152447. * The vertical blur PostProcess id in the pipeline
  152448. */
  152449. SSAOBlurVRenderEffect: string;
  152450. /**
  152451. * @ignore
  152452. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152453. */
  152454. SSAOCombineRenderEffect: string;
  152455. /**
  152456. * The output strength of the SSAO post-process. Default value is 1.0.
  152457. */
  152458. totalStrength: number;
  152459. /**
  152460. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152461. */
  152462. radius: number;
  152463. /**
  152464. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152465. * Must not be equal to fallOff and superior to fallOff.
  152466. * Default value is 0.0075
  152467. */
  152468. area: number;
  152469. /**
  152470. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152471. * Must not be equal to area and inferior to area.
  152472. * Default value is 0.000001
  152473. */
  152474. fallOff: number;
  152475. /**
  152476. * The base color of the SSAO post-process
  152477. * The final result is "base + ssao" between [0, 1]
  152478. */
  152479. base: number;
  152480. private _scene;
  152481. private _depthTexture;
  152482. private _randomTexture;
  152483. private _originalColorPostProcess;
  152484. private _ssaoPostProcess;
  152485. private _blurHPostProcess;
  152486. private _blurVPostProcess;
  152487. private _ssaoCombinePostProcess;
  152488. private _firstUpdate;
  152489. /**
  152490. * Gets active scene
  152491. */
  152492. get scene(): Scene;
  152493. /**
  152494. * @constructor
  152495. * @param name - The rendering pipeline name
  152496. * @param scene - The scene linked to this pipeline
  152497. * @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 }
  152498. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152499. */
  152500. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152501. /**
  152502. * Get the class name
  152503. * @returns "SSAORenderingPipeline"
  152504. */
  152505. getClassName(): string;
  152506. /**
  152507. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152508. */
  152509. dispose(disableDepthRender?: boolean): void;
  152510. private _createBlurPostProcess;
  152511. /** @hidden */
  152512. _rebuild(): void;
  152513. private _createSSAOPostProcess;
  152514. private _createSSAOCombinePostProcess;
  152515. private _createRandomTexture;
  152516. }
  152517. }
  152518. declare module BABYLON {
  152519. /**
  152520. * Contains all parameters needed for the prepass to perform
  152521. * screen space reflections
  152522. */
  152523. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152524. /**
  152525. * Is ssr enabled
  152526. */
  152527. enabled: boolean;
  152528. /**
  152529. * Name of the configuration
  152530. */
  152531. name: string;
  152532. /**
  152533. * Textures that should be present in the MRT for this effect to work
  152534. */
  152535. readonly texturesRequired: number[];
  152536. }
  152537. }
  152538. declare module BABYLON {
  152539. /** @hidden */
  152540. export var screenSpaceReflectionPixelShader: {
  152541. name: string;
  152542. shader: string;
  152543. };
  152544. }
  152545. declare module BABYLON {
  152546. /**
  152547. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152548. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152549. */
  152550. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152551. /**
  152552. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152553. */
  152554. threshold: number;
  152555. /**
  152556. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152557. */
  152558. strength: number;
  152559. /**
  152560. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152561. */
  152562. reflectionSpecularFalloffExponent: number;
  152563. /**
  152564. * 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]
  152565. */
  152566. step: number;
  152567. /**
  152568. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152569. */
  152570. roughnessFactor: number;
  152571. private _forceGeometryBuffer;
  152572. private _geometryBufferRenderer;
  152573. private _prePassRenderer;
  152574. private _enableSmoothReflections;
  152575. private _reflectionSamples;
  152576. private _smoothSteps;
  152577. /**
  152578. * Gets a string identifying the name of the class
  152579. * @returns "ScreenSpaceReflectionPostProcess" string
  152580. */
  152581. getClassName(): string;
  152582. /**
  152583. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152584. * @param name The name of the effect.
  152585. * @param scene The scene containing the objects to calculate reflections.
  152586. * @param options The required width/height ratio to downsize to before computing the render pass.
  152587. * @param camera The camera to apply the render pass to.
  152588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152589. * @param engine The engine which the post process will be applied. (default: current engine)
  152590. * @param reusable If the post process can be reused on the same frame. (default: false)
  152591. * @param textureType Type of textures used when performing the post process. (default: 0)
  152592. * @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)
  152593. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152594. */
  152595. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152596. /**
  152597. * Gets wether or not smoothing reflections is enabled.
  152598. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152599. */
  152600. get enableSmoothReflections(): boolean;
  152601. /**
  152602. * Sets wether or not smoothing reflections is enabled.
  152603. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152604. */
  152605. set enableSmoothReflections(enabled: boolean);
  152606. /**
  152607. * Gets the number of samples taken while computing reflections. More samples count is high,
  152608. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152609. */
  152610. get reflectionSamples(): number;
  152611. /**
  152612. * Sets the number of samples taken while computing reflections. More samples count is high,
  152613. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152614. */
  152615. set reflectionSamples(samples: number);
  152616. /**
  152617. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152618. * more the post-process will require GPU power and can generate a drop in FPS.
  152619. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152620. */
  152621. get smoothSteps(): number;
  152622. set smoothSteps(steps: number);
  152623. private _updateEffectDefines;
  152624. /** @hidden */
  152625. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152626. }
  152627. }
  152628. declare module BABYLON {
  152629. /** @hidden */
  152630. export var standardPixelShader: {
  152631. name: string;
  152632. shader: string;
  152633. };
  152634. }
  152635. declare module BABYLON {
  152636. /**
  152637. * Standard rendering pipeline
  152638. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152639. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152640. */
  152641. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152642. /**
  152643. * Public members
  152644. */
  152645. /**
  152646. * Post-process which contains the original scene color before the pipeline applies all the effects
  152647. */
  152648. originalPostProcess: Nullable<PostProcess>;
  152649. /**
  152650. * Post-process used to down scale an image x4
  152651. */
  152652. downSampleX4PostProcess: Nullable<PostProcess>;
  152653. /**
  152654. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152655. */
  152656. brightPassPostProcess: Nullable<PostProcess>;
  152657. /**
  152658. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152659. */
  152660. blurHPostProcesses: PostProcess[];
  152661. /**
  152662. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152663. */
  152664. blurVPostProcesses: PostProcess[];
  152665. /**
  152666. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152667. */
  152668. textureAdderPostProcess: Nullable<PostProcess>;
  152669. /**
  152670. * Post-process used to create volumetric lighting effect
  152671. */
  152672. volumetricLightPostProcess: Nullable<PostProcess>;
  152673. /**
  152674. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152675. */
  152676. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152677. /**
  152678. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152679. */
  152680. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152681. /**
  152682. * Post-process used to merge the volumetric light effect and the real scene color
  152683. */
  152684. volumetricLightMergePostProces: Nullable<PostProcess>;
  152685. /**
  152686. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152687. */
  152688. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152689. /**
  152690. * Base post-process used to calculate the average luminance of the final image for HDR
  152691. */
  152692. luminancePostProcess: Nullable<PostProcess>;
  152693. /**
  152694. * Post-processes used to create down sample post-processes in order to get
  152695. * the average luminance of the final image for HDR
  152696. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152697. */
  152698. luminanceDownSamplePostProcesses: PostProcess[];
  152699. /**
  152700. * Post-process used to create a HDR effect (light adaptation)
  152701. */
  152702. hdrPostProcess: Nullable<PostProcess>;
  152703. /**
  152704. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152705. */
  152706. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152707. /**
  152708. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152709. */
  152710. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152711. /**
  152712. * Post-process used to merge the final HDR post-process and the real scene color
  152713. */
  152714. hdrFinalPostProcess: Nullable<PostProcess>;
  152715. /**
  152716. * Post-process used to create a lens flare effect
  152717. */
  152718. lensFlarePostProcess: Nullable<PostProcess>;
  152719. /**
  152720. * Post-process that merges the result of the lens flare post-process and the real scene color
  152721. */
  152722. lensFlareComposePostProcess: Nullable<PostProcess>;
  152723. /**
  152724. * Post-process used to create a motion blur effect
  152725. */
  152726. motionBlurPostProcess: Nullable<PostProcess>;
  152727. /**
  152728. * Post-process used to create a depth of field effect
  152729. */
  152730. depthOfFieldPostProcess: Nullable<PostProcess>;
  152731. /**
  152732. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152733. */
  152734. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152735. /**
  152736. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152737. */
  152738. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152739. /**
  152740. * Represents the brightness threshold in order to configure the illuminated surfaces
  152741. */
  152742. brightThreshold: number;
  152743. /**
  152744. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152745. */
  152746. blurWidth: number;
  152747. /**
  152748. * Sets if the blur for highlighted surfaces must be only horizontal
  152749. */
  152750. horizontalBlur: boolean;
  152751. /**
  152752. * Gets the overall exposure used by the pipeline
  152753. */
  152754. get exposure(): number;
  152755. /**
  152756. * Sets the overall exposure used by the pipeline
  152757. */
  152758. set exposure(value: number);
  152759. /**
  152760. * Texture used typically to simulate "dirty" on camera lens
  152761. */
  152762. lensTexture: Nullable<Texture>;
  152763. /**
  152764. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152765. */
  152766. volumetricLightCoefficient: number;
  152767. /**
  152768. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152769. */
  152770. volumetricLightPower: number;
  152771. /**
  152772. * Used the set the blur intensity to smooth the volumetric lights
  152773. */
  152774. volumetricLightBlurScale: number;
  152775. /**
  152776. * Light (spot or directional) used to generate the volumetric lights rays
  152777. * The source light must have a shadow generate so the pipeline can get its
  152778. * depth map
  152779. */
  152780. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152781. /**
  152782. * For eye adaptation, represents the minimum luminance the eye can see
  152783. */
  152784. hdrMinimumLuminance: number;
  152785. /**
  152786. * For eye adaptation, represents the decrease luminance speed
  152787. */
  152788. hdrDecreaseRate: number;
  152789. /**
  152790. * For eye adaptation, represents the increase luminance speed
  152791. */
  152792. hdrIncreaseRate: number;
  152793. /**
  152794. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152795. */
  152796. get hdrAutoExposure(): boolean;
  152797. /**
  152798. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152799. */
  152800. set hdrAutoExposure(value: boolean);
  152801. /**
  152802. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152803. */
  152804. lensColorTexture: Nullable<Texture>;
  152805. /**
  152806. * The overall strengh for the lens flare effect
  152807. */
  152808. lensFlareStrength: number;
  152809. /**
  152810. * Dispersion coefficient for lens flare ghosts
  152811. */
  152812. lensFlareGhostDispersal: number;
  152813. /**
  152814. * Main lens flare halo width
  152815. */
  152816. lensFlareHaloWidth: number;
  152817. /**
  152818. * Based on the lens distortion effect, defines how much the lens flare result
  152819. * is distorted
  152820. */
  152821. lensFlareDistortionStrength: number;
  152822. /**
  152823. * Configures the blur intensity used for for lens flare (halo)
  152824. */
  152825. lensFlareBlurWidth: number;
  152826. /**
  152827. * Lens star texture must be used to simulate rays on the flares and is available
  152828. * in the documentation
  152829. */
  152830. lensStarTexture: Nullable<Texture>;
  152831. /**
  152832. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152833. * flare effect by taking account of the dirt texture
  152834. */
  152835. lensFlareDirtTexture: Nullable<Texture>;
  152836. /**
  152837. * Represents the focal length for the depth of field effect
  152838. */
  152839. depthOfFieldDistance: number;
  152840. /**
  152841. * Represents the blur intensity for the blurred part of the depth of field effect
  152842. */
  152843. depthOfFieldBlurWidth: number;
  152844. /**
  152845. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152846. */
  152847. get motionStrength(): number;
  152848. /**
  152849. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152850. */
  152851. set motionStrength(strength: number);
  152852. /**
  152853. * Gets wether or not the motion blur post-process is object based or screen based.
  152854. */
  152855. get objectBasedMotionBlur(): boolean;
  152856. /**
  152857. * Sets wether or not the motion blur post-process should be object based or screen based
  152858. */
  152859. set objectBasedMotionBlur(value: boolean);
  152860. /**
  152861. * List of animations for the pipeline (IAnimatable implementation)
  152862. */
  152863. animations: Animation[];
  152864. /**
  152865. * Private members
  152866. */
  152867. private _scene;
  152868. private _currentDepthOfFieldSource;
  152869. private _basePostProcess;
  152870. private _fixedExposure;
  152871. private _currentExposure;
  152872. private _hdrAutoExposure;
  152873. private _hdrCurrentLuminance;
  152874. private _motionStrength;
  152875. private _isObjectBasedMotionBlur;
  152876. private _floatTextureType;
  152877. private _camerasToBeAttached;
  152878. private _ratio;
  152879. private _bloomEnabled;
  152880. private _depthOfFieldEnabled;
  152881. private _vlsEnabled;
  152882. private _lensFlareEnabled;
  152883. private _hdrEnabled;
  152884. private _motionBlurEnabled;
  152885. private _fxaaEnabled;
  152886. private _screenSpaceReflectionsEnabled;
  152887. private _motionBlurSamples;
  152888. private _volumetricLightStepsCount;
  152889. private _samples;
  152890. /**
  152891. * @ignore
  152892. * Specifies if the bloom pipeline is enabled
  152893. */
  152894. get BloomEnabled(): boolean;
  152895. set BloomEnabled(enabled: boolean);
  152896. /**
  152897. * @ignore
  152898. * Specifies if the depth of field pipeline is enabed
  152899. */
  152900. get DepthOfFieldEnabled(): boolean;
  152901. set DepthOfFieldEnabled(enabled: boolean);
  152902. /**
  152903. * @ignore
  152904. * Specifies if the lens flare pipeline is enabed
  152905. */
  152906. get LensFlareEnabled(): boolean;
  152907. set LensFlareEnabled(enabled: boolean);
  152908. /**
  152909. * @ignore
  152910. * Specifies if the HDR pipeline is enabled
  152911. */
  152912. get HDREnabled(): boolean;
  152913. set HDREnabled(enabled: boolean);
  152914. /**
  152915. * @ignore
  152916. * Specifies if the volumetric lights scattering effect is enabled
  152917. */
  152918. get VLSEnabled(): boolean;
  152919. set VLSEnabled(enabled: boolean);
  152920. /**
  152921. * @ignore
  152922. * Specifies if the motion blur effect is enabled
  152923. */
  152924. get MotionBlurEnabled(): boolean;
  152925. set MotionBlurEnabled(enabled: boolean);
  152926. /**
  152927. * Specifies if anti-aliasing is enabled
  152928. */
  152929. get fxaaEnabled(): boolean;
  152930. set fxaaEnabled(enabled: boolean);
  152931. /**
  152932. * Specifies if screen space reflections are enabled.
  152933. */
  152934. get screenSpaceReflectionsEnabled(): boolean;
  152935. set screenSpaceReflectionsEnabled(enabled: boolean);
  152936. /**
  152937. * Specifies the number of steps used to calculate the volumetric lights
  152938. * Typically in interval [50, 200]
  152939. */
  152940. get volumetricLightStepsCount(): number;
  152941. set volumetricLightStepsCount(count: number);
  152942. /**
  152943. * Specifies the number of samples used for the motion blur effect
  152944. * Typically in interval [16, 64]
  152945. */
  152946. get motionBlurSamples(): number;
  152947. set motionBlurSamples(samples: number);
  152948. /**
  152949. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152950. */
  152951. get samples(): number;
  152952. set samples(sampleCount: number);
  152953. /**
  152954. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152955. * @constructor
  152956. * @param name The rendering pipeline name
  152957. * @param scene The scene linked to this pipeline
  152958. * @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)
  152959. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152960. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152961. */
  152962. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152963. private _buildPipeline;
  152964. private _createDownSampleX4PostProcess;
  152965. private _createBrightPassPostProcess;
  152966. private _createBlurPostProcesses;
  152967. private _createTextureAdderPostProcess;
  152968. private _createVolumetricLightPostProcess;
  152969. private _createLuminancePostProcesses;
  152970. private _createHdrPostProcess;
  152971. private _createLensFlarePostProcess;
  152972. private _createDepthOfFieldPostProcess;
  152973. private _createMotionBlurPostProcess;
  152974. private _getDepthTexture;
  152975. private _disposePostProcesses;
  152976. /**
  152977. * Dispose of the pipeline and stop all post processes
  152978. */
  152979. dispose(): void;
  152980. /**
  152981. * Serialize the rendering pipeline (Used when exporting)
  152982. * @returns the serialized object
  152983. */
  152984. serialize(): any;
  152985. /**
  152986. * Parse the serialized pipeline
  152987. * @param source Source pipeline.
  152988. * @param scene The scene to load the pipeline to.
  152989. * @param rootUrl The URL of the serialized pipeline.
  152990. * @returns An instantiated pipeline from the serialized object.
  152991. */
  152992. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152993. /**
  152994. * Luminance steps
  152995. */
  152996. static LuminanceSteps: number;
  152997. }
  152998. }
  152999. declare module BABYLON {
  153000. /** @hidden */
  153001. export var stereoscopicInterlacePixelShader: {
  153002. name: string;
  153003. shader: string;
  153004. };
  153005. }
  153006. declare module BABYLON {
  153007. /**
  153008. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  153009. */
  153010. export class StereoscopicInterlacePostProcessI extends PostProcess {
  153011. private _stepSize;
  153012. private _passedProcess;
  153013. /**
  153014. * Gets a string identifying the name of the class
  153015. * @returns "StereoscopicInterlacePostProcessI" string
  153016. */
  153017. getClassName(): string;
  153018. /**
  153019. * Initializes a StereoscopicInterlacePostProcessI
  153020. * @param name The name of the effect.
  153021. * @param rigCameras The rig cameras to be appled to the post process
  153022. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  153023. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  153024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153025. * @param engine The engine which the post process will be applied. (default: current engine)
  153026. * @param reusable If the post process can be reused on the same frame. (default: false)
  153027. */
  153028. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153029. }
  153030. /**
  153031. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  153032. */
  153033. export class StereoscopicInterlacePostProcess extends PostProcess {
  153034. private _stepSize;
  153035. private _passedProcess;
  153036. /**
  153037. * Gets a string identifying the name of the class
  153038. * @returns "StereoscopicInterlacePostProcess" string
  153039. */
  153040. getClassName(): string;
  153041. /**
  153042. * Initializes a StereoscopicInterlacePostProcess
  153043. * @param name The name of the effect.
  153044. * @param rigCameras The rig cameras to be appled to the post process
  153045. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  153046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153047. * @param engine The engine which the post process will be applied. (default: current engine)
  153048. * @param reusable If the post process can be reused on the same frame. (default: false)
  153049. */
  153050. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153051. }
  153052. }
  153053. declare module BABYLON {
  153054. /** @hidden */
  153055. export var tonemapPixelShader: {
  153056. name: string;
  153057. shader: string;
  153058. };
  153059. }
  153060. declare module BABYLON {
  153061. /** Defines operator used for tonemapping */
  153062. export enum TonemappingOperator {
  153063. /** Hable */
  153064. Hable = 0,
  153065. /** Reinhard */
  153066. Reinhard = 1,
  153067. /** HejiDawson */
  153068. HejiDawson = 2,
  153069. /** Photographic */
  153070. Photographic = 3
  153071. }
  153072. /**
  153073. * Defines a post process to apply tone mapping
  153074. */
  153075. export class TonemapPostProcess extends PostProcess {
  153076. private _operator;
  153077. /** Defines the required exposure adjustement */
  153078. exposureAdjustment: number;
  153079. /**
  153080. * Gets a string identifying the name of the class
  153081. * @returns "TonemapPostProcess" string
  153082. */
  153083. getClassName(): string;
  153084. /**
  153085. * Creates a new TonemapPostProcess
  153086. * @param name defines the name of the postprocess
  153087. * @param _operator defines the operator to use
  153088. * @param exposureAdjustment defines the required exposure adjustement
  153089. * @param camera defines the camera to use (can be null)
  153090. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153091. * @param engine defines the hosting engine (can be ignore if camera is set)
  153092. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153093. */
  153094. constructor(name: string, _operator: TonemappingOperator,
  153095. /** Defines the required exposure adjustement */
  153096. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153097. }
  153098. }
  153099. declare module BABYLON {
  153100. /** @hidden */
  153101. export var volumetricLightScatteringPixelShader: {
  153102. name: string;
  153103. shader: string;
  153104. };
  153105. }
  153106. declare module BABYLON {
  153107. /** @hidden */
  153108. export var volumetricLightScatteringPassVertexShader: {
  153109. name: string;
  153110. shader: string;
  153111. };
  153112. }
  153113. declare module BABYLON {
  153114. /** @hidden */
  153115. export var volumetricLightScatteringPassPixelShader: {
  153116. name: string;
  153117. shader: string;
  153118. };
  153119. }
  153120. declare module BABYLON {
  153121. /**
  153122. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153123. */
  153124. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153125. private _volumetricLightScatteringPass;
  153126. private _volumetricLightScatteringRTT;
  153127. private _viewPort;
  153128. private _screenCoordinates;
  153129. private _cachedDefines;
  153130. /**
  153131. * If not undefined, the mesh position is computed from the attached node position
  153132. */
  153133. attachedNode: {
  153134. position: Vector3;
  153135. };
  153136. /**
  153137. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153138. */
  153139. customMeshPosition: Vector3;
  153140. /**
  153141. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153142. */
  153143. useCustomMeshPosition: boolean;
  153144. /**
  153145. * If the post-process should inverse the light scattering direction
  153146. */
  153147. invert: boolean;
  153148. /**
  153149. * The internal mesh used by the post-process
  153150. */
  153151. mesh: Mesh;
  153152. /**
  153153. * @hidden
  153154. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153155. */
  153156. get useDiffuseColor(): boolean;
  153157. set useDiffuseColor(useDiffuseColor: boolean);
  153158. /**
  153159. * Array containing the excluded meshes not rendered in the internal pass
  153160. */
  153161. excludedMeshes: AbstractMesh[];
  153162. /**
  153163. * Controls the overall intensity of the post-process
  153164. */
  153165. exposure: number;
  153166. /**
  153167. * Dissipates each sample's contribution in range [0, 1]
  153168. */
  153169. decay: number;
  153170. /**
  153171. * Controls the overall intensity of each sample
  153172. */
  153173. weight: number;
  153174. /**
  153175. * Controls the density of each sample
  153176. */
  153177. density: number;
  153178. /**
  153179. * @constructor
  153180. * @param name The post-process name
  153181. * @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)
  153182. * @param camera The camera that the post-process will be attached to
  153183. * @param mesh The mesh used to create the light scattering
  153184. * @param samples The post-process quality, default 100
  153185. * @param samplingModeThe post-process filtering mode
  153186. * @param engine The babylon engine
  153187. * @param reusable If the post-process is reusable
  153188. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153189. */
  153190. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153191. /**
  153192. * Returns the string "VolumetricLightScatteringPostProcess"
  153193. * @returns "VolumetricLightScatteringPostProcess"
  153194. */
  153195. getClassName(): string;
  153196. private _isReady;
  153197. /**
  153198. * Sets the new light position for light scattering effect
  153199. * @param position The new custom light position
  153200. */
  153201. setCustomMeshPosition(position: Vector3): void;
  153202. /**
  153203. * Returns the light position for light scattering effect
  153204. * @return Vector3 The custom light position
  153205. */
  153206. getCustomMeshPosition(): Vector3;
  153207. /**
  153208. * Disposes the internal assets and detaches the post-process from the camera
  153209. */
  153210. dispose(camera: Camera): void;
  153211. /**
  153212. * Returns the render target texture used by the post-process
  153213. * @return the render target texture used by the post-process
  153214. */
  153215. getPass(): RenderTargetTexture;
  153216. private _meshExcluded;
  153217. private _createPass;
  153218. private _updateMeshScreenCoordinates;
  153219. /**
  153220. * Creates a default mesh for the Volumeric Light Scattering post-process
  153221. * @param name The mesh name
  153222. * @param scene The scene where to create the mesh
  153223. * @return the default mesh
  153224. */
  153225. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153226. }
  153227. }
  153228. declare module BABYLON {
  153229. /** @hidden */
  153230. export var screenSpaceCurvaturePixelShader: {
  153231. name: string;
  153232. shader: string;
  153233. };
  153234. }
  153235. declare module BABYLON {
  153236. /**
  153237. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153238. */
  153239. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153240. /**
  153241. * Defines how much ridge the curvature effect displays.
  153242. */
  153243. ridge: number;
  153244. /**
  153245. * Defines how much valley the curvature effect displays.
  153246. */
  153247. valley: number;
  153248. private _geometryBufferRenderer;
  153249. /**
  153250. * Gets a string identifying the name of the class
  153251. * @returns "ScreenSpaceCurvaturePostProcess" string
  153252. */
  153253. getClassName(): string;
  153254. /**
  153255. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153256. * @param name The name of the effect.
  153257. * @param scene The scene containing the objects to blur according to their velocity.
  153258. * @param options The required width/height ratio to downsize to before computing the render pass.
  153259. * @param camera The camera to apply the render pass to.
  153260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153261. * @param engine The engine which the post process will be applied. (default: current engine)
  153262. * @param reusable If the post process can be reused on the same frame. (default: false)
  153263. * @param textureType Type of textures used when performing the post process. (default: 0)
  153264. * @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)
  153265. */
  153266. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153267. /**
  153268. * Support test.
  153269. */
  153270. static get IsSupported(): boolean;
  153271. /** @hidden */
  153272. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153273. }
  153274. }
  153275. declare module BABYLON {
  153276. interface Scene {
  153277. /** @hidden (Backing field) */
  153278. _boundingBoxRenderer: BoundingBoxRenderer;
  153279. /** @hidden (Backing field) */
  153280. _forceShowBoundingBoxes: boolean;
  153281. /**
  153282. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153283. */
  153284. forceShowBoundingBoxes: boolean;
  153285. /**
  153286. * Gets the bounding box renderer associated with the scene
  153287. * @returns a BoundingBoxRenderer
  153288. */
  153289. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153290. }
  153291. interface AbstractMesh {
  153292. /** @hidden (Backing field) */
  153293. _showBoundingBox: boolean;
  153294. /**
  153295. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153296. */
  153297. showBoundingBox: boolean;
  153298. }
  153299. /**
  153300. * Component responsible of rendering the bounding box of the meshes in a scene.
  153301. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153302. */
  153303. export class BoundingBoxRenderer implements ISceneComponent {
  153304. /**
  153305. * The component name helpfull to identify the component in the list of scene components.
  153306. */
  153307. readonly name: string;
  153308. /**
  153309. * The scene the component belongs to.
  153310. */
  153311. scene: Scene;
  153312. /**
  153313. * Color of the bounding box lines placed in front of an object
  153314. */
  153315. frontColor: Color3;
  153316. /**
  153317. * Color of the bounding box lines placed behind an object
  153318. */
  153319. backColor: Color3;
  153320. /**
  153321. * Defines if the renderer should show the back lines or not
  153322. */
  153323. showBackLines: boolean;
  153324. /**
  153325. * Observable raised before rendering a bounding box
  153326. */
  153327. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153328. /**
  153329. * Observable raised after rendering a bounding box
  153330. */
  153331. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153332. /**
  153333. * @hidden
  153334. */
  153335. renderList: SmartArray<BoundingBox>;
  153336. private _colorShader;
  153337. private _vertexBuffers;
  153338. private _indexBuffer;
  153339. private _fillIndexBuffer;
  153340. private _fillIndexData;
  153341. /**
  153342. * Instantiates a new bounding box renderer in a scene.
  153343. * @param scene the scene the renderer renders in
  153344. */
  153345. constructor(scene: Scene);
  153346. /**
  153347. * Registers the component in a given scene
  153348. */
  153349. register(): void;
  153350. private _evaluateSubMesh;
  153351. private _activeMesh;
  153352. private _prepareRessources;
  153353. private _createIndexBuffer;
  153354. /**
  153355. * Rebuilds the elements related to this component in case of
  153356. * context lost for instance.
  153357. */
  153358. rebuild(): void;
  153359. /**
  153360. * @hidden
  153361. */
  153362. reset(): void;
  153363. /**
  153364. * Render the bounding boxes of a specific rendering group
  153365. * @param renderingGroupId defines the rendering group to render
  153366. */
  153367. render(renderingGroupId: number): void;
  153368. /**
  153369. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153370. * @param mesh Define the mesh to render the occlusion bounding box for
  153371. */
  153372. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153373. /**
  153374. * Dispose and release the resources attached to this renderer.
  153375. */
  153376. dispose(): void;
  153377. }
  153378. }
  153379. declare module BABYLON {
  153380. interface Scene {
  153381. /** @hidden (Backing field) */
  153382. _depthRenderer: {
  153383. [id: string]: DepthRenderer;
  153384. };
  153385. /**
  153386. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153387. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153388. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153389. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153390. * @returns the created depth renderer
  153391. */
  153392. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153393. /**
  153394. * Disables a depth renderer for a given camera
  153395. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153396. */
  153397. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153398. }
  153399. /**
  153400. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153401. * in several rendering techniques.
  153402. */
  153403. export class DepthRendererSceneComponent implements ISceneComponent {
  153404. /**
  153405. * The component name helpfull to identify the component in the list of scene components.
  153406. */
  153407. readonly name: string;
  153408. /**
  153409. * The scene the component belongs to.
  153410. */
  153411. scene: Scene;
  153412. /**
  153413. * Creates a new instance of the component for the given scene
  153414. * @param scene Defines the scene to register the component in
  153415. */
  153416. constructor(scene: Scene);
  153417. /**
  153418. * Registers the component in a given scene
  153419. */
  153420. register(): void;
  153421. /**
  153422. * Rebuilds the elements related to this component in case of
  153423. * context lost for instance.
  153424. */
  153425. rebuild(): void;
  153426. /**
  153427. * Disposes the component and the associated ressources
  153428. */
  153429. dispose(): void;
  153430. private _gatherRenderTargets;
  153431. private _gatherActiveCameraRenderTargets;
  153432. }
  153433. }
  153434. declare module BABYLON {
  153435. interface AbstractScene {
  153436. /** @hidden (Backing field) */
  153437. _prePassRenderer: Nullable<PrePassRenderer>;
  153438. /**
  153439. * Gets or Sets the current prepass renderer associated to the scene.
  153440. */
  153441. prePassRenderer: Nullable<PrePassRenderer>;
  153442. /**
  153443. * Enables the prepass and associates it with the scene
  153444. * @returns the PrePassRenderer
  153445. */
  153446. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153447. /**
  153448. * Disables the prepass associated with the scene
  153449. */
  153450. disablePrePassRenderer(): void;
  153451. }
  153452. /**
  153453. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153454. * in several rendering techniques.
  153455. */
  153456. export class PrePassRendererSceneComponent implements ISceneComponent {
  153457. /**
  153458. * The component name helpful to identify the component in the list of scene components.
  153459. */
  153460. readonly name: string;
  153461. /**
  153462. * The scene the component belongs to.
  153463. */
  153464. scene: Scene;
  153465. /**
  153466. * Creates a new instance of the component for the given scene
  153467. * @param scene Defines the scene to register the component in
  153468. */
  153469. constructor(scene: Scene);
  153470. /**
  153471. * Registers the component in a given scene
  153472. */
  153473. register(): void;
  153474. private _beforeCameraDraw;
  153475. private _afterCameraDraw;
  153476. private _beforeClearStage;
  153477. /**
  153478. * Rebuilds the elements related to this component in case of
  153479. * context lost for instance.
  153480. */
  153481. rebuild(): void;
  153482. /**
  153483. * Disposes the component and the associated ressources
  153484. */
  153485. dispose(): void;
  153486. }
  153487. }
  153488. declare module BABYLON {
  153489. /** @hidden */
  153490. export var fibonacci: {
  153491. name: string;
  153492. shader: string;
  153493. };
  153494. }
  153495. declare module BABYLON {
  153496. /** @hidden */
  153497. export var diffusionProfile: {
  153498. name: string;
  153499. shader: string;
  153500. };
  153501. }
  153502. declare module BABYLON {
  153503. /** @hidden */
  153504. export var subSurfaceScatteringPixelShader: {
  153505. name: string;
  153506. shader: string;
  153507. };
  153508. }
  153509. declare module BABYLON {
  153510. /**
  153511. * Sub surface scattering post process
  153512. */
  153513. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153514. /**
  153515. * Gets a string identifying the name of the class
  153516. * @returns "SubSurfaceScatteringPostProcess" string
  153517. */
  153518. getClassName(): string;
  153519. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153520. }
  153521. }
  153522. declare module BABYLON {
  153523. /**
  153524. * Contains all parameters needed for the prepass to perform
  153525. * screen space subsurface scattering
  153526. */
  153527. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153528. /** @hidden */
  153529. static _SceneComponentInitialization: (scene: Scene) => void;
  153530. private _ssDiffusionS;
  153531. private _ssFilterRadii;
  153532. private _ssDiffusionD;
  153533. /**
  153534. * Post process to attach for screen space subsurface scattering
  153535. */
  153536. postProcess: SubSurfaceScatteringPostProcess;
  153537. /**
  153538. * Diffusion profile color for subsurface scattering
  153539. */
  153540. get ssDiffusionS(): number[];
  153541. /**
  153542. * Diffusion profile max color channel value for subsurface scattering
  153543. */
  153544. get ssDiffusionD(): number[];
  153545. /**
  153546. * Diffusion profile filter radius for subsurface scattering
  153547. */
  153548. get ssFilterRadii(): number[];
  153549. /**
  153550. * Is subsurface enabled
  153551. */
  153552. enabled: boolean;
  153553. /**
  153554. * Name of the configuration
  153555. */
  153556. name: string;
  153557. /**
  153558. * Diffusion profile colors for subsurface scattering
  153559. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153560. * See ...
  153561. * Note that you can only store up to 5 of them
  153562. */
  153563. ssDiffusionProfileColors: Color3[];
  153564. /**
  153565. * Defines the ratio real world => scene units.
  153566. * Used for subsurface scattering
  153567. */
  153568. metersPerUnit: number;
  153569. /**
  153570. * Textures that should be present in the MRT for this effect to work
  153571. */
  153572. readonly texturesRequired: number[];
  153573. private _scene;
  153574. /**
  153575. * Builds a subsurface configuration object
  153576. * @param scene The scene
  153577. */
  153578. constructor(scene: Scene);
  153579. /**
  153580. * Adds a new diffusion profile.
  153581. * Useful for more realistic subsurface scattering on diverse materials.
  153582. * @param color The color of the diffusion profile. Should be the average color of the material.
  153583. * @return The index of the diffusion profile for the material subsurface configuration
  153584. */
  153585. addDiffusionProfile(color: Color3): number;
  153586. /**
  153587. * Creates the sss post process
  153588. * @return The created post process
  153589. */
  153590. createPostProcess(): SubSurfaceScatteringPostProcess;
  153591. /**
  153592. * Deletes all diffusion profiles.
  153593. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153594. */
  153595. clearAllDiffusionProfiles(): void;
  153596. /**
  153597. * Disposes this object
  153598. */
  153599. dispose(): void;
  153600. /**
  153601. * @hidden
  153602. * https://zero-radiance.github.io/post/sampling-diffusion/
  153603. *
  153604. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153605. * ------------------------------------------------------------------------------------
  153606. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153607. * PDF[r, phi, s] = r * R[r, phi, s]
  153608. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153609. * ------------------------------------------------------------------------------------
  153610. * We importance sample the color channel with the widest scattering distance.
  153611. */
  153612. getDiffusionProfileParameters(color: Color3): number;
  153613. /**
  153614. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153615. * 'u' is the random number (the value of the CDF): [0, 1).
  153616. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153617. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153618. */
  153619. private _sampleBurleyDiffusionProfile;
  153620. }
  153621. }
  153622. declare module BABYLON {
  153623. interface AbstractScene {
  153624. /** @hidden (Backing field) */
  153625. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153626. /**
  153627. * Gets or Sets the current prepass renderer associated to the scene.
  153628. */
  153629. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153630. /**
  153631. * Enables the subsurface effect for prepass
  153632. * @returns the SubSurfaceConfiguration
  153633. */
  153634. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153635. /**
  153636. * Disables the subsurface effect for prepass
  153637. */
  153638. disableSubSurfaceForPrePass(): void;
  153639. }
  153640. /**
  153641. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153642. * in several rendering techniques.
  153643. */
  153644. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153645. /**
  153646. * The component name helpful to identify the component in the list of scene components.
  153647. */
  153648. readonly name: string;
  153649. /**
  153650. * The scene the component belongs to.
  153651. */
  153652. scene: Scene;
  153653. /**
  153654. * Creates a new instance of the component for the given scene
  153655. * @param scene Defines the scene to register the component in
  153656. */
  153657. constructor(scene: Scene);
  153658. /**
  153659. * Registers the component in a given scene
  153660. */
  153661. register(): void;
  153662. /**
  153663. * Serializes the component data to the specified json object
  153664. * @param serializationObject The object to serialize to
  153665. */
  153666. serialize(serializationObject: any): void;
  153667. /**
  153668. * Adds all the elements from the container to the scene
  153669. * @param container the container holding the elements
  153670. */
  153671. addFromContainer(container: AbstractScene): void;
  153672. /**
  153673. * Removes all the elements in the container from the scene
  153674. * @param container contains the elements to remove
  153675. * @param dispose if the removed element should be disposed (default: false)
  153676. */
  153677. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153678. /**
  153679. * Rebuilds the elements related to this component in case of
  153680. * context lost for instance.
  153681. */
  153682. rebuild(): void;
  153683. /**
  153684. * Disposes the component and the associated ressources
  153685. */
  153686. dispose(): void;
  153687. }
  153688. }
  153689. declare module BABYLON {
  153690. /** @hidden */
  153691. export var outlinePixelShader: {
  153692. name: string;
  153693. shader: string;
  153694. };
  153695. }
  153696. declare module BABYLON {
  153697. /** @hidden */
  153698. export var outlineVertexShader: {
  153699. name: string;
  153700. shader: string;
  153701. };
  153702. }
  153703. declare module BABYLON {
  153704. interface Scene {
  153705. /** @hidden */
  153706. _outlineRenderer: OutlineRenderer;
  153707. /**
  153708. * Gets the outline renderer associated with the scene
  153709. * @returns a OutlineRenderer
  153710. */
  153711. getOutlineRenderer(): OutlineRenderer;
  153712. }
  153713. interface AbstractMesh {
  153714. /** @hidden (Backing field) */
  153715. _renderOutline: boolean;
  153716. /**
  153717. * Gets or sets a boolean indicating if the outline must be rendered as well
  153718. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153719. */
  153720. renderOutline: boolean;
  153721. /** @hidden (Backing field) */
  153722. _renderOverlay: boolean;
  153723. /**
  153724. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153725. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153726. */
  153727. renderOverlay: boolean;
  153728. }
  153729. /**
  153730. * This class is responsible to draw bothe outline/overlay of meshes.
  153731. * It should not be used directly but through the available method on mesh.
  153732. */
  153733. export class OutlineRenderer implements ISceneComponent {
  153734. /**
  153735. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153736. */
  153737. private static _StencilReference;
  153738. /**
  153739. * The name of the component. Each component must have a unique name.
  153740. */
  153741. name: string;
  153742. /**
  153743. * The scene the component belongs to.
  153744. */
  153745. scene: Scene;
  153746. /**
  153747. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153748. */
  153749. zOffset: number;
  153750. private _engine;
  153751. private _effect;
  153752. private _cachedDefines;
  153753. private _savedDepthWrite;
  153754. /**
  153755. * Instantiates a new outline renderer. (There could be only one per scene).
  153756. * @param scene Defines the scene it belongs to
  153757. */
  153758. constructor(scene: Scene);
  153759. /**
  153760. * Register the component to one instance of a scene.
  153761. */
  153762. register(): void;
  153763. /**
  153764. * Rebuilds the elements related to this component in case of
  153765. * context lost for instance.
  153766. */
  153767. rebuild(): void;
  153768. /**
  153769. * Disposes the component and the associated ressources.
  153770. */
  153771. dispose(): void;
  153772. /**
  153773. * Renders the outline in the canvas.
  153774. * @param subMesh Defines the sumesh to render
  153775. * @param batch Defines the batch of meshes in case of instances
  153776. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153777. */
  153778. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153779. /**
  153780. * Returns whether or not the outline renderer is ready for a given submesh.
  153781. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153782. * @param subMesh Defines the submesh to check readyness for
  153783. * @param useInstances Defines wheter wee are trying to render instances or not
  153784. * @returns true if ready otherwise false
  153785. */
  153786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153787. private _beforeRenderingMesh;
  153788. private _afterRenderingMesh;
  153789. }
  153790. }
  153791. declare module BABYLON {
  153792. /**
  153793. * Defines the basic options interface of a Sprite Frame Source Size.
  153794. */
  153795. export interface ISpriteJSONSpriteSourceSize {
  153796. /**
  153797. * number of the original width of the Frame
  153798. */
  153799. w: number;
  153800. /**
  153801. * number of the original height of the Frame
  153802. */
  153803. h: number;
  153804. }
  153805. /**
  153806. * Defines the basic options interface of a Sprite Frame Data.
  153807. */
  153808. export interface ISpriteJSONSpriteFrameData {
  153809. /**
  153810. * number of the x offset of the Frame
  153811. */
  153812. x: number;
  153813. /**
  153814. * number of the y offset of the Frame
  153815. */
  153816. y: number;
  153817. /**
  153818. * number of the width of the Frame
  153819. */
  153820. w: number;
  153821. /**
  153822. * number of the height of the Frame
  153823. */
  153824. h: number;
  153825. }
  153826. /**
  153827. * Defines the basic options interface of a JSON Sprite.
  153828. */
  153829. export interface ISpriteJSONSprite {
  153830. /**
  153831. * string name of the Frame
  153832. */
  153833. filename: string;
  153834. /**
  153835. * ISpriteJSONSpriteFrame basic object of the frame data
  153836. */
  153837. frame: ISpriteJSONSpriteFrameData;
  153838. /**
  153839. * boolean to flag is the frame was rotated.
  153840. */
  153841. rotated: boolean;
  153842. /**
  153843. * boolean to flag is the frame was trimmed.
  153844. */
  153845. trimmed: boolean;
  153846. /**
  153847. * ISpriteJSONSpriteFrame basic object of the source data
  153848. */
  153849. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153850. /**
  153851. * ISpriteJSONSpriteFrame basic object of the source data
  153852. */
  153853. sourceSize: ISpriteJSONSpriteSourceSize;
  153854. }
  153855. /**
  153856. * Defines the basic options interface of a JSON atlas.
  153857. */
  153858. export interface ISpriteJSONAtlas {
  153859. /**
  153860. * Array of objects that contain the frame data.
  153861. */
  153862. frames: Array<ISpriteJSONSprite>;
  153863. /**
  153864. * object basic object containing the sprite meta data.
  153865. */
  153866. meta?: object;
  153867. }
  153868. }
  153869. declare module BABYLON {
  153870. /** @hidden */
  153871. export var spriteMapPixelShader: {
  153872. name: string;
  153873. shader: string;
  153874. };
  153875. }
  153876. declare module BABYLON {
  153877. /** @hidden */
  153878. export var spriteMapVertexShader: {
  153879. name: string;
  153880. shader: string;
  153881. };
  153882. }
  153883. declare module BABYLON {
  153884. /**
  153885. * Defines the basic options interface of a SpriteMap
  153886. */
  153887. export interface ISpriteMapOptions {
  153888. /**
  153889. * Vector2 of the number of cells in the grid.
  153890. */
  153891. stageSize?: Vector2;
  153892. /**
  153893. * Vector2 of the size of the output plane in World Units.
  153894. */
  153895. outputSize?: Vector2;
  153896. /**
  153897. * Vector3 of the position of the output plane in World Units.
  153898. */
  153899. outputPosition?: Vector3;
  153900. /**
  153901. * Vector3 of the rotation of the output plane.
  153902. */
  153903. outputRotation?: Vector3;
  153904. /**
  153905. * number of layers that the system will reserve in resources.
  153906. */
  153907. layerCount?: number;
  153908. /**
  153909. * number of max animation frames a single cell will reserve in resources.
  153910. */
  153911. maxAnimationFrames?: number;
  153912. /**
  153913. * number cell index of the base tile when the system compiles.
  153914. */
  153915. baseTile?: number;
  153916. /**
  153917. * boolean flip the sprite after its been repositioned by the framing data.
  153918. */
  153919. flipU?: boolean;
  153920. /**
  153921. * Vector3 scalar of the global RGB values of the SpriteMap.
  153922. */
  153923. colorMultiply?: Vector3;
  153924. }
  153925. /**
  153926. * Defines the IDisposable interface in order to be cleanable from resources.
  153927. */
  153928. export interface ISpriteMap extends IDisposable {
  153929. /**
  153930. * String name of the SpriteMap.
  153931. */
  153932. name: string;
  153933. /**
  153934. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153935. */
  153936. atlasJSON: ISpriteJSONAtlas;
  153937. /**
  153938. * Texture of the SpriteMap.
  153939. */
  153940. spriteSheet: Texture;
  153941. /**
  153942. * The parameters to initialize the SpriteMap with.
  153943. */
  153944. options: ISpriteMapOptions;
  153945. }
  153946. /**
  153947. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153948. */
  153949. export class SpriteMap implements ISpriteMap {
  153950. /** The Name of the spriteMap */
  153951. name: string;
  153952. /** The JSON file with the frame and meta data */
  153953. atlasJSON: ISpriteJSONAtlas;
  153954. /** The systems Sprite Sheet Texture */
  153955. spriteSheet: Texture;
  153956. /** Arguments passed with the Constructor */
  153957. options: ISpriteMapOptions;
  153958. /** Public Sprite Storage array, parsed from atlasJSON */
  153959. sprites: Array<ISpriteJSONSprite>;
  153960. /** Returns the Number of Sprites in the System */
  153961. get spriteCount(): number;
  153962. /** Returns the Position of Output Plane*/
  153963. get position(): Vector3;
  153964. /** Returns the Position of Output Plane*/
  153965. set position(v: Vector3);
  153966. /** Returns the Rotation of Output Plane*/
  153967. get rotation(): Vector3;
  153968. /** Returns the Rotation of Output Plane*/
  153969. set rotation(v: Vector3);
  153970. /** Sets the AnimationMap*/
  153971. get animationMap(): RawTexture;
  153972. /** Sets the AnimationMap*/
  153973. set animationMap(v: RawTexture);
  153974. /** Scene that the SpriteMap was created in */
  153975. private _scene;
  153976. /** Texture Buffer of Float32 that holds tile frame data*/
  153977. private _frameMap;
  153978. /** Texture Buffers of Float32 that holds tileMap data*/
  153979. private _tileMaps;
  153980. /** Texture Buffer of Float32 that holds Animation Data*/
  153981. private _animationMap;
  153982. /** Custom ShaderMaterial Central to the System*/
  153983. private _material;
  153984. /** Custom ShaderMaterial Central to the System*/
  153985. private _output;
  153986. /** Systems Time Ticker*/
  153987. private _time;
  153988. /**
  153989. * Creates a new SpriteMap
  153990. * @param name defines the SpriteMaps Name
  153991. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153992. * @param spriteSheet is the Texture that the Sprites are on.
  153993. * @param options a basic deployment configuration
  153994. * @param scene The Scene that the map is deployed on
  153995. */
  153996. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153997. /**
  153998. * Returns tileID location
  153999. * @returns Vector2 the cell position ID
  154000. */
  154001. getTileID(): Vector2;
  154002. /**
  154003. * Gets the UV location of the mouse over the SpriteMap.
  154004. * @returns Vector2 the UV position of the mouse interaction
  154005. */
  154006. getMousePosition(): Vector2;
  154007. /**
  154008. * Creates the "frame" texture Buffer
  154009. * -------------------------------------
  154010. * Structure of frames
  154011. * "filename": "Falling-Water-2.png",
  154012. * "frame": {"x":69,"y":103,"w":24,"h":32},
  154013. * "rotated": true,
  154014. * "trimmed": true,
  154015. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  154016. * "sourceSize": {"w":32,"h":32}
  154017. * @returns RawTexture of the frameMap
  154018. */
  154019. private _createFrameBuffer;
  154020. /**
  154021. * Creates the tileMap texture Buffer
  154022. * @param buffer normally and array of numbers, or a false to generate from scratch
  154023. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  154024. * @returns RawTexture of the tileMap
  154025. */
  154026. private _createTileBuffer;
  154027. /**
  154028. * Modifies the data of the tileMaps
  154029. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  154030. * @param pos is the iVector2 Coordinates of the Tile
  154031. * @param tile The SpriteIndex of the new Tile
  154032. */
  154033. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  154034. /**
  154035. * Creates the animationMap texture Buffer
  154036. * @param buffer normally and array of numbers, or a false to generate from scratch
  154037. * @returns RawTexture of the animationMap
  154038. */
  154039. private _createTileAnimationBuffer;
  154040. /**
  154041. * Modifies the data of the animationMap
  154042. * @param cellID is the Index of the Sprite
  154043. * @param _frame is the target Animation frame
  154044. * @param toCell is the Target Index of the next frame of the animation
  154045. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  154046. * @param speed is a global scalar of the time variable on the map.
  154047. */
  154048. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  154049. /**
  154050. * Exports the .tilemaps file
  154051. */
  154052. saveTileMaps(): void;
  154053. /**
  154054. * Imports the .tilemaps file
  154055. * @param url of the .tilemaps file
  154056. */
  154057. loadTileMaps(url: string): void;
  154058. /**
  154059. * Release associated resources
  154060. */
  154061. dispose(): void;
  154062. }
  154063. }
  154064. declare module BABYLON {
  154065. /**
  154066. * Class used to manage multiple sprites of different sizes on the same spritesheet
  154067. * @see https://doc.babylonjs.com/babylon101/sprites
  154068. */
  154069. export class SpritePackedManager extends SpriteManager {
  154070. /** defines the packed manager's name */
  154071. name: string;
  154072. /**
  154073. * Creates a new sprite manager from a packed sprite sheet
  154074. * @param name defines the manager's name
  154075. * @param imgUrl defines the sprite sheet url
  154076. * @param capacity defines the maximum allowed number of sprites
  154077. * @param scene defines the hosting scene
  154078. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154079. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154080. * @param samplingMode defines the smapling mode to use with spritesheet
  154081. * @param fromPacked set to true; do not alter
  154082. */
  154083. constructor(
  154084. /** defines the packed manager's name */
  154085. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154086. }
  154087. }
  154088. declare module BABYLON {
  154089. /**
  154090. * Defines the list of states available for a task inside a AssetsManager
  154091. */
  154092. export enum AssetTaskState {
  154093. /**
  154094. * Initialization
  154095. */
  154096. INIT = 0,
  154097. /**
  154098. * Running
  154099. */
  154100. RUNNING = 1,
  154101. /**
  154102. * Done
  154103. */
  154104. DONE = 2,
  154105. /**
  154106. * Error
  154107. */
  154108. ERROR = 3
  154109. }
  154110. /**
  154111. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154112. */
  154113. export abstract class AbstractAssetTask {
  154114. /**
  154115. * Task name
  154116. */ name: string;
  154117. /**
  154118. * Callback called when the task is successful
  154119. */
  154120. onSuccess: (task: any) => void;
  154121. /**
  154122. * Callback called when the task is not successful
  154123. */
  154124. onError: (task: any, message?: string, exception?: any) => void;
  154125. /**
  154126. * Creates a new AssetsManager
  154127. * @param name defines the name of the task
  154128. */
  154129. constructor(
  154130. /**
  154131. * Task name
  154132. */ name: string);
  154133. private _isCompleted;
  154134. private _taskState;
  154135. private _errorObject;
  154136. /**
  154137. * Get if the task is completed
  154138. */
  154139. get isCompleted(): boolean;
  154140. /**
  154141. * Gets the current state of the task
  154142. */
  154143. get taskState(): AssetTaskState;
  154144. /**
  154145. * Gets the current error object (if task is in error)
  154146. */
  154147. get errorObject(): {
  154148. message?: string;
  154149. exception?: any;
  154150. };
  154151. /**
  154152. * Internal only
  154153. * @hidden
  154154. */
  154155. _setErrorObject(message?: string, exception?: any): void;
  154156. /**
  154157. * Execute the current task
  154158. * @param scene defines the scene where you want your assets to be loaded
  154159. * @param onSuccess is a callback called when the task is successfully executed
  154160. * @param onError is a callback called if an error occurs
  154161. */
  154162. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154163. /**
  154164. * Execute the current task
  154165. * @param scene defines the scene where you want your assets to be loaded
  154166. * @param onSuccess is a callback called when the task is successfully executed
  154167. * @param onError is a callback called if an error occurs
  154168. */
  154169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154170. /**
  154171. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154172. * This can be used with failed tasks that have the reason for failure fixed.
  154173. */
  154174. reset(): void;
  154175. private onErrorCallback;
  154176. private onDoneCallback;
  154177. }
  154178. /**
  154179. * Define the interface used by progress events raised during assets loading
  154180. */
  154181. export interface IAssetsProgressEvent {
  154182. /**
  154183. * Defines the number of remaining tasks to process
  154184. */
  154185. remainingCount: number;
  154186. /**
  154187. * Defines the total number of tasks
  154188. */
  154189. totalCount: number;
  154190. /**
  154191. * Defines the task that was just processed
  154192. */
  154193. task: AbstractAssetTask;
  154194. }
  154195. /**
  154196. * Class used to share progress information about assets loading
  154197. */
  154198. export class AssetsProgressEvent implements IAssetsProgressEvent {
  154199. /**
  154200. * Defines the number of remaining tasks to process
  154201. */
  154202. remainingCount: number;
  154203. /**
  154204. * Defines the total number of tasks
  154205. */
  154206. totalCount: number;
  154207. /**
  154208. * Defines the task that was just processed
  154209. */
  154210. task: AbstractAssetTask;
  154211. /**
  154212. * Creates a AssetsProgressEvent
  154213. * @param remainingCount defines the number of remaining tasks to process
  154214. * @param totalCount defines the total number of tasks
  154215. * @param task defines the task that was just processed
  154216. */
  154217. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154218. }
  154219. /**
  154220. * Define a task used by AssetsManager to load assets into a container
  154221. */
  154222. export class ContainerAssetTask extends AbstractAssetTask {
  154223. /**
  154224. * Defines the name of the task
  154225. */
  154226. name: string;
  154227. /**
  154228. * Defines the list of mesh's names you want to load
  154229. */
  154230. meshesNames: any;
  154231. /**
  154232. * Defines the root url to use as a base to load your meshes and associated resources
  154233. */
  154234. rootUrl: string;
  154235. /**
  154236. * Defines the filename or File of the scene to load from
  154237. */
  154238. sceneFilename: string | File;
  154239. /**
  154240. * Get the loaded asset container
  154241. */
  154242. loadedContainer: AssetContainer;
  154243. /**
  154244. * Gets the list of loaded meshes
  154245. */
  154246. loadedMeshes: Array<AbstractMesh>;
  154247. /**
  154248. * Gets the list of loaded particle systems
  154249. */
  154250. loadedParticleSystems: Array<IParticleSystem>;
  154251. /**
  154252. * Gets the list of loaded skeletons
  154253. */
  154254. loadedSkeletons: Array<Skeleton>;
  154255. /**
  154256. * Gets the list of loaded animation groups
  154257. */
  154258. loadedAnimationGroups: Array<AnimationGroup>;
  154259. /**
  154260. * Callback called when the task is successful
  154261. */
  154262. onSuccess: (task: ContainerAssetTask) => void;
  154263. /**
  154264. * Callback called when the task is successful
  154265. */
  154266. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154267. /**
  154268. * Creates a new ContainerAssetTask
  154269. * @param name defines the name of the task
  154270. * @param meshesNames defines the list of mesh's names you want to load
  154271. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154272. * @param sceneFilename defines the filename or File of the scene to load from
  154273. */
  154274. constructor(
  154275. /**
  154276. * Defines the name of the task
  154277. */
  154278. name: string,
  154279. /**
  154280. * Defines the list of mesh's names you want to load
  154281. */
  154282. meshesNames: any,
  154283. /**
  154284. * Defines the root url to use as a base to load your meshes and associated resources
  154285. */
  154286. rootUrl: string,
  154287. /**
  154288. * Defines the filename or File of the scene to load from
  154289. */
  154290. sceneFilename: string | File);
  154291. /**
  154292. * Execute the current task
  154293. * @param scene defines the scene where you want your assets to be loaded
  154294. * @param onSuccess is a callback called when the task is successfully executed
  154295. * @param onError is a callback called if an error occurs
  154296. */
  154297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154298. }
  154299. /**
  154300. * Define a task used by AssetsManager to load meshes
  154301. */
  154302. export class MeshAssetTask extends AbstractAssetTask {
  154303. /**
  154304. * Defines the name of the task
  154305. */
  154306. name: string;
  154307. /**
  154308. * Defines the list of mesh's names you want to load
  154309. */
  154310. meshesNames: any;
  154311. /**
  154312. * Defines the root url to use as a base to load your meshes and associated resources
  154313. */
  154314. rootUrl: string;
  154315. /**
  154316. * Defines the filename or File of the scene to load from
  154317. */
  154318. sceneFilename: string | File;
  154319. /**
  154320. * Gets the list of loaded meshes
  154321. */
  154322. loadedMeshes: Array<AbstractMesh>;
  154323. /**
  154324. * Gets the list of loaded particle systems
  154325. */
  154326. loadedParticleSystems: Array<IParticleSystem>;
  154327. /**
  154328. * Gets the list of loaded skeletons
  154329. */
  154330. loadedSkeletons: Array<Skeleton>;
  154331. /**
  154332. * Gets the list of loaded animation groups
  154333. */
  154334. loadedAnimationGroups: Array<AnimationGroup>;
  154335. /**
  154336. * Callback called when the task is successful
  154337. */
  154338. onSuccess: (task: MeshAssetTask) => void;
  154339. /**
  154340. * Callback called when the task is successful
  154341. */
  154342. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154343. /**
  154344. * Creates a new MeshAssetTask
  154345. * @param name defines the name of the task
  154346. * @param meshesNames defines the list of mesh's names you want to load
  154347. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154348. * @param sceneFilename defines the filename or File of the scene to load from
  154349. */
  154350. constructor(
  154351. /**
  154352. * Defines the name of the task
  154353. */
  154354. name: string,
  154355. /**
  154356. * Defines the list of mesh's names you want to load
  154357. */
  154358. meshesNames: any,
  154359. /**
  154360. * Defines the root url to use as a base to load your meshes and associated resources
  154361. */
  154362. rootUrl: string,
  154363. /**
  154364. * Defines the filename or File of the scene to load from
  154365. */
  154366. sceneFilename: string | File);
  154367. /**
  154368. * Execute the current task
  154369. * @param scene defines the scene where you want your assets to be loaded
  154370. * @param onSuccess is a callback called when the task is successfully executed
  154371. * @param onError is a callback called if an error occurs
  154372. */
  154373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154374. }
  154375. /**
  154376. * Define a task used by AssetsManager to load text content
  154377. */
  154378. export class TextFileAssetTask extends AbstractAssetTask {
  154379. /**
  154380. * Defines the name of the task
  154381. */
  154382. name: string;
  154383. /**
  154384. * Defines the location of the file to load
  154385. */
  154386. url: string;
  154387. /**
  154388. * Gets the loaded text string
  154389. */
  154390. text: string;
  154391. /**
  154392. * Callback called when the task is successful
  154393. */
  154394. onSuccess: (task: TextFileAssetTask) => void;
  154395. /**
  154396. * Callback called when the task is successful
  154397. */
  154398. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154399. /**
  154400. * Creates a new TextFileAssetTask object
  154401. * @param name defines the name of the task
  154402. * @param url defines the location of the file to load
  154403. */
  154404. constructor(
  154405. /**
  154406. * Defines the name of the task
  154407. */
  154408. name: string,
  154409. /**
  154410. * Defines the location of the file to load
  154411. */
  154412. url: string);
  154413. /**
  154414. * Execute the current task
  154415. * @param scene defines the scene where you want your assets to be loaded
  154416. * @param onSuccess is a callback called when the task is successfully executed
  154417. * @param onError is a callback called if an error occurs
  154418. */
  154419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154420. }
  154421. /**
  154422. * Define a task used by AssetsManager to load binary data
  154423. */
  154424. export class BinaryFileAssetTask extends AbstractAssetTask {
  154425. /**
  154426. * Defines the name of the task
  154427. */
  154428. name: string;
  154429. /**
  154430. * Defines the location of the file to load
  154431. */
  154432. url: string;
  154433. /**
  154434. * Gets the lodaded data (as an array buffer)
  154435. */
  154436. data: ArrayBuffer;
  154437. /**
  154438. * Callback called when the task is successful
  154439. */
  154440. onSuccess: (task: BinaryFileAssetTask) => void;
  154441. /**
  154442. * Callback called when the task is successful
  154443. */
  154444. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154445. /**
  154446. * Creates a new BinaryFileAssetTask object
  154447. * @param name defines the name of the new task
  154448. * @param url defines the location of the file to load
  154449. */
  154450. constructor(
  154451. /**
  154452. * Defines the name of the task
  154453. */
  154454. name: string,
  154455. /**
  154456. * Defines the location of the file to load
  154457. */
  154458. url: string);
  154459. /**
  154460. * Execute the current task
  154461. * @param scene defines the scene where you want your assets to be loaded
  154462. * @param onSuccess is a callback called when the task is successfully executed
  154463. * @param onError is a callback called if an error occurs
  154464. */
  154465. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154466. }
  154467. /**
  154468. * Define a task used by AssetsManager to load images
  154469. */
  154470. export class ImageAssetTask extends AbstractAssetTask {
  154471. /**
  154472. * Defines the name of the task
  154473. */
  154474. name: string;
  154475. /**
  154476. * Defines the location of the image to load
  154477. */
  154478. url: string;
  154479. /**
  154480. * Gets the loaded images
  154481. */
  154482. image: HTMLImageElement;
  154483. /**
  154484. * Callback called when the task is successful
  154485. */
  154486. onSuccess: (task: ImageAssetTask) => void;
  154487. /**
  154488. * Callback called when the task is successful
  154489. */
  154490. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154491. /**
  154492. * Creates a new ImageAssetTask
  154493. * @param name defines the name of the task
  154494. * @param url defines the location of the image to load
  154495. */
  154496. constructor(
  154497. /**
  154498. * Defines the name of the task
  154499. */
  154500. name: string,
  154501. /**
  154502. * Defines the location of the image to load
  154503. */
  154504. url: string);
  154505. /**
  154506. * Execute the current task
  154507. * @param scene defines the scene where you want your assets to be loaded
  154508. * @param onSuccess is a callback called when the task is successfully executed
  154509. * @param onError is a callback called if an error occurs
  154510. */
  154511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154512. }
  154513. /**
  154514. * Defines the interface used by texture loading tasks
  154515. */
  154516. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154517. /**
  154518. * Gets the loaded texture
  154519. */
  154520. texture: TEX;
  154521. }
  154522. /**
  154523. * Define a task used by AssetsManager to load 2D textures
  154524. */
  154525. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154526. /**
  154527. * Defines the name of the task
  154528. */
  154529. name: string;
  154530. /**
  154531. * Defines the location of the file to load
  154532. */
  154533. url: string;
  154534. /**
  154535. * Defines if mipmap should not be generated (default is false)
  154536. */
  154537. noMipmap?: boolean | undefined;
  154538. /**
  154539. * Defines if texture must be inverted on Y axis (default is true)
  154540. */
  154541. invertY: boolean;
  154542. /**
  154543. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154544. */
  154545. samplingMode: number;
  154546. /**
  154547. * Gets the loaded texture
  154548. */
  154549. texture: Texture;
  154550. /**
  154551. * Callback called when the task is successful
  154552. */
  154553. onSuccess: (task: TextureAssetTask) => void;
  154554. /**
  154555. * Callback called when the task is successful
  154556. */
  154557. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154558. /**
  154559. * Creates a new TextureAssetTask object
  154560. * @param name defines the name of the task
  154561. * @param url defines the location of the file to load
  154562. * @param noMipmap defines if mipmap should not be generated (default is false)
  154563. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154564. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154565. */
  154566. constructor(
  154567. /**
  154568. * Defines the name of the task
  154569. */
  154570. name: string,
  154571. /**
  154572. * Defines the location of the file to load
  154573. */
  154574. url: string,
  154575. /**
  154576. * Defines if mipmap should not be generated (default is false)
  154577. */
  154578. noMipmap?: boolean | undefined,
  154579. /**
  154580. * Defines if texture must be inverted on Y axis (default is true)
  154581. */
  154582. invertY?: boolean,
  154583. /**
  154584. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154585. */
  154586. samplingMode?: number);
  154587. /**
  154588. * Execute the current task
  154589. * @param scene defines the scene where you want your assets to be loaded
  154590. * @param onSuccess is a callback called when the task is successfully executed
  154591. * @param onError is a callback called if an error occurs
  154592. */
  154593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154594. }
  154595. /**
  154596. * Define a task used by AssetsManager to load cube textures
  154597. */
  154598. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154599. /**
  154600. * Defines the name of the task
  154601. */
  154602. name: string;
  154603. /**
  154604. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154605. */
  154606. url: string;
  154607. /**
  154608. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154609. */
  154610. extensions?: string[] | undefined;
  154611. /**
  154612. * Defines if mipmaps should not be generated (default is false)
  154613. */
  154614. noMipmap?: boolean | undefined;
  154615. /**
  154616. * Defines the explicit list of files (undefined by default)
  154617. */
  154618. files?: string[] | undefined;
  154619. /**
  154620. * Gets the loaded texture
  154621. */
  154622. texture: CubeTexture;
  154623. /**
  154624. * Callback called when the task is successful
  154625. */
  154626. onSuccess: (task: CubeTextureAssetTask) => void;
  154627. /**
  154628. * Callback called when the task is successful
  154629. */
  154630. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154631. /**
  154632. * Creates a new CubeTextureAssetTask
  154633. * @param name defines the name of the task
  154634. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154635. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154636. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154637. * @param files defines the explicit list of files (undefined by default)
  154638. */
  154639. constructor(
  154640. /**
  154641. * Defines the name of the task
  154642. */
  154643. name: string,
  154644. /**
  154645. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154646. */
  154647. url: string,
  154648. /**
  154649. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154650. */
  154651. extensions?: string[] | undefined,
  154652. /**
  154653. * Defines if mipmaps should not be generated (default is false)
  154654. */
  154655. noMipmap?: boolean | undefined,
  154656. /**
  154657. * Defines the explicit list of files (undefined by default)
  154658. */
  154659. files?: string[] | undefined);
  154660. /**
  154661. * Execute the current task
  154662. * @param scene defines the scene where you want your assets to be loaded
  154663. * @param onSuccess is a callback called when the task is successfully executed
  154664. * @param onError is a callback called if an error occurs
  154665. */
  154666. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154667. }
  154668. /**
  154669. * Define a task used by AssetsManager to load HDR cube textures
  154670. */
  154671. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154672. /**
  154673. * Defines the name of the task
  154674. */
  154675. name: string;
  154676. /**
  154677. * Defines the location of the file to load
  154678. */
  154679. url: string;
  154680. /**
  154681. * Defines the desired size (the more it increases the longer the generation will be)
  154682. */
  154683. size: number;
  154684. /**
  154685. * Defines if mipmaps should not be generated (default is false)
  154686. */
  154687. noMipmap: boolean;
  154688. /**
  154689. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154690. */
  154691. generateHarmonics: boolean;
  154692. /**
  154693. * 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)
  154694. */
  154695. gammaSpace: boolean;
  154696. /**
  154697. * Internal Use Only
  154698. */
  154699. reserved: boolean;
  154700. /**
  154701. * Gets the loaded texture
  154702. */
  154703. texture: HDRCubeTexture;
  154704. /**
  154705. * Callback called when the task is successful
  154706. */
  154707. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154708. /**
  154709. * Callback called when the task is successful
  154710. */
  154711. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154712. /**
  154713. * Creates a new HDRCubeTextureAssetTask object
  154714. * @param name defines the name of the task
  154715. * @param url defines the location of the file to load
  154716. * @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.
  154717. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154718. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154719. * @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)
  154720. * @param reserved Internal use only
  154721. */
  154722. constructor(
  154723. /**
  154724. * Defines the name of the task
  154725. */
  154726. name: string,
  154727. /**
  154728. * Defines the location of the file to load
  154729. */
  154730. url: string,
  154731. /**
  154732. * Defines the desired size (the more it increases the longer the generation will be)
  154733. */
  154734. size: number,
  154735. /**
  154736. * Defines if mipmaps should not be generated (default is false)
  154737. */
  154738. noMipmap?: boolean,
  154739. /**
  154740. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154741. */
  154742. generateHarmonics?: boolean,
  154743. /**
  154744. * 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)
  154745. */
  154746. gammaSpace?: boolean,
  154747. /**
  154748. * Internal Use Only
  154749. */
  154750. reserved?: boolean);
  154751. /**
  154752. * Execute the current task
  154753. * @param scene defines the scene where you want your assets to be loaded
  154754. * @param onSuccess is a callback called when the task is successfully executed
  154755. * @param onError is a callback called if an error occurs
  154756. */
  154757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154758. }
  154759. /**
  154760. * Define a task used by AssetsManager to load Equirectangular cube textures
  154761. */
  154762. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154763. /**
  154764. * Defines the name of the task
  154765. */
  154766. name: string;
  154767. /**
  154768. * Defines the location of the file to load
  154769. */
  154770. url: string;
  154771. /**
  154772. * Defines the desired size (the more it increases the longer the generation will be)
  154773. */
  154774. size: number;
  154775. /**
  154776. * Defines if mipmaps should not be generated (default is false)
  154777. */
  154778. noMipmap: boolean;
  154779. /**
  154780. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154781. * but the standard material would require them in Gamma space) (default is true)
  154782. */
  154783. gammaSpace: boolean;
  154784. /**
  154785. * Gets the loaded texture
  154786. */
  154787. texture: EquiRectangularCubeTexture;
  154788. /**
  154789. * Callback called when the task is successful
  154790. */
  154791. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154792. /**
  154793. * Callback called when the task is successful
  154794. */
  154795. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154796. /**
  154797. * Creates a new EquiRectangularCubeTextureAssetTask object
  154798. * @param name defines the name of the task
  154799. * @param url defines the location of the file to load
  154800. * @param size defines the desired size (the more it increases the longer the generation will be)
  154801. * If the size is omitted this implies you are using a preprocessed cubemap.
  154802. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154803. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154804. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154805. * (default is true)
  154806. */
  154807. constructor(
  154808. /**
  154809. * Defines the name of the task
  154810. */
  154811. name: string,
  154812. /**
  154813. * Defines the location of the file to load
  154814. */
  154815. url: string,
  154816. /**
  154817. * Defines the desired size (the more it increases the longer the generation will be)
  154818. */
  154819. size: number,
  154820. /**
  154821. * Defines if mipmaps should not be generated (default is false)
  154822. */
  154823. noMipmap?: boolean,
  154824. /**
  154825. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154826. * but the standard material would require them in Gamma space) (default is true)
  154827. */
  154828. gammaSpace?: boolean);
  154829. /**
  154830. * Execute the current task
  154831. * @param scene defines the scene where you want your assets to be loaded
  154832. * @param onSuccess is a callback called when the task is successfully executed
  154833. * @param onError is a callback called if an error occurs
  154834. */
  154835. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154836. }
  154837. /**
  154838. * This class can be used to easily import assets into a scene
  154839. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154840. */
  154841. export class AssetsManager {
  154842. private _scene;
  154843. private _isLoading;
  154844. protected _tasks: AbstractAssetTask[];
  154845. protected _waitingTasksCount: number;
  154846. protected _totalTasksCount: number;
  154847. /**
  154848. * Callback called when all tasks are processed
  154849. */
  154850. onFinish: (tasks: AbstractAssetTask[]) => void;
  154851. /**
  154852. * Callback called when a task is successful
  154853. */
  154854. onTaskSuccess: (task: AbstractAssetTask) => void;
  154855. /**
  154856. * Callback called when a task had an error
  154857. */
  154858. onTaskError: (task: AbstractAssetTask) => void;
  154859. /**
  154860. * Callback called when a task is done (whatever the result is)
  154861. */
  154862. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154863. /**
  154864. * Observable called when all tasks are processed
  154865. */
  154866. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154867. /**
  154868. * Observable called when a task had an error
  154869. */
  154870. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154871. /**
  154872. * Observable called when all tasks were executed
  154873. */
  154874. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154875. /**
  154876. * Observable called when a task is done (whatever the result is)
  154877. */
  154878. onProgressObservable: Observable<IAssetsProgressEvent>;
  154879. /**
  154880. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154881. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154882. */
  154883. useDefaultLoadingScreen: boolean;
  154884. /**
  154885. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154886. * when all assets have been downloaded.
  154887. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154888. */
  154889. autoHideLoadingUI: boolean;
  154890. /**
  154891. * Creates a new AssetsManager
  154892. * @param scene defines the scene to work on
  154893. */
  154894. constructor(scene: Scene);
  154895. /**
  154896. * Add a ContainerAssetTask to the list of active tasks
  154897. * @param taskName defines the name of the new task
  154898. * @param meshesNames defines the name of meshes to load
  154899. * @param rootUrl defines the root url to use to locate files
  154900. * @param sceneFilename defines the filename of the scene file
  154901. * @returns a new ContainerAssetTask object
  154902. */
  154903. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154904. /**
  154905. * Add a MeshAssetTask to the list of active tasks
  154906. * @param taskName defines the name of the new task
  154907. * @param meshesNames defines the name of meshes to load
  154908. * @param rootUrl defines the root url to use to locate files
  154909. * @param sceneFilename defines the filename of the scene file
  154910. * @returns a new MeshAssetTask object
  154911. */
  154912. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154913. /**
  154914. * Add a TextFileAssetTask to the list of active tasks
  154915. * @param taskName defines the name of the new task
  154916. * @param url defines the url of the file to load
  154917. * @returns a new TextFileAssetTask object
  154918. */
  154919. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154920. /**
  154921. * Add a BinaryFileAssetTask to the list of active tasks
  154922. * @param taskName defines the name of the new task
  154923. * @param url defines the url of the file to load
  154924. * @returns a new BinaryFileAssetTask object
  154925. */
  154926. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154927. /**
  154928. * Add a ImageAssetTask to the list of active tasks
  154929. * @param taskName defines the name of the new task
  154930. * @param url defines the url of the file to load
  154931. * @returns a new ImageAssetTask object
  154932. */
  154933. addImageTask(taskName: string, url: string): ImageAssetTask;
  154934. /**
  154935. * Add a TextureAssetTask to the list of active tasks
  154936. * @param taskName defines the name of the new task
  154937. * @param url defines the url of the file to load
  154938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154939. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154940. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154941. * @returns a new TextureAssetTask object
  154942. */
  154943. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154944. /**
  154945. * Add a CubeTextureAssetTask to the list of active tasks
  154946. * @param taskName defines the name of the new task
  154947. * @param url defines the url of the file to load
  154948. * @param extensions defines the extension to use to load the cube map (can be null)
  154949. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154950. * @param files defines the list of files to load (can be null)
  154951. * @returns a new CubeTextureAssetTask object
  154952. */
  154953. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154954. /**
  154955. *
  154956. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154957. * @param taskName defines the name of the new task
  154958. * @param url defines the url of the file to load
  154959. * @param size defines the size you want for the cubemap (can be null)
  154960. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154961. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154962. * @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)
  154963. * @param reserved Internal use only
  154964. * @returns a new HDRCubeTextureAssetTask object
  154965. */
  154966. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154967. /**
  154968. *
  154969. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154970. * @param taskName defines the name of the new task
  154971. * @param url defines the url of the file to load
  154972. * @param size defines the size you want for the cubemap (can be null)
  154973. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154974. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154975. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154976. * @returns a new EquiRectangularCubeTextureAssetTask object
  154977. */
  154978. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154979. /**
  154980. * Remove a task from the assets manager.
  154981. * @param task the task to remove
  154982. */
  154983. removeTask(task: AbstractAssetTask): void;
  154984. private _decreaseWaitingTasksCount;
  154985. private _runTask;
  154986. /**
  154987. * Reset the AssetsManager and remove all tasks
  154988. * @return the current instance of the AssetsManager
  154989. */
  154990. reset(): AssetsManager;
  154991. /**
  154992. * Start the loading process
  154993. * @return the current instance of the AssetsManager
  154994. */
  154995. load(): AssetsManager;
  154996. /**
  154997. * Start the loading process as an async operation
  154998. * @return a promise returning the list of failed tasks
  154999. */
  155000. loadAsync(): Promise<void>;
  155001. }
  155002. }
  155003. declare module BABYLON {
  155004. /**
  155005. * Wrapper class for promise with external resolve and reject.
  155006. */
  155007. export class Deferred<T> {
  155008. /**
  155009. * The promise associated with this deferred object.
  155010. */
  155011. readonly promise: Promise<T>;
  155012. private _resolve;
  155013. private _reject;
  155014. /**
  155015. * The resolve method of the promise associated with this deferred object.
  155016. */
  155017. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  155018. /**
  155019. * The reject method of the promise associated with this deferred object.
  155020. */
  155021. get reject(): (reason?: any) => void;
  155022. /**
  155023. * Constructor for this deferred object.
  155024. */
  155025. constructor();
  155026. }
  155027. }
  155028. declare module BABYLON {
  155029. /**
  155030. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  155031. */
  155032. export class MeshExploder {
  155033. private _centerMesh;
  155034. private _meshes;
  155035. private _meshesOrigins;
  155036. private _toCenterVectors;
  155037. private _scaledDirection;
  155038. private _newPosition;
  155039. private _centerPosition;
  155040. /**
  155041. * Explodes meshes from a center mesh.
  155042. * @param meshes The meshes to explode.
  155043. * @param centerMesh The mesh to be center of explosion.
  155044. */
  155045. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  155046. private _setCenterMesh;
  155047. /**
  155048. * Get class name
  155049. * @returns "MeshExploder"
  155050. */
  155051. getClassName(): string;
  155052. /**
  155053. * "Exploded meshes"
  155054. * @returns Array of meshes with the centerMesh at index 0.
  155055. */
  155056. getMeshes(): Array<Mesh>;
  155057. /**
  155058. * Explodes meshes giving a specific direction
  155059. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  155060. */
  155061. explode(direction?: number): void;
  155062. }
  155063. }
  155064. declare module BABYLON {
  155065. /**
  155066. * Class used to help managing file picking and drag'n'drop
  155067. */
  155068. export class FilesInput {
  155069. /**
  155070. * List of files ready to be loaded
  155071. */
  155072. static get FilesToLoad(): {
  155073. [key: string]: File;
  155074. };
  155075. /**
  155076. * Callback called when a file is processed
  155077. */
  155078. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155079. private _engine;
  155080. private _currentScene;
  155081. private _sceneLoadedCallback;
  155082. private _progressCallback;
  155083. private _additionalRenderLoopLogicCallback;
  155084. private _textureLoadingCallback;
  155085. private _startingProcessingFilesCallback;
  155086. private _onReloadCallback;
  155087. private _errorCallback;
  155088. private _elementToMonitor;
  155089. private _sceneFileToLoad;
  155090. private _filesToLoad;
  155091. /**
  155092. * Creates a new FilesInput
  155093. * @param engine defines the rendering engine
  155094. * @param scene defines the hosting scene
  155095. * @param sceneLoadedCallback callback called when scene is loaded
  155096. * @param progressCallback callback called to track progress
  155097. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155098. * @param textureLoadingCallback callback called when a texture is loading
  155099. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155100. * @param onReloadCallback callback called when a reload is requested
  155101. * @param errorCallback callback call if an error occurs
  155102. */
  155103. 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>);
  155104. private _dragEnterHandler;
  155105. private _dragOverHandler;
  155106. private _dropHandler;
  155107. /**
  155108. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155109. * @param elementToMonitor defines the DOM element to track
  155110. */
  155111. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155112. /** Gets the current list of files to load */
  155113. get filesToLoad(): File[];
  155114. /**
  155115. * Release all associated resources
  155116. */
  155117. dispose(): void;
  155118. private renderFunction;
  155119. private drag;
  155120. private drop;
  155121. private _traverseFolder;
  155122. private _processFiles;
  155123. /**
  155124. * Load files from a drop event
  155125. * @param event defines the drop event to use as source
  155126. */
  155127. loadFiles(event: any): void;
  155128. private _processReload;
  155129. /**
  155130. * Reload the current scene from the loaded files
  155131. */
  155132. reload(): void;
  155133. }
  155134. }
  155135. declare module BABYLON {
  155136. /**
  155137. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155138. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155139. */
  155140. export class SceneOptimization {
  155141. /**
  155142. * Defines the priority of this optimization (0 by default which means first in the list)
  155143. */
  155144. priority: number;
  155145. /**
  155146. * Gets a string describing the action executed by the current optimization
  155147. * @returns description string
  155148. */
  155149. getDescription(): string;
  155150. /**
  155151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155152. * @param scene defines the current scene where to apply this optimization
  155153. * @param optimizer defines the current optimizer
  155154. * @returns true if everything that can be done was applied
  155155. */
  155156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155157. /**
  155158. * Creates the SceneOptimization object
  155159. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155160. * @param desc defines the description associated with the optimization
  155161. */
  155162. constructor(
  155163. /**
  155164. * Defines the priority of this optimization (0 by default which means first in the list)
  155165. */
  155166. priority?: number);
  155167. }
  155168. /**
  155169. * Defines an optimization used to reduce the size of render target textures
  155170. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155171. */
  155172. export class TextureOptimization extends SceneOptimization {
  155173. /**
  155174. * Defines the priority of this optimization (0 by default which means first in the list)
  155175. */
  155176. priority: number;
  155177. /**
  155178. * 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
  155179. */
  155180. maximumSize: number;
  155181. /**
  155182. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155183. */
  155184. step: number;
  155185. /**
  155186. * Gets a string describing the action executed by the current optimization
  155187. * @returns description string
  155188. */
  155189. getDescription(): string;
  155190. /**
  155191. * Creates the TextureOptimization object
  155192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155193. * @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
  155194. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155195. */
  155196. constructor(
  155197. /**
  155198. * Defines the priority of this optimization (0 by default which means first in the list)
  155199. */
  155200. priority?: number,
  155201. /**
  155202. * 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
  155203. */
  155204. maximumSize?: number,
  155205. /**
  155206. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155207. */
  155208. step?: number);
  155209. /**
  155210. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155211. * @param scene defines the current scene where to apply this optimization
  155212. * @param optimizer defines the current optimizer
  155213. * @returns true if everything that can be done was applied
  155214. */
  155215. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155216. }
  155217. /**
  155218. * Defines an optimization used to increase or decrease the rendering resolution
  155219. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155220. */
  155221. export class HardwareScalingOptimization extends SceneOptimization {
  155222. /**
  155223. * Defines the priority of this optimization (0 by default which means first in the list)
  155224. */
  155225. priority: number;
  155226. /**
  155227. * Defines the maximum scale to use (2 by default)
  155228. */
  155229. maximumScale: number;
  155230. /**
  155231. * Defines the step to use between two passes (0.5 by default)
  155232. */
  155233. step: number;
  155234. private _currentScale;
  155235. private _directionOffset;
  155236. /**
  155237. * Gets a string describing the action executed by the current optimization
  155238. * @return description string
  155239. */
  155240. getDescription(): string;
  155241. /**
  155242. * Creates the HardwareScalingOptimization object
  155243. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155244. * @param maximumScale defines the maximum scale to use (2 by default)
  155245. * @param step defines the step to use between two passes (0.5 by default)
  155246. */
  155247. constructor(
  155248. /**
  155249. * Defines the priority of this optimization (0 by default which means first in the list)
  155250. */
  155251. priority?: number,
  155252. /**
  155253. * Defines the maximum scale to use (2 by default)
  155254. */
  155255. maximumScale?: number,
  155256. /**
  155257. * Defines the step to use between two passes (0.5 by default)
  155258. */
  155259. step?: number);
  155260. /**
  155261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155262. * @param scene defines the current scene where to apply this optimization
  155263. * @param optimizer defines the current optimizer
  155264. * @returns true if everything that can be done was applied
  155265. */
  155266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155267. }
  155268. /**
  155269. * Defines an optimization used to remove shadows
  155270. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155271. */
  155272. export class ShadowsOptimization extends SceneOptimization {
  155273. /**
  155274. * Gets a string describing the action executed by the current optimization
  155275. * @return description string
  155276. */
  155277. getDescription(): string;
  155278. /**
  155279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155280. * @param scene defines the current scene where to apply this optimization
  155281. * @param optimizer defines the current optimizer
  155282. * @returns true if everything that can be done was applied
  155283. */
  155284. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155285. }
  155286. /**
  155287. * Defines an optimization used to turn post-processes off
  155288. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155289. */
  155290. export class PostProcessesOptimization extends SceneOptimization {
  155291. /**
  155292. * Gets a string describing the action executed by the current optimization
  155293. * @return description string
  155294. */
  155295. getDescription(): string;
  155296. /**
  155297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155298. * @param scene defines the current scene where to apply this optimization
  155299. * @param optimizer defines the current optimizer
  155300. * @returns true if everything that can be done was applied
  155301. */
  155302. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155303. }
  155304. /**
  155305. * Defines an optimization used to turn lens flares off
  155306. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155307. */
  155308. export class LensFlaresOptimization extends SceneOptimization {
  155309. /**
  155310. * Gets a string describing the action executed by the current optimization
  155311. * @return description string
  155312. */
  155313. getDescription(): string;
  155314. /**
  155315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155316. * @param scene defines the current scene where to apply this optimization
  155317. * @param optimizer defines the current optimizer
  155318. * @returns true if everything that can be done was applied
  155319. */
  155320. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155321. }
  155322. /**
  155323. * Defines an optimization based on user defined callback.
  155324. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155325. */
  155326. export class CustomOptimization extends SceneOptimization {
  155327. /**
  155328. * Callback called to apply the custom optimization.
  155329. */
  155330. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155331. /**
  155332. * Callback called to get custom description
  155333. */
  155334. onGetDescription: () => string;
  155335. /**
  155336. * Gets a string describing the action executed by the current optimization
  155337. * @returns description string
  155338. */
  155339. getDescription(): string;
  155340. /**
  155341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155342. * @param scene defines the current scene where to apply this optimization
  155343. * @param optimizer defines the current optimizer
  155344. * @returns true if everything that can be done was applied
  155345. */
  155346. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155347. }
  155348. /**
  155349. * Defines an optimization used to turn particles off
  155350. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155351. */
  155352. export class ParticlesOptimization extends SceneOptimization {
  155353. /**
  155354. * Gets a string describing the action executed by the current optimization
  155355. * @return description string
  155356. */
  155357. getDescription(): string;
  155358. /**
  155359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155360. * @param scene defines the current scene where to apply this optimization
  155361. * @param optimizer defines the current optimizer
  155362. * @returns true if everything that can be done was applied
  155363. */
  155364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155365. }
  155366. /**
  155367. * Defines an optimization used to turn render targets off
  155368. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155369. */
  155370. export class RenderTargetsOptimization extends SceneOptimization {
  155371. /**
  155372. * Gets a string describing the action executed by the current optimization
  155373. * @return description string
  155374. */
  155375. getDescription(): string;
  155376. /**
  155377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155378. * @param scene defines the current scene where to apply this optimization
  155379. * @param optimizer defines the current optimizer
  155380. * @returns true if everything that can be done was applied
  155381. */
  155382. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155383. }
  155384. /**
  155385. * Defines an optimization used to merge meshes with compatible materials
  155386. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155387. */
  155388. export class MergeMeshesOptimization extends SceneOptimization {
  155389. private static _UpdateSelectionTree;
  155390. /**
  155391. * Gets or sets a boolean which defines if optimization octree has to be updated
  155392. */
  155393. static get UpdateSelectionTree(): boolean;
  155394. /**
  155395. * Gets or sets a boolean which defines if optimization octree has to be updated
  155396. */
  155397. static set UpdateSelectionTree(value: boolean);
  155398. /**
  155399. * Gets a string describing the action executed by the current optimization
  155400. * @return description string
  155401. */
  155402. getDescription(): string;
  155403. private _canBeMerged;
  155404. /**
  155405. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155406. * @param scene defines the current scene where to apply this optimization
  155407. * @param optimizer defines the current optimizer
  155408. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155409. * @returns true if everything that can be done was applied
  155410. */
  155411. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155412. }
  155413. /**
  155414. * Defines a list of options used by SceneOptimizer
  155415. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155416. */
  155417. export class SceneOptimizerOptions {
  155418. /**
  155419. * Defines the target frame rate to reach (60 by default)
  155420. */
  155421. targetFrameRate: number;
  155422. /**
  155423. * Defines the interval between two checkes (2000ms by default)
  155424. */
  155425. trackerDuration: number;
  155426. /**
  155427. * Gets the list of optimizations to apply
  155428. */
  155429. optimizations: SceneOptimization[];
  155430. /**
  155431. * Creates a new list of options used by SceneOptimizer
  155432. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155433. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155434. */
  155435. constructor(
  155436. /**
  155437. * Defines the target frame rate to reach (60 by default)
  155438. */
  155439. targetFrameRate?: number,
  155440. /**
  155441. * Defines the interval between two checkes (2000ms by default)
  155442. */
  155443. trackerDuration?: number);
  155444. /**
  155445. * Add a new optimization
  155446. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155447. * @returns the current SceneOptimizerOptions
  155448. */
  155449. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155450. /**
  155451. * Add a new custom optimization
  155452. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155453. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155454. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155455. * @returns the current SceneOptimizerOptions
  155456. */
  155457. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155458. /**
  155459. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155460. * @param targetFrameRate defines the target frame rate (60 by default)
  155461. * @returns a SceneOptimizerOptions object
  155462. */
  155463. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155464. /**
  155465. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155466. * @param targetFrameRate defines the target frame rate (60 by default)
  155467. * @returns a SceneOptimizerOptions object
  155468. */
  155469. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155470. /**
  155471. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155472. * @param targetFrameRate defines the target frame rate (60 by default)
  155473. * @returns a SceneOptimizerOptions object
  155474. */
  155475. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155476. }
  155477. /**
  155478. * Class used to run optimizations in order to reach a target frame rate
  155479. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155480. */
  155481. export class SceneOptimizer implements IDisposable {
  155482. private _isRunning;
  155483. private _options;
  155484. private _scene;
  155485. private _currentPriorityLevel;
  155486. private _targetFrameRate;
  155487. private _trackerDuration;
  155488. private _currentFrameRate;
  155489. private _sceneDisposeObserver;
  155490. private _improvementMode;
  155491. /**
  155492. * Defines an observable called when the optimizer reaches the target frame rate
  155493. */
  155494. onSuccessObservable: Observable<SceneOptimizer>;
  155495. /**
  155496. * Defines an observable called when the optimizer enables an optimization
  155497. */
  155498. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155499. /**
  155500. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155501. */
  155502. onFailureObservable: Observable<SceneOptimizer>;
  155503. /**
  155504. * Gets a boolean indicating if the optimizer is in improvement mode
  155505. */
  155506. get isInImprovementMode(): boolean;
  155507. /**
  155508. * Gets the current priority level (0 at start)
  155509. */
  155510. get currentPriorityLevel(): number;
  155511. /**
  155512. * Gets the current frame rate checked by the SceneOptimizer
  155513. */
  155514. get currentFrameRate(): number;
  155515. /**
  155516. * Gets or sets the current target frame rate (60 by default)
  155517. */
  155518. get targetFrameRate(): number;
  155519. /**
  155520. * Gets or sets the current target frame rate (60 by default)
  155521. */
  155522. set targetFrameRate(value: number);
  155523. /**
  155524. * Gets or sets the current interval between two checks (every 2000ms by default)
  155525. */
  155526. get trackerDuration(): number;
  155527. /**
  155528. * Gets or sets the current interval between two checks (every 2000ms by default)
  155529. */
  155530. set trackerDuration(value: number);
  155531. /**
  155532. * Gets the list of active optimizations
  155533. */
  155534. get optimizations(): SceneOptimization[];
  155535. /**
  155536. * Creates a new SceneOptimizer
  155537. * @param scene defines the scene to work on
  155538. * @param options defines the options to use with the SceneOptimizer
  155539. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155540. * @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)
  155541. */
  155542. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155543. /**
  155544. * Stops the current optimizer
  155545. */
  155546. stop(): void;
  155547. /**
  155548. * Reset the optimizer to initial step (current priority level = 0)
  155549. */
  155550. reset(): void;
  155551. /**
  155552. * Start the optimizer. By default it will try to reach a specific framerate
  155553. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155554. */
  155555. start(): void;
  155556. private _checkCurrentState;
  155557. /**
  155558. * Release all resources
  155559. */
  155560. dispose(): void;
  155561. /**
  155562. * Helper function to create a SceneOptimizer with one single line of code
  155563. * @param scene defines the scene to work on
  155564. * @param options defines the options to use with the SceneOptimizer
  155565. * @param onSuccess defines a callback to call on success
  155566. * @param onFailure defines a callback to call on failure
  155567. * @returns the new SceneOptimizer object
  155568. */
  155569. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155570. }
  155571. }
  155572. declare module BABYLON {
  155573. /**
  155574. * Class used to serialize a scene into a string
  155575. */
  155576. export class SceneSerializer {
  155577. /**
  155578. * Clear cache used by a previous serialization
  155579. */
  155580. static ClearCache(): void;
  155581. /**
  155582. * Serialize a scene into a JSON compatible object
  155583. * @param scene defines the scene to serialize
  155584. * @returns a JSON compatible object
  155585. */
  155586. static Serialize(scene: Scene): any;
  155587. /**
  155588. * Serialize a mesh into a JSON compatible object
  155589. * @param toSerialize defines the mesh to serialize
  155590. * @param withParents defines if parents must be serialized as well
  155591. * @param withChildren defines if children must be serialized as well
  155592. * @returns a JSON compatible object
  155593. */
  155594. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155595. }
  155596. }
  155597. declare module BABYLON {
  155598. /**
  155599. * Class used to host texture specific utilities
  155600. */
  155601. export class TextureTools {
  155602. /**
  155603. * Uses the GPU to create a copy texture rescaled at a given size
  155604. * @param texture Texture to copy from
  155605. * @param width defines the desired width
  155606. * @param height defines the desired height
  155607. * @param useBilinearMode defines if bilinear mode has to be used
  155608. * @return the generated texture
  155609. */
  155610. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155611. }
  155612. }
  155613. declare module BABYLON {
  155614. /**
  155615. * This represents the different options available for the video capture.
  155616. */
  155617. export interface VideoRecorderOptions {
  155618. /** Defines the mime type of the video. */
  155619. mimeType: string;
  155620. /** Defines the FPS the video should be recorded at. */
  155621. fps: number;
  155622. /** Defines the chunk size for the recording data. */
  155623. recordChunckSize: number;
  155624. /** The audio tracks to attach to the recording. */
  155625. audioTracks?: MediaStreamTrack[];
  155626. }
  155627. /**
  155628. * This can help with recording videos from BabylonJS.
  155629. * This is based on the available WebRTC functionalities of the browser.
  155630. *
  155631. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155632. */
  155633. export class VideoRecorder {
  155634. private static readonly _defaultOptions;
  155635. /**
  155636. * Returns whether or not the VideoRecorder is available in your browser.
  155637. * @param engine Defines the Babylon Engine.
  155638. * @returns true if supported otherwise false.
  155639. */
  155640. static IsSupported(engine: Engine): boolean;
  155641. private readonly _options;
  155642. private _canvas;
  155643. private _mediaRecorder;
  155644. private _recordedChunks;
  155645. private _fileName;
  155646. private _resolve;
  155647. private _reject;
  155648. /**
  155649. * True when a recording is already in progress.
  155650. */
  155651. get isRecording(): boolean;
  155652. /**
  155653. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155654. * @param engine Defines the BabylonJS Engine you wish to record.
  155655. * @param options Defines options that can be used to customize the capture.
  155656. */
  155657. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155658. /**
  155659. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155660. */
  155661. stopRecording(): void;
  155662. /**
  155663. * Starts recording the canvas for a max duration specified in parameters.
  155664. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155665. * If null no automatic download will start and you can rely on the promise to get the data back.
  155666. * @param maxDuration Defines the maximum recording time in seconds.
  155667. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155668. * @return A promise callback at the end of the recording with the video data in Blob.
  155669. */
  155670. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155671. /**
  155672. * Releases internal resources used during the recording.
  155673. */
  155674. dispose(): void;
  155675. private _handleDataAvailable;
  155676. private _handleError;
  155677. private _handleStop;
  155678. }
  155679. }
  155680. declare module BABYLON {
  155681. /**
  155682. * Class containing a set of static utilities functions for screenshots
  155683. */
  155684. export class ScreenshotTools {
  155685. /**
  155686. * Captures a screenshot of the current rendering
  155687. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155688. * @param engine defines the rendering engine
  155689. * @param camera defines the source camera
  155690. * @param size This parameter can be set to a single number or to an object with the
  155691. * following (optional) properties: precision, width, height. If a single number is passed,
  155692. * it will be used for both width and height. If an object is passed, the screenshot size
  155693. * will be derived from the parameters. The precision property is a multiplier allowing
  155694. * rendering at a higher or lower resolution
  155695. * @param successCallback defines the callback receives a single parameter which contains the
  155696. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155697. * src parameter of an <img> to display it
  155698. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155699. * Check your browser for supported MIME types
  155700. */
  155701. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155702. /**
  155703. * Captures a screenshot of the current rendering
  155704. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155705. * @param engine defines the rendering engine
  155706. * @param camera defines the source camera
  155707. * @param size This parameter can be set to a single number or to an object with the
  155708. * following (optional) properties: precision, width, height. If a single number is passed,
  155709. * it will be used for both width and height. If an object is passed, the screenshot size
  155710. * will be derived from the parameters. The precision property is a multiplier allowing
  155711. * rendering at a higher or lower resolution
  155712. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155713. * Check your browser for supported MIME types
  155714. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155715. * to the src parameter of an <img> to display it
  155716. */
  155717. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155718. /**
  155719. * Generates an image screenshot from the specified camera.
  155720. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155721. * @param engine The engine to use for rendering
  155722. * @param camera The camera to use for rendering
  155723. * @param size This parameter can be set to a single number or to an object with the
  155724. * following (optional) properties: precision, width, height. If a single number is passed,
  155725. * it will be used for both width and height. If an object is passed, the screenshot size
  155726. * will be derived from the parameters. The precision property is a multiplier allowing
  155727. * rendering at a higher or lower resolution
  155728. * @param successCallback The callback receives a single parameter which contains the
  155729. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155730. * src parameter of an <img> to display it
  155731. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155732. * Check your browser for supported MIME types
  155733. * @param samples Texture samples (default: 1)
  155734. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155735. * @param fileName A name for for the downloaded file.
  155736. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155737. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155738. */
  155739. 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;
  155740. /**
  155741. * Generates an image screenshot from the specified camera.
  155742. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155743. * @param engine The engine to use for rendering
  155744. * @param camera The camera to use for rendering
  155745. * @param size This parameter can be set to a single number or to an object with the
  155746. * following (optional) properties: precision, width, height. If a single number is passed,
  155747. * it will be used for both width and height. If an object is passed, the screenshot size
  155748. * will be derived from the parameters. The precision property is a multiplier allowing
  155749. * rendering at a higher or lower resolution
  155750. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155751. * Check your browser for supported MIME types
  155752. * @param samples Texture samples (default: 1)
  155753. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155754. * @param fileName A name for for the downloaded file.
  155755. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155756. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155757. * to the src parameter of an <img> to display it
  155758. */
  155759. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155760. /**
  155761. * Gets height and width for screenshot size
  155762. * @private
  155763. */
  155764. private static _getScreenshotSize;
  155765. }
  155766. }
  155767. declare module BABYLON {
  155768. /**
  155769. * Interface for a data buffer
  155770. */
  155771. export interface IDataBuffer {
  155772. /**
  155773. * Reads bytes from the data buffer.
  155774. * @param byteOffset The byte offset to read
  155775. * @param byteLength The byte length to read
  155776. * @returns A promise that resolves when the bytes are read
  155777. */
  155778. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155779. /**
  155780. * The byte length of the buffer.
  155781. */
  155782. readonly byteLength: number;
  155783. }
  155784. /**
  155785. * Utility class for reading from a data buffer
  155786. */
  155787. export class DataReader {
  155788. /**
  155789. * The data buffer associated with this data reader.
  155790. */
  155791. readonly buffer: IDataBuffer;
  155792. /**
  155793. * The current byte offset from the beginning of the data buffer.
  155794. */
  155795. byteOffset: number;
  155796. private _dataView;
  155797. private _dataByteOffset;
  155798. /**
  155799. * Constructor
  155800. * @param buffer The buffer to read
  155801. */
  155802. constructor(buffer: IDataBuffer);
  155803. /**
  155804. * Loads the given byte length.
  155805. * @param byteLength The byte length to load
  155806. * @returns A promise that resolves when the load is complete
  155807. */
  155808. loadAsync(byteLength: number): Promise<void>;
  155809. /**
  155810. * Read a unsigned 32-bit integer from the currently loaded data range.
  155811. * @returns The 32-bit integer read
  155812. */
  155813. readUint32(): number;
  155814. /**
  155815. * Read a byte array from the currently loaded data range.
  155816. * @param byteLength The byte length to read
  155817. * @returns The byte array read
  155818. */
  155819. readUint8Array(byteLength: number): Uint8Array;
  155820. /**
  155821. * Read a string from the currently loaded data range.
  155822. * @param byteLength The byte length to read
  155823. * @returns The string read
  155824. */
  155825. readString(byteLength: number): string;
  155826. /**
  155827. * Skips the given byte length the currently loaded data range.
  155828. * @param byteLength The byte length to skip
  155829. */
  155830. skipBytes(byteLength: number): void;
  155831. }
  155832. }
  155833. declare module BABYLON {
  155834. /**
  155835. * Class for storing data to local storage if available or in-memory storage otherwise
  155836. */
  155837. export class DataStorage {
  155838. private static _Storage;
  155839. private static _GetStorage;
  155840. /**
  155841. * Reads a string from the data storage
  155842. * @param key The key to read
  155843. * @param defaultValue The value if the key doesn't exist
  155844. * @returns The string value
  155845. */
  155846. static ReadString(key: string, defaultValue: string): string;
  155847. /**
  155848. * Writes a string to the data storage
  155849. * @param key The key to write
  155850. * @param value The value to write
  155851. */
  155852. static WriteString(key: string, value: string): void;
  155853. /**
  155854. * Reads a boolean from the data storage
  155855. * @param key The key to read
  155856. * @param defaultValue The value if the key doesn't exist
  155857. * @returns The boolean value
  155858. */
  155859. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155860. /**
  155861. * Writes a boolean to the data storage
  155862. * @param key The key to write
  155863. * @param value The value to write
  155864. */
  155865. static WriteBoolean(key: string, value: boolean): void;
  155866. /**
  155867. * Reads a number from the data storage
  155868. * @param key The key to read
  155869. * @param defaultValue The value if the key doesn't exist
  155870. * @returns The number value
  155871. */
  155872. static ReadNumber(key: string, defaultValue: number): number;
  155873. /**
  155874. * Writes a number to the data storage
  155875. * @param key The key to write
  155876. * @param value The value to write
  155877. */
  155878. static WriteNumber(key: string, value: number): void;
  155879. }
  155880. }
  155881. declare module BABYLON {
  155882. /**
  155883. * Class used to record delta files between 2 scene states
  155884. */
  155885. export class SceneRecorder {
  155886. private _trackedScene;
  155887. private _savedJSON;
  155888. /**
  155889. * Track a given scene. This means the current scene state will be considered the original state
  155890. * @param scene defines the scene to track
  155891. */
  155892. track(scene: Scene): void;
  155893. /**
  155894. * Get the delta between current state and original state
  155895. * @returns a string containing the delta
  155896. */
  155897. getDelta(): any;
  155898. private _compareArray;
  155899. private _compareObjects;
  155900. private _compareCollections;
  155901. private static GetShadowGeneratorById;
  155902. /**
  155903. * Apply a given delta to a given scene
  155904. * @param deltaJSON defines the JSON containing the delta
  155905. * @param scene defines the scene to apply the delta to
  155906. */
  155907. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155908. private static _ApplyPropertiesToEntity;
  155909. private static _ApplyDeltaForEntity;
  155910. }
  155911. }
  155912. declare module BABYLON {
  155913. /**
  155914. * A 3D trajectory consisting of an order list of vectors describing a
  155915. * path of motion through 3D space.
  155916. */
  155917. export class Trajectory {
  155918. private _points;
  155919. private readonly _segmentLength;
  155920. /**
  155921. * Serialize to JSON.
  155922. * @returns serialized JSON string
  155923. */
  155924. serialize(): string;
  155925. /**
  155926. * Deserialize from JSON.
  155927. * @param json serialized JSON string
  155928. * @returns deserialized Trajectory
  155929. */
  155930. static Deserialize(json: string): Trajectory;
  155931. /**
  155932. * Create a new empty Trajectory.
  155933. * @param segmentLength radius of discretization for Trajectory points
  155934. */
  155935. constructor(segmentLength?: number);
  155936. /**
  155937. * Get the length of the Trajectory.
  155938. * @returns length of the Trajectory
  155939. */
  155940. getLength(): number;
  155941. /**
  155942. * Append a new point to the Trajectory.
  155943. * NOTE: This implementation has many allocations.
  155944. * @param point point to append to the Trajectory
  155945. */
  155946. add(point: DeepImmutable<Vector3>): void;
  155947. /**
  155948. * Create a new Trajectory with a segment length chosen to make it
  155949. * probable that the new Trajectory will have a specified number of
  155950. * segments. This operation is imprecise.
  155951. * @param targetResolution number of segments desired
  155952. * @returns new Trajectory with approximately the requested number of segments
  155953. */
  155954. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155955. /**
  155956. * Convert Trajectory segments into tokenized representation. This
  155957. * representation is an array of numbers where each nth number is the
  155958. * index of the token which is most similar to the nth segment of the
  155959. * Trajectory.
  155960. * @param tokens list of vectors which serve as discrete tokens
  155961. * @returns list of indices of most similar token per segment
  155962. */
  155963. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155964. private static _forwardDir;
  155965. private static _inverseFromVec;
  155966. private static _upDir;
  155967. private static _fromToVec;
  155968. private static _lookMatrix;
  155969. /**
  155970. * Transform the rotation (i.e., direction) of a segment to isolate
  155971. * the relative transformation represented by the segment. This operation
  155972. * may or may not succeed due to singularities in the equations that define
  155973. * motion relativity in this context.
  155974. * @param priorVec the origin of the prior segment
  155975. * @param fromVec the origin of the current segment
  155976. * @param toVec the destination of the current segment
  155977. * @param result reference to output variable
  155978. * @returns whether or not transformation was successful
  155979. */
  155980. private static _transformSegmentDirToRef;
  155981. private static _bestMatch;
  155982. private static _score;
  155983. private static _bestScore;
  155984. /**
  155985. * Determine which token vector is most similar to the
  155986. * segment vector.
  155987. * @param segment segment vector
  155988. * @param tokens token vector list
  155989. * @returns index of the most similar token to the segment
  155990. */
  155991. private static _tokenizeSegment;
  155992. }
  155993. /**
  155994. * Class representing a set of known, named trajectories to which Trajectories can be
  155995. * added and using which Trajectories can be recognized.
  155996. */
  155997. export class TrajectoryClassifier {
  155998. private _maximumAllowableMatchCost;
  155999. private _vector3Alphabet;
  156000. private _levenshteinAlphabet;
  156001. private _nameToDescribedTrajectory;
  156002. /**
  156003. * Serialize to JSON.
  156004. * @returns JSON serialization
  156005. */
  156006. serialize(): string;
  156007. /**
  156008. * Deserialize from JSON.
  156009. * @param json JSON serialization
  156010. * @returns deserialized TrajectorySet
  156011. */
  156012. static Deserialize(json: string): TrajectoryClassifier;
  156013. /**
  156014. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  156015. * VERY naive, need to be generating these things from known
  156016. * sets. Better version later, probably eliminating this one.
  156017. * @returns auto-generated TrajectorySet
  156018. */
  156019. static Generate(): TrajectoryClassifier;
  156020. private constructor();
  156021. /**
  156022. * Add a new Trajectory to the set with a given name.
  156023. * @param trajectory new Trajectory to be added
  156024. * @param classification name to which to add the Trajectory
  156025. */
  156026. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  156027. /**
  156028. * Remove a known named trajectory and all Trajectories associated with it.
  156029. * @param classification name to remove
  156030. * @returns whether anything was removed
  156031. */
  156032. deleteClassification(classification: string): boolean;
  156033. /**
  156034. * Attempt to recognize a Trajectory from among all the classifications
  156035. * already known to the classifier.
  156036. * @param trajectory Trajectory to be recognized
  156037. * @returns classification of Trajectory if recognized, null otherwise
  156038. */
  156039. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  156040. }
  156041. }
  156042. declare module BABYLON {
  156043. /**
  156044. * An interface for all Hit test features
  156045. */
  156046. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  156047. /**
  156048. * Triggered when new babylon (transformed) hit test results are available
  156049. */
  156050. onHitTestResultObservable: Observable<T[]>;
  156051. }
  156052. /**
  156053. * Options used for hit testing
  156054. */
  156055. export interface IWebXRLegacyHitTestOptions {
  156056. /**
  156057. * Only test when user interacted with the scene. Default - hit test every frame
  156058. */
  156059. testOnPointerDownOnly?: boolean;
  156060. /**
  156061. * The node to use to transform the local results to world coordinates
  156062. */
  156063. worldParentNode?: TransformNode;
  156064. }
  156065. /**
  156066. * Interface defining the babylon result of raycasting/hit-test
  156067. */
  156068. export interface IWebXRLegacyHitResult {
  156069. /**
  156070. * Transformation matrix that can be applied to a node that will put it in the hit point location
  156071. */
  156072. transformationMatrix: Matrix;
  156073. /**
  156074. * The native hit test result
  156075. */
  156076. xrHitResult: XRHitResult | XRHitTestResult;
  156077. }
  156078. /**
  156079. * The currently-working hit-test module.
  156080. * Hit test (or Ray-casting) is used to interact with the real world.
  156081. * For further information read here - https://github.com/immersive-web/hit-test
  156082. */
  156083. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156084. /**
  156085. * options to use when constructing this feature
  156086. */
  156087. readonly options: IWebXRLegacyHitTestOptions;
  156088. private _direction;
  156089. private _mat;
  156090. private _onSelectEnabled;
  156091. private _origin;
  156092. /**
  156093. * The module's name
  156094. */
  156095. static readonly Name: string;
  156096. /**
  156097. * The (Babylon) version of this module.
  156098. * This is an integer representing the implementation version.
  156099. * This number does not correspond to the WebXR specs version
  156100. */
  156101. static readonly Version: number;
  156102. /**
  156103. * Populated with the last native XR Hit Results
  156104. */
  156105. lastNativeXRHitResults: XRHitResult[];
  156106. /**
  156107. * Triggered when new babylon (transformed) hit test results are available
  156108. */
  156109. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156110. /**
  156111. * Creates a new instance of the (legacy version) hit test feature
  156112. * @param _xrSessionManager an instance of WebXRSessionManager
  156113. * @param options options to use when constructing this feature
  156114. */
  156115. constructor(_xrSessionManager: WebXRSessionManager,
  156116. /**
  156117. * options to use when constructing this feature
  156118. */
  156119. options?: IWebXRLegacyHitTestOptions);
  156120. /**
  156121. * execute a hit test with an XR Ray
  156122. *
  156123. * @param xrSession a native xrSession that will execute this hit test
  156124. * @param xrRay the ray (position and direction) to use for ray-casting
  156125. * @param referenceSpace native XR reference space to use for the hit-test
  156126. * @param filter filter function that will filter the results
  156127. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156128. */
  156129. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156130. /**
  156131. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156132. * @param event the (select) event to use to select with
  156133. * @param referenceSpace the reference space to use for this hit test
  156134. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156135. */
  156136. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156137. /**
  156138. * attach this feature
  156139. * Will usually be called by the features manager
  156140. *
  156141. * @returns true if successful.
  156142. */
  156143. attach(): boolean;
  156144. /**
  156145. * detach this feature.
  156146. * Will usually be called by the features manager
  156147. *
  156148. * @returns true if successful.
  156149. */
  156150. detach(): boolean;
  156151. /**
  156152. * Dispose this feature and all of the resources attached
  156153. */
  156154. dispose(): void;
  156155. protected _onXRFrame(frame: XRFrame): void;
  156156. private _onHitTestResults;
  156157. private _onSelect;
  156158. }
  156159. }
  156160. declare module BABYLON {
  156161. /**
  156162. * Options used for hit testing (version 2)
  156163. */
  156164. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156165. /**
  156166. * Do not create a permanent hit test. Will usually be used when only
  156167. * transient inputs are needed.
  156168. */
  156169. disablePermanentHitTest?: boolean;
  156170. /**
  156171. * Enable transient (for example touch-based) hit test inspections
  156172. */
  156173. enableTransientHitTest?: boolean;
  156174. /**
  156175. * Offset ray for the permanent hit test
  156176. */
  156177. offsetRay?: Vector3;
  156178. /**
  156179. * Offset ray for the transient hit test
  156180. */
  156181. transientOffsetRay?: Vector3;
  156182. /**
  156183. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156184. */
  156185. useReferenceSpace?: boolean;
  156186. /**
  156187. * Override the default entity type(s) of the hit-test result
  156188. */
  156189. entityTypes?: XRHitTestTrackableType[];
  156190. }
  156191. /**
  156192. * Interface defining the babylon result of hit-test
  156193. */
  156194. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  156195. /**
  156196. * The input source that generated this hit test (if transient)
  156197. */
  156198. inputSource?: XRInputSource;
  156199. /**
  156200. * Is this a transient hit test
  156201. */
  156202. isTransient?: boolean;
  156203. /**
  156204. * Position of the hit test result
  156205. */
  156206. position: Vector3;
  156207. /**
  156208. * Rotation of the hit test result
  156209. */
  156210. rotationQuaternion: Quaternion;
  156211. /**
  156212. * The native hit test result
  156213. */
  156214. xrHitResult: XRHitTestResult;
  156215. }
  156216. /**
  156217. * The currently-working hit-test module.
  156218. * Hit test (or Ray-casting) is used to interact with the real world.
  156219. * For further information read here - https://github.com/immersive-web/hit-test
  156220. *
  156221. * Tested on chrome (mobile) 80.
  156222. */
  156223. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156224. /**
  156225. * options to use when constructing this feature
  156226. */
  156227. readonly options: IWebXRHitTestOptions;
  156228. private _tmpMat;
  156229. private _tmpPos;
  156230. private _tmpQuat;
  156231. private _transientXrHitTestSource;
  156232. private _xrHitTestSource;
  156233. private initHitTestSource;
  156234. /**
  156235. * The module's name
  156236. */
  156237. static readonly Name: string;
  156238. /**
  156239. * The (Babylon) version of this module.
  156240. * This is an integer representing the implementation version.
  156241. * This number does not correspond to the WebXR specs version
  156242. */
  156243. static readonly Version: number;
  156244. /**
  156245. * When set to true, each hit test will have its own position/rotation objects
  156246. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156247. * the developers will clone them or copy them as they see fit.
  156248. */
  156249. autoCloneTransformation: boolean;
  156250. /**
  156251. * Triggered when new babylon (transformed) hit test results are available
  156252. * Note - this will be called when results come back from the device. It can be an empty array!!
  156253. */
  156254. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156255. /**
  156256. * Use this to temporarily pause hit test checks.
  156257. */
  156258. paused: boolean;
  156259. /**
  156260. * Creates a new instance of the hit test feature
  156261. * @param _xrSessionManager an instance of WebXRSessionManager
  156262. * @param options options to use when constructing this feature
  156263. */
  156264. constructor(_xrSessionManager: WebXRSessionManager,
  156265. /**
  156266. * options to use when constructing this feature
  156267. */
  156268. options?: IWebXRHitTestOptions);
  156269. /**
  156270. * attach this feature
  156271. * Will usually be called by the features manager
  156272. *
  156273. * @returns true if successful.
  156274. */
  156275. attach(): boolean;
  156276. /**
  156277. * detach this feature.
  156278. * Will usually be called by the features manager
  156279. *
  156280. * @returns true if successful.
  156281. */
  156282. detach(): boolean;
  156283. /**
  156284. * Dispose this feature and all of the resources attached
  156285. */
  156286. dispose(): void;
  156287. protected _onXRFrame(frame: XRFrame): void;
  156288. private _processWebXRHitTestResult;
  156289. }
  156290. }
  156291. declare module BABYLON {
  156292. /**
  156293. * Configuration options of the anchor system
  156294. */
  156295. export interface IWebXRAnchorSystemOptions {
  156296. /**
  156297. * a node that will be used to convert local to world coordinates
  156298. */
  156299. worldParentNode?: TransformNode;
  156300. /**
  156301. * If set to true a reference of the created anchors will be kept until the next session starts
  156302. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156303. */
  156304. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156305. }
  156306. /**
  156307. * A babylon container for an XR Anchor
  156308. */
  156309. export interface IWebXRAnchor {
  156310. /**
  156311. * A babylon-assigned ID for this anchor
  156312. */
  156313. id: number;
  156314. /**
  156315. * Transformation matrix to apply to an object attached to this anchor
  156316. */
  156317. transformationMatrix: Matrix;
  156318. /**
  156319. * The native anchor object
  156320. */
  156321. xrAnchor: XRAnchor;
  156322. /**
  156323. * if defined, this object will be constantly updated by the anchor's position and rotation
  156324. */
  156325. attachedNode?: TransformNode;
  156326. }
  156327. /**
  156328. * An implementation of the anchor system for WebXR.
  156329. * For further information see https://github.com/immersive-web/anchors/
  156330. */
  156331. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156332. private _options;
  156333. private _lastFrameDetected;
  156334. private _trackedAnchors;
  156335. private _referenceSpaceForFrameAnchors;
  156336. private _futureAnchors;
  156337. /**
  156338. * The module's name
  156339. */
  156340. static readonly Name: string;
  156341. /**
  156342. * The (Babylon) version of this module.
  156343. * This is an integer representing the implementation version.
  156344. * This number does not correspond to the WebXR specs version
  156345. */
  156346. static readonly Version: number;
  156347. /**
  156348. * Observers registered here will be executed when a new anchor was added to the session
  156349. */
  156350. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156351. /**
  156352. * Observers registered here will be executed when an anchor was removed from the session
  156353. */
  156354. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  156355. /**
  156356. * Observers registered here will be executed when an existing anchor updates
  156357. * This can execute N times every frame
  156358. */
  156359. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  156360. /**
  156361. * Set the reference space to use for anchor creation, when not using a hit test.
  156362. * Will default to the session's reference space if not defined
  156363. */
  156364. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156365. /**
  156366. * constructs a new anchor system
  156367. * @param _xrSessionManager an instance of WebXRSessionManager
  156368. * @param _options configuration object for this feature
  156369. */
  156370. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156371. private _tmpVector;
  156372. private _tmpQuaternion;
  156373. private _populateTmpTransformation;
  156374. /**
  156375. * Create a new anchor point using a hit test result at a specific point in the scene
  156376. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156377. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156378. *
  156379. * @param hitTestResult The hit test result to use for this anchor creation
  156380. * @param position an optional position offset for this anchor
  156381. * @param rotationQuaternion an optional rotation offset for this anchor
  156382. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156383. */
  156384. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156385. /**
  156386. * Add a new anchor at a specific position and rotation
  156387. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156388. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156389. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156390. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156391. *
  156392. * @param position the position in which to add an anchor
  156393. * @param rotationQuaternion an optional rotation for the anchor transformation
  156394. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156395. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156396. */
  156397. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156398. /**
  156399. * detach this feature.
  156400. * Will usually be called by the features manager
  156401. *
  156402. * @returns true if successful.
  156403. */
  156404. detach(): boolean;
  156405. /**
  156406. * Dispose this feature and all of the resources attached
  156407. */
  156408. dispose(): void;
  156409. protected _onXRFrame(frame: XRFrame): void;
  156410. /**
  156411. * avoiding using Array.find for global support.
  156412. * @param xrAnchor the plane to find in the array
  156413. */
  156414. private _findIndexInAnchorArray;
  156415. private _updateAnchorWithXRFrame;
  156416. private _createAnchorAtTransformation;
  156417. }
  156418. }
  156419. declare module BABYLON {
  156420. /**
  156421. * Options used in the plane detector module
  156422. */
  156423. export interface IWebXRPlaneDetectorOptions {
  156424. /**
  156425. * The node to use to transform the local results to world coordinates
  156426. */
  156427. worldParentNode?: TransformNode;
  156428. /**
  156429. * If set to true a reference of the created planes will be kept until the next session starts
  156430. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156431. */
  156432. doNotRemovePlanesOnSessionEnded?: boolean;
  156433. }
  156434. /**
  156435. * A babylon interface for a WebXR plane.
  156436. * A Plane is actually a polygon, built from N points in space
  156437. *
  156438. * Supported in chrome 79, not supported in canary 81 ATM
  156439. */
  156440. export interface IWebXRPlane {
  156441. /**
  156442. * a babylon-assigned ID for this polygon
  156443. */
  156444. id: number;
  156445. /**
  156446. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156447. */
  156448. polygonDefinition: Array<Vector3>;
  156449. /**
  156450. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156451. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156452. */
  156453. transformationMatrix: Matrix;
  156454. /**
  156455. * the native xr-plane object
  156456. */
  156457. xrPlane: XRPlane;
  156458. }
  156459. /**
  156460. * The plane detector is used to detect planes in the real world when in AR
  156461. * For more information see https://github.com/immersive-web/real-world-geometry/
  156462. */
  156463. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156464. private _options;
  156465. private _detectedPlanes;
  156466. private _enabled;
  156467. private _lastFrameDetected;
  156468. /**
  156469. * The module's name
  156470. */
  156471. static readonly Name: string;
  156472. /**
  156473. * The (Babylon) version of this module.
  156474. * This is an integer representing the implementation version.
  156475. * This number does not correspond to the WebXR specs version
  156476. */
  156477. static readonly Version: number;
  156478. /**
  156479. * Observers registered here will be executed when a new plane was added to the session
  156480. */
  156481. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156482. /**
  156483. * Observers registered here will be executed when a plane is no longer detected in the session
  156484. */
  156485. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156486. /**
  156487. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156488. * This can execute N times every frame
  156489. */
  156490. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156491. /**
  156492. * construct a new Plane Detector
  156493. * @param _xrSessionManager an instance of xr Session manager
  156494. * @param _options configuration to use when constructing this feature
  156495. */
  156496. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156497. /**
  156498. * detach this feature.
  156499. * Will usually be called by the features manager
  156500. *
  156501. * @returns true if successful.
  156502. */
  156503. detach(): boolean;
  156504. /**
  156505. * Dispose this feature and all of the resources attached
  156506. */
  156507. dispose(): void;
  156508. protected _onXRFrame(frame: XRFrame): void;
  156509. private _init;
  156510. private _updatePlaneWithXRPlane;
  156511. /**
  156512. * avoiding using Array.find for global support.
  156513. * @param xrPlane the plane to find in the array
  156514. */
  156515. private findIndexInPlaneArray;
  156516. }
  156517. }
  156518. declare module BABYLON {
  156519. /**
  156520. * Options interface for the background remover plugin
  156521. */
  156522. export interface IWebXRBackgroundRemoverOptions {
  156523. /**
  156524. * Further background meshes to disable when entering AR
  156525. */
  156526. backgroundMeshes?: AbstractMesh[];
  156527. /**
  156528. * flags to configure the removal of the environment helper.
  156529. * If not set, the entire background will be removed. If set, flags should be set as well.
  156530. */
  156531. environmentHelperRemovalFlags?: {
  156532. /**
  156533. * Should the skybox be removed (default false)
  156534. */
  156535. skyBox?: boolean;
  156536. /**
  156537. * Should the ground be removed (default false)
  156538. */
  156539. ground?: boolean;
  156540. };
  156541. /**
  156542. * don't disable the environment helper
  156543. */
  156544. ignoreEnvironmentHelper?: boolean;
  156545. }
  156546. /**
  156547. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156548. */
  156549. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156550. /**
  156551. * read-only options to be used in this module
  156552. */
  156553. readonly options: IWebXRBackgroundRemoverOptions;
  156554. /**
  156555. * The module's name
  156556. */
  156557. static readonly Name: string;
  156558. /**
  156559. * The (Babylon) version of this module.
  156560. * This is an integer representing the implementation version.
  156561. * This number does not correspond to the WebXR specs version
  156562. */
  156563. static readonly Version: number;
  156564. /**
  156565. * registered observers will be triggered when the background state changes
  156566. */
  156567. onBackgroundStateChangedObservable: Observable<boolean>;
  156568. /**
  156569. * constructs a new background remover module
  156570. * @param _xrSessionManager the session manager for this module
  156571. * @param options read-only options to be used in this module
  156572. */
  156573. constructor(_xrSessionManager: WebXRSessionManager,
  156574. /**
  156575. * read-only options to be used in this module
  156576. */
  156577. options?: IWebXRBackgroundRemoverOptions);
  156578. /**
  156579. * attach this feature
  156580. * Will usually be called by the features manager
  156581. *
  156582. * @returns true if successful.
  156583. */
  156584. attach(): boolean;
  156585. /**
  156586. * detach this feature.
  156587. * Will usually be called by the features manager
  156588. *
  156589. * @returns true if successful.
  156590. */
  156591. detach(): boolean;
  156592. /**
  156593. * Dispose this feature and all of the resources attached
  156594. */
  156595. dispose(): void;
  156596. protected _onXRFrame(_xrFrame: XRFrame): void;
  156597. private _setBackgroundState;
  156598. }
  156599. }
  156600. declare module BABYLON {
  156601. /**
  156602. * Options for the controller physics feature
  156603. */
  156604. export class IWebXRControllerPhysicsOptions {
  156605. /**
  156606. * Should the headset get its own impostor
  156607. */
  156608. enableHeadsetImpostor?: boolean;
  156609. /**
  156610. * Optional parameters for the headset impostor
  156611. */
  156612. headsetImpostorParams?: {
  156613. /**
  156614. * The type of impostor to create. Default is sphere
  156615. */
  156616. impostorType: number;
  156617. /**
  156618. * the size of the impostor. Defaults to 10cm
  156619. */
  156620. impostorSize?: number | {
  156621. width: number;
  156622. height: number;
  156623. depth: number;
  156624. };
  156625. /**
  156626. * Friction definitions
  156627. */
  156628. friction?: number;
  156629. /**
  156630. * Restitution
  156631. */
  156632. restitution?: number;
  156633. };
  156634. /**
  156635. * The physics properties of the future impostors
  156636. */
  156637. physicsProperties?: {
  156638. /**
  156639. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156640. * Note that this requires a physics engine that supports mesh impostors!
  156641. */
  156642. useControllerMesh?: boolean;
  156643. /**
  156644. * The type of impostor to create. Default is sphere
  156645. */
  156646. impostorType?: number;
  156647. /**
  156648. * the size of the impostor. Defaults to 10cm
  156649. */
  156650. impostorSize?: number | {
  156651. width: number;
  156652. height: number;
  156653. depth: number;
  156654. };
  156655. /**
  156656. * Friction definitions
  156657. */
  156658. friction?: number;
  156659. /**
  156660. * Restitution
  156661. */
  156662. restitution?: number;
  156663. };
  156664. /**
  156665. * the xr input to use with this pointer selection
  156666. */
  156667. xrInput: WebXRInput;
  156668. }
  156669. /**
  156670. * Add physics impostor to your webxr controllers,
  156671. * including naive calculation of their linear and angular velocity
  156672. */
  156673. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156674. private readonly _options;
  156675. private _attachController;
  156676. private _controllers;
  156677. private _debugMode;
  156678. private _delta;
  156679. private _headsetImpostor?;
  156680. private _headsetMesh?;
  156681. private _lastTimestamp;
  156682. private _tmpQuaternion;
  156683. private _tmpVector;
  156684. /**
  156685. * The module's name
  156686. */
  156687. static readonly Name: string;
  156688. /**
  156689. * The (Babylon) version of this module.
  156690. * This is an integer representing the implementation version.
  156691. * This number does not correspond to the webxr specs version
  156692. */
  156693. static readonly Version: number;
  156694. /**
  156695. * Construct a new Controller Physics Feature
  156696. * @param _xrSessionManager the corresponding xr session manager
  156697. * @param _options options to create this feature with
  156698. */
  156699. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156700. /**
  156701. * @hidden
  156702. * enable debugging - will show console outputs and the impostor mesh
  156703. */
  156704. _enablePhysicsDebug(): void;
  156705. /**
  156706. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156707. * @param xrController the controller to add
  156708. */
  156709. addController(xrController: WebXRInputSource): void;
  156710. /**
  156711. * attach this feature
  156712. * Will usually be called by the features manager
  156713. *
  156714. * @returns true if successful.
  156715. */
  156716. attach(): boolean;
  156717. /**
  156718. * detach this feature.
  156719. * Will usually be called by the features manager
  156720. *
  156721. * @returns true if successful.
  156722. */
  156723. detach(): boolean;
  156724. /**
  156725. * Get the headset impostor, if enabled
  156726. * @returns the impostor
  156727. */
  156728. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156729. /**
  156730. * Get the physics impostor of a specific controller.
  156731. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156732. * @param controller the controller or the controller id of which to get the impostor
  156733. * @returns the impostor or null
  156734. */
  156735. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156736. /**
  156737. * Update the physics properties provided in the constructor
  156738. * @param newProperties the new properties object
  156739. */
  156740. setPhysicsProperties(newProperties: {
  156741. impostorType?: number;
  156742. impostorSize?: number | {
  156743. width: number;
  156744. height: number;
  156745. depth: number;
  156746. };
  156747. friction?: number;
  156748. restitution?: number;
  156749. }): void;
  156750. protected _onXRFrame(_xrFrame: any): void;
  156751. private _detachController;
  156752. }
  156753. }
  156754. declare module BABYLON {
  156755. /**
  156756. * A babylon interface for a "WebXR" feature point.
  156757. * Represents the position and confidence value of a given feature point.
  156758. */
  156759. export interface IWebXRFeaturePoint {
  156760. /**
  156761. * Represents the position of the feature point in world space.
  156762. */
  156763. position: Vector3;
  156764. /**
  156765. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156766. */
  156767. confidenceValue: number;
  156768. }
  156769. /**
  156770. * The feature point system is used to detect feature points from real world geometry.
  156771. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156772. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156773. */
  156774. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156775. private _enabled;
  156776. private _featurePointCloud;
  156777. /**
  156778. * The module's name
  156779. */
  156780. static readonly Name: string;
  156781. /**
  156782. * The (Babylon) version of this module.
  156783. * This is an integer representing the implementation version.
  156784. * This number does not correspond to the WebXR specs version
  156785. */
  156786. static readonly Version: number;
  156787. /**
  156788. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156789. * Will notify the observers about which feature points have been added.
  156790. */
  156791. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156792. /**
  156793. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156794. * Will notify the observers about which feature points have been updated.
  156795. */
  156796. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156797. /**
  156798. * The current feature point cloud maintained across frames.
  156799. */
  156800. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156801. /**
  156802. * construct the feature point system
  156803. * @param _xrSessionManager an instance of xr Session manager
  156804. */
  156805. constructor(_xrSessionManager: WebXRSessionManager);
  156806. /**
  156807. * Detach this feature.
  156808. * Will usually be called by the features manager
  156809. *
  156810. * @returns true if successful.
  156811. */
  156812. detach(): boolean;
  156813. /**
  156814. * Dispose this feature and all of the resources attached
  156815. */
  156816. dispose(): void;
  156817. /**
  156818. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156819. */
  156820. protected _onXRFrame(frame: XRFrame): void;
  156821. /**
  156822. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156823. */
  156824. private _init;
  156825. }
  156826. }
  156827. declare module BABYLON {
  156828. /**
  156829. * Configuration interface for the hand tracking feature
  156830. */
  156831. export interface IWebXRHandTrackingOptions {
  156832. /**
  156833. * The xrInput that will be used as source for new hands
  156834. */
  156835. xrInput: WebXRInput;
  156836. /**
  156837. * Configuration object for the joint meshes
  156838. */
  156839. jointMeshes?: {
  156840. /**
  156841. * Should the meshes created be invisible (defaults to false)
  156842. */
  156843. invisible?: boolean;
  156844. /**
  156845. * A source mesh to be used to create instances. Defaults to a sphere.
  156846. * This mesh will be the source for all other (25) meshes.
  156847. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156848. */
  156849. sourceMesh?: Mesh;
  156850. /**
  156851. * This function will be called after a mesh was created for a specific joint.
  156852. * Using this function you can either manipulate the instance or return a new mesh.
  156853. * When returning a new mesh the instance created before will be disposed
  156854. */
  156855. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156856. /**
  156857. * Should the source mesh stay visible. Defaults to false
  156858. */
  156859. keepOriginalVisible?: boolean;
  156860. /**
  156861. * Scale factor for all instances (defaults to 2)
  156862. */
  156863. scaleFactor?: number;
  156864. /**
  156865. * Should each instance have its own physics impostor
  156866. */
  156867. enablePhysics?: boolean;
  156868. /**
  156869. * If enabled, override default physics properties
  156870. */
  156871. physicsProps?: {
  156872. friction?: number;
  156873. restitution?: number;
  156874. impostorType?: number;
  156875. };
  156876. /**
  156877. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156878. */
  156879. handMesh?: AbstractMesh;
  156880. };
  156881. }
  156882. /**
  156883. * Parts of the hands divided to writs and finger names
  156884. */
  156885. export const enum HandPart {
  156886. /**
  156887. * HandPart - Wrist
  156888. */
  156889. WRIST = "wrist",
  156890. /**
  156891. * HandPart - The THumb
  156892. */
  156893. THUMB = "thumb",
  156894. /**
  156895. * HandPart - Index finger
  156896. */
  156897. INDEX = "index",
  156898. /**
  156899. * HandPart - Middle finger
  156900. */
  156901. MIDDLE = "middle",
  156902. /**
  156903. * HandPart - Ring finger
  156904. */
  156905. RING = "ring",
  156906. /**
  156907. * HandPart - Little finger
  156908. */
  156909. LITTLE = "little"
  156910. }
  156911. /**
  156912. * Representing a single hand (with its corresponding native XRHand object)
  156913. */
  156914. export class WebXRHand implements IDisposable {
  156915. /** the controller to which the hand correlates */
  156916. readonly xrController: WebXRInputSource;
  156917. /** the meshes to be used to track the hand joints */
  156918. readonly trackedMeshes: AbstractMesh[];
  156919. /**
  156920. * Hand-parts definition (key is HandPart)
  156921. */
  156922. handPartsDefinition: {
  156923. [key: string]: number[];
  156924. };
  156925. /**
  156926. * Populate the HandPartsDefinition object.
  156927. * This is called as a side effect since certain browsers don't have XRHand defined.
  156928. */
  156929. private generateHandPartsDefinition;
  156930. /**
  156931. * Construct a new hand object
  156932. * @param xrController the controller to which the hand correlates
  156933. * @param trackedMeshes the meshes to be used to track the hand joints
  156934. */
  156935. constructor(
  156936. /** the controller to which the hand correlates */
  156937. xrController: WebXRInputSource,
  156938. /** the meshes to be used to track the hand joints */
  156939. trackedMeshes: AbstractMesh[]);
  156940. /**
  156941. * Update this hand from the latest xr frame
  156942. * @param xrFrame xrFrame to update from
  156943. * @param referenceSpace The current viewer reference space
  156944. * @param scaleFactor optional scale factor for the meshes
  156945. */
  156946. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156947. /**
  156948. * Get meshes of part of the hand
  156949. * @param part the part of hand to get
  156950. * @returns An array of meshes that correlate to the hand part requested
  156951. */
  156952. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156953. /**
  156954. * Dispose this Hand object
  156955. */
  156956. dispose(): void;
  156957. }
  156958. /**
  156959. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156960. */
  156961. export class WebXRHandTracking extends WebXRAbstractFeature {
  156962. /**
  156963. * options to use when constructing this feature
  156964. */
  156965. readonly options: IWebXRHandTrackingOptions;
  156966. private static _idCounter;
  156967. /**
  156968. * The module's name
  156969. */
  156970. static readonly Name: string;
  156971. /**
  156972. * The (Babylon) version of this module.
  156973. * This is an integer representing the implementation version.
  156974. * This number does not correspond to the WebXR specs version
  156975. */
  156976. static readonly Version: number;
  156977. /**
  156978. * This observable will notify registered observers when a new hand object was added and initialized
  156979. */
  156980. onHandAddedObservable: Observable<WebXRHand>;
  156981. /**
  156982. * This observable will notify its observers right before the hand object is disposed
  156983. */
  156984. onHandRemovedObservable: Observable<WebXRHand>;
  156985. private _hands;
  156986. /**
  156987. * Creates a new instance of the hit test feature
  156988. * @param _xrSessionManager an instance of WebXRSessionManager
  156989. * @param options options to use when constructing this feature
  156990. */
  156991. constructor(_xrSessionManager: WebXRSessionManager,
  156992. /**
  156993. * options to use when constructing this feature
  156994. */
  156995. options: IWebXRHandTrackingOptions);
  156996. /**
  156997. * Check if the needed objects are defined.
  156998. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156999. */
  157000. isCompatible(): boolean;
  157001. /**
  157002. * attach this feature
  157003. * Will usually be called by the features manager
  157004. *
  157005. * @returns true if successful.
  157006. */
  157007. attach(): boolean;
  157008. /**
  157009. * detach this feature.
  157010. * Will usually be called by the features manager
  157011. *
  157012. * @returns true if successful.
  157013. */
  157014. detach(): boolean;
  157015. /**
  157016. * Dispose this feature and all of the resources attached
  157017. */
  157018. dispose(): void;
  157019. /**
  157020. * Get the hand object according to the controller id
  157021. * @param controllerId the controller id to which we want to get the hand
  157022. * @returns null if not found or the WebXRHand object if found
  157023. */
  157024. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  157025. /**
  157026. * Get a hand object according to the requested handedness
  157027. * @param handedness the handedness to request
  157028. * @returns null if not found or the WebXRHand object if found
  157029. */
  157030. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  157031. protected _onXRFrame(_xrFrame: XRFrame): void;
  157032. private _attachHand;
  157033. private _detachHand;
  157034. }
  157035. }
  157036. declare module BABYLON {
  157037. /**
  157038. * The motion controller class for all microsoft mixed reality controllers
  157039. */
  157040. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  157041. protected readonly _mapping: {
  157042. defaultButton: {
  157043. valueNodeName: string;
  157044. unpressedNodeName: string;
  157045. pressedNodeName: string;
  157046. };
  157047. defaultAxis: {
  157048. valueNodeName: string;
  157049. minNodeName: string;
  157050. maxNodeName: string;
  157051. };
  157052. buttons: {
  157053. "xr-standard-trigger": {
  157054. rootNodeName: string;
  157055. componentProperty: string;
  157056. states: string[];
  157057. };
  157058. "xr-standard-squeeze": {
  157059. rootNodeName: string;
  157060. componentProperty: string;
  157061. states: string[];
  157062. };
  157063. "xr-standard-touchpad": {
  157064. rootNodeName: string;
  157065. labelAnchorNodeName: string;
  157066. touchPointNodeName: string;
  157067. };
  157068. "xr-standard-thumbstick": {
  157069. rootNodeName: string;
  157070. componentProperty: string;
  157071. states: string[];
  157072. };
  157073. };
  157074. axes: {
  157075. "xr-standard-touchpad": {
  157076. "x-axis": {
  157077. rootNodeName: string;
  157078. };
  157079. "y-axis": {
  157080. rootNodeName: string;
  157081. };
  157082. };
  157083. "xr-standard-thumbstick": {
  157084. "x-axis": {
  157085. rootNodeName: string;
  157086. };
  157087. "y-axis": {
  157088. rootNodeName: string;
  157089. };
  157090. };
  157091. };
  157092. };
  157093. /**
  157094. * The base url used to load the left and right controller models
  157095. */
  157096. static MODEL_BASE_URL: string;
  157097. /**
  157098. * The name of the left controller model file
  157099. */
  157100. static MODEL_LEFT_FILENAME: string;
  157101. /**
  157102. * The name of the right controller model file
  157103. */
  157104. static MODEL_RIGHT_FILENAME: string;
  157105. profileId: string;
  157106. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157107. protected _getFilenameAndPath(): {
  157108. filename: string;
  157109. path: string;
  157110. };
  157111. protected _getModelLoadingConstraints(): boolean;
  157112. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157113. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157114. protected _updateModel(): void;
  157115. }
  157116. }
  157117. declare module BABYLON {
  157118. /**
  157119. * The motion controller class for oculus touch (quest, rift).
  157120. * This class supports legacy mapping as well the standard xr mapping
  157121. */
  157122. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157123. private _forceLegacyControllers;
  157124. private _modelRootNode;
  157125. /**
  157126. * The base url used to load the left and right controller models
  157127. */
  157128. static MODEL_BASE_URL: string;
  157129. /**
  157130. * The name of the left controller model file
  157131. */
  157132. static MODEL_LEFT_FILENAME: string;
  157133. /**
  157134. * The name of the right controller model file
  157135. */
  157136. static MODEL_RIGHT_FILENAME: string;
  157137. /**
  157138. * Base Url for the Quest controller model.
  157139. */
  157140. static QUEST_MODEL_BASE_URL: string;
  157141. profileId: string;
  157142. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157143. protected _getFilenameAndPath(): {
  157144. filename: string;
  157145. path: string;
  157146. };
  157147. protected _getModelLoadingConstraints(): boolean;
  157148. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157149. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157150. protected _updateModel(): void;
  157151. /**
  157152. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157153. * between the touch and touch 2.
  157154. */
  157155. private _isQuest;
  157156. }
  157157. }
  157158. declare module BABYLON {
  157159. /**
  157160. * The motion controller class for the standard HTC-Vive controllers
  157161. */
  157162. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157163. private _modelRootNode;
  157164. /**
  157165. * The base url used to load the left and right controller models
  157166. */
  157167. static MODEL_BASE_URL: string;
  157168. /**
  157169. * File name for the controller model.
  157170. */
  157171. static MODEL_FILENAME: string;
  157172. profileId: string;
  157173. /**
  157174. * Create a new Vive motion controller object
  157175. * @param scene the scene to use to create this controller
  157176. * @param gamepadObject the corresponding gamepad object
  157177. * @param handedness the handedness of the controller
  157178. */
  157179. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157180. protected _getFilenameAndPath(): {
  157181. filename: string;
  157182. path: string;
  157183. };
  157184. protected _getModelLoadingConstraints(): boolean;
  157185. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157186. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157187. protected _updateModel(): void;
  157188. }
  157189. }
  157190. declare module BABYLON {
  157191. /**
  157192. * A cursor which tracks a point on a path
  157193. */
  157194. export class PathCursor {
  157195. private path;
  157196. /**
  157197. * Stores path cursor callbacks for when an onchange event is triggered
  157198. */
  157199. private _onchange;
  157200. /**
  157201. * The value of the path cursor
  157202. */
  157203. value: number;
  157204. /**
  157205. * The animation array of the path cursor
  157206. */
  157207. animations: Animation[];
  157208. /**
  157209. * Initializes the path cursor
  157210. * @param path The path to track
  157211. */
  157212. constructor(path: Path2);
  157213. /**
  157214. * Gets the cursor point on the path
  157215. * @returns A point on the path cursor at the cursor location
  157216. */
  157217. getPoint(): Vector3;
  157218. /**
  157219. * Moves the cursor ahead by the step amount
  157220. * @param step The amount to move the cursor forward
  157221. * @returns This path cursor
  157222. */
  157223. moveAhead(step?: number): PathCursor;
  157224. /**
  157225. * Moves the cursor behind by the step amount
  157226. * @param step The amount to move the cursor back
  157227. * @returns This path cursor
  157228. */
  157229. moveBack(step?: number): PathCursor;
  157230. /**
  157231. * Moves the cursor by the step amount
  157232. * If the step amount is greater than one, an exception is thrown
  157233. * @param step The amount to move the cursor
  157234. * @returns This path cursor
  157235. */
  157236. move(step: number): PathCursor;
  157237. /**
  157238. * Ensures that the value is limited between zero and one
  157239. * @returns This path cursor
  157240. */
  157241. private ensureLimits;
  157242. /**
  157243. * Runs onchange callbacks on change (used by the animation engine)
  157244. * @returns This path cursor
  157245. */
  157246. private raiseOnChange;
  157247. /**
  157248. * Executes a function on change
  157249. * @param f A path cursor onchange callback
  157250. * @returns This path cursor
  157251. */
  157252. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157253. }
  157254. }
  157255. declare module BABYLON {
  157256. /** @hidden */
  157257. export var blurPixelShader: {
  157258. name: string;
  157259. shader: string;
  157260. };
  157261. }
  157262. declare module BABYLON {
  157263. /** @hidden */
  157264. export var pointCloudVertexDeclaration: {
  157265. name: string;
  157266. shader: string;
  157267. };
  157268. }
  157269. // Mixins
  157270. interface Window {
  157271. mozIndexedDB: IDBFactory;
  157272. webkitIndexedDB: IDBFactory;
  157273. msIndexedDB: IDBFactory;
  157274. webkitURL: typeof URL;
  157275. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157276. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157277. WebGLRenderingContext: WebGLRenderingContext;
  157278. MSGesture: MSGesture;
  157279. CANNON: any;
  157280. AudioContext: AudioContext;
  157281. webkitAudioContext: AudioContext;
  157282. PointerEvent: any;
  157283. Math: Math;
  157284. Uint8Array: Uint8ArrayConstructor;
  157285. Float32Array: Float32ArrayConstructor;
  157286. mozURL: typeof URL;
  157287. msURL: typeof URL;
  157288. VRFrameData: any; // WebVR, from specs 1.1
  157289. DracoDecoderModule: any;
  157290. setImmediate(handler: (...args: any[]) => void): number;
  157291. }
  157292. interface HTMLCanvasElement {
  157293. requestPointerLock(): void;
  157294. msRequestPointerLock?(): void;
  157295. mozRequestPointerLock?(): void;
  157296. webkitRequestPointerLock?(): void;
  157297. /** Track wether a record is in progress */
  157298. isRecording: boolean;
  157299. /** Capture Stream method defined by some browsers */
  157300. captureStream(fps?: number): MediaStream;
  157301. }
  157302. interface CanvasRenderingContext2D {
  157303. msImageSmoothingEnabled: boolean;
  157304. }
  157305. interface MouseEvent {
  157306. mozMovementX: number;
  157307. mozMovementY: number;
  157308. webkitMovementX: number;
  157309. webkitMovementY: number;
  157310. msMovementX: number;
  157311. msMovementY: number;
  157312. }
  157313. interface Navigator {
  157314. mozGetVRDevices: (any: any) => any;
  157315. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157316. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157317. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157318. webkitGetGamepads(): Gamepad[];
  157319. msGetGamepads(): Gamepad[];
  157320. webkitGamepads(): Gamepad[];
  157321. }
  157322. interface HTMLVideoElement {
  157323. mozSrcObject: any;
  157324. }
  157325. interface Math {
  157326. fround(x: number): number;
  157327. imul(a: number, b: number): number;
  157328. }
  157329. interface WebGLRenderingContext {
  157330. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157331. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157332. vertexAttribDivisor(index: number, divisor: number): void;
  157333. createVertexArray(): any;
  157334. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157335. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157336. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157337. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157338. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157339. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157340. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157341. // Queries
  157342. createQuery(): WebGLQuery;
  157343. deleteQuery(query: WebGLQuery): void;
  157344. beginQuery(target: number, query: WebGLQuery): void;
  157345. endQuery(target: number): void;
  157346. getQueryParameter(query: WebGLQuery, pname: number): any;
  157347. getQuery(target: number, pname: number): any;
  157348. MAX_SAMPLES: number;
  157349. RGBA8: number;
  157350. READ_FRAMEBUFFER: number;
  157351. DRAW_FRAMEBUFFER: number;
  157352. UNIFORM_BUFFER: number;
  157353. HALF_FLOAT_OES: number;
  157354. RGBA16F: number;
  157355. RGBA32F: number;
  157356. R32F: number;
  157357. RG32F: number;
  157358. RGB32F: number;
  157359. R16F: number;
  157360. RG16F: number;
  157361. RGB16F: number;
  157362. RED: number;
  157363. RG: number;
  157364. R8: number;
  157365. RG8: number;
  157366. UNSIGNED_INT_24_8: number;
  157367. DEPTH24_STENCIL8: number;
  157368. MIN: number;
  157369. MAX: number;
  157370. /* Multiple Render Targets */
  157371. drawBuffers(buffers: number[]): void;
  157372. readBuffer(src: number): void;
  157373. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157374. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157375. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157376. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157377. // Occlusion Query
  157378. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157379. ANY_SAMPLES_PASSED: number;
  157380. QUERY_RESULT_AVAILABLE: number;
  157381. QUERY_RESULT: number;
  157382. }
  157383. interface WebGLProgram {
  157384. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157385. }
  157386. interface EXT_disjoint_timer_query {
  157387. QUERY_COUNTER_BITS_EXT: number;
  157388. TIME_ELAPSED_EXT: number;
  157389. TIMESTAMP_EXT: number;
  157390. GPU_DISJOINT_EXT: number;
  157391. QUERY_RESULT_EXT: number;
  157392. QUERY_RESULT_AVAILABLE_EXT: number;
  157393. queryCounterEXT(query: WebGLQuery, target: number): void;
  157394. createQueryEXT(): WebGLQuery;
  157395. beginQueryEXT(target: number, query: WebGLQuery): void;
  157396. endQueryEXT(target: number): void;
  157397. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157398. deleteQueryEXT(query: WebGLQuery): void;
  157399. }
  157400. interface WebGLUniformLocation {
  157401. _currentState: any;
  157402. }
  157403. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157404. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157405. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157406. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157407. interface WebGLRenderingContext {
  157408. readonly RASTERIZER_DISCARD: number;
  157409. readonly DEPTH_COMPONENT24: number;
  157410. readonly TEXTURE_3D: number;
  157411. readonly TEXTURE_2D_ARRAY: number;
  157412. readonly TEXTURE_COMPARE_FUNC: number;
  157413. readonly TEXTURE_COMPARE_MODE: number;
  157414. readonly COMPARE_REF_TO_TEXTURE: number;
  157415. readonly TEXTURE_WRAP_R: number;
  157416. readonly HALF_FLOAT: number;
  157417. readonly RGB8: number;
  157418. readonly RED_INTEGER: number;
  157419. readonly RG_INTEGER: number;
  157420. readonly RGB_INTEGER: number;
  157421. readonly RGBA_INTEGER: number;
  157422. readonly R8_SNORM: number;
  157423. readonly RG8_SNORM: number;
  157424. readonly RGB8_SNORM: number;
  157425. readonly RGBA8_SNORM: number;
  157426. readonly R8I: number;
  157427. readonly RG8I: number;
  157428. readonly RGB8I: number;
  157429. readonly RGBA8I: number;
  157430. readonly R8UI: number;
  157431. readonly RG8UI: number;
  157432. readonly RGB8UI: number;
  157433. readonly RGBA8UI: number;
  157434. readonly R16I: number;
  157435. readonly RG16I: number;
  157436. readonly RGB16I: number;
  157437. readonly RGBA16I: number;
  157438. readonly R16UI: number;
  157439. readonly RG16UI: number;
  157440. readonly RGB16UI: number;
  157441. readonly RGBA16UI: number;
  157442. readonly R32I: number;
  157443. readonly RG32I: number;
  157444. readonly RGB32I: number;
  157445. readonly RGBA32I: number;
  157446. readonly R32UI: number;
  157447. readonly RG32UI: number;
  157448. readonly RGB32UI: number;
  157449. readonly RGBA32UI: number;
  157450. readonly RGB10_A2UI: number;
  157451. readonly R11F_G11F_B10F: number;
  157452. readonly RGB9_E5: number;
  157453. readonly RGB10_A2: number;
  157454. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157455. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157456. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157457. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157458. readonly DEPTH_COMPONENT32F: number;
  157459. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157460. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157461. 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;
  157462. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157463. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157464. readonly TRANSFORM_FEEDBACK: number;
  157465. readonly INTERLEAVED_ATTRIBS: number;
  157466. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157467. createTransformFeedback(): WebGLTransformFeedback;
  157468. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157469. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157470. beginTransformFeedback(primitiveMode: number): void;
  157471. endTransformFeedback(): void;
  157472. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157473. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157474. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157475. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157476. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157477. }
  157478. interface ImageBitmap {
  157479. readonly width: number;
  157480. readonly height: number;
  157481. close(): void;
  157482. }
  157483. interface WebGLQuery extends WebGLObject {
  157484. }
  157485. declare var WebGLQuery: {
  157486. prototype: WebGLQuery;
  157487. new(): WebGLQuery;
  157488. };
  157489. interface WebGLSampler extends WebGLObject {
  157490. }
  157491. declare var WebGLSampler: {
  157492. prototype: WebGLSampler;
  157493. new(): WebGLSampler;
  157494. };
  157495. interface WebGLSync extends WebGLObject {
  157496. }
  157497. declare var WebGLSync: {
  157498. prototype: WebGLSync;
  157499. new(): WebGLSync;
  157500. };
  157501. interface WebGLTransformFeedback extends WebGLObject {
  157502. }
  157503. declare var WebGLTransformFeedback: {
  157504. prototype: WebGLTransformFeedback;
  157505. new(): WebGLTransformFeedback;
  157506. };
  157507. interface WebGLVertexArrayObject extends WebGLObject {
  157508. }
  157509. declare var WebGLVertexArrayObject: {
  157510. prototype: WebGLVertexArrayObject;
  157511. new(): WebGLVertexArrayObject;
  157512. };
  157513. // Type definitions for WebVR API
  157514. // Project: https://w3c.github.io/webvr/
  157515. // Definitions by: six a <https://github.com/lostfictions>
  157516. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157517. interface VRDisplay extends EventTarget {
  157518. /**
  157519. * Dictionary of capabilities describing the VRDisplay.
  157520. */
  157521. readonly capabilities: VRDisplayCapabilities;
  157522. /**
  157523. * z-depth defining the far plane of the eye view frustum
  157524. * enables mapping of values in the render target depth
  157525. * attachment to scene coordinates. Initially set to 10000.0.
  157526. */
  157527. depthFar: number;
  157528. /**
  157529. * z-depth defining the near plane of the eye view frustum
  157530. * enables mapping of values in the render target depth
  157531. * attachment to scene coordinates. Initially set to 0.01.
  157532. */
  157533. depthNear: number;
  157534. /**
  157535. * An identifier for this distinct VRDisplay. Used as an
  157536. * association point in the Gamepad API.
  157537. */
  157538. readonly displayId: number;
  157539. /**
  157540. * A display name, a user-readable name identifying it.
  157541. */
  157542. readonly displayName: string;
  157543. readonly isConnected: boolean;
  157544. readonly isPresenting: boolean;
  157545. /**
  157546. * If this VRDisplay supports room-scale experiences, the optional
  157547. * stage attribute contains details on the room-scale parameters.
  157548. */
  157549. readonly stageParameters: VRStageParameters | null;
  157550. /**
  157551. * Passing the value returned by `requestAnimationFrame` to
  157552. * `cancelAnimationFrame` will unregister the callback.
  157553. * @param handle Define the hanle of the request to cancel
  157554. */
  157555. cancelAnimationFrame(handle: number): void;
  157556. /**
  157557. * Stops presenting to the VRDisplay.
  157558. * @returns a promise to know when it stopped
  157559. */
  157560. exitPresent(): Promise<void>;
  157561. /**
  157562. * Return the current VREyeParameters for the given eye.
  157563. * @param whichEye Define the eye we want the parameter for
  157564. * @returns the eye parameters
  157565. */
  157566. getEyeParameters(whichEye: string): VREyeParameters;
  157567. /**
  157568. * Populates the passed VRFrameData with the information required to render
  157569. * the current frame.
  157570. * @param frameData Define the data structure to populate
  157571. * @returns true if ok otherwise false
  157572. */
  157573. getFrameData(frameData: VRFrameData): boolean;
  157574. /**
  157575. * Get the layers currently being presented.
  157576. * @returns the list of VR layers
  157577. */
  157578. getLayers(): VRLayer[];
  157579. /**
  157580. * Return a VRPose containing the future predicted pose of the VRDisplay
  157581. * when the current frame will be presented. The value returned will not
  157582. * change until JavaScript has returned control to the browser.
  157583. *
  157584. * The VRPose will contain the position, orientation, velocity,
  157585. * and acceleration of each of these properties.
  157586. * @returns the pose object
  157587. */
  157588. getPose(): VRPose;
  157589. /**
  157590. * Return the current instantaneous pose of the VRDisplay, with no
  157591. * prediction applied.
  157592. * @returns the current instantaneous pose
  157593. */
  157594. getImmediatePose(): VRPose;
  157595. /**
  157596. * The callback passed to `requestAnimationFrame` will be called
  157597. * any time a new frame should be rendered. When the VRDisplay is
  157598. * presenting the callback will be called at the native refresh
  157599. * rate of the HMD. When not presenting this function acts
  157600. * identically to how window.requestAnimationFrame acts. Content should
  157601. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157602. * asynchronously from other displays and at differing refresh rates.
  157603. * @param callback Define the eaction to run next frame
  157604. * @returns the request handle it
  157605. */
  157606. requestAnimationFrame(callback: FrameRequestCallback): number;
  157607. /**
  157608. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157609. * Repeat calls while already presenting will update the VRLayers being displayed.
  157610. * @param layers Define the list of layer to present
  157611. * @returns a promise to know when the request has been fulfilled
  157612. */
  157613. requestPresent(layers: VRLayer[]): Promise<void>;
  157614. /**
  157615. * Reset the pose for this display, treating its current position and
  157616. * orientation as the "origin/zero" values. VRPose.position,
  157617. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157618. * updated when calling resetPose(). This should be called in only
  157619. * sitting-space experiences.
  157620. */
  157621. resetPose(): void;
  157622. /**
  157623. * The VRLayer provided to the VRDisplay will be captured and presented
  157624. * in the HMD. Calling this function has the same effect on the source
  157625. * canvas as any other operation that uses its source image, and canvases
  157626. * created without preserveDrawingBuffer set to true will be cleared.
  157627. * @param pose Define the pose to submit
  157628. */
  157629. submitFrame(pose?: VRPose): void;
  157630. }
  157631. declare var VRDisplay: {
  157632. prototype: VRDisplay;
  157633. new(): VRDisplay;
  157634. };
  157635. interface VRLayer {
  157636. leftBounds?: number[] | Float32Array | null;
  157637. rightBounds?: number[] | Float32Array | null;
  157638. source?: HTMLCanvasElement | null;
  157639. }
  157640. interface VRDisplayCapabilities {
  157641. readonly canPresent: boolean;
  157642. readonly hasExternalDisplay: boolean;
  157643. readonly hasOrientation: boolean;
  157644. readonly hasPosition: boolean;
  157645. readonly maxLayers: number;
  157646. }
  157647. interface VREyeParameters {
  157648. /** @deprecated */
  157649. readonly fieldOfView: VRFieldOfView;
  157650. readonly offset: Float32Array;
  157651. readonly renderHeight: number;
  157652. readonly renderWidth: number;
  157653. }
  157654. interface VRFieldOfView {
  157655. readonly downDegrees: number;
  157656. readonly leftDegrees: number;
  157657. readonly rightDegrees: number;
  157658. readonly upDegrees: number;
  157659. }
  157660. interface VRFrameData {
  157661. readonly leftProjectionMatrix: Float32Array;
  157662. readonly leftViewMatrix: Float32Array;
  157663. readonly pose: VRPose;
  157664. readonly rightProjectionMatrix: Float32Array;
  157665. readonly rightViewMatrix: Float32Array;
  157666. readonly timestamp: number;
  157667. }
  157668. interface VRPose {
  157669. readonly angularAcceleration: Float32Array | null;
  157670. readonly angularVelocity: Float32Array | null;
  157671. readonly linearAcceleration: Float32Array | null;
  157672. readonly linearVelocity: Float32Array | null;
  157673. readonly orientation: Float32Array | null;
  157674. readonly position: Float32Array | null;
  157675. readonly timestamp: number;
  157676. }
  157677. interface VRStageParameters {
  157678. sittingToStandingTransform?: Float32Array;
  157679. sizeX?: number;
  157680. sizeY?: number;
  157681. }
  157682. interface Navigator {
  157683. getVRDisplays(): Promise<VRDisplay[]>;
  157684. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157685. }
  157686. interface Window {
  157687. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157688. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157689. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157690. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157691. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157692. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157693. }
  157694. interface Gamepad {
  157695. readonly displayId: number;
  157696. }
  157697. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157698. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157699. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157700. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157701. type XRHandedness = "none" | "left" | "right";
  157702. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157703. type XREye = "none" | "left" | "right";
  157704. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157705. interface XRSpace extends EventTarget {}
  157706. interface XRRenderState {
  157707. depthNear?: number;
  157708. depthFar?: number;
  157709. inlineVerticalFieldOfView?: number;
  157710. baseLayer?: XRWebGLLayer;
  157711. }
  157712. interface XRInputSource {
  157713. handedness: XRHandedness;
  157714. targetRayMode: XRTargetRayMode;
  157715. targetRaySpace: XRSpace;
  157716. gripSpace: XRSpace | undefined;
  157717. gamepad: Gamepad | undefined;
  157718. profiles: Array<string>;
  157719. hand: XRHand | undefined;
  157720. }
  157721. interface XRSessionInit {
  157722. optionalFeatures?: string[];
  157723. requiredFeatures?: string[];
  157724. }
  157725. interface XRSession {
  157726. addEventListener: Function;
  157727. removeEventListener: Function;
  157728. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157729. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157730. requestAnimationFrame: Function;
  157731. end(): Promise<void>;
  157732. renderState: XRRenderState;
  157733. inputSources: Array<XRInputSource>;
  157734. // hit test
  157735. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157736. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157737. // legacy AR hit test
  157738. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157739. // legacy plane detection
  157740. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157741. }
  157742. interface XRReferenceSpace extends XRSpace {
  157743. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157744. onreset: any;
  157745. }
  157746. type XRPlaneSet = Set<XRPlane>;
  157747. type XRAnchorSet = Set<XRAnchor>;
  157748. interface XRFrame {
  157749. session: XRSession;
  157750. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157751. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157752. // AR
  157753. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157754. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157755. // Anchors
  157756. trackedAnchors?: XRAnchorSet;
  157757. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157758. // Planes
  157759. worldInformation: {
  157760. detectedPlanes?: XRPlaneSet;
  157761. };
  157762. // Hand tracking
  157763. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157764. }
  157765. interface XRViewerPose extends XRPose {
  157766. views: Array<XRView>;
  157767. }
  157768. interface XRPose {
  157769. transform: XRRigidTransform;
  157770. emulatedPosition: boolean;
  157771. }
  157772. interface XRWebGLLayerOptions {
  157773. antialias?: boolean;
  157774. depth?: boolean;
  157775. stencil?: boolean;
  157776. alpha?: boolean;
  157777. multiview?: boolean;
  157778. framebufferScaleFactor?: number;
  157779. }
  157780. declare var XRWebGLLayer: {
  157781. prototype: XRWebGLLayer;
  157782. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157783. };
  157784. interface XRWebGLLayer {
  157785. framebuffer: WebGLFramebuffer;
  157786. framebufferWidth: number;
  157787. framebufferHeight: number;
  157788. getViewport: Function;
  157789. }
  157790. declare class XRRigidTransform {
  157791. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157792. position: DOMPointReadOnly;
  157793. orientation: DOMPointReadOnly;
  157794. matrix: Float32Array;
  157795. inverse: XRRigidTransform;
  157796. }
  157797. interface XRView {
  157798. eye: XREye;
  157799. projectionMatrix: Float32Array;
  157800. transform: XRRigidTransform;
  157801. }
  157802. interface XRInputSourceChangeEvent {
  157803. session: XRSession;
  157804. removed: Array<XRInputSource>;
  157805. added: Array<XRInputSource>;
  157806. }
  157807. interface XRInputSourceEvent extends Event {
  157808. readonly frame: XRFrame;
  157809. readonly inputSource: XRInputSource;
  157810. }
  157811. // Experimental(er) features
  157812. declare class XRRay {
  157813. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157814. origin: DOMPointReadOnly;
  157815. direction: DOMPointReadOnly;
  157816. matrix: Float32Array;
  157817. }
  157818. declare enum XRHitTestTrackableType {
  157819. "point",
  157820. "plane",
  157821. "mesh",
  157822. }
  157823. interface XRHitResult {
  157824. hitMatrix: Float32Array;
  157825. }
  157826. interface XRTransientInputHitTestResult {
  157827. readonly inputSource: XRInputSource;
  157828. readonly results: Array<XRHitTestResult>;
  157829. }
  157830. interface XRHitTestResult {
  157831. getPose(baseSpace: XRSpace): XRPose | undefined;
  157832. // When anchor system is enabled
  157833. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157834. }
  157835. interface XRHitTestSource {
  157836. cancel(): void;
  157837. }
  157838. interface XRTransientInputHitTestSource {
  157839. cancel(): void;
  157840. }
  157841. interface XRHitTestOptionsInit {
  157842. space: XRSpace;
  157843. entityTypes?: Array<XRHitTestTrackableType>;
  157844. offsetRay?: XRRay;
  157845. }
  157846. interface XRTransientInputHitTestOptionsInit {
  157847. profile: string;
  157848. entityTypes?: Array<XRHitTestTrackableType>;
  157849. offsetRay?: XRRay;
  157850. }
  157851. interface XRAnchor {
  157852. anchorSpace: XRSpace;
  157853. delete(): void;
  157854. }
  157855. interface XRPlane {
  157856. orientation: "Horizontal" | "Vertical";
  157857. planeSpace: XRSpace;
  157858. polygon: Array<DOMPointReadOnly>;
  157859. lastChangedTime: number;
  157860. }
  157861. interface XRJointSpace extends XRSpace {}
  157862. interface XRJointPose extends XRPose {
  157863. radius: number | undefined;
  157864. }
  157865. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157866. readonly length: number;
  157867. [index: number]: XRJointSpace;
  157868. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157869. readonly WRIST: number;
  157870. readonly THUMB_METACARPAL: number;
  157871. readonly THUMB_PHALANX_PROXIMAL: number;
  157872. readonly THUMB_PHALANX_DISTAL: number;
  157873. readonly THUMB_PHALANX_TIP: number;
  157874. readonly INDEX_METACARPAL: number;
  157875. readonly INDEX_PHALANX_PROXIMAL: number;
  157876. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157877. readonly INDEX_PHALANX_DISTAL: number;
  157878. readonly INDEX_PHALANX_TIP: number;
  157879. readonly MIDDLE_METACARPAL: number;
  157880. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157881. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157882. readonly MIDDLE_PHALANX_DISTAL: number;
  157883. readonly MIDDLE_PHALANX_TIP: number;
  157884. readonly RING_METACARPAL: number;
  157885. readonly RING_PHALANX_PROXIMAL: number;
  157886. readonly RING_PHALANX_INTERMEDIATE: number;
  157887. readonly RING_PHALANX_DISTAL: number;
  157888. readonly RING_PHALANX_TIP: number;
  157889. readonly LITTLE_METACARPAL: number;
  157890. readonly LITTLE_PHALANX_PROXIMAL: number;
  157891. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157892. readonly LITTLE_PHALANX_DISTAL: number;
  157893. readonly LITTLE_PHALANX_TIP: number;
  157894. }
  157895. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157896. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157897. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157898. interface XRSession {
  157899. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157900. }
  157901. interface XRFrame {
  157902. featurePointCloud? : Array<number>;
  157903. }